Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
/** Used as the `TypeError` message for "Functions" methods. */
2
var FUNC_ERROR_TEXT = 'Expected a function';
3
4
/**
5
* The base implementation of `_.delay` and `_.defer` which accepts an index
6
* of where to slice the arguments to provide to `func`.
7
*
8
* @private
9
* @param {Function} func The function to delay.
10
* @param {number} wait The number of milliseconds to delay invocation.
11
* @param {Object} args The arguments provide to `func`.
12
* @returns {number} Returns the timer id.
13
*/
14
function baseDelay(func, wait, args) {
15
if (typeof func != 'function') {
16
throw new TypeError(FUNC_ERROR_TEXT);
17
}
18
return setTimeout(function() { func.apply(undefined, args); }, wait);
19
}
20
21
module.exports = baseDelay;
22
23