Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auto-destroy.js 516B

123456789101112131415161718192021222324252627282930
  1. var test = require('tape')
  2. var through = require('../')
  3. // must emit end before close.
  4. test('end before close', function (assert) {
  5. var ts = through()
  6. ts.autoDestroy = false
  7. var ended = false, closed = false
  8. ts.on('end', function () {
  9. assert.ok(!closed)
  10. ended = true
  11. })
  12. ts.on('close', function () {
  13. assert.ok(ended)
  14. closed = true
  15. })
  16. ts.write(1)
  17. ts.write(2)
  18. ts.write(3)
  19. ts.end()
  20. assert.ok(ended)
  21. assert.notOk(closed)
  22. ts.destroy()
  23. assert.ok(closed)
  24. assert.end()
  25. })