mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Use the built-in partial feature of modern setTimeout.
This commit is contained in:
2
defer.js
2
defer.js
@@ -16,7 +16,7 @@ function defer(func, ...args) {
|
|||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError('Expected a function');
|
throw new TypeError('Expected a function');
|
||||||
}
|
}
|
||||||
return setTimeout(() => func(...args), 1);
|
return setTimeout(func, 1, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defer;
|
export default defer;
|
||||||
|
|||||||
2
delay.js
2
delay.js
@@ -19,7 +19,7 @@ function delay(func, wait, ...args) {
|
|||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError('Expected a function');
|
throw new TypeError('Expected a function');
|
||||||
}
|
}
|
||||||
return setTimeout(() => func(...args), toNumber(wait) || 0);
|
return setTimeout(func, toNumber(wait) || 0, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default delay;
|
export default delay;
|
||||||
|
|||||||
Reference in New Issue
Block a user