mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 04:31:20 -08:00
移除两个依赖
This commit is contained in:
1 parent
dc8337dc65
commit
98c600c244
10 files changed
+257
-368
No files matched your search
@@ -61,6 +61,31 @@ export function debounce(func, wait, context) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
export function throttle(callback, delay) {
|
||||
let isThrottled = false;
|
||||
let args;
|
||||
let context;
|
||||
function fn(...args2) {
|
||||
if (isThrottled) {
|
||||
args = args2;
|
||||
context = this;
|
||||
return;
|
||||
}
|
||||
|
||||
isThrottled = true;
|
||||
callback.apply(this, args2);
|
||||
setTimeout(() => {
|
||||
isThrottled = false;
|
||||
if (args) {
|
||||
fn.apply(context, args);
|
||||
args = null;
|
||||
context = null;
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
export function mergeDeep(...objects) {
|
||||
const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
|
||||
return objects.reduce((prev, obj) => {
|
||||
|
||||
Reference in new issue
Block a user