Skip to content

Commit

Permalink
[squash] jasnell comment
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Jan 4, 2018
1 parent 0cf413b commit 51e7ecc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/internal/wrap_js_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const errors = require('internal/errors');
const kCurrentWriteRequest = Symbol('kCurrentWriteRequest');
const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest');

function isClosing() { return this.owner.isClosing(); }
function onreadstart() { return this.owner.readStart(); }
function onreadstop() { return this.owner.readStop(); }
function onshutdown(req) { return this.owner.doShutdown(req); }
function onwrite(req, bufs) { return this.owner.doWrite(req, bufs); }

/* This class serves as a wrapper for when the C++ side of Node wants access
* to a standard JS stream. For example, TLS or HTTP do not operate on network
* resources conceptually, although that is the common case and what we are
Expand All @@ -32,13 +38,11 @@ class JSStreamWrap extends Socket {
};
// Inside of the following functions, `this` refers to the handle
// and `this.owner` refers to this JSStreamWrap instance.
handle.isClosing = function() { return this.owner.isClosing(); };
handle.onreadstart = function() { return this.owner.readStart(); };
handle.onreadstop = function() { return this.owner.readStop(); };
handle.onshutdown = function(req) { return this.owner.doShutdown(req); };
handle.onwrite = function(req, bufs) {
return this.owner.doWrite(req, bufs);
};
handle.isClosing = isClosing;
handle.onreadstart = onreadstart;
handle.onreadstop = onreadstop;
handle.onshutdown = onshutdown;
handle.onwrite = onwrite;

stream.pause();
stream.on('error', (err) => this.emit('error', err));
Expand Down

0 comments on commit 51e7ecc

Please sign in to comment.