You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
693 B

4 years ago
  1. var baseDelay = require('./_baseDelay'),
  2. baseRest = require('./_baseRest');
  3. /**
  4. * Defers invoking the `func` until the current call stack has cleared. Any
  5. * additional arguments are provided to `func` when it's invoked.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 0.1.0
  10. * @category Function
  11. * @param {Function} func The function to defer.
  12. * @param {...*} [args] The arguments to invoke `func` with.
  13. * @returns {number} Returns the timer id.
  14. * @example
  15. *
  16. * _.defer(function(text) {
  17. * console.log(text);
  18. * }, 'deferred');
  19. * // => Logs 'deferred' after one millisecond.
  20. */
  21. var defer = baseRest(function(func, args) {
  22. return baseDelay(func, 1, args);
  23. });
  24. module.exports = defer;