Use the built-in partial feature of modern setTimeout.

This commit is contained in:
John-David Dalton
2017-02-02 23:26:00 -08:00
parent c068eedcf3
commit ac53cc7d69
2 changed files with 2 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ function defer(func, ...args) {
if (typeof func != 'function') {
throw new TypeError('Expected a function');
}
return setTimeout(() => func(...args), 1);
return setTimeout(func, 1, ...args);
}
export default defer;

View File

@@ -19,7 +19,7 @@ function delay(func, wait, ...args) {
if (typeof func != 'function') {
throw new TypeError('Expected a function');
}
return setTimeout(() => func(...args), toNumber(wait) || 0);
return setTimeout(func, toNumber(wait) || 0, ...args);
}
export default delay;