Comparing version 2.8.6 to 2.9.0
23
index.js
@@ -46,2 +46,10 @@ 'use strict' | ||
const isArrayBuffer = b => b instanceof ArrayBuffer || | ||
typeof b === 'object' && | ||
b.constructor && | ||
b.constructor.name === 'ArrayBuffer' && | ||
b.byteLength >= 0 | ||
const isArrayBufferView = b => !B.isBuffer(b) && ArrayBuffer.isView(b) | ||
module.exports = class Minipass extends EE { | ||
@@ -118,4 +126,15 @@ constructor (options) { | ||
if (typeof chunk !== 'string' && !B.isBuffer(chunk) && !this[OBJECTMODE]) | ||
this.objectMode = true | ||
// convert array buffers and typed array views into buffers | ||
// at some point in the future, we may want to do the opposite! | ||
// leave strings and buffers as-is | ||
// anything else switches us into object mode | ||
if (!this[OBJECTMODE] && !B.isBuffer(chunk)) { | ||
if (isArrayBufferView(chunk)) | ||
chunk = B.from(chunk.buffer, chunk.byteOffset, chunk.byteLength) | ||
else if (isArrayBuffer(chunk)) | ||
chunk = B.from(chunk) | ||
else if (typeof chunk !== 'string') | ||
// use the setter so we throw if we have encoding set | ||
this.objectMode = true | ||
} | ||
@@ -122,0 +141,0 @@ // this ensures at this point that the chunk is a buffer or string |
{ | ||
"name": "minipass", | ||
"version": "2.8.6", | ||
"version": "2.9.0", | ||
"description": "minimal implementation of a PassThrough stream", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"end-of-stream": "^1.4.0", | ||
"tap": "^14.6.4", | ||
"tap": "^14.6.5", | ||
"through2": "^2.0.3" | ||
@@ -15,0 +15,0 @@ }, |
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
36504
461