Comparing version 1.0.1 to 1.0.2
@@ -34,2 +34,4 @@ 'use strict' | ||
* input stream | ||
* @param {boolean} [options.readError=false] - If true, when a read() | ||
* underflows, throw an error. | ||
* | ||
@@ -88,4 +90,8 @@ * @example <caption>source</caption> | ||
delete options.watchPipe | ||
const readError = !! options.readError | ||
delete options.readError | ||
super(options) | ||
this.readError = readError | ||
if (watchPipe) { | ||
@@ -225,2 +231,3 @@ this.on('pipe', readable => { | ||
* decoding output a string, otherwise a Buffer | ||
* @throws Error - if readError is true and there was underflow | ||
* @fires NoFilter#read | ||
@@ -239,2 +246,7 @@ */ | ||
this.emit('read', buf) | ||
if (this.readError && (buf.length < size)) { | ||
throw new Error(`Read ${buf.length}, wanted ${size}`) | ||
} | ||
} else if (this.readError) { | ||
throw new Error(`No data available, wanted ${size}`) | ||
} | ||
@@ -373,2 +385,9 @@ return buf | ||
toString(encoding, start, end) { | ||
if ((!encoding || (encoding === 'utf8')) && util.TextDecoder) { | ||
const td = new util.TextDecoder('utf8', { | ||
fatal: true, | ||
ignoreBOM: true | ||
}) | ||
return td.decode(this.slice(start, end)) | ||
} | ||
return this.slice().toString(encoding, start, end) | ||
@@ -375,0 +394,0 @@ } |
{ | ||
"name": "nofilter", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Read and write a growable buffer as a stream", | ||
@@ -9,8 +9,5 @@ "main": "lib/index.js", | ||
"lint": "eslint lib/*.js bin/* test/*.js", | ||
"coverage": "nyc -r none npm test", | ||
"coveragehtml": "nyc report -r html", | ||
"precoveragehtml": "npm run coverage", | ||
"coverage": "nyc -r html npm test", | ||
"test": "mocha test/*.js", | ||
"doc": "jsdoc -c .jsdoc.conf", | ||
"watch": "watch 'npm run coveragehtml' src/ test/", | ||
"release": "npm version patch && git push --follow-tags && npm publish", | ||
@@ -43,7 +40,7 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls" | ||
"chai": "^4.2", | ||
"coveralls": "^3.0.2", | ||
"coveralls": "^3.0.3", | ||
"jsdoc": "^3.5.5", | ||
"minami": "^1.2.3", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0" | ||
"mocha": "^6.0.2", | ||
"nyc": "^13.3.0" | ||
}, | ||
@@ -50,0 +47,0 @@ "engines": { |
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
25112
770