handle-thing
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -10,4 +10,15 @@ var assert = require('assert') | ||
// Node.js version | ||
var match = /^v(\d+)\.(\d+)\./.exec(process.version) | ||
var version = match ? Number(match[1]) + Number('0.' + match[2]) : 11 | ||
var onreadMode = version >= 11.1 ? 2 : 1 | ||
var mode = 'modern' | ||
var setNRead | ||
if (onreadMode === 2) { | ||
var sw = process.binding('stream_wrap') | ||
setNRead = function (nread) { | ||
sw.streamBaseState[sw.kReadBytesOrError] = nread | ||
} | ||
} | ||
function Handle (stream, options) { | ||
@@ -35,2 +46,11 @@ EventEmitter.call(this) | ||
Handle.prototype._onread = function _onread (nread, buffer) { | ||
if (onreadMode === 1) { | ||
this.onread(nread, buffer) | ||
} else { | ||
setNRead(nread) | ||
this.onread(buffer) | ||
} | ||
} | ||
Handle.prototype._queueReq = function _queueReq (type, req) { | ||
@@ -86,7 +106,7 @@ return this.pending.append(type, req) | ||
this._stream.on('data', function (chunk) { | ||
self.onread(chunk.length, chunk) | ||
self._onread(chunk.length, chunk) | ||
}) | ||
this._stream.on('end', function () { | ||
self.onread(uv.UV_EOF, Buffer.alloc(0)) | ||
self._onread(uv.UV_EOF, Buffer.alloc(0)) | ||
}) | ||
@@ -97,3 +117,3 @@ | ||
if (self._reading) { | ||
self.onread(uv.UV_ECONNRESET, Buffer.alloc(0)) | ||
self._onread(uv.UV_ECONNRESET, Buffer.alloc(0)) | ||
} | ||
@@ -100,0 +120,0 @@ }) |
{ | ||
"name": "handle-thing", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Wrap Streams2 instance into a HandleWrap", | ||
@@ -5,0 +5,0 @@ "main": "lib/handle.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12147
335
1