| /** |
| * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> |
| * Build: `lodash modularize underscore exports="node" -o ./underscore/` |
| * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> |
| * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> |
| * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors |
| * Available under MIT license <http://lodash.com/license> |
| */ |
| var isFunction = require('../objects/isFunction'), |
| slice = require('../internals/slice'); |
| |
| /** |
| * Executes the `func` function after `wait` milliseconds. Additional arguments |
| * will be provided to `func` when it is invoked. |
| * |
| * @static |
| * @memberOf _ |
| * @category Functions |
| * @param {Function} func The function to delay. |
| * @param {number} wait The number of milliseconds to delay execution. |
| * @param {...*} [arg] Arguments to invoke the function with. |
| * @returns {number} Returns the timer id. |
| * @example |
| * |
| * _.delay(function(text) { console.log(text); }, 1000, 'later'); |
| * // => logs 'later' after one second |
| */ |
| function delay(func, wait) { |
| if (!isFunction(func)) { |
| throw new TypeError; |
| } |
| var args = slice(arguments, 2); |
| return setTimeout(function() { func.apply(undefined, args); }, wait); |
| } |
| |
| module.exports = delay; |