mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
170bc31669
Remove unused methods for reading data from `JSStream` and add those required for emitting data or an EOF event to the JS side, in essentially the same way that `LibuvStreamWrap` does it. PR-URL: https://github.com/nodejs/node/pull/16269 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
23 lines
658 B
JavaScript
23 lines
658 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const StreamWrap = require('_stream_wrap');
|
|
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');
|
|
}
|