mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

Its confusing to call a js class with a handle a "Wrap", usually it's the C++ handle that is called a Wrap (tcp_wrap, tls_wrap, ...). Its derived from Socket, and makes a JS stream look like a Socket, so call it that. Also, remove use of lib/_stream_wrap.js so it can be deprecated some time. PR-URL: https://github.com/nodejs/node/pull/25153 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
44 lines
831 B
JavaScript
44 lines
831 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
|
|
const StreamWrap = require('internal/js_stream_socket');
|
|
const Duplex = require('stream').Duplex;
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {},
|
|
write() {}
|
|
});
|
|
|
|
stream.setEncoding('ascii');
|
|
|
|
const wrap = new StreamWrap(stream);
|
|
|
|
wrap.on('error', common.expectsError({
|
|
type: Error,
|
|
code: 'ERR_STREAM_WRAP',
|
|
message: 'Stream has StringDecoder set or is in objectMode'
|
|
}));
|
|
|
|
stream.push('ohai');
|
|
}
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {},
|
|
write() {},
|
|
objectMode: true
|
|
});
|
|
|
|
const wrap = new StreamWrap(stream);
|
|
|
|
wrap.on('error', common.expectsError({
|
|
type: Error,
|
|
code: 'ERR_STREAM_WRAP',
|
|
message: 'Stream has StringDecoder set or is in objectMode'
|
|
}));
|
|
|
|
stream.push(new Error('foo'));
|
|
}
|