-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a new getter to duplex stream to replace the property `this .writableState.finished` of the object that inherited duplex. Refs: #445 PR-URL: #28007 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
Showing
5 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { Duplex } = require('stream'); | ||
const assert = require('assert'); | ||
|
||
// basic | ||
{ | ||
// Find it on Duplex.prototype | ||
assert(Duplex.prototype.hasOwnProperty('writableFinished')); | ||
} | ||
|
||
// event | ||
{ | ||
const duplex = new Duplex(); | ||
|
||
duplex._write = (chunk, encoding, cb) => { | ||
// The state finished should start in false. | ||
assert.strictEqual(duplex.writableFinished, false); | ||
cb(); | ||
}; | ||
|
||
duplex.on('finish', common.mustCall(() => { | ||
assert.strictEqual(duplex.writableFinished, true); | ||
})); | ||
|
||
duplex.end('testing finished state', common.mustCall(() => { | ||
assert.strictEqual(duplex.writableFinished, true); | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { Writable } = require('stream'); | ||
const assert = require('assert'); | ||
|
||
// basic | ||
{ | ||
// Find it on Writable.prototype | ||
assert(Writable.prototype.hasOwnProperty('writableFinished')); | ||
} | ||
|
||
// event | ||
{ | ||
const writable = new Writable(); | ||
|
||
writable._write = (chunk, encoding, cb) => { | ||
// The state finished should start in false. | ||
assert.strictEqual(writable.writableFinished, false); | ||
cb(); | ||
}; | ||
|
||
writable.on('finish', common.mustCall(() => { | ||
assert.strictEqual(writable.writableFinished, true); | ||
})); | ||
|
||
writable.end('testing finished state', common.mustCall(() => { | ||
assert.strictEqual(writable.writableFinished, true); | ||
})); | ||
} |