| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9b9762c commit d9c3364
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + | ||
| 5 | + const Stream = require('stream'); | ||
| 6 | + const Readable = Stream.Readable; | ||
| 7 | + const Writable = Stream.Writable; | ||
| 8 | + | ||
| 9 | + const source = Readable({read: () => {}}); | ||
| 10 | + const dest1 = Writable({write: () => {}}); | ||
| 11 | + const dest2 = Writable({write: () => {}}); | ||
| 12 | + | ||
| 13 | + source.pipe(dest1); | ||
| 14 | + source.pipe(dest2); | ||
| 15 | + | ||
| 16 | + dest1.on('unpipe', common.mustCall(() => {})); | ||
| 17 | + dest2.on('unpipe', common.mustCall(() => {})); | ||
| 18 | + | ||
| 19 | + assert.strictEqual(source._readableState.pipes[0], dest1); | ||
| 20 | + assert.strictEqual(source._readableState.pipes[1], dest2); | ||
| 21 | + assert.strictEqual(source._readableState.pipes.length, 2); | ||
| 22 | + | ||
| 23 | + // Should be able to unpipe them in the reverse order that they were piped. | ||
| 24 | + | ||
| 25 | + source.unpipe(dest2); | ||
| 26 | + | ||
| 27 | + assert.strictEqual(source._readableState.pipes, dest1); | ||
| 28 | + assert.notStrictEqual(source._readableState.pipes, dest2); | ||
| 29 | + | ||
| 30 | + source.unpipe(dest1); | ||
| 31 | + | ||
| 32 | + assert.strictEqual(source._readableState.pipes, null); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments