mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 07:19:19 +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>
24 lines
700 B
JavaScript
24 lines
700 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const StreamWrap = require('internal/js_stream_socket');
|
|
const { PassThrough } = require('stream');
|
|
const { Socket } = require('net');
|
|
|
|
{
|
|
const wrap = new StreamWrap(new PassThrough());
|
|
assert(wrap instanceof Socket);
|
|
wrap.on('data', common.mustCall((d) => assert.strictEqual(`${d}`, 'foo')));
|
|
wrap.on('end', common.mustNotCall());
|
|
wrap.write('foo');
|
|
}
|
|
|
|
{
|
|
const wrap = new StreamWrap(new PassThrough());
|
|
assert(wrap instanceof Socket);
|
|
wrap.on('data', common.mustCall((d) => assert.strictEqual(`${d}`, 'foo')));
|
|
wrap.on('end', common.mustCall());
|
|
wrap.end('foo');
|
|
}
|