Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

defer.js 441B

1234567891011121314151617181920212223242526
  1. module.exports = defer;
  2. /**
  3. * Runs provided function on next iteration of the event loop
  4. *
  5. * @param {function} fn - function to run
  6. */
  7. function defer(fn)
  8. {
  9. var nextTick = typeof setImmediate == 'function'
  10. ? setImmediate
  11. : (
  12. typeof process == 'object' && typeof process.nextTick == 'function'
  13. ? process.nextTick
  14. : null
  15. );
  16. if (nextTick)
  17. {
  18. nextTick(fn);
  19. }
  20. else
  21. {
  22. setTimeout(fn, 0);
  23. }
  24. }