mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-12-20 17:55:42 +08:00
21
public/time.worker.js
Normal file
21
public/time.worker.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// author: inu1255
|
||||
|
||||
const apis = {
|
||||
sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
}
|
||||
|
||||
onmessage = (event) => {
|
||||
const data = event.data
|
||||
if (!data) return
|
||||
const { cb, method, args } = data
|
||||
if (!apis[method]) {
|
||||
postMessage({ cb, err: 'no such method' })
|
||||
return
|
||||
}
|
||||
apis[method].apply(null, args).then(
|
||||
(res) => postMessage({ cb, data: res }),
|
||||
(err) => postMessage({ cb, err })
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user