delay.js 742 B

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