feat: 完善client相关功能 重构server部分

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2021-08-14 12:43:20 +08:00
parent 774763be13
commit 53502e12cf
34 changed files with 2893 additions and 20 deletions

View File

@@ -0,0 +1,23 @@
const pick = (obj, ...attr) => {
return attr.reduce((acc, k) => {
if (obj.hasOwnProperty(k)) {
acc[k] = obj[k]
}
return acc
}, {})
}
// Keep a reference to the real timeout functions so they can be used when overridden
const NATIVE_SET_TIMEOUT = setTimeout
const NATIVE_CLEAR_TIMEOUT = clearTimeout
const installTimerFunctions = (obj, opts) => {
if (opts.useNativeTimers) {
obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis)
obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis)
} else {
obj.setTimeoutFn = setTimeout.bind(globalThis)
obj.clearTimeoutFn = clearTimeout.bind(globalThis)
}
}
export { pick, installTimerFunctions }