pipeline.asynct.js 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var es = require('..')
  2. exports['do not duplicate errors'] = function (test) {
  3. var errors = 0;
  4. var pipe = es.pipeline(
  5. es.through(function(data) {
  6. return this.emit('data', data);
  7. }),
  8. es.through(function(data) {
  9. return this.emit('error', new Error(data));
  10. })
  11. )
  12. pipe.on('error', function(err) {
  13. errors++
  14. console.log('error count', errors)
  15. process.nextTick(function () {
  16. return test.done();
  17. })
  18. })
  19. return pipe.write('meh');
  20. }
  21. exports['3 pipe do not duplicate errors'] = function (test) {
  22. var errors = 0;
  23. var pipe = es.pipeline(
  24. es.through(function(data) {
  25. return this.emit('data', data);
  26. }),
  27. es.through(function(data) {
  28. return this.emit('error', new Error(data));
  29. }),
  30. es.through()
  31. )
  32. pipe.on('error', function(err) {
  33. errors++
  34. console.log('error count', errors)
  35. process.nextTick(function () {
  36. return test.done();
  37. })
  38. })
  39. return pipe.write('meh');
  40. }
  41. require('./helper')(module)