1
|
var baseDelay = require('./_baseDelay'),
|
2
|
baseRest = require('./_baseRest'),
|
3
|
toNumber = require('./toNumber');
|
4
|
|
5
|
/**
|
6
|
* Invokes `func` after `wait` milliseconds. Any additional arguments are
|
7
|
* provided to `func` when it's invoked.
|
8
|
*
|
9
|
* @static
|
10
|
* @memberOf _
|
11
|
* @since 0.1.0
|
12
|
* @category Function
|
13
|
* @param {Function} func The function to delay.
|
14
|
* @param {number} wait The number of milliseconds to delay invocation.
|
15
|
* @param {...*} [args] The arguments to invoke `func` with.
|
16
|
* @returns {number} Returns the timer id.
|
17
|
* @example
|
18
|
*
|
19
|
* _.delay(function(text) {
|
20
|
* console.log(text);
|
21
|
* }, 1000, 'later');
|
22
|
* // => Logs 'later' after one second.
|
23
|
*/
|
24
|
var delay = baseRest(function(func, wait, args) {
|
25
|
return baseDelay(func, toNumber(wait) || 0, args);
|
26
|
});
|
27
|
|
28
|
module.exports = delay;
|