a zip code crypto-currency system good for red ONLY

pipe.js 972B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. var ee = require('../');
  3. module.exports = function (t, a) {
  4. var x = {}, y = {}, z = {}, count, count2, count3, pipe;
  5. ee(x);
  6. x = Object.create(x);
  7. ee(y);
  8. ee(z);
  9. count = 0;
  10. count2 = 0;
  11. count3 = 0;
  12. x.on('foo', function () {
  13. ++count;
  14. });
  15. y.on('foo', function () {
  16. ++count2;
  17. });
  18. z.on('foo', function () {
  19. ++count3;
  20. });
  21. x.emit('foo');
  22. a(count, 1, "Pre pipe, x");
  23. a(count2, 0, "Pre pipe, y");
  24. a(count3, 0, "Pre pipe, z");
  25. pipe = t(x, y);
  26. x.emit('foo');
  27. a(count, 2, "Post pipe, x");
  28. a(count2, 1, "Post pipe, y");
  29. a(count3, 0, "Post pipe, z");
  30. y.emit('foo');
  31. a(count, 2, "Post pipe, on y, x");
  32. a(count2, 2, "Post pipe, on y, y");
  33. a(count3, 0, "Post pipe, on y, z");
  34. t(x, z);
  35. x.emit('foo');
  36. a(count, 3, "Post pipe z, x");
  37. a(count2, 3, "Post pipe z, y");
  38. a(count3, 1, "Post pipe z, z");
  39. pipe.close();
  40. x.emit('foo');
  41. a(count, 4, "Close pipe y, x");
  42. a(count2, 3, "Close pipe y, y");
  43. a(count3, 2, "Close pipe y, z");
  44. };