diff options
author | Calvin Metcalf <cmetcalf@appgeo.com> | 2017-05-04 15:33:14 +0200 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-05-28 07:00:40 -0700 |
commit | 07c7f198dbfa75dffbf45f91eab6fb535056af94 (patch) | |
tree | 53dbc9bc7ade185b8e8b6a2df1b34c5a00edec82 /test/parallel/test-stream-transform-constructor-set-methods.js | |
parent | 87cef63ccbbc3db875c4d4e98c42d90623c2ed0e (diff) | |
download | node-new-07c7f198dbfa75dffbf45f91eab6fb535056af94.tar.gz |
stream: add final method
Adds the ability to for write streams to have an _final method which acts
similarly to the _flush method that transform streams have but is called before
the finish event is emitted and if asynchronous delays the stream from
finishing. The `final` option may also be passed in order to set it.
PR-URL: https://github.com/nodejs/node/pull/12828
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-transform-constructor-set-methods.js')
-rw-r--r-- | test/parallel/test-stream-transform-constructor-set-methods.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/parallel/test-stream-transform-constructor-set-methods.js b/test/parallel/test-stream-transform-constructor-set-methods.js index 1423f4de10..3e1325c0fd 100644 --- a/test/parallel/test-stream-transform-constructor-set-methods.js +++ b/test/parallel/test-stream-transform-constructor-set-methods.js @@ -1,24 +1,25 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const Transform = require('stream').Transform; -let _transformCalled = false; -function _transform(d, e, n) { - _transformCalled = true; +const _transform = common.mustCall(function _transform(d, e, n) { n(); -} +}); -let _flushCalled = false; -function _flush(n) { - _flushCalled = true; +const _final = common.mustCall(function _final(n) { n(); -} +}); + +const _flush = common.mustCall(function _flush(n) { + n(); +}); const t = new Transform({ transform: _transform, - flush: _flush + flush: _flush, + final: _final }); const t2 = new Transform({}); @@ -34,6 +35,5 @@ assert.throws(() => { process.on('exit', () => { assert.strictEqual(t._transform, _transform); assert.strictEqual(t._flush, _flush); - assert.strictEqual(_transformCalled, true); - assert.strictEqual(_flushCalled, true); + assert.strictEqual(t._final, _final); }); |