timeout.js 337 B

1234567891011121314151617
  1. var slice = require('../array/slice');
  2. /**
  3. * Delays the call of a function within a given context.
  4. */
  5. function timeout(fn, millis, context){
  6. var args = slice(arguments, 3);
  7. return setTimeout(function() {
  8. fn.apply(context, args);
  9. }, millis);
  10. }
  11. module.exports = timeout;