0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-wrap-js-stream-duplex.js
Anna Henningsen 170bc31669
src: turn JS stream into a full duplex
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>
2017-10-23 16:50:42 +02:00

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');
}