mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
c9794880e8
Use the same error code and always emit the error instead of throwing it. PR-URL: https://github.com/nodejs/node/pull/18813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaë Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
41 lines
772 B
JavaScript
41 lines
772 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
const { strictEqual } = require('assert');
|
|
const { Transform } = require('stream');
|
|
|
|
const t = new Transform();
|
|
|
|
t.on('error', common.expectsError({
|
|
type: Error,
|
|
code: 'ERR_METHOD_NOT_IMPLEMENTED',
|
|
message: 'The _transform() method is not implemented'
|
|
}));
|
|
|
|
t.end(Buffer.from('blerg'));
|
|
|
|
const _transform = common.mustCall((chunk, _, next) => {
|
|
next();
|
|
});
|
|
|
|
const _final = common.mustCall((next) => {
|
|
next();
|
|
});
|
|
|
|
const _flush = common.mustCall((next) => {
|
|
next();
|
|
});
|
|
|
|
const t2 = new Transform({
|
|
transform: _transform,
|
|
flush: _flush,
|
|
final: _final
|
|
});
|
|
|
|
strictEqual(t2._transform, _transform);
|
|
strictEqual(t2._flush, _flush);
|
|
strictEqual(t2._final, _final);
|
|
|
|
t2.end(Buffer.from('blerg'));
|
|
t2.resume();
|