Guest User

Untitled

a guest
Sep 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. (function () {
  2. "use strict";
  3.  
  4. var emitter = require('events').EventEmitter
  5. , catcher = new emitter()
  6. , count = 0
  7. , timeout = 1000 * 1000
  8. ;
  9.  
  10. catcher.on('a', function(num) {
  11. console.log(num);
  12. });
  13.  
  14. while(timeout > 0) {
  15. timeout -= 1;
  16. setTimeout(function() {
  17. catcher.emit('a', count);
  18. count += 1;
  19. }, timeout);
  20. }
  21. }());
Add Comment
Please, Sign In to add comment