eb8d3793d1cfe120e9213852def139a3c94c3ce1b7f3dcaf02e456ff9b823017c0860c19d7f0663cdf3c6c7faa79c993f1b6db6a9ef3db9bd3dabd9c06acf6 670 B

123456789101112131415161718192021
  1. /** Error message constants. */
  2. var FUNC_ERROR_TEXT = 'Expected a function';
  3. /**
  4. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  5. * to provide to `func`.
  6. *
  7. * @private
  8. * @param {Function} func The function to delay.
  9. * @param {number} wait The number of milliseconds to delay invocation.
  10. * @param {Array} args The arguments to provide to `func`.
  11. * @returns {number|Object} Returns the timer id or timeout object.
  12. */
  13. function baseDelay(func, wait, args) {
  14. if (typeof func != 'function') {
  15. throw new TypeError(FUNC_ERROR_TEXT);
  16. }
  17. return setTimeout(function() { func.apply(undefined, args); }, wait);
  18. }
  19. export default baseDelay;