Comparing version 2.0.3 to 3.0.0
572
lib/index.js
@@ -7,10 +7,2 @@ 'use strict' | ||
let util = null | ||
let customInspect = Symbol.for('nodejs.util.inspect.custom') | ||
try { | ||
util = require('util') | ||
customInspect = util.inspect.custom | ||
} catch (ignored) { | ||
// Do without | ||
} | ||
const td = new TextDecoder('utf8', {fatal: true, ignoreBOM: true}) | ||
@@ -41,13 +33,13 @@ | ||
* @param {string|Buffer} [input] - Source data | ||
* @param {string} [inputEncoding=null] - Encoding name for input, | ||
* @param {BufferEncoding} [inputEncoding=null] - Encoding name for input, | ||
* ignored if input is not a String | ||
* @param {Object} [options={}] - Other options | ||
* @param {object} [options={}] - Other options | ||
* @param {string|Buffer} [options.input=null] - Input source data | ||
* @param {string} [options.inputEncoding=null] - Encoding name for input, | ||
* ignored if input is not a String | ||
* @param {number} [options.highWaterMark=16384] - The maximum number of bytes | ||
* to store in the internal buffer before ceasing to read from the | ||
* @param {BufferEncoding} [options.inputEncoding=null] - Encoding name for | ||
* input, ignored if input is not a String | ||
* @param {number} [options.highWaterMark=16384] - The maximum number of | ||
* bytes to store in the internal buffer before ceasing to read from the | ||
* underlying resource. Default=16kb, or 16 for objectMode streams | ||
* @param {string} [options.encoding=null] - If specified, then buffers will | ||
* be decoded to strings using the specified encoding | ||
* @param {BufferEncoding} [options.encoding=null] - If specified, then | ||
* buffers will be decoded to strings using the specified encoding | ||
* @param {boolean} [options.objectMode=false] - Whether this stream should | ||
@@ -69,2 +61,3 @@ * behave as a stream of objects. Meaning that stream.read(n) returns a | ||
let inp = null | ||
/** @type BufferEncoding? */ | ||
let inpE = null | ||
@@ -113,3 +106,5 @@ switch (typeof(input)) { | ||
this.on('pipe', readable => { | ||
// @ts-ignore: TS2339 (using internal interface) | ||
const om = readable._readableState.objectMode | ||
// @ts-ignore: TS2339 (using internal interface) | ||
if ((this.length > 0) && (om !== this._readableState.objectMode)) { | ||
@@ -121,3 +116,5 @@ throw new Error( | ||
// @ts-ignore: TS2339 (using internal interface) | ||
this._readableState.objectMode = om | ||
// @ts-ignore: TS2339 (using internal interface) | ||
this._writableState.objectMode = om | ||
@@ -135,3 +132,3 @@ }) | ||
* | ||
* @param {Object} obj The object to test. | ||
* @param {object} obj The object to test. | ||
* @returns {boolean} true if obj is a NoFilter | ||
@@ -209,2 +206,3 @@ */ | ||
if (allBufs) { | ||
// @ts-ignore: TS2322, tsc can't see the type checking above | ||
return Buffer.concat(bufs, length) | ||
@@ -221,5 +219,6 @@ } | ||
/** | ||
* @private | ||
* @ignore | ||
*/ | ||
_transform(chunk, encoding, callback) { | ||
// @ts-ignore: TS2339 (using internal interface) | ||
if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { | ||
@@ -236,2 +235,3 @@ chunk = Buffer.from(chunk, encoding) | ||
_bufArray() { | ||
// @ts-ignore: TS2339 (using internal interface) | ||
let bufs = this._readableState.buffer | ||
@@ -322,3 +322,3 @@ // HACK: replace with something else one day. This is what I get for | ||
* @param {NoFilter} other - The other object to compare | ||
* @returns {Number} -1, 0, 1 for less, equal, greater | ||
* @returns {number} -1, 0, 1 for less, equal, greater | ||
*/ | ||
@@ -359,4 +359,4 @@ compare(other) { | ||
* | ||
* @param {Number} [start=0] - beginning offset | ||
* @param {Number} [end=length] - ending offset | ||
* @param {number} [start=0] - beginning offset | ||
* @param {number} [end=length] - ending offset | ||
* @returns {Buffer|Array} if in object mode, an array of objects. Otherwise, | ||
@@ -366,2 +366,3 @@ * concatenated array of contents. | ||
slice(start, end) { | ||
// @ts-ignore: TS2339 (using internal interface) | ||
if (this._readableState.objectMode) { | ||
@@ -387,4 +388,4 @@ return this._bufArray().slice(start, end) | ||
* | ||
* @param {Number} index - The byte to retrieve | ||
* @returns {Number} 0-255 | ||
* @param {number} index - The byte to retrieve | ||
* @returns {number} 0-255 | ||
*/ | ||
@@ -399,3 +400,3 @@ get(index) { | ||
* | ||
* @returns {Object} | ||
* @returns {string|object} | ||
* | ||
@@ -419,6 +420,6 @@ * @example output for 'foo' | ||
* | ||
* @param {String} [encoding='utf8'] - Which to use for decoding? | ||
* @param {Number} [start=0] - Start offset | ||
* @param {Number} [end=length] - End offset | ||
* @returns {String} | ||
* @param {BufferEncoding} [encoding='utf8'] - Which to use for decoding? | ||
* @param {number} [start=0] - Start offset | ||
* @param {number} [end=length] - End offset | ||
* @returns {string} | ||
*/ | ||
@@ -438,24 +439,10 @@ toString(encoding, start, end) { | ||
* @private | ||
* @deprecated | ||
*/ | ||
inspect(depth, options) { | ||
return this[customInspect](depth, options) | ||
} | ||
/** | ||
* @private | ||
*/ | ||
[customInspect](depth, options) { | ||
[Symbol.for('nodejs.util.inspect.custom')](depth, options) { | ||
const bufs = this._bufArray() | ||
const hex = bufs.map(b => { | ||
if (Buffer.isBuffer(b)) { | ||
if ((options != null ? options.stylize : undefined)) { | ||
return options.stylize(b.toString('hex'), 'string') | ||
} | ||
return b.toString('hex') | ||
return options.stylize(b.toString('hex'), 'string') | ||
} | ||
if (util) { | ||
return util.inspect(b, options) | ||
} | ||
return b.toString() | ||
return JSON.stringify(b) | ||
}).join(', ') | ||
@@ -468,6 +455,6 @@ return `${this.constructor.name} [${hex}]` | ||
* | ||
* @member {number} | ||
* @readonly | ||
* @returns {number} | ||
*/ | ||
get length() { | ||
// @ts-ignore: TS2339 (using internal interface) | ||
return this._readableState.length | ||
@@ -536,47 +523,13 @@ } | ||
} | ||
} | ||
/** | ||
* @param {string} meth - method to call | ||
* @param {number} len - number of bytes to write | ||
* @private | ||
*/ | ||
function _read_gen(meth, len) { | ||
// eslint-disable-next-line func-names | ||
return function(val) { | ||
// eslint-disable-next-line no-invalid-this | ||
const b = this.read(len) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b[meth].call(b, 0, true) | ||
} | ||
} | ||
/** | ||
* @param {string} meth - method to call | ||
* @param {number} len - number of bytes to write | ||
* @private | ||
*/ | ||
function _write_gen(meth, len) { | ||
// eslint-disable-next-line func-names | ||
return function(val) { | ||
const b = Buffer.alloc(len) | ||
b[meth].call(b, val, 0, true) | ||
// eslint-disable-next-line no-invalid-this | ||
return this.push(b) | ||
} | ||
} | ||
Object.assign(NoFilter.prototype, { | ||
/** | ||
* Write an 8-bit unsigned integer to the stream. Adds 1 byte. | ||
* | ||
* @function writeUInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value - 0-255 | ||
* @param {number} value - 0-255 | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt8: _write_gen('writeUInt8', 1), | ||
writeUInt8(value) { | ||
const b = Buffer.from([value]) | ||
return this.push(b) | ||
} | ||
@@ -587,9 +540,10 @@ /** | ||
* | ||
* @function writeUInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt16LE: _write_gen('writeUInt16LE', 2), | ||
writeUInt16LE(value) { | ||
const b = Buffer.alloc(2) | ||
b.writeUInt16LE(value) | ||
return this.push(b) | ||
} | ||
@@ -600,9 +554,10 @@ /** | ||
* | ||
* @function writeUInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt16BE: _write_gen('writeUInt16BE', 2), | ||
writeUInt16BE(value) { | ||
const b = Buffer.alloc(2) | ||
b.writeUInt16BE(value) | ||
return this.push(b) | ||
} | ||
@@ -613,9 +568,10 @@ /** | ||
* | ||
* @function writeUInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt32LE: _write_gen('writeUInt32LE', 4), | ||
writeUInt32LE(value) { | ||
const b = Buffer.alloc(4) | ||
b.writeUInt32LE(value) | ||
return this.push(b) | ||
} | ||
@@ -626,9 +582,10 @@ /** | ||
* | ||
* @function writeUInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt32BE: _write_gen('writeUInt32BE', 4), | ||
writeUInt32BE(value) { | ||
const b = Buffer.alloc(4) | ||
b.writeUInt32BE(value) | ||
return this.push(b) | ||
} | ||
@@ -638,9 +595,9 @@ /** | ||
* | ||
* @function writeInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt8: _write_gen('writeInt8', 1), | ||
writeInt8(value) { | ||
const b = Buffer.from([value]) | ||
return this.push(b) | ||
} | ||
@@ -650,9 +607,10 @@ /** | ||
* | ||
* @function writeInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt16LE: _write_gen('writeInt16LE', 2), | ||
writeInt16LE(value) { | ||
const b = Buffer.alloc(2) | ||
b.writeUInt16LE(value) | ||
return this.push(b) | ||
} | ||
@@ -662,9 +620,10 @@ /** | ||
* | ||
* @function writeInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt16BE: _write_gen('writeInt16BE', 2), | ||
writeInt16BE(value) { | ||
const b = Buffer.alloc(2) | ||
b.writeUInt16BE(value) | ||
return this.push(b) | ||
} | ||
@@ -674,9 +633,10 @@ /** | ||
* | ||
* @function writeInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt32LE: _write_gen('writeInt32LE', 4), | ||
writeInt32LE(value) { | ||
const b = Buffer.alloc(4) | ||
b.writeUInt32LE(value) | ||
return this.push(b) | ||
} | ||
@@ -686,9 +646,10 @@ /** | ||
* | ||
* @function writeInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt32BE: _write_gen('writeInt32BE', 4), | ||
writeInt32BE(value) { | ||
const b = Buffer.alloc(4) | ||
b.writeUInt32BE(value) | ||
return this.push(b) | ||
} | ||
@@ -698,9 +659,10 @@ /** | ||
* | ||
* @function writeFloatLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeFloatLE: _write_gen('writeFloatLE', 4), | ||
writeFloatLE(value) { | ||
const b = Buffer.alloc(4) | ||
b.writeFloatLE(value) | ||
return this.push(b) | ||
} | ||
@@ -710,20 +672,22 @@ /** | ||
* | ||
* @function writeFloatBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeFloatBE: _write_gen('writeFloatBE', 4), | ||
writeFloatBE(value) { | ||
const b = Buffer.alloc(4) | ||
b.writeFloatBE(value) | ||
return this.push(b) | ||
} | ||
/** | ||
* Write a little-endian 64-bit float to the stream. Adds 8 bytes. | ||
* Write a little-endian 64-bit double to the stream. Adds 8 bytes. | ||
* | ||
* @function writeDoubleLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeDoubleLE: _write_gen('writeDoubleLE', 8), | ||
writeDoubleLE(value) { | ||
const b = Buffer.alloc(8) | ||
b.writeDoubleLE(value) | ||
return this.push(b) | ||
} | ||
@@ -733,19 +697,71 @@ /** | ||
* | ||
* @function writeDoubleBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @param {number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeDoubleBE: _write_gen('writeDoubleBE', 8), | ||
writeDoubleBE(value) { | ||
const b = Buffer.alloc(8) | ||
b.writeDoubleBE(value) | ||
return this.push(b) | ||
} | ||
/** | ||
* Write a signed little-endian 64-bit BigInt to the stream. Adds 8 bytes. | ||
* | ||
* @param {bigint} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeBigInt64LE(value) { | ||
const b = Buffer.alloc(8) | ||
b.writeBigInt64LE(value) | ||
return this.push(b) | ||
} | ||
/** | ||
* Write a signed big-endian 64-bit BigInt to the stream. Adds 8 bytes. | ||
* | ||
* @param {bigint} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeBigInt64BE(value) { | ||
const b = Buffer.alloc(8) | ||
b.writeBigInt64BE(value) | ||
return this.push(b) | ||
} | ||
/** | ||
* Write an unsigned little-endian 64-bit BigInt to the stream. Adds 8 bytes. | ||
* | ||
* @param {bigint} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeBigUInt64LE(value) { | ||
const b = Buffer.alloc(8) | ||
b.writeBigUInt64LE(value) | ||
return this.push(b) | ||
} | ||
/** | ||
* Write an unsigned big-endian 64-bit BigInt to the stream. Adds 8 bytes. | ||
* | ||
* @param {bigint} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeBigUInt64BE(value) { | ||
const b = Buffer.alloc(8) | ||
b.writeBigUInt64BE(value) | ||
return this.push(b) | ||
} | ||
/** | ||
* Read an unsigned 8-bit integer from the stream. Consumes 1 byte. | ||
* | ||
* @function readUInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readUInt8: _read_gen('readUInt8', 1), | ||
readUInt8() { | ||
const b = this.read(1) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readUInt8() | ||
} | ||
@@ -756,19 +772,25 @@ /** | ||
* | ||
* @function readUInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readUInt16LE: _read_gen('readUInt16LE', 2), | ||
readUInt16LE() { | ||
const b = this.read(2) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readUInt16LE() | ||
} | ||
/** | ||
* Read a big-endian unsigned 16-bit integer from the stream. | ||
* Read a little-endian unsigned 16-bit integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readUInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readUInt16BE: _read_gen('readUInt16BE', 2), | ||
readUInt16BE() { | ||
const b = this.read(2) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readUInt16BE() | ||
} | ||
@@ -779,74 +801,94 @@ /** | ||
* | ||
* @function readUInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readUInt32LE: _read_gen('readUInt32LE', 4), | ||
readUInt32LE() { | ||
const b = this.read(4) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readUInt32LE() | ||
} | ||
/** | ||
* Read a big-endian unsigned 16-bit integer from the stream. | ||
* Read a little-endian unsigned 16-bit integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readUInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readUInt32BE: _read_gen('readUInt32BE', 4), | ||
readUInt32BE() { | ||
const b = this.read(4) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readUInt32BE() | ||
} | ||
/** | ||
* Read a signed 8-bit integer from the stream. | ||
* Consumes 1 byte. | ||
* Read a signed 8-bit integer from the stream. Consumes 1 byte. | ||
* | ||
* @function readInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readInt8: _read_gen('readInt8', 1), | ||
readInt8() { | ||
const b = this.read(1) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readInt8() | ||
} | ||
/** | ||
* Read a signed 16-bit little-endian integer from the stream. | ||
* Read a little-endian signed 16-bit integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readInt16LE: _read_gen('readInt16LE', 2), | ||
readInt16LE() { | ||
const b = this.read(2) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readInt16LE() | ||
} | ||
/** | ||
* Read a signed 16-bit big-endian integer from the stream. | ||
* Read a little-endian signed 16-bit integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readInt16BE: _read_gen('readInt16BE', 2), | ||
readInt16BE() { | ||
const b = this.read(2) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readInt16BE() | ||
} | ||
/** | ||
* Read a signed 32-bit little-endian integer from the stream. | ||
* Read a little-endian signed 32-bit integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readInt32LE: _read_gen('readInt32LE', 4), | ||
readInt32LE() { | ||
const b = this.read(4) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readInt32LE() | ||
} | ||
/** | ||
* Read a signed 32-bit big-endian integer from the stream. | ||
* Read a little-endian signed 16-bit integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readInt32BE: _read_gen('readInt32BE', 4), | ||
readInt32BE() { | ||
const b = this.read(4) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readInt32BE() | ||
} | ||
@@ -857,8 +899,11 @@ /** | ||
* | ||
* @function readFloatLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readFloatLE: _read_gen('readFloatLE', 4), | ||
readFloatLE() { | ||
const b = this.read(4) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readFloatLE() | ||
} | ||
@@ -869,8 +914,11 @@ /** | ||
* | ||
* @function readFloatBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readFloatBE: _read_gen('readFloatBE', 4), | ||
readFloatBE() { | ||
const b = this.read(4) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readFloatBE() | ||
} | ||
@@ -881,8 +929,11 @@ /** | ||
* | ||
* @function readDoubleLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readDoubleLE: _read_gen('readDoubleLE', 8), | ||
readDoubleLE() { | ||
const b = this.read(8) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readDoubleLE() | ||
} | ||
@@ -893,10 +944,69 @@ /** | ||
* | ||
* @function readDoubleBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
* @returns {number} value | ||
*/ | ||
readDoubleBE: _read_gen('readDoubleBE', 8) | ||
}) | ||
readDoubleBE() { | ||
const b = this.read(8) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readDoubleBE() | ||
} | ||
/** | ||
* Read a signed 64-bit little-endian BigInt from the stream. | ||
* Consumes 8 bytes. | ||
* | ||
* @returns {bigint} value | ||
*/ | ||
readBigInt64LE() { | ||
const b = this.read(8) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readBigInt64LE() | ||
} | ||
/** | ||
* Read a signed 64-bit big-endian BigInt from the stream. | ||
* Consumes 8 bytes. | ||
* | ||
* @returns {bigint} value | ||
*/ | ||
readBigInt64BE() { | ||
const b = this.read(8) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readBigInt64BE() | ||
} | ||
/** | ||
* Read an unsigned 64-bit little-endian BigInt from the stream. | ||
* Consumes 8 bytes. | ||
* | ||
* @returns {bigint} value | ||
*/ | ||
readBigUInt64LE() { | ||
const b = this.read(8) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readBigUInt64LE() | ||
} | ||
/** | ||
* Read an unsigned 64-bit big-endian BigInt from the stream. | ||
* Consumes 8 bytes. | ||
* | ||
* @returns {bigint} value | ||
*/ | ||
readBigUInt64BE() { | ||
const b = this.read(8) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b.readBigUInt64BE() | ||
} | ||
} | ||
module.exports = NoFilter |
{ | ||
"name": "nofilter", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Read and write a growable buffer as a stream", | ||
"main": "lib/index.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"clean": "rm -rf coverage doc **/.DS_Store", | ||
"lint": "eslint lib/*.js test/*.js", | ||
"lint": "eslint . --ext js", | ||
"coverage": "nyc -r html npm test", | ||
@@ -39,9 +40,9 @@ "test": "mocha test/*.js", | ||
"@cto.af/eslint-config": "*", | ||
"@types/node": "^14.14.25", | ||
"@types/node": "^16.3.2", | ||
"chai": "^4.3", | ||
"coveralls": "^3.1.0", | ||
"eslint": "^7.20.0", | ||
"eslint-plugin-chai-friendly": "^0.6.0", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^7.30.0", | ||
"eslint-plugin-chai-friendly": "^0.7.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"jsdoc": "^3.6.6", | ||
"jsdoc": "^3.6.7", | ||
"minami": "^1.2.3", | ||
@@ -55,4 +56,4 @@ "mocha": "^7.2.0", | ||
"engines": { | ||
"node": ">=10.18" | ||
"node": ">=12.9" | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
[![Build Status](https://travis-ci.org/hildjj/nofilter.svg?branch=master)](https://travis-ci.org/hildjj/nofilter) | ||
[![Coverage Status](https://coveralls.io/repos/hildjj/nofilter/badge.svg?branch=master&service=github)](https://coveralls.io/github/hildjj/nofilter?branch=master) | ||
[![Tests](https://github.com/hildjj/nofilter/actions/workflows/node.js.yml/badge.svg)](https://github.com/hildjj/nofilter/actions/workflows/node.js.yml) | ||
[![coverage](https://codecov.io/gh/hildjj/nofilter/branch/main/graph/badge.svg?token=7BdD02c03C)](https://codecov.io/gh/hildjj/nofilter) | ||
@@ -16,4 +16,9 @@ # NoFilter | ||
```javascript | ||
var NoFilter = require('nofilter'); | ||
nf = new NoFilter(); | ||
const NoFilter = require('nofilter'); | ||
// In ES6: | ||
// import NoFilter from 'nofilter' | ||
// In typescript: | ||
// import NoFilter = require('nofilter') | ||
const nf = new NoFilter(); | ||
nf.on('finish', function() { | ||
@@ -27,4 +32,3 @@ console.log(nf.toString('base64')); | ||
```javascript | ||
var NoFilter = require('nofilter'); | ||
nf = new NoFilter('010203', 'hex'); | ||
const nf = new NoFilter('010203', 'hex'); | ||
nf.pipe(process.stdout); | ||
@@ -31,0 +35,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
43224
5
1364
36