time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

defer.js (693B)


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