mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-12-22 18:22:46 +08:00
refactor: 将time.js相关代码最小化 压缩插件体积
This commit is contained in:
@@ -1,21 +1,2 @@
|
||||
// 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 })
|
||||
)
|
||||
}
|
||||
// time.worker.js 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:cb,err:"no such method"});return}apis[method].apply(null,args).then(res=>postMessage({cb:cb,data:res}),err=>postMessage({cb:cb,err:err}))};
|
||||
Reference in New Issue
Block a user