Front end of the Slack clone application.

123456789101112131415161718192021222324252627
  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. }