stream: fix misleading error message
The method to implement is `_write` not `_transform`. PR-URL: https://github.com/nodejs/node/pull/18604 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
87b9bceacb
commit
e9b5b4fae3
@ -541,7 +541,7 @@ function clearBuffer(stream, state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Writable.prototype._write = function(chunk, encoding, cb) {
|
Writable.prototype._write = function(chunk, encoding, cb) {
|
||||||
cb(new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', '_transform'));
|
cb(new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', '_write'));
|
||||||
};
|
};
|
||||||
|
|
||||||
Writable.prototype._writev = null;
|
Writable.prototype._writev = null;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const Writable = require('stream').Writable;
|
const Writable = require('stream').Writable;
|
||||||
@ -26,6 +26,16 @@ w2.write(Buffer.from('blerg'));
|
|||||||
w2.write(Buffer.from('blerg'));
|
w2.write(Buffer.from('blerg'));
|
||||||
w2.end();
|
w2.end();
|
||||||
|
|
||||||
|
const w3 = new Writable();
|
||||||
|
|
||||||
|
w3.on('error', common.expectsError({
|
||||||
|
type: Error,
|
||||||
|
code: 'ERR_METHOD_NOT_IMPLEMENTED',
|
||||||
|
message: 'The _write method is not implemented'
|
||||||
|
}));
|
||||||
|
|
||||||
|
w3.end(Buffer.from('blerg'));
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert.strictEqual(w._write, _write);
|
assert.strictEqual(w._write, _write);
|
||||||
assert(_writeCalled);
|
assert(_writeCalled);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user