-function objectToUrlEncoded (obj: any) {
- const str: string[] = []
- for (const key of Object.keys(obj)) {
- str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]))
- }
+function copyToClipboard (text: string) {
+ const el = document.createElement('textarea')
+ el.value = text
+ el.setAttribute('readonly', '')
+ el.style.position = 'absolute'
+ el.style.left = '-9999px'
+ document.body.appendChild(el)
+ el.select()
+ document.execCommand('copy')
+ document.body.removeChild(el)
+}
- return str.join('&')
+function wait (ms: number) {
+ return new Promise<void>(res => {
+ setTimeout(() => res(), ms)
+ })
}
export {
- objectToUrlEncoded
+ copyToClipboard,
+ wait
}