Comparing version 0.0.3 to 1.0.0
1030
lib/index.js
@@ -1,342 +0,808 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
var NoFilter, stream, util, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
'use strict' | ||
stream = require('stream'); | ||
const stream = require('stream') | ||
const util = require('util') | ||
util = require('util'); | ||
/** | ||
* NoFilter stream. Can be used to sink or source data to and from | ||
* other node streams. Implemented as the "identity" Transform stream | ||
* (hence the name), but allows for inspecting data that is in-flight. | ||
* | ||
* Allows passing in source data (input, inputEncoding) at creation | ||
* time. Source data can also be passed in the options object. | ||
* | ||
* @param {string|Buffer} [input] - Source data | ||
* @param {string} [inputEncoding=null] - Encoding name for input, | ||
* ignored if input is not a String | ||
* @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=16kb] - 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 {boolean} [options.objectMode=false] - Whether this stream should | ||
* behave as a stream of objects. Meaning that stream.read(n) returns a | ||
* single value instead of a Buffer of size n | ||
* @param {boolean} [options.decodeStrings=true] - Whether or not to decode | ||
* strings into Buffers before passing them to _write() | ||
* @param {boolean} [options.watchPipe=true] - Whether to watch for 'pipe' | ||
* events, setting this stream's objectMode based on the objectMode of the | ||
* input stream | ||
* | ||
* @example <caption>source</caption> | ||
* const n = new NoFilter('Zm9v', 'base64'); | ||
* n.pipe(process.stdout); | ||
* | ||
* @example <caption>sink</caption> | ||
* const n = new Nofilter(); | ||
* // NOTE: 'finish' fires when the input is done writing | ||
* n.on('finish', function() { console.log(n.toString('base64')); }); | ||
* process.stdin.pipe(n); | ||
* | ||
*/ | ||
class NoFilter extends stream.Transform { | ||
constructor(input, inputEncoding, options) { | ||
if (options == null) { | ||
options = {} | ||
} | ||
let inp | ||
let inpE | ||
switch (typeof(input)) { | ||
case 'object': | ||
if (Buffer.isBuffer(input)) { | ||
inp = input | ||
if ((inputEncoding != null) && (typeof(inputEncoding) === 'object')) { | ||
options = inputEncoding | ||
} | ||
} else { | ||
options = input | ||
} | ||
break | ||
case 'string': | ||
inp = input | ||
if ((inputEncoding != null) && (typeof(inputEncoding) === 'object')) { | ||
options = inputEncoding | ||
} else { | ||
inpE = inputEncoding | ||
} | ||
break | ||
} | ||
module.exports = NoFilter = (function(superClass) { | ||
var _read_gen, _write_gen, get; | ||
if ((options == null)) { | ||
options = {} | ||
} | ||
if (inp == null) { | ||
inp = options.input | ||
} | ||
if (inpE == null) { | ||
inpE = options.inputEncoding | ||
} | ||
delete options.input | ||
delete options.inputEncoding | ||
const watchPipe = options.watchPipe != null ? options.watchPipe : true | ||
delete options.watchPipe | ||
super(options) | ||
extend(NoFilter, superClass); | ||
if (watchPipe) { | ||
this.on('pipe', readable => { | ||
const om = readable._readableState.objectMode | ||
if ((this.length > 0) && (om !== this._readableState.objectMode)) { | ||
throw new Error( | ||
'Do not switch objectMode in the middle of the stream') | ||
} | ||
function NoFilter(input, inputEncoding, options) { | ||
var inp, inpE, ref, watchPipe; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
inp = void 0; | ||
inpE = void 0; | ||
switch (typeof input) { | ||
case 'object': | ||
if (Buffer.isBuffer(input)) { | ||
inp = input; | ||
if ((inputEncoding != null) && (typeof inputEncoding === 'object')) { | ||
options = inputEncoding; | ||
} | ||
} else { | ||
options = input; | ||
} | ||
break; | ||
case 'string': | ||
inp = input; | ||
if ((inputEncoding != null) && (typeof inputEncoding === 'object')) { | ||
options = inputEncoding; | ||
} else { | ||
inpE = inputEncoding; | ||
} | ||
} | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (inp == null) { | ||
inp = options.input; | ||
} | ||
if (inpE == null) { | ||
inpE = options.inputEncoding; | ||
} | ||
delete options.input; | ||
delete options.inputEncoding; | ||
watchPipe = (ref = options.watchPipe) != null ? ref : true; | ||
delete options.watchPipe; | ||
NoFilter.__super__.constructor.call(this, options); | ||
if (watchPipe) { | ||
this.on('pipe', (function(_this) { | ||
return function(readable) { | ||
var om; | ||
om = readable._readableState.objectMode; | ||
if ((_this.length > 0) && (om !== _this._readableState.objectMode)) { | ||
throw new Error('Do not switch objectMode in the middle of the stream'); | ||
} | ||
_this._readableState.objectMode = om; | ||
return _this._writableState.objectMode = om; | ||
}; | ||
})(this)); | ||
} | ||
if (inp != null) { | ||
this.end(inp, inpE); | ||
} | ||
this._readableState.objectMode = om | ||
return this._writableState.objectMode = om | ||
}) | ||
} | ||
NoFilter.isNoFilter = function(obj) { | ||
return obj instanceof this; | ||
}; | ||
if (inp != null) { | ||
this.end(inp, inpE) | ||
} | ||
} | ||
NoFilter.compare = function(nf1, nf2) { | ||
if (!(nf1 instanceof this)) { | ||
throw new TypeError('Arguments must be NoFilters'); | ||
/** | ||
* Is the given object a {NoFilter}? | ||
* | ||
* @param {Object} obj The object to test. | ||
* @returns {boolean} true if obj is a NoFilter | ||
*/ | ||
static isNoFilter(obj) { | ||
return obj instanceof this | ||
} | ||
/** | ||
* The same as nf1.compare(nf2). Useful for sorting an Array of NoFilters. | ||
* | ||
* @param {NoFilter} nf1 - The first object to compare | ||
* @param {NoFilter} nf2 - The second object to compare | ||
* @returns {number} -1, 0, 1 for less, equal, greater | ||
* | ||
* @example | ||
* const arr = [new NoFilter('1234'), new NoFilter('0123')]; | ||
* arr.sort(Buffer.compare); | ||
*/ | ||
static compare(nf1, nf2) { | ||
if (!(nf1 instanceof this)) { | ||
throw new TypeError('Arguments must be NoFilters') | ||
} | ||
if (nf1 === nf2) { | ||
return 0 | ||
} else { | ||
return nf1.compare(nf2) | ||
} | ||
} | ||
/** | ||
* Returns a buffer which is the result of concatenating all the | ||
* NoFilters in the list together. If the list has no items, or if | ||
* the totalLength is 0, then it returns a zero-length buffer. | ||
* | ||
* If length is not provided, it is read from the buffers in the | ||
* list. However, this adds an additional loop to the function, so | ||
* it is faster to provide the length explicitly. | ||
* | ||
* @param {Array<NoFilter>} list Inputs. Must not be in object mode. | ||
* @param {number} [length=null] Number of bytes or objects to read | ||
* @returns {Buffer} The concatenated values | ||
*/ | ||
static concat(list, length) { | ||
if (!Array.isArray(list)) { | ||
throw new TypeError('list argument must be an Array of NoFilters') | ||
} | ||
if ((list.length === 0) || (length === 0)) { | ||
return new Buffer.alloc(0) | ||
} | ||
if ((length == null)) { | ||
length = list.reduce((tot, nf) => { | ||
if (!(nf instanceof NoFilter)) { | ||
throw new TypeError('list argument must be an Array of NoFilters') | ||
} | ||
return tot + nf.length | ||
}, 0) | ||
} | ||
const bufs = list.map((nf) => { | ||
if (!(nf instanceof NoFilter)) { | ||
throw new TypeError('list argument must be an Array of NoFilters') | ||
} | ||
if (nf1 === nf2) { | ||
return 0; | ||
} else { | ||
return nf1.compare(nf2); | ||
if (nf._readableState.objectMode) { | ||
// TODO: if any of them are in object mode, then return an array? | ||
throw new Error('NoFilter may not be in object mode for concat') | ||
} | ||
}; | ||
return nf.slice() | ||
}) | ||
return Buffer.concat(bufs, length) | ||
} | ||
NoFilter.concat = function(list, length) { | ||
var bufs; | ||
if (!Array.isArray(list)) { | ||
throw new TypeError('list argument must be an Array of NoFilters'); | ||
/** | ||
* @private | ||
*/ | ||
_transform(chunk, encoding, callback) { | ||
if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { | ||
chunk = Buffer.from(chunk, encoding) | ||
} | ||
this.push(chunk) | ||
callback() | ||
} | ||
/** | ||
* @private | ||
*/ | ||
_bufArray() { | ||
let bufs = this._readableState.buffer | ||
// HACK: replace with something else one day. This is what I get for | ||
// relying on internals. | ||
if (!Array.isArray(bufs)) { | ||
let b = bufs.head | ||
bufs = [] | ||
while (b != null) { | ||
bufs.push(b.data) | ||
b = b.next | ||
} | ||
if ((list.length === 0) || (length === 0)) { | ||
return new Buffer(0); | ||
} | ||
if (length == null) { | ||
length = list.reduce(function(tot, nf) { | ||
if (!(nf instanceof NoFilter)) { | ||
throw new TypeError('list argument must be an Array of NoFilters'); | ||
} | ||
return tot + nf.length; | ||
}, 0); | ||
} | ||
bufs = list.map(function(nf) { | ||
if (!(nf instanceof NoFilter)) { | ||
throw new TypeError('list argument must be an Array of NoFilters'); | ||
} | ||
return bufs | ||
} | ||
/** | ||
* Pulls some data out of the internal buffer and returns it. | ||
* If there is no data available, then it will return null. | ||
* | ||
* If you pass in a size argument, then it will return that many bytes. If | ||
* size bytes are not available, then it will return null, unless we've | ||
* ended, in which case it will return the data remaining in the buffer. | ||
* | ||
* If you do not specify a size argument, then it will return all the data in | ||
* the internal buffer. | ||
* | ||
* @param {number} [size=null] - Number of bytes to read. | ||
* @returns {string|Buffer|null} If no data or not enough data, null. If | ||
* decoding output a string, otherwise a Buffer | ||
* @fires NoFilter#read | ||
*/ | ||
read(size) { | ||
const buf = super.read(size) | ||
if (buf != null) { | ||
/* | ||
* Read event. Fired whenever anything is read from the stream. | ||
* | ||
* @event NoFilter#read | ||
* @type {Buffer|string|Object} | ||
* | ||
*/ | ||
this.emit('read', buf) | ||
} | ||
return buf | ||
} | ||
/** | ||
* Return a promise fulfilled with the full contents, after the 'finish' | ||
* event fires. Errors on the stream cause the promise to be rejected. | ||
* | ||
* @param {function} [cb=null] - finished/error callback used in *addition* | ||
* to the promise | ||
* @returns {Promise<Buffer>} fulfilled when complete | ||
*/ | ||
promise(cb) { | ||
let done = false | ||
return new Promise((resolve, reject) => { | ||
this.on('finish', () => { | ||
const data = this.read() | ||
if ((cb != null) && !done) { | ||
done = true | ||
cb(null, data) | ||
} | ||
if (nf._readableState.objectMode) { | ||
throw new Error('NoFilter may not be in object mode for concat'); | ||
resolve(data) | ||
}) | ||
this.on('error', (er) => { | ||
if ((cb != null) && !done) { | ||
done = true | ||
cb(er) | ||
} | ||
return nf.slice(); | ||
}); | ||
return Buffer.concat(bufs, length); | ||
}; | ||
reject(er) | ||
}) | ||
}) | ||
} | ||
NoFilter.prototype._transform = function(chunk, encoding, callback) { | ||
if (!this._readableState.objectMode && !Buffer.isBuffer(chunk)) { | ||
chunk = new Buffer(chunk, encoding); | ||
} | ||
this.push(chunk); | ||
return callback(); | ||
}; | ||
/** | ||
* Returns a number indicating whether this comes before or after or is the | ||
* same as the other NoFilter in sort order. | ||
* | ||
* @param {NoFilter} other - The other object to compare | ||
* @returns {Number} -1, 0, 1 for less, equal, greater | ||
*/ | ||
compare(other) { | ||
if (!(other instanceof NoFilter)) { | ||
throw new TypeError('Arguments must be NoFilters') | ||
} | ||
if (this._readableState.objectMode || other._readableState.objectMode) { | ||
throw new Error('Must not be in object mode to compare') | ||
} | ||
if (this === other) { | ||
return 0 | ||
} else { | ||
return this.slice().compare(other.slice()) | ||
} | ||
} | ||
NoFilter.prototype._bufArray = function() { | ||
var b, bufs; | ||
bufs = this._readableState.buffer; | ||
if (!Array.isArray(bufs)) { | ||
b = bufs.head; | ||
bufs = []; | ||
while (b != null) { | ||
bufs.push(b.data); | ||
b = b.next; | ||
} | ||
} | ||
return bufs; | ||
}; | ||
/** | ||
* Do these NoFilter's contain the same bytes? Doesn't work if either is | ||
* in object mode. | ||
* | ||
* @param {NoFilter} other | ||
* @returns {boolean} Equal? | ||
*/ | ||
equals(other) { | ||
return this.compare(other) === 0 | ||
} | ||
NoFilter.prototype.read = function(size) { | ||
var buf; | ||
buf = NoFilter.__super__.read.call(this, size); | ||
if (buf != null) { | ||
this.emit('read', buf); | ||
} | ||
return buf; | ||
}; | ||
/** | ||
* Read bytes or objects without consuming them. Useful for diagnostics. | ||
* Note: as a side-effect, concatenates multiple writes together into what | ||
* looks like a single write, so that this concat doesn't have to happen | ||
* multiple times when you're futzing with the same NoFilter. | ||
* | ||
* @param {Number} [start=0] - beginning offset | ||
* @param {Number} [end=length] - ending offset | ||
* @returns {Buffer|Array} if in object mode, an array of objects. Otherwize, | ||
* concatenated array of contents. | ||
*/ | ||
slice(start, end) { | ||
if (this._readableState.objectMode) { | ||
return this._bufArray().slice(start, end) | ||
} | ||
const bufs = this._bufArray() | ||
switch (bufs.length) { | ||
case 0: return Buffer.alloc(0) | ||
case 1: return bufs[0].slice(start, end) | ||
default: | ||
const b = Buffer.concat(bufs) | ||
// TODO: store the concatented bufs back | ||
// @_readableState.buffer = [b] | ||
return b.slice(start, end) | ||
} | ||
} | ||
NoFilter.prototype.promise = function(cb) { | ||
var done; | ||
done = false; | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
_this.on('finish', function() { | ||
var data; | ||
data = _this.read(); | ||
if ((cb != null) && !done) { | ||
done = true; | ||
cb(null, data); | ||
} | ||
return resolve(data); | ||
}); | ||
return _this.on('error', function(er) { | ||
if ((cb != null) && !done) { | ||
done = true; | ||
cb(er); | ||
} | ||
return reject(er); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
/** | ||
* Get a byte by offset. I didn't want to get into metaprogramming | ||
* to give you the `NoFilter[0]` syntax. | ||
* | ||
* @param {Number} index - The byte to retrieve | ||
* @returns {Number} 0-255 | ||
*/ | ||
get(index) { | ||
return this.slice()[index] | ||
} | ||
NoFilter.prototype.compare = function(other) { | ||
if (!(other instanceof NoFilter)) { | ||
throw new TypeError('Arguments must be NoFilters'); | ||
} | ||
if (this._readableState.objectMode || other._readableState.objectMode) { | ||
throw new Error('Must not be in object mode to compare'); | ||
} | ||
if (this === other) { | ||
return 0; | ||
} else { | ||
return this.slice().compare(other.slice()); | ||
} | ||
}; | ||
/** | ||
* Return an object compatible with Buffer's toJSON implementation, so | ||
* that round-tripping will produce a Buffer. | ||
* | ||
* @returns {Object} | ||
* | ||
* @example output for 'foo' | ||
* { type: 'Buffer', data: [ 102, 111, 111 ] } | ||
*/ | ||
toJSON() { | ||
const b = this.slice() | ||
if (Buffer.isBuffer(b)) { | ||
return b.toJSON() | ||
} else { | ||
return b | ||
} | ||
} | ||
NoFilter.prototype.equals = function(other) { | ||
return this.compare(other) === 0; | ||
}; | ||
/** | ||
* Decodes and returns a string from buffer data encoded using the specified | ||
* character set encoding. If encoding is undefined or null, then encoding | ||
* defaults to 'utf8'. The start and end parameters default to 0 and | ||
* NoFilter.length when undefined. | ||
* | ||
* @param {String} [encoding='utf8'] - Which to use for decoding? | ||
* @param {Number} [start=0] - Start offset | ||
* @param {Number} [end=length] - End offset | ||
* @returns {String} | ||
*/ | ||
toString(encoding, start, end) { | ||
return this.slice().toString(encoding, start, end) | ||
} | ||
NoFilter.prototype.slice = function(start, end) { | ||
var b, bufs; | ||
if (this._readableState.objectMode) { | ||
return this._bufArray().slice(start, end); | ||
} else { | ||
bufs = this._bufArray(); | ||
switch (bufs.length) { | ||
case 0: | ||
return new Buffer(0); | ||
case 1: | ||
return bufs[0].slice(start, end); | ||
default: | ||
b = Buffer.concat(bufs); | ||
return b.slice(start, end); | ||
} | ||
} | ||
}; | ||
/** | ||
* @private | ||
* @deprecated | ||
*/ | ||
inspect(depth, options) { | ||
return this[util.inspect.custom](depth, options) | ||
} | ||
NoFilter.prototype.get = function(index) { | ||
return this.slice()[index]; | ||
}; | ||
NoFilter.prototype.toJSON = function() { | ||
var b; | ||
b = this.slice(); | ||
/** | ||
* @private | ||
*/ | ||
[util.inspect.custom](depth, options) { | ||
const bufs = this._bufArray() | ||
const hex = bufs.map((b) => { | ||
if (Buffer.isBuffer(b)) { | ||
return b.toJSON(); | ||
if ((options != null ? options.stylize : undefined)) { | ||
return options.stylize(b.toString('hex'), 'string') | ||
} else { | ||
return b.toString('hex') | ||
} | ||
} else { | ||
return b; | ||
return util.inspect(b, options) | ||
} | ||
}; | ||
}).join(', ') | ||
return `${this.constructor.name} [${hex}]` | ||
} | ||
NoFilter.prototype.toString = function(encoding, start, end) { | ||
return this.slice().toString(encoding, start, end); | ||
}; | ||
/** | ||
* Current readable length, in bytes. | ||
* | ||
* @member {number} | ||
* @readonly | ||
*/ | ||
get length() { | ||
return this._readableState.length | ||
} | ||
NoFilter.prototype.inspect = function(depth, options) { | ||
var bufs, hex; | ||
bufs = this._bufArray(); | ||
hex = bufs.map(function(b) { | ||
if (Buffer.isBuffer(b)) { | ||
if (options != null ? options.stylize : void 0) { | ||
return options.stylize(b.toString('hex'), 'string'); | ||
} else { | ||
return b.toString('hex'); | ||
} | ||
} else { | ||
return util.inspect(b, options); | ||
} | ||
}).join(', '); | ||
return this.constructor.name + " [" + hex + "]"; | ||
}; | ||
/** | ||
* Write a JavaScript BigInt to the stream. Negative numbers will be | ||
* written as their 2's complement version. | ||
* | ||
* @param {bigint} val - The value to write | ||
* @returns {boolean} true on success | ||
*/ | ||
writeBigInt(val) { | ||
let str = val.toString(16) | ||
if (val < 0) { | ||
// two's complement | ||
// Note: str always starts with '-' here. | ||
const sz = BigInt(Math.floor(str.length / 2)) | ||
const mask = BigInt(1) << (sz * BigInt(8)) | ||
val = mask + val | ||
str = val.toString(16) | ||
} | ||
if (str.length % 2) { | ||
str = '0' + str | ||
} | ||
return this.push(Buffer.from(str, 'hex')) | ||
} | ||
_read_gen = function(meth, len) { | ||
return function(val) { | ||
var b; | ||
b = this.read(len); | ||
if (!Buffer.isBuffer(b)) { | ||
return null; | ||
} | ||
return b[meth].call(b, 0, true); | ||
}; | ||
}; | ||
/** | ||
* Read a variable-sized JavaScript unsigned BigInt from the stream. | ||
* | ||
* @param {number} [len=null] - number of bytes to read or all remaining | ||
* if null | ||
* @returns {bigint} | ||
*/ | ||
readUBigInt(len) { | ||
const b = this.read(len) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return BigInt('0x' + b.toString('hex')) | ||
} | ||
_write_gen = function(meth, len) { | ||
return function(val) { | ||
var b; | ||
b = new Buffer(len); | ||
b[meth].call(b, val, 0, true); | ||
return this.push(b); | ||
}; | ||
}; | ||
/** | ||
* Read a variable-sized JavaScript signed BigInt from the stream in 2's | ||
* complement format. | ||
* | ||
* @param {number} [len=null] - number of bytes to read or all remaining | ||
* if null | ||
* @returns {bigint} | ||
*/ | ||
readBigInt(len) { | ||
const b = this.read(len) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
let ret = BigInt('0x' + b.toString('hex')) | ||
// negative? | ||
if (b[0] & 0x80) { | ||
// two's complement | ||
const mask = BigInt(1) << (BigInt(b.length) * BigInt(8)) | ||
ret = ret - mask | ||
} | ||
return ret | ||
} | ||
} | ||
NoFilter.prototype.writeUInt8 = _write_gen('writeUInt8', 1); | ||
/** | ||
* @private | ||
*/ | ||
function _read_gen(meth, len) { | ||
return function(val) { | ||
const b = this.read(len) | ||
if (!Buffer.isBuffer(b)) { | ||
return null | ||
} | ||
return b[meth].call(b, 0, true) | ||
} | ||
} | ||
NoFilter.prototype.writeUInt16LE = _write_gen('writeUInt16LE', 2); | ||
/** | ||
* @private | ||
*/ | ||
function _write_gen(meth, len) { | ||
return function(val) { | ||
const b = Buffer.alloc(len) | ||
b[meth].call(b, val, 0, true) | ||
return this.push(b) | ||
} | ||
} | ||
NoFilter.prototype.writeUInt16BE = _write_gen('writeUInt16BE', 2); | ||
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 | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt8: _write_gen('writeUInt8', 1), | ||
NoFilter.prototype.writeUInt32LE = _write_gen('writeUInt32LE', 4); | ||
/** | ||
* Write a little-endian 16-bit unsigned integer to the stream. Adds | ||
* 2 bytes. | ||
* | ||
* @function writeUInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt16LE: _write_gen('writeUInt16LE', 2), | ||
NoFilter.prototype.writeUInt32BE = _write_gen('writeUInt32BE', 4); | ||
/** | ||
* Write a big-endian 16-bit unsigned integer to the stream. Adds | ||
* 2 bytes. | ||
* | ||
* @function writeUInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt16BE: _write_gen('writeUInt16BE', 2), | ||
NoFilter.prototype.writeInt8 = _write_gen('writeInt8', 1); | ||
/** | ||
* Write a little-endian 32-bit unsigned integer to the stream. Adds | ||
* 4 bytes. | ||
* | ||
* @function writeUInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt32LE: _write_gen('writeUInt32LE', 4), | ||
NoFilter.prototype.writeInt16LE = _write_gen('writeInt16LE', 2); | ||
/** | ||
* Write a big-endian 32-bit unsigned integer to the stream. Adds | ||
* 4 bytes. | ||
* | ||
* @function writeUInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeUInt32BE: _write_gen('writeUInt32BE', 4), | ||
NoFilter.prototype.writeInt16BE = _write_gen('writeInt16BE', 2); | ||
/** | ||
* Write a signed 8-bit integer to the stream. Adds 1 byte. | ||
* | ||
* @function writeInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt8: _write_gen('writeInt8', 1), | ||
NoFilter.prototype.writeInt32LE = _write_gen('writeInt32LE', 4); | ||
/** | ||
* Write a signed little-endian 16-bit integer to the stream. Adds 2 bytes. | ||
* | ||
* @function writeInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt16LE: _write_gen('writeInt16LE', 2), | ||
NoFilter.prototype.writeInt32BE = _write_gen('writeInt32BE', 4); | ||
/** | ||
* Write a signed big-endian 16-bit integer to the stream. Adds 2 bytes. | ||
* | ||
* @function writeInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt16BE: _write_gen('writeInt16BE', 2), | ||
NoFilter.prototype.writeFloatLE = _write_gen('writeFloatLE', 4); | ||
/** | ||
* Write a signed little-endian 32-bit integer to the stream. Adds 4 bytes. | ||
* | ||
* @function writeInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt32LE: _write_gen('writeInt32LE', 4), | ||
NoFilter.prototype.writeFloatBE = _write_gen('writeFloatBE', 4); | ||
/** | ||
* Write a signed big-endian 32-bit integer to the stream. Adds 4 bytes. | ||
* | ||
* @function writeInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeInt32BE: _write_gen('writeInt32BE', 4), | ||
NoFilter.prototype.writeDoubleLE = _write_gen('writeDoubleLE', 8); | ||
/** | ||
* Write a little-endian 32-bit float to the stream. Adds 4 bytes. | ||
* | ||
* @function writeFloatLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeFloatLE: _write_gen('writeFloatLE', 4), | ||
NoFilter.prototype.writeDoubleBE = _write_gen('writeDoubleBE', 8); | ||
/** | ||
* Write a big-endian 32-bit float to the stream. Adds 4 bytes. | ||
* | ||
* @function writeFloatBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeFloatBE: _write_gen('writeFloatBE', 4), | ||
NoFilter.prototype.readUInt8 = _read_gen('readUInt8', 1); | ||
/** | ||
* Write a little-endian 64-bit float to the stream. Adds 8 bytes. | ||
* | ||
* @function writeDoubleLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeDoubleLE: _write_gen('writeDoubleLE', 8), | ||
NoFilter.prototype.readUInt16LE = _read_gen('readUInt16LE', 2); | ||
/** | ||
* Write a big-endian 64-bit float to the stream. Adds 8 bytes. | ||
* | ||
* @function writeDoubleBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @param {Number} value | ||
* @returns {boolean} true on success | ||
*/ | ||
writeDoubleBE: _write_gen('writeDoubleBE', 8), | ||
NoFilter.prototype.readUInt16BE = _read_gen('readUInt16BE', 2); | ||
/** | ||
* Read an unsigned 8-bit integer from the stream. Consumes 1 byte. | ||
* | ||
* @function readUInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readUInt8: _read_gen('readUInt8', 1), | ||
NoFilter.prototype.readUInt32LE = _read_gen('readUInt32LE', 4); | ||
/** | ||
* Read a little-endian unsigned 16-bit integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readUInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readUInt16LE: _read_gen('readUInt16LE', 2), | ||
NoFilter.prototype.readUInt32BE = _read_gen('readUInt32BE', 4); | ||
/** | ||
* Read a big-endian unsigned 16-bit integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readUInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readUInt16BE: _read_gen('readUInt16BE', 2), | ||
NoFilter.prototype.readInt8 = _read_gen('readInt8', 1); | ||
/** | ||
* Read a little-endian unsigned 32-bit integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readUInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readUInt32LE: _read_gen('readUInt32LE', 4), | ||
NoFilter.prototype.readInt16LE = _read_gen('readInt16LE', 2); | ||
/** | ||
* Read a big-endian unsigned 16-bit integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readUInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readUInt32BE: _read_gen('readUInt32BE', 4), | ||
NoFilter.prototype.readInt16BE = _read_gen('readInt16BE', 2); | ||
/** | ||
* Read a signed 8-bit integer from the stream. | ||
* Consumes 1 byte. | ||
* | ||
* @function readInt8 | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readInt8: _read_gen('readInt8', 1), | ||
NoFilter.prototype.readInt32LE = _read_gen('readInt32LE', 4); | ||
/** | ||
* Read a signed 16-bit little-endian integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readInt16LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readInt16LE: _read_gen('readInt16LE', 2), | ||
NoFilter.prototype.readInt32BE = _read_gen('readInt32BE', 4); | ||
/** | ||
* Read a signed 16-bit big-endian integer from the stream. | ||
* Consumes 2 bytes. | ||
* | ||
* @function readInt16BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readInt16BE: _read_gen('readInt16BE', 2), | ||
NoFilter.prototype.readFloatLE = _read_gen('readFloatLE', 4); | ||
/** | ||
* Read a signed 32-bit little-endian integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readInt32LE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readInt32LE: _read_gen('readInt32LE', 4), | ||
NoFilter.prototype.readFloatBE = _read_gen('readFloatBE', 4); | ||
/** | ||
* Read a signed 32-bit big-endian integer from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readInt32BE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readInt32BE: _read_gen('readInt32BE', 4), | ||
NoFilter.prototype.readDoubleLE = _read_gen('readDoubleLE', 8); | ||
/** | ||
* Read a 32-bit little-endian float from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readFloatLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readFloatLE: _read_gen('readFloatLE', 4), | ||
NoFilter.prototype.readDoubleBE = _read_gen('readDoubleBE', 8); | ||
/** | ||
* Read a 32-bit big-endian float from the stream. | ||
* Consumes 4 bytes. | ||
* | ||
* @function readFloatBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readFloatBE: _read_gen('readFloatBE', 4), | ||
get = function(props) { | ||
var getter, name, results; | ||
results = []; | ||
for (name in props) { | ||
getter = props[name]; | ||
results.push(NoFilter.prototype.__defineGetter__(name, getter)); | ||
} | ||
return results; | ||
}; | ||
/** | ||
* Read a 64-bit little-endian float from the stream. | ||
* Consumes 8 bytes. | ||
* | ||
* @function readDoubleLE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readDoubleLE: _read_gen('readDoubleLE', 8), | ||
get({ | ||
length: function() { | ||
return this._readableState.length; | ||
} | ||
}); | ||
/** | ||
* Read a 64-bit big-endian float from the stream. | ||
* Consumes 8 bytes. | ||
* | ||
* @function readDoubleBE | ||
* @memberOf NoFilter | ||
* @instance | ||
* @returns {Number} value | ||
*/ | ||
readDoubleBE: _read_gen('readDoubleBE', 8) | ||
}) | ||
return NoFilter; | ||
})(stream.Transform); | ||
}).call(this); | ||
//# sourceMappingURL=index.js.map | ||
module.exports = NoFilter |
{ | ||
"name": "nofilter", | ||
"version": "0.0.3", | ||
"version": "1.0.0", | ||
"description": "Read and write a growable buffer as a stream", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"clean": "rm -rf coverage lib doc man/* **/.DS_Store", | ||
"lint": "coffeelint src test", | ||
"coffee": "coffee -cm -o lib/ src", | ||
"clean": "rm -rf coverage doc man/* **/.DS_Store", | ||
"lint": "eslint lib/*.js bin/* test/*.js", | ||
"coverage": "nyc -r none npm test", | ||
"precoverage": "npm run coffee -s", | ||
"coveragehtml": "nyc report -r html", | ||
"precoveragehtml": "npm run coverage", | ||
"test": "mocha test/*.coffee", | ||
"pretest": "npm run coffee -s", | ||
"doc": "codo src", | ||
"prepublish": "npm run coffee && npm run doc", | ||
"watch": "watch 'npm run coveragehtml' src/", | ||
"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", | ||
@@ -45,9 +41,12 @@ "coveralls": "nyc report --reporter=text-lcov | coveralls" | ||
"devDependencies": { | ||
"chai": "^3.3", | ||
"codo": "^2.1", | ||
"coffee-script": "^1.10", | ||
"coveralls": "^2.11", | ||
"mocha": "^3.0", | ||
"nyc": "^8.1" | ||
"chai": "^4.1", | ||
"coveralls": "^3.0.2", | ||
"jsdoc": "^3.5.5", | ||
"minami": "^1.2.3", | ||
"mocha": "^5.2.0", | ||
"nyc": "^12.0.2" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
} | ||
} |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
752
0
24544
4
1