-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #16269 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
3 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'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'); | ||
} |