diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2018-02-17 05:58:58 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-02-20 07:19:40 +0300 |
commit | dabdf57b2d60d665728894b4c1397b35aa9d41c0 (patch) | |
tree | 1ef82c16d05ff8235cf4bb1fe40f7d2193e2bd4f /node_modules/npm-profile | |
parent | 9999e83f87c957113a12a6bf014a2099d720d716 (diff) |
mississippi@2.0.0
Diffstat (limited to 'node_modules/npm-profile')
105 files changed, 6310 insertions, 0 deletions
diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/index.js new file mode 100644 index 000000000..d635b29c5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/index.js @@ -0,0 +1,10 @@ +module.exports.pipe = require('pump') +module.exports.each = require('stream-each') +module.exports.pipeline = require('pumpify') +module.exports.duplex = require('duplexify') +module.exports.through = require('through2') +module.exports.concat = require('concat-stream') +module.exports.finished = require('end-of-stream') +module.exports.from = require('from2') +module.exports.to = require('flush-write-stream') +module.exports.parallel = require('parallel-transform') diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/LICENSE new file mode 100644 index 000000000..99c130e1d --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/LICENSE @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2013 Max Ogden + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/index.js new file mode 100644 index 000000000..b16ad1343 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/index.js @@ -0,0 +1,143 @@ +var Writable = require('readable-stream').Writable +var inherits = require('inherits') + +if (typeof Uint8Array === 'undefined') { + var U8 = require('typedarray').Uint8Array +} else { + var U8 = Uint8Array +} + +function ConcatStream(opts, cb) { + if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb) + + if (typeof opts === 'function') { + cb = opts + opts = {} + } + if (!opts) opts = {} + + var encoding = opts.encoding + var shouldInferEncoding = false + + if (!encoding) { + shouldInferEncoding = true + } else { + encoding = String(encoding).toLowerCase() + if (encoding === 'u8' || encoding === 'uint8') { + encoding = 'uint8array' + } + } + + Writable.call(this, { objectMode: true }) + + this.encoding = encoding + this.shouldInferEncoding = shouldInferEncoding + + if (cb) this.on('finish', function () { cb(this.getBody()) }) + this.body = [] +} + +module.exports = ConcatStream +inherits(ConcatStream, Writable) + +ConcatStream.prototype._write = function(chunk, enc, next) { + this.body.push(chunk) + next() +} + +ConcatStream.prototype.inferEncoding = function (buff) { + var firstBuffer = buff === undefined ? this.body[0] : buff; + if (Buffer.isBuffer(firstBuffer)) return 'buffer' + if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array' + if (Array.isArray(firstBuffer)) return 'array' + if (typeof firstBuffer === 'string') return 'string' + if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object' + return 'buffer' +} + +ConcatStream.prototype.getBody = function () { + if (!this.encoding && this.body.length === 0) return [] + if (this.shouldInferEncoding) this.encoding = this.inferEncoding() + if (this.encoding === 'array') return arrayConcat(this.body) + if (this.encoding === 'string') return stringConcat(this.body) + if (this.encoding === 'buffer') return bufferConcat(this.body) + if (this.encoding === 'uint8array') return u8Concat(this.body) + return this.body +} + +var isArray = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]' +} + +function isArrayish (arr) { + return /Array\]$/.test(Object.prototype.toString.call(arr)) +} + +function isBufferish (p) { + return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function') +} + +function stringConcat (parts) { + var strings = [] + var needsToString = false + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (typeof p === 'string') { + strings.push(p) + } else if (Buffer.isBuffer(p)) { + strings.push(p) + } else if (isBufferish(p)) { + strings.push(new Buffer(p)) + } else { + strings.push(new Buffer(String(p))) + } + } + if (Buffer.isBuffer(parts[0])) { + strings = Buffer.concat(strings) + strings = strings.toString('utf8') + } else { + strings = strings.join('') + } + return strings +} + +function bufferConcat (parts) { + var bufs = [] + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (Buffer.isBuffer(p)) { + bufs.push(p) + } else if (isBufferish(p)) { + bufs.push(new Buffer(p)) + } else { + bufs.push(new Buffer(String(p))) + } + } + return Buffer.concat(bufs) +} + +function arrayConcat (parts) { + var res = [] + for (var i = 0; i < parts.length; i++) { + res.push.apply(res, parts[i]) + } + return res +} + +function u8Concat (parts) { + var len = 0 + for (var i = 0; i < parts.length; i++) { + if (typeof parts[i] === 'string') { + parts[i] = new Buffer(parts[i]) + } + len += parts[i].length + } + var u8 = new U8(len) + for (var i = 0, offset = 0; i < parts.length; i++) { + var part = parts[i] + for (var j = 0; j < part.length; j++) { + u8[offset++] = part[j] + } + } + return u8 +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/.travis.yml new file mode 100644 index 000000000..cc4dba29d --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/LICENSE new file mode 100644 index 000000000..11adfaec9 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/LICENSE @@ -0,0 +1,35 @@ +/* + Copyright (c) 2010, Linden Research, Inc. + Copyright (c) 2012, Joshua Bell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + $/LicenseInfo$ + */ + +// Original can be found at: +// https://bitbucket.org/lindenlab/llsd +// Modifications by Joshua Bell inexorabletash@gmail.com +// https://github.com/inexorabletash/polyfill + +// ES3/ES5 implementation of the Krhonos Typed Array Specification +// Ref: http://www.khronos.org/registry/typedarray/specs/latest/ +// Date: 2011-02-01 +// +// Variations: +// * Allows typed_array.get/set() as alias for subscripts (typed_array[]) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/example/tarray.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/example/tarray.js new file mode 100644 index 000000000..8423d7c9b --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/example/tarray.js @@ -0,0 +1,4 @@ +var Uint8Array = require('../').Uint8Array; +var ua = new Uint8Array(5); +ua[1] = 256 + 55; +console.log(ua[1]); diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/index.js new file mode 100644 index 000000000..5e540841f --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/index.js @@ -0,0 +1,630 @@ +var undefined = (void 0); // Paranoia + +// Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to +// create, and consume so much memory, that the browser appears frozen. +var MAX_ARRAY_LENGTH = 1e5; + +// Approximations of internal ECMAScript conversion functions +var ECMAScript = (function() { + // Stash a copy in case other scripts modify these + var opts = Object.prototype.toString, + ophop = Object.prototype.hasOwnProperty; + + return { + // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues: + Class: function(v) { return opts.call(v).replace(/^\[object *|\]$/g, ''); }, + HasProperty: function(o, p) { return p in o; }, + HasOwnProperty: function(o, p) { return ophop.call(o, p); }, + IsCallable: function(o) { return typeof o === 'function'; }, + ToInt32: function(v) { return v >> 0; }, + ToUint32: function(v) { return v >>> 0; } + }; +}()); + +// Snapshot intrinsics +var LN2 = Math.LN2, + abs = Math.abs, + floor = Math.floor, + log = Math.log, + min = Math.min, + pow = Math.pow, + round = Math.round; + +// ES5: lock down object properties +function configureProperties(obj) { + if (getOwnPropNames && defineProp) { + var props = getOwnPropNames(obj), i; + for (i = 0; i < props.length; i += 1) { + defineProp(obj, props[i], { + value: obj[props[i]], + writable: false, + enumerable: false, + configurable: false + }); + } + } +} + +// emulate ES5 getter/setter API using legacy APIs +// http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx +// (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but +// note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless) +var defineProp +if (Object.defineProperty && (function() { + try { + Object.defineProperty({}, 'x', {}); + return true; + } catch (e) { + return false; + } + })()) { + defineProp = Object.defineProperty; +} else { + defineProp = function(o, p, desc) { + if (!o === Object(o)) throw new TypeError("Object.defineProperty called on non-object"); + if (ECMAScript.HasProperty(desc, 'get') && Object.prototype.__defineGetter__) { Object.prototype.__defineGetter__.call(o, p, desc.get); } + if (ECMAScript.HasProperty(desc, 'set') && Object.prototype.__defineSetter__) { Object.prototype.__defineSetter__.call(o, p, desc.set); } + if (ECMAScript.HasProperty(desc, 'value')) { o[p] = desc.value; } + return o; + }; +} + +var getOwnPropNames = Object.getOwnPropertyNames || function (o) { + if (o !== Object(o)) throw new TypeError("Object.getOwnPropertyNames called on non-object"); + var props = [], p; + for (p in o) { + if (ECMAScript.HasOwnProperty(o, p)) { + props.push(p); + } + } + return props; +}; + +// ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value) +// for index in 0 ... obj.length +function makeArrayAccessors(obj) { + if (!defineProp) { return; } + + if (obj.length > MAX_ARRAY_LENGTH) throw new RangeError("Array too large for polyfill"); + + function makeArrayAccessor(index) { + defineProp(obj, index, { + 'get': function() { return obj._getter(index); }, + 'set': function(v) { obj._setter(index, v); }, + enumerable: true, + configurable: false + }); + } + + var i; + for (i = 0; i < obj.length; i += 1) { + makeArrayAccessor(i); + } +} + +// Internal conversion functions: +// pack<Type>() - take a number (interpreted as Type), output a byte array +// unpack<Type>() - take a byte array, output a Type-like number + +function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; } +function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; } + +function packI8(n) { return [n & 0xff]; } +function unpackI8(bytes) { return as_signed(bytes[0], 8); } + +function packU8(n) { return [n & 0xff]; } +function unpackU8(bytes) { return as_unsigned(bytes[0], 8); } + +function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; } + +function packI16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackI16(bytes) { return as_signed(bytes[0] << 8 | bytes[1], 16); } + +function packU16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackU16(bytes) { return as_unsigned(bytes[0] << 8 | bytes[1], 16); } + +function packI32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackI32(bytes) { return as_signed(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + +function packU32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackU32(bytes) { return as_unsigned(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + +function packIEEE754(v, ebits, fbits) { + + var bias = (1 << (ebits - 1)) - 1, + s, e, f, ln, + i, bits, str, bytes; + + function roundToEven(n) { + var w = floor(n), f = n - w; + if (f < 0.5) + return w; + if (f > 0.5) + return w + 1; + return w % 2 ? w + 1 : w; + } + + // Compute sign, exponent, fraction + if (v !== v) { + // NaN + // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping + e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); + + if (v >= pow(2, 1 - bias)) { + e = min(floor(log(v) / LN2), 1023); + f = roundToEven(v / pow(2, e) * pow(2, fbits)); + if (f / pow(2, fbits) >= 2) { + e = e + 1; + f = 1; + } + if (e > bias) { + // Overflow + e = (1 << ebits) - 1; + f = 0; + } else { + // Normalized + e = e + bias; + f = f - pow(2, fbits); + } + } else { + // Denormalized + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); + } + } + + // Pack sign, exponent, fraction + bits = []; + for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); } + for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); } + bits.push(s ? 1 : 0); + bits.reverse(); + str = bits.join(''); + + // Bits to bytes + bytes = []; + while (str.length) { + bytes.push(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; +} + +function unpackIEEE754(bytes, ebits, fbits) { + + // Bytes to bits + var bits = [], i, j, b, str, + bias, s, e, f; + + for (i = bytes.length; i; i -= 1) { + b = bytes[i - 1]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); + + // Unpack sign, exponent, fraction + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); + + // Produce number + if (e === (1 << ebits) - 1) { + return f !== 0 ? NaN : s * Infinity; + } else if (e > 0) { + // Normalized + return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + } else if (f !== 0) { + // Denormalized + return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + } else { + return s < 0 ? -0 : 0; + } +} + +function unpackF64(b) { return unpackIEEE754(b, 11, 52); } +function packF64(v) { return packIEEE754(v, 11, 52); } +function unpackF32(b) { return unpackIEEE754(b, 8, 23); } +function packF32(v) { return packIEEE754(v, 8, 23); } + + +// +// 3 The ArrayBuffer Type +// + +(function() { + + /** @constructor */ + var ArrayBuffer = function ArrayBuffer(length) { + length = ECMAScript.ToInt32(length); + if (length < 0) throw new RangeError('ArrayBuffer size is not a small enough positive integer'); + + this.byteLength = length; + this._bytes = []; + this._bytes.length = length; + + var i; + for (i = 0; i < this.byteLength; i += 1) { + this._bytes[i] = 0; + } + + configureProperties(this); + }; + + exports.ArrayBuffer = exports.ArrayBuffer || ArrayBuffer; + + // + // 4 The ArrayBufferView Type + // + + // NOTE: this constructor is not exported + /** @constructor */ + var ArrayBufferView = function ArrayBufferView() { + //this.buffer = null; + //this.byteOffset = 0; + //this.byteLength = 0; + }; + + // + // 5 The Typed Array View Types + // + + function makeConstructor(bytesPerElement, pack, unpack) { + // Each TypedArray type requires a distinct constructor instance with + // identical logic, which this produces. + + var ctor; + ctor = function(buffer, byteOffset, length) { + var array, sequence, i, s; + + if (!arguments.length || typeof arguments[0] === 'number') { + // Constructor(unsigned long length) + this.length = ECMAScript.ToInt32(arguments[0]); + if (length < 0) throw new RangeError('ArrayBufferView size is not a small enough positive integer'); + + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + } else if (typeof arguments[0] === 'object' && arguments[0].constructor === ctor) { + // Constructor(TypedArray array) + array = arguments[0]; + + this.length = array.length; + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + + for (i = 0; i < this.length; i += 1) { + this._setter(i, array._getter(i)); + } + } else if (typeof arguments[0] === 'object' && + !(arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(sequence<type> array) + sequence = arguments[0]; + + this.length = ECMAScript.ToUint32(sequence.length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + + for (i = 0; i < this.length; i += 1) { + s = sequence[i]; + this._setter(i, Number(s)); + } + } else if (typeof arguments[0] === 'object' && + (arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, optional unsigned long length) + this.buffer = buffer; + + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } + + if (this.byteOffset % this.BYTES_PER_ELEMENT) { + // The given byteOffset must be a multiple of the element + // size of the specific type, otherwise an exception is raised. + throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size."); + } + + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + + if (this.byteLength % this.BYTES_PER_ELEMENT) { + throw new RangeError("length of buffer minus byteOffset not a multiple of the element size"); + } + this.length = this.byteLength / this.BYTES_PER_ELEMENT; + } else { + this.length = ECMAScript.ToUint32(length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + } + + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + + this.constructor = ctor; + + configureProperties(this); + makeArrayAccessors(this); + }; + + ctor.prototype = new ArrayBufferView(); + ctor.prototype.BYTES_PER_ELEMENT = bytesPerElement; + ctor.prototype._pack = pack; + ctor.prototype._unpack = unpack; + ctor.BYTES_PER_ELEMENT = bytesPerElement; + + // getter type (unsigned long index); + ctor.prototype._getter = function(index) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined; + } + + var bytes = [], i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + bytes.push(this.buffer._bytes[o]); + } + return this._unpack(bytes); + }; + + // NONSTANDARD: convenience alias for getter: type get(unsigned long index); + ctor.prototype.get = ctor.prototype._getter; + + // setter void (unsigned long index, type value); + ctor.prototype._setter = function(index, value) { + if (arguments.length < 2) throw new SyntaxError("Not enough arguments"); + + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined; + } + + var bytes = this._pack(value), i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + this.buffer._bytes[o] = bytes[i]; + } + }; + + // void set(TypedArray array, optional unsigned long offset); + // void set(sequence<type> array, optional unsigned long offset); + ctor.prototype.set = function(index, value) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + var array, sequence, offset, len, + i, s, d, + byteOffset, byteLength, tmp; + + if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) { + // void set(TypedArray array, optional unsigned long offset); + array = arguments[0]; + offset = ECMAScript.ToUint32(arguments[1]); + + if (offset + array.length > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } + + byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT; + byteLength = array.length * this.BYTES_PER_ELEMENT; + + if (array.buffer === this.buffer) { + tmp = []; + for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) { + tmp[i] = array.buffer._bytes[s]; + } + for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) { + this.buffer._bytes[d] = tmp[i]; + } + } else { + for (i = 0, s = array.byteOffset, d = byteOffset; + i < byteLength; i += 1, s += 1, d += 1) { + this.buffer._bytes[d] = array.buffer._bytes[s]; + } + } + } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') { + // void set(sequence<type> array, optional unsigned long offset); + sequence = arguments[0]; + len = ECMAScript.ToUint32(sequence.length); + offset = ECMAScript.ToUint32(arguments[1]); + + if (offset + len > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } + + for (i = 0; i < len; i += 1) { + s = sequence[i]; + this._setter(offset + i, Number(s)); + } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + }; + + // TypedArray subarray(long begin, optional long end); + ctor.prototype.subarray = function(start, end) { + function clamp(v, min, max) { return v < min ? min : v > max ? max : v; } + + start = ECMAScript.ToInt32(start); + end = ECMAScript.ToInt32(end); + + if (arguments.length < 1) { start = 0; } + if (arguments.length < 2) { end = this.length; } + + if (start < 0) { start = this.length + start; } + if (end < 0) { end = this.length + end; } + + start = clamp(start, 0, this.length); + end = clamp(end, 0, this.length); + + var len = end - start; + if (len < 0) { + len = 0; + } + + return new this.constructor( + this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len); + }; + + return ctor; + } + + var Int8Array = makeConstructor(1, packI8, unpackI8); + var Uint8Array = makeConstructor(1, packU8, unpackU8); + var Uint8ClampedArray = makeConstructor(1, packU8Clamped, unpackU8); + var Int16Array = makeConstructor(2, packI16, unpackI16); + var Uint16Array = makeConstructor(2, packU16, unpackU16); + var Int32Array = makeConstructor(4, packI32, unpackI32); + var Uint32Array = makeConstructor(4, packU32, unpackU32); + var Float32Array = makeConstructor(4, packF32, unpackF32); + var Float64Array = makeConstructor(8, packF64, unpackF64); + + exports.Int8Array = exports.Int8Array || Int8Array; + exports.Uint8Array = exports.Uint8Array || Uint8Array; + exports.Uint8ClampedArray = exports.Uint8ClampedArray || Uint8ClampedArray; + exports.Int16Array = exports.Int16Array || Int16Array; + exports.Uint16Array = exports.Uint16Array || Uint16Array; + exports.Int32Array = exports.Int32Array || Int32Array; + exports.Uint32Array = exports.Uint32Array || Uint32Array; + exports.Float32Array = exports.Float32Array || Float32Array; + exports.Float64Array = exports.Float64Array || Float64Array; +}()); + +// +// 6 The DataView View Type +// + +(function() { + function r(array, index) { + return ECMAScript.IsCallable(array.get) ? array.get(index) : array[index]; + } + + var IS_BIG_ENDIAN = (function() { + var u16array = new(exports.Uint16Array)([0x1234]), + u8array = new(exports.Uint8Array)(u16array.buffer); + return r(u8array, 0) === 0x12; + }()); + + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, + // optional unsigned long byteLength) + /** @constructor */ + var DataView = function DataView(buffer, byteOffset, byteLength) { + if (arguments.length === 0) { + buffer = new exports.ArrayBuffer(0); + } else if (!(buffer instanceof exports.ArrayBuffer || ECMAScript.Class(buffer) === 'ArrayBuffer')) { + throw new TypeError("TypeError"); + } + + this.buffer = buffer || new exports.ArrayBuffer(0); + + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } + + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + } else { + this.byteLength = ECMAScript.ToUint32(byteLength); + } + + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } + + configureProperties(this); + }; + + function makeGetter(arrayType) { + return function(byteOffset, littleEndian) { + + byteOffset = ECMAScript.ToUint32(byteOffset); + + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + byteOffset += this.byteOffset; + + var uint8Array = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT), + bytes = [], i; + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(uint8Array, i)); + } + + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } + + return r(new arrayType(new exports.Uint8Array(bytes).buffer), 0); + }; + } + + DataView.prototype.getUint8 = makeGetter(exports.Uint8Array); + DataView.prototype.getInt8 = makeGetter(exports.Int8Array); + DataView.prototype.getUint16 = makeGetter(exports.Uint16Array); + DataView.prototype.getInt16 = makeGetter(exports.Int16Array); + DataView.prototype.getUint32 = makeGetter(exports.Uint32Array); + DataView.prototype.getInt32 = makeGetter(exports.Int32Array); + DataView.prototype.getFloat32 = makeGetter(exports.Float32Array); + DataView.prototype.getFloat64 = makeGetter(exports.Float64Array); + + function makeSetter(arrayType) { + return function(byteOffset, value, littleEndian) { + + byteOffset = ECMAScript.ToUint32(byteOffset); + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + + // Get bytes + var typeArray = new arrayType([value]), + byteArray = new exports.Uint8Array(typeArray.buffer), + bytes = [], i, byteView; + + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(byteArray, i)); + } + + // Flip if necessary + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } + + // Write them + byteView = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT); + byteView.set(bytes); + }; + } + + DataView.prototype.setUint8 = makeSetter(exports.Uint8Array); + DataView.prototype.setInt8 = makeSetter(exports.Int8Array); + DataView.prototype.setUint16 = makeSetter(exports.Uint16Array); + DataView.prototype.setInt16 = makeSetter(exports.Int16Array); + DataView.prototype.setUint32 = makeSetter(exports.Uint32Array); + DataView.prototype.setInt32 = makeSetter(exports.Int32Array); + DataView.prototype.setFloat32 = makeSetter(exports.Float32Array); + DataView.prototype.setFloat64 = makeSetter(exports.Float64Array); + + exports.DataView = exports.DataView || DataView; + +}()); diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/package.json new file mode 100644 index 000000000..e78d29033 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/package.json @@ -0,0 +1,83 @@ +{ + "_from": "typedarray@^0.0.6", + "_id": "typedarray@0.0.6", + "_inBundle": false, + "_integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "_location": "/npm-profile/make-fetch-happen/mississippi/concat-stream/typedarray", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "typedarray@^0.0.6", + "name": "typedarray", + "escapedName": "typedarray", + "rawSpec": "^0.0.6", + "saveSpec": null, + "fetchSpec": "^0.0.6" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi/concat-stream" + ], + "_resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "_shasum": "867ac74e3864187b1d3d47d996a78ec5c8830777", + "_spec": "typedarray@^0.0.6", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/typedarray/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "TypedArray polyfill for old browsers", + "devDependencies": { + "tape": "~2.3.2" + }, + "homepage": "https://github.com/substack/typedarray", + "keywords": [ + "ArrayBuffer", + "DataView", + "Float32Array", + "Float64Array", + "Int8Array", + "Int16Array", + "Int32Array", + "Uint8Array", + "Uint8ClampedArray", + "Uint16Array", + "Uint32Array", + "typed", + "array", + "polyfill" + ], + "license": "MIT", + "main": "index.js", + "name": "typedarray", + "repository": { + "type": "git", + "url": "git://github.com/substack/typedarray.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "testling": { + "files": "test/*.js", + "browsers": [ + "ie/6..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "0.0.6" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/readme.markdown b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/readme.markdown new file mode 100644 index 000000000..d18f6f719 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/readme.markdown @@ -0,0 +1,61 @@ +# typedarray + +TypedArray polyfill ripped from [this +module](https://raw.github.com/inexorabletash/polyfill). + +[![build status](https://secure.travis-ci.org/substack/typedarray.png)](http://travis-ci.org/substack/typedarray) + +[![testling badge](https://ci.testling.com/substack/typedarray.png)](https://ci.testling.com/substack/typedarray) + +# example + +``` js +var Uint8Array = require('typedarray').Uint8Array; +var ua = new Uint8Array(5); +ua[1] = 256 + 55; +console.log(ua[1]); +``` + +output: + +``` +55 +``` + +# methods + +``` js +var TA = require('typedarray') +``` + +The `TA` object has the following constructors: + +* TA.ArrayBuffer +* TA.DataView +* TA.Float32Array +* TA.Float64Array +* TA.Int8Array +* TA.Int16Array +* TA.Int32Array +* TA.Uint8Array +* TA.Uint8ClampedArray +* TA.Uint16Array +* TA.Uint32Array + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install typedarray +``` + +To use this module in the browser, compile with +[browserify](http://browserify.org) +or download a UMD build from browserify CDN: + +http://wzrd.in/standalone/typedarray@latest + +# license + +MIT diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/test/server/undef_globals.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/test/server/undef_globals.js new file mode 100644 index 000000000..425950f9f --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/test/server/undef_globals.js @@ -0,0 +1,19 @@ +var test = require('tape'); +var vm = require('vm'); +var fs = require('fs'); +var src = fs.readFileSync(__dirname + '/../../index.js', 'utf8'); + +test('u8a without globals', function (t) { + var c = { + module: { exports: {} }, + }; + c.exports = c.module.exports; + vm.runInNewContext(src, c); + var TA = c.module.exports; + var ua = new(TA.Uint8Array)(5); + + t.equal(ua.length, 5); + ua[1] = 256 + 55; + t.equal(ua[1], 55); + t.end(); +}); diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/test/tarray.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/test/tarray.js new file mode 100644 index 000000000..df596a34f --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/node_modules/typedarray/test/tarray.js @@ -0,0 +1,10 @@ +var TA = require('../'); +var test = require('tape'); + +test('tiny u8a test', function (t) { + var ua = new(TA.Uint8Array)(5); + t.equal(ua.length, 5); + ua[1] = 256 + 55; + t.equal(ua[1], 55); + t.end(); +}); diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/package.json new file mode 100644 index 000000000..96d51c9ff --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/package.json @@ -0,0 +1,83 @@ +{ + "_from": "concat-stream@^1.5.0", + "_id": "concat-stream@1.6.0", + "_inBundle": false, + "_integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "_location": "/npm-profile/make-fetch-happen/mississippi/concat-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "concat-stream@^1.5.0", + "name": "concat-stream", + "escapedName": "concat-stream", + "rawSpec": "^1.5.0", + "saveSpec": null, + "fetchSpec": "^1.5.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "_shasum": "0aac662fd52be78964d5532f694784e70110acf7", + "_spec": "concat-stream@^1.5.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Max Ogden", + "email": "max@maxogden.com" + }, + "bugs": { + "url": "http://github.com/maxogden/concat-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "deprecated": false, + "description": "writable stream that concatenates strings or binary data and calls a callback with the result", + "devDependencies": { + "tape": "^4.6.3" + }, + "engines": [ + "node >= 0.8" + ], + "files": [ + "index.js" + ], + "homepage": "https://github.com/maxogden/concat-stream#readme", + "license": "MIT", + "main": "index.js", + "name": "concat-stream", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/maxogden/concat-stream.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "tags": [ + "stream", + "simple", + "util", + "utility" + ], + "testling": { + "files": "test/*.js", + "browsers": [ + "ie/8..latest", + "firefox/17..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "1.6.0" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/readme.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/readme.md new file mode 100644 index 000000000..f45e6fc87 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/concat-stream/readme.md @@ -0,0 +1,102 @@ +# concat-stream + +Writable stream that concatenates all the data from a stream and calls a callback with the result. Use this when you want to collect all the data from a stream into a single buffer. + +[![Build Status](https://travis-ci.org/maxogden/concat-stream.svg?branch=master)](https://travis-ci.org/maxogden/concat-stream) + +[![NPM](https://nodei.co/npm/concat-stream.png)](https://nodei.co/npm/concat-stream/) + +### description + +Streams emit many buffers. If you want to collect all of the buffers, and when the stream ends concatenate all of the buffers together and receive a single buffer then this is the module for you. + +Only use this if you know you can fit all of the output of your stream into a single Buffer (e.g. in RAM). + +There are also `objectMode` streams that emit things other than Buffers, and you can concatenate these too. See below for details. + +## Related + +`concat-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. + +### examples + +#### Buffers + +```js +var fs = require('fs') +var concat = require('concat-stream') + +var readStream = fs.createReadStream('cat.png') +var concatStream = concat(gotPicture) + +readStream.on('error', handleError) +readStream.pipe(concatStream) + +function gotPicture(imageBuffer) { + // imageBuffer is all of `cat.png` as a node.js Buffer +} + +function handleError(err) { + // handle your error appropriately here, e.g.: + console.error(err) // print the error to STDERR + process.exit(1) // exit program with non-zero exit code +} + +``` + +#### Arrays + +```js +var write = concat(function(data) {}) +write.write([1,2,3]) +write.write([4,5,6]) +write.end() +// data will be [1,2,3,4,5,6] in the above callback +``` + +#### Uint8Arrays + +```js +var write = concat(function(data) {}) +var a = new Uint8Array(3) +a[0] = 97; a[1] = 98; a[2] = 99 +write.write(a) +write.write('!') +write.end(Buffer('!!1')) +``` + +See `test/` for more examples + +# methods + +```js +var concat = require('concat-stream') +``` + +## var writable = concat(opts={}, cb) + +Return a `writable` stream that will fire `cb(data)` with all of the data that +was written to the stream. Data can be written to `writable` as strings, +Buffers, arrays of byte integers, and Uint8Arrays. + +By default `concat-stream` will give you back the same data type as the type of the first buffer written to the stream. Use `opts.encoding` to set what format `data` should be returned as, e.g. if you if you don't want to rely on the built-in type checking or for some other reason. + +* `string` - get a string +* `buffer` - get back a Buffer +* `array` - get an array of byte integers +* `uint8array`, `u8`, `uint8` - get back a Uint8Array +* `object`, get back an array of Objects + +If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`. + +If nothing is written to `writable` then `data` will be an empty array `[]`. + +# error handling + +`concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors. + +We recommend using [`end-of-stream`](https://npmjs.org/end-of-stream) or [`pump`](https://npmjs.org/pump) for writing error tolerant stream code. + +# license + +MIT LICENSE diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/.travis.yml new file mode 100644 index 000000000..ecd4193f6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "4" + - "6" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/LICENSE new file mode 100644 index 000000000..757562ec5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/README.md new file mode 100644 index 000000000..8352900fc --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/README.md @@ -0,0 +1,97 @@ +# duplexify + +Turn a writeable and readable stream into a single streams2 duplex stream. + +Similar to [duplexer2](https://github.com/deoxxa/duplexer2) except it supports both streams2 and streams1 as input +and it allows you to set the readable and writable part asynchronously using `setReadable(stream)` and `setWritable(stream)` + +``` +npm install duplexify +``` + +[![build status](http://img.shields.io/travis/mafintosh/duplexify.svg?style=flat)](http://travis-ci.org/mafintosh/duplexify) + +## Usage + +Use `duplexify(writable, readable, streamOptions)` (or `duplexify.obj(writable, readable)` to create an object stream) + +``` js +var duplexify = require('duplexify') + +// turn writableStream and readableStream into a single duplex stream +var dup = duplexify(writableStream, readableStream) + +dup.write('hello world') // will write to writableStream +dup.on('data', function(data) { + // will read from readableStream +}) +``` + +You can also set the readable and writable parts asynchronously + +``` js +var dup = duplexify() + +dup.write('hello world') // write will buffer until the writable + // part has been set + +// wait a bit ... +dup.setReadable(readableStream) + +// maybe wait some more? +dup.setWritable(writableStream) +``` + +If you call `setReadable` or `setWritable` multiple times it will unregister the previous readable/writable stream. +To disable the readable or writable part call `setReadable` or `setWritable` with `null`. + +If the readable or writable streams emits an error or close it will destroy both streams and bubble up the event. +You can also explicitly destroy the streams by calling `dup.destroy()`. The `destroy` method optionally takes an +error object as argument, in which case the error is emitted as part of the `error` event. + +``` js +dup.on('error', function(err) { + console.log('readable or writable emitted an error - close will follow') +}) + +dup.on('close', function() { + console.log('the duplex stream is destroyed') +}) + +dup.destroy() // calls destroy on the readable and writable part (if present) +``` + +## HTTP request example + +Turn a node core http request into a duplex stream is as easy as + +``` js +var duplexify = require('duplexify') +var http = require('http') + +var request = function(opts) { + var req = http.request(opts) + var dup = duplexify(req) + req.on('response', function(res) { + dup.setReadable(res) + }) + return dup +} + +var req = request({ + method: 'GET', + host: 'www.google.com', + port: 80 +}) + +req.end() +req.pipe(process.stdout) +``` + +## License + +MIT + +## Related + +`duplexify` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/example.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/example.js new file mode 100644 index 000000000..5585c1975 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/example.js @@ -0,0 +1,21 @@ +var duplexify = require('duplexify') +var http = require('http') + +var request = function(opts) { + var req = http.request(opts) + var dup = duplexify() + dup.setWritable(req) + req.on('response', function(res) { + dup.setReadable(res) + }) + return dup +} + +var req = request({ + method: 'GET', + host: 'www.google.com', + port: 80 +}) + +req.end() +req.pipe(process.stdout) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/index.js new file mode 100644 index 000000000..84bb5e122 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/index.js @@ -0,0 +1,239 @@ +var stream = require('readable-stream') +var eos = require('end-of-stream') +var inherits = require('inherits') +var shift = require('stream-shift') + +var SIGNAL_FLUSH = new Buffer([0]) + +var onuncork = function(self, fn) { + if (self._corked) self.once('uncork', fn) + else fn() +} + +var destroyer = function(self, end) { + return function(err) { + if (err) self._destroyInterval(err) + else if (end && !self._ended) self.end() + } +} + +var end = function(ws, fn) { + if (!ws) return fn() + if (ws._writableState && ws._writableState.finished) return fn() + if (ws._writableState) return ws.end(fn) + ws.end() + fn() +} + +var toStreams2 = function(rs) { + return new (stream.Readable)({objectMode:true, highWaterMark:16}).wrap(rs) +} + +var Duplexify = function(writable, readable, opts) { + if (!(this instanceof Duplexify)) return new Duplexify(writable, readable, opts) + stream.Duplex.call(this, opts) + + this._writable = null + this._readable = null + this._readable2 = null + + this._forwardDestroy = !opts || opts.destroy !== false + this._forwardEnd = !opts || opts.end !== false + this._corked = 1 // start corked + this._ondrain = null + this._drained = false + this._forwarding = false + this._unwrite = null + this._unread = null + this._ended = false + this._error = null + this._preferError = false + + this.destroyed = false + + if (writable) this.setWritable(writable) + if (readable) this.setReadable(readable) +} + +inherits(Duplexify, stream.Duplex) + +Duplexify.obj = function(writable, readable, opts) { + if (!opts) opts = {} + opts.objectMode = true + opts.highWaterMark = 16 + return new Duplexify(writable, readable, opts) +} + +Duplexify.prototype.cork = function() { + if (++this._corked === 1) this.emit('cork') +} + +Duplexify.prototype.uncork = function() { + if (this._corked && --this._corked === 0) this.emit('uncork') +} + +Duplexify.prototype.setWritable = function(writable) { + if (this._unwrite) this._unwrite() + + if (this.destroyed) { + if (writable && writable.destroy) writable.destroy() + return + } + + if (writable === null || writable === false) { + this.end() + return + } + + var self = this + var unend = eos(writable, {writable:true, readable:false}, destroyer(this, this._forwardEnd)) + + var ondrain = function() { + var ondrain = self._ondrain + self._ondrain = null + if (ondrain) ondrain() + } + + var clear = function() { + self._writable.removeListener('drain', ondrain) + unend() + } + + if (this._unwrite) process.nextTick(ondrain) // force a drain on stream reset to avoid livelocks + + this._writable = writable + this._writable.on('drain', ondrain) + this._unwrite = clear + + this.uncork() // always uncork setWritable +} + +Duplexify.prototype.setReadable = function(readable) { + if (this._unread) this._unread() + + if (this.destroyed) { + if (readable && readable.destroy) readable.destroy() + return + } + + if (readable === null || readable === false) { + this.push(null) + this.resume() + return + } + + var self = this + var unend = eos(readable, {writable:false, readable:true}, destroyer(this)) + + var onreadable = function() { + self._forward() + } + + var onend = function() { + self.push(null) + } + + var clear = function() { + self._readable2.removeListener('readable', onreadable) + self._readable2.removeListener('end', onend) + unend() + } + + this._drained = true + this._readable = readable + this._readable2 = readable._readableState ? readable : toStreams2(readable) + this._readable2.on('readable', onreadable) + this._readable2.on('end', onend) + this._unread = clear + + this._forward() +} + +Duplexify.prototype._read = function() { + this._drained = true + this._forward() +} + +Duplexify.prototype._forward = function() { + if (this._forwarding || !this._readable2 || !this._drained) return + this._forwarding = true + + var data + + while (this._drained && (data = shift(this._readable2)) !== null) { + if (this.destroyed) continue + this._drained = this.push(data) + } + + this._forwarding = false +} + +Duplexify.prototype.destroy = function(err) { + if (this._preferError && !this._error && err) this._error = err + + if (this.destroyed) return + this.destroyed = true + + var self = this + process.nextTick(function() { + self._destroy(self._preferError ? self._error : err) + }) +} + +Duplexify.prototype._destroyInterval = function(err) { + if (this.destroyed) return + if (err.message !== 'premature close') return this.destroy(err) + this._preferError = true + this.destroy(null) +} + +Duplexify.prototype._destroy = function(err) { + if (err) { + var ondrain = this._ondrain + this._ondrain = null + if (ondrain) ondrain(err) + else this.emit('error', err) + } + + if (this._forwardDestroy) { + if (this._readable && this._readable.destroy) this._readable.destroy() + if (this._writable && this._writable.destroy) this._writable.destroy() + } + + this.emit('close') +} + +Duplexify.prototype._write = function(data, enc, cb) { + if (this.destroyed) return cb() + if (this._corked) return onuncork(this, this._write.bind(this, data, enc, cb)) + if (data === SIGNAL_FLUSH) return this._finish(cb) + if (!this._writable) return cb() + + if (this._writable.write(data) === false) this._ondrain = cb + else cb() +} + + +Duplexify.prototype._finish = function(cb) { + var self = this + this.emit('preend') + onuncork(this, function() { + end(self._forwardEnd && self._writable, function() { + // haxx to not emit prefinish twice + if (self._writableState.prefinished === false) self._writableState.prefinished = true + self.emit('prefinish') + onuncork(self, cb) + }) + }) +} + +Duplexify.prototype.end = function(data, enc, cb) { + if (typeof data === 'function') return this.end(null, null, data) + if (typeof enc === 'function') return this.end(data, null, enc) + this._ended = true + if (data) this.write(data) + if (!this._writableState.ending) this.write(SIGNAL_FLUSH) + return stream.Writable.prototype.end.call(this, cb) +} + +module.exports = Duplexify diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/.travis.yml new file mode 100644 index 000000000..ecd4193f6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "4" + - "6" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/LICENSE new file mode 100644 index 000000000..bae9da7bf --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/README.md new file mode 100644 index 000000000..d9cc2d945 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/README.md @@ -0,0 +1,25 @@ +# stream-shift + +Returns the next buffer/object in a stream's readable queue + +``` +npm install stream-shift +``` + +[![build status](http://img.shields.io/travis/mafintosh/stream-shift.svg?style=flat)](http://travis-ci.org/mafintosh/stream-shift) + +## Usage + +``` js +var shift = require('stream-shift') + +console.log(shift(someStream)) // first item in its buffer +``` + +## Credit + +Thanks [@dignifiedquire](https://github.com/dignifiedquire) for making this work on node 6 + +## License + +MIT diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/index.js new file mode 100644 index 000000000..c4b18b9c2 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/index.js @@ -0,0 +1,20 @@ +module.exports = shift + +function shift (stream) { + var rs = stream._readableState + if (!rs) return null + return rs.objectMode ? stream.read() : stream.read(getStateLength(rs)) +} + +function getStateLength (state) { + if (state.buffer.length) { + // Since node 6.3.0 state.buffer is a BufferList not an array + if (state.buffer.head) { + return state.buffer.head.data.length + } + + return state.buffer[0].length + } + + return state.length +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/package.json new file mode 100644 index 000000000..504872bf6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/package.json @@ -0,0 +1,53 @@ +{ + "_from": "stream-shift@^1.0.0", + "_id": "stream-shift@1.0.0", + "_inBundle": false, + "_integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", + "_location": "/npm-profile/make-fetch-happen/mississippi/duplexify/stream-shift", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "stream-shift@^1.0.0", + "name": "stream-shift", + "escapedName": "stream-shift", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi/duplexify" + ], + "_resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "_shasum": "d5c752825e5367e786f78e18e445ea223a155952", + "_spec": "stream-shift@^1.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify", + "author": { + "name": "Mathias Buus", + "url": "@mafintosh" + }, + "bugs": { + "url": "https://github.com/mafintosh/stream-shift/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "Returns the next buffer/object in a stream's readable queue", + "devDependencies": { + "standard": "^7.1.2", + "tape": "^4.6.0", + "through2": "^2.0.1" + }, + "homepage": "https://github.com/mafintosh/stream-shift", + "license": "MIT", + "main": "index.js", + "name": "stream-shift", + "repository": { + "type": "git", + "url": "git+https://github.com/mafintosh/stream-shift.git" + }, + "scripts": { + "test": "standard && tape test.js" + }, + "version": "1.0.0" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/test.js new file mode 100644 index 000000000..c0222c37d --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/test.js @@ -0,0 +1,48 @@ +var tape = require('tape') +var through = require('through2') +var stream = require('stream') +var shift = require('./') + +tape('shifts next', function (t) { + var passthrough = through() + + passthrough.write('hello') + passthrough.write('world') + + t.same(shift(passthrough), Buffer('hello')) + t.same(shift(passthrough), Buffer('world')) + t.end() +}) + +tape('shifts next with core', function (t) { + var passthrough = stream.PassThrough() + + passthrough.write('hello') + passthrough.write('world') + + t.same(shift(passthrough), Buffer('hello')) + t.same(shift(passthrough), Buffer('world')) + t.end() +}) + +tape('shifts next with object mode', function (t) { + var passthrough = through({objectMode: true}) + + passthrough.write({hello: 1}) + passthrough.write({world: 1}) + + t.same(shift(passthrough), {hello: 1}) + t.same(shift(passthrough), {world: 1}) + t.end() +}) + +tape('shifts next with object mode with core', function (t) { + var passthrough = stream.PassThrough({objectMode: true}) + + passthrough.write({hello: 1}) + passthrough.write({world: 1}) + + t.same(shift(passthrough), {hello: 1}) + t.same(shift(passthrough), {world: 1}) + t.end() +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/package.json new file mode 100644 index 000000000..61bdc63d2 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/package.json @@ -0,0 +1,67 @@ +{ + "_from": "duplexify@^3.4.2", + "_id": "duplexify@3.5.3", + "_inBundle": false, + "_integrity": "sha512-g8ID9OroF9hKt2POf8YLayy+9594PzmM3scI00/uBXocX3TWNgoB67hjzkFe9ITAbQOne/lLdBxHXvYUM4ZgGA==", + "_location": "/npm-profile/make-fetch-happen/mississippi/duplexify", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "duplexify@^3.4.2", + "name": "duplexify", + "escapedName": "duplexify", + "rawSpec": "^3.4.2", + "saveSpec": null, + "fetchSpec": "^3.4.2" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi", + "/npm-profile/make-fetch-happen/mississippi/pumpify" + ], + "_resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.3.tgz", + "_shasum": "8b5818800df92fd0125b27ab896491912858243e", + "_spec": "duplexify@^3.4.2", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus" + }, + "bugs": { + "url": "https://github.com/mafintosh/duplexify/issues" + }, + "bundleDependencies": false, + "dependencies": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + }, + "deprecated": false, + "description": "Turn a writable and readable stream into a streams2 duplex stream with support for async initialization and streams1/streams2 input", + "devDependencies": { + "concat-stream": "^1.5.2", + "tape": "^4.0.0", + "through2": "^2.0.0" + }, + "homepage": "https://github.com/mafintosh/duplexify", + "keywords": [ + "duplex", + "streams2", + "streams", + "stream", + "writable", + "readable", + "async" + ], + "license": "MIT", + "main": "index.js", + "name": "duplexify", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/duplexify.git" + }, + "scripts": { + "test": "tape test.js" + }, + "version": "3.5.3" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/test.js new file mode 100644 index 000000000..4330e93cf --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/test.js @@ -0,0 +1,291 @@ +var tape = require('tape') +var through = require('through2') +var concat = require('concat-stream') +var net = require('net') +var duplexify = require('./') + +tape('passthrough', function(t) { + t.plan(2) + + var pt = through() + var dup = duplexify(pt, pt) + + dup.end('hello world') + dup.on('finish', function() { + t.ok(true, 'should finish') + }) + dup.pipe(concat(function(data) { + t.same(data.toString(), 'hello world', 'same in as out') + })) +}) + +tape('passthrough + double end', function(t) { + t.plan(2) + + var pt = through() + var dup = duplexify(pt, pt) + + dup.end('hello world') + dup.end() + + dup.on('finish', function() { + t.ok(true, 'should finish') + }) + dup.pipe(concat(function(data) { + t.same(data.toString(), 'hello world', 'same in as out') + })) +}) + +tape('async passthrough + end', function(t) { + t.plan(2) + + var pt = through.obj({highWaterMark:1}, function(data, enc, cb) { + setTimeout(function() { + cb(null, data) + }, 100) + }) + + var dup = duplexify(pt, pt) + + dup.write('hello ') + dup.write('world') + dup.end() + + dup.on('finish', function() { + t.ok(true, 'should finish') + }) + dup.pipe(concat(function(data) { + t.same(data.toString(), 'hello world', 'same in as out') + })) +}) + +tape('duplex', function(t) { + var readExpected = ['read-a', 'read-b', 'read-c'] + var writeExpected = ['write-a', 'write-b', 'write-c'] + + t.plan(readExpected.length+writeExpected.length+2) + + var readable = through.obj() + var writable = through.obj(function(data, enc, cb) { + t.same(data, writeExpected.shift(), 'onwrite should match') + cb() + }) + + var dup = duplexify.obj(writable, readable) + + readExpected.slice().forEach(function(data) { + readable.write(data) + }) + readable.end() + + writeExpected.slice().forEach(function(data) { + dup.write(data) + }) + dup.end() + + dup.on('data', function(data) { + t.same(data, readExpected.shift(), 'ondata should match') + }) + dup.on('end', function() { + t.ok(true, 'should end') + }) + dup.on('finish', function() { + t.ok(true, 'should finish') + }) +}) + +tape('async', function(t) { + var dup = duplexify() + var pt = through() + + dup.pipe(concat(function(data) { + t.same(data.toString(), 'i was async', 'same in as out') + t.end() + })) + + dup.write('i') + dup.write(' was ') + dup.end('async') + + setTimeout(function() { + dup.setWritable(pt) + setTimeout(function() { + dup.setReadable(pt) + }, 50) + }, 50) +}) + +tape('destroy', function(t) { + t.plan(2) + + var write = through() + var read = through() + var dup = duplexify(write, read) + + write.destroy = function() { + t.ok(true, 'write destroyed') + } + + dup.on('close', function() { + t.ok(true, 'close emitted') + }) + + dup.destroy() + dup.destroy() // should only work once +}) + +tape('destroy both', function(t) { + t.plan(3) + + var write = through() + var read = through() + var dup = duplexify(write, read) + + write.destroy = function() { + t.ok(true, 'write destroyed') + } + + read.destroy = function() { + t.ok(true, 'read destroyed') + } + + dup.on('close', function() { + t.ok(true, 'close emitted') + }) + + dup.destroy() + dup.destroy() // should only work once +}) + +tape('bubble read errors', function(t) { + t.plan(2) + + var write = through() + var read = through() + var dup = duplexify(write, read) + + dup.on('error', function(err) { + t.same(err.message, 'read-error', 'received read error') + }) + dup.on('close', function() { + t.ok(true, 'close emitted') + }) + + read.emit('error', new Error('read-error')) + write.emit('error', new Error('write-error')) // only emit first error +}) + +tape('bubble write errors', function(t) { + t.plan(2) + + var write = through() + var read = through() + var dup = duplexify(write, read) + + dup.on('error', function(err) { + t.same(err.message, 'write-error', 'received write error') + }) + dup.on('close', function() { + t.ok(true, 'close emitted') + }) + + write.emit('error', new Error('write-error')) + read.emit('error', new Error('read-error')) // only emit first error +}) + +tape('reset writable / readable', function(t) { + t.plan(3) + + var toUpperCase = function(data, enc, cb) { + cb(null, data.toString().toUpperCase()) + } + + var passthrough = through() + var upper = through(toUpperCase) + var dup = duplexify(passthrough, passthrough) + + dup.once('data', function(data) { + t.same(data.toString(), 'hello') + dup.setWritable(upper) + dup.setReadable(upper) + dup.once('data', function(data) { + t.same(data.toString(), 'HELLO') + dup.once('data', function(data) { + t.same(data.toString(), 'HI') + t.end() + }) + }) + dup.write('hello') + dup.write('hi') + }) + dup.write('hello') +}) + +tape('cork', function(t) { + var passthrough = through() + var dup = duplexify(passthrough, passthrough) + var ok = false + + dup.on('prefinish', function() { + dup.cork() + setTimeout(function() { + ok = true + dup.uncork() + }, 100) + }) + dup.on('finish', function() { + t.ok(ok) + t.end() + }) + dup.end() +}) + +tape('prefinish not twice', function(t) { + var passthrough = through() + var dup = duplexify(passthrough, passthrough) + var prefinished = false + + dup.on('prefinish', function() { + t.ok(!prefinished, 'only prefinish once') + prefinished = true + }) + + dup.on('finish', function() { + t.end() + }) + + dup.end() +}) + +tape('close', function(t) { + var passthrough = through() + var dup = duplexify(passthrough, passthrough) + + passthrough.emit('close') + dup.on('close', function() { + t.ok(true, 'should forward close') + t.end() + }) +}) + +tape('works with node native streams (net)', function(t) { + t.plan(1) + + var server = net.createServer(function(socket) { + var dup = duplexify(socket, socket) + + dup.once('data', function(chunk) { + t.same(chunk, Buffer('hello world')) + server.close() + socket.end() + t.end() + }) + }) + + server.listen(0, function () { + var socket = net.connect(server.address().port) + var dup = duplexify(socket, socket) + + dup.write(Buffer('hello world')) + }) +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE new file mode 100644 index 000000000..757562ec5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md new file mode 100644 index 000000000..f2560c939 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/README.md @@ -0,0 +1,52 @@ +# end-of-stream + +A node module that calls a callback when a readable/writable/duplex stream has completed or failed. + + npm install end-of-stream + +## Usage + +Simply pass a stream and a callback to the `eos`. +Both legacy streams, streams2 and stream3 are supported. + +``` js +var eos = require('end-of-stream'); + +eos(readableStream, function(err) { + // this will be set to the stream instance + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended', this === readableStream); +}); + +eos(writableStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has finished', this === writableStream); +}); + +eos(duplexStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended and finished', this === duplexStream); +}); + +eos(duplexStream, {readable:false}, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has finished but might still be readable'); +}); + +eos(duplexStream, {writable:false}, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended but might still be writable'); +}); + +eos(readableStream, {error:false}, function(err) { + // do not treat emit('error', err) as a end-of-stream +}); +``` + +## License + +MIT + +## Related + +`end-of-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js new file mode 100644 index 000000000..be426c227 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/index.js @@ -0,0 +1,87 @@ +var once = require('once'); + +var noop = function() {}; + +var isRequest = function(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +}; + +var isChildProcess = function(stream) { + return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3 +}; + +var eos = function(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + + callback = once(callback || noop); + + var ws = stream._writableState; + var rs = stream._readableState; + var readable = opts.readable || (opts.readable !== false && stream.readable); + var writable = opts.writable || (opts.writable !== false && stream.writable); + + var onlegacyfinish = function() { + if (!stream.writable) onfinish(); + }; + + var onfinish = function() { + writable = false; + if (!readable) callback.call(stream); + }; + + var onend = function() { + readable = false; + if (!writable) callback.call(stream); + }; + + var onexit = function(exitCode) { + callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null); + }; + + var onerror = function(err) { + callback.call(stream, err); + }; + + var onclose = function() { + if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close')); + if (writable && !(ws && ws.ended)) return callback.call(stream, new Error('premature close')); + }; + + var onrequest = function() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest(); + else stream.on('request', onrequest); + } else if (writable && !ws) { // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + if (isChildProcess(stream)) stream.on('exit', onexit); + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + + return function() { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('exit', onexit); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +}; + +module.exports = eos; diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json new file mode 100644 index 000000000..d43f40986 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/end-of-stream/package.json @@ -0,0 +1,66 @@ +{ + "_from": "end-of-stream@^1.1.0", + "_id": "end-of-stream@1.4.1", + "_inBundle": false, + "_integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "_location": "/npm-profile/make-fetch-happen/mississippi/end-of-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "end-of-stream@^1.1.0", + "name": "end-of-stream", + "escapedName": "end-of-stream", + "rawSpec": "^1.1.0", + "saveSpec": null, + "fetchSpec": "^1.1.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi", + "/npm-profile/make-fetch-happen/mississippi/duplexify", + "/npm-profile/make-fetch-happen/mississippi/pump", + "/npm-profile/make-fetch-happen/mississippi/pumpify/pump", + "/npm-profile/make-fetch-happen/mississippi/stream-each" + ], + "_resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "_shasum": "ed29634d19baba463b6ce6b80a37213eab71ec43", + "_spec": "end-of-stream@^1.1.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus", + "email": "mathiasbuus@gmail.com" + }, + "bugs": { + "url": "https://github.com/mafintosh/end-of-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "once": "^1.4.0" + }, + "deprecated": false, + "description": "Call a callback when a readable/writable/duplex stream has completed or failed.", + "files": [ + "index.js" + ], + "homepage": "https://github.com/mafintosh/end-of-stream", + "keywords": [ + "stream", + "streams", + "callback", + "finish", + "close", + "end", + "wait" + ], + "license": "MIT", + "main": "index.js", + "name": "end-of-stream", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/end-of-stream.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.4.1" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/.npmignore new file mode 100644 index 000000000..3e70011a1 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/.npmignore @@ -0,0 +1,3 @@ +node_modules +bundle.js +test.html diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/.travis.yml new file mode 100644 index 000000000..c04282170 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - '0.10' + - '0.12' + - '4.0' + - '5.0' diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/LICENSE new file mode 100644 index 000000000..66a4d2a14 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/README.md new file mode 100644 index 000000000..7ea7b699b --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/README.md @@ -0,0 +1,59 @@ +# flush-write-stream + +A write stream constructor that supports a flush function that is called before `finish` is emitted + +``` +npm install flush-write-stream +``` + +[![build status](http://img.shields.io/travis/mafintosh/flush-write-stream.svg?style=flat)](http://travis-ci.org/mafintosh/flush-write-stream) + +## Usage + +``` js +var writer = require('flush-write-stream') + +var ws = writer(write, flush) + +ws.on('finish', function () { + console.log('finished') +}) + +ws.write('hello') +ws.write('world') +ws.end() + +function write (data, enc, cb) { + // i am your normal ._write method + console.log('writing', data.toString()) + cb() +} + +function flush (cb) { + // i am called before finish is emitted + setTimeout(cb, 1000) // wait 1 sec +} +``` + +If you run the above it will produce the following output + +``` +writing hello +writing world +(nothing happens for 1 sec) +finished +``` + +## API + +#### `var ws = writer([options], write, [flush])` + +Create a new writable stream. Options are forwarded to the stream constructor. + +#### `var ws = writer.obj([options], write, [flush])` + +Same as the above except `objectMode` is set to `true` per default. + +## License + +MIT diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/example.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/example.js new file mode 100644 index 000000000..fa6b5dab2 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/example.js @@ -0,0 +1,22 @@ +var writer = require('./') + +var ws = writer(write, flush) + +ws.on('finish', function () { + console.log('finished') +}) + +ws.write('hello') +ws.write('world') +ws.end() + +function write (data, enc, cb) { + // i am your normal ._write method + console.log('writing', data.toString()) + cb() +} + +function flush (cb) { + // i am called before finish is emitted + setTimeout(cb, 1000) // wait 1 sec +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/index.js new file mode 100644 index 000000000..e82e12612 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/index.js @@ -0,0 +1,52 @@ +var stream = require('readable-stream') +var inherits = require('inherits') + +var SIGNAL_FLUSH = new Buffer([0]) + +module.exports = WriteStream + +function WriteStream (opts, write, flush) { + if (!(this instanceof WriteStream)) return new WriteStream(opts, write, flush) + + if (typeof opts === 'function') { + flush = write + write = opts + opts = {} + } + + stream.Writable.call(this, opts) + + this.destroyed = false + this._worker = write || null + this._flush = flush || null +} + +inherits(WriteStream, stream.Writable) + +WriteStream.obj = function (opts, worker, flush) { + if (typeof opts === 'function') return WriteStream.obj(null, opts, worker) + if (!opts) opts = {} + opts.objectMode = true + return new WriteStream(opts, worker, flush) +} + +WriteStream.prototype._write = function (data, enc, cb) { + if (SIGNAL_FLUSH === data) this._flush(cb) + else this._worker(data, enc, cb) +} + +WriteStream.prototype.end = function (data, enc, cb) { + if (!this._flush) return stream.Writable.prototype.end.apply(this, arguments) + if (typeof data === 'function') return this.end(null, null, data) + if (typeof enc === 'function') return this.end(data, null, enc) + if (data) this.write(data) + if (!this._writableState.ending) this.write(SIGNAL_FLUSH) + return stream.Writable.prototype.end.call(this, cb) +} + +WriteStream.prototype.destroy = function (err) { + if (this.destroyed) return + this.destroyed = true + if (err) this.emit('error', err) + this.emit('close') +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/package.json new file mode 100644 index 000000000..dd469e50a --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/package.json @@ -0,0 +1,54 @@ +{ + "_from": "flush-write-stream@^1.0.0", + "_id": "flush-write-stream@1.0.2", + "_inBundle": false, + "_integrity": "sha1-yBuQ2HRnZvGmCaRoCZRsRd2K5Bc=", + "_location": "/npm-profile/make-fetch-happen/mississippi/flush-write-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "flush-write-stream@^1.0.0", + "name": "flush-write-stream", + "escapedName": "flush-write-stream", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.2.tgz", + "_shasum": "c81b90d8746766f1a609a46809946c45dd8ae417", + "_spec": "flush-write-stream@^1.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus", + "url": "@mafintosh" + }, + "bugs": { + "url": "https://github.com/mafintosh/flush-write-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.4" + }, + "deprecated": false, + "description": "A write stream constructor that supports a flush function that is called before finish is emitted", + "devDependencies": { + "tape": "^4.2.2" + }, + "homepage": "https://github.com/mafintosh/flush-write-stream", + "license": "MIT", + "main": "index.js", + "name": "flush-write-stream", + "repository": { + "type": "git", + "url": "git+https://github.com/mafintosh/flush-write-stream.git" + }, + "scripts": { + "test": "tape test.js" + }, + "version": "1.0.2" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/test.js new file mode 100644 index 000000000..6cd0c20e1 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/flush-write-stream/test.js @@ -0,0 +1,85 @@ +var tape = require('tape') +var writer = require('./') + +tape('is a write stream', function (t) { + var expected = ['hello', 'world', 'verden'] + var ws = writer.obj(write) + + ws.write('hello') + ws.write('world') + ws.write('verden') + ws.end(function () { + t.same(expected.length, 0) + t.end() + }) + + function write (data, enc, cb) { + t.same(data, expected.shift()) + cb() + } +}) + +tape('is flushable', function (t) { + var expected = ['hello', 'world', 'verden'] + var flushed = false + + var ws = writer.obj(write, flush) + + ws.write('hello') + ws.write('world') + ws.write('verden') + ws.end(function () { + t.same(expected.length, 0) + t.ok(flushed, 'was flushed') + t.end() + }) + + function write (data, enc, cb) { + t.same(data, expected.shift()) + cb() + } + + function flush (cb) { + flushed = true + process.nextTick(cb) + } +}) + +tape('can pass options', function (t) { + var expected = ['hello', 'world', 'verden'] + var flushed = false + + var ws = writer({objectMode: true}, write, flush) + + ws.write('hello') + ws.write('world') + ws.write('verden') + ws.end(function () { + t.same(expected.length, 0) + t.ok(flushed, 'was flushed') + t.end() + }) + + function write (data, enc, cb) { + t.same(data, expected.shift()) + cb() + } + + function flush (cb) { + flushed = true + process.nextTick(cb) + } +}) + +tape('emits error on destroy', function (t) { + var expected = new Error() + + var ws = writer({objectMode: true}, function () {}) + + ws.on('error', function (err) { + t.equal(err, expected) + }) + ws.on('close', t.end) + + ws.destroy(expected) +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/.travis.yml new file mode 100644 index 000000000..b03ffabca --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +before_install: + - npm install -g npm +node_js: + - "0.8" + - "0.10" + - "0.12" + - "iojs" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/LICENSE.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/LICENSE.md new file mode 100644 index 000000000..146cb32a7 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/LICENSE.md @@ -0,0 +1,21 @@ +## The MIT License (MIT) ## + +Copyright (c) 2014 Hugh Kennedy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/README.md new file mode 100644 index 000000000..3e041a412 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/README.md @@ -0,0 +1,70 @@ +# from2 [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/from2&title=from2&description=hughsk/from2%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) # + +`from2` is a high-level module for creating readable streams that properly handle backpressure. + +Convience wrapper for +[readable-stream](http://github.com/isaacs/readable-stream)'s `ReadableStream` +base class, with an API lifted from +[from](http://github.com/dominictarr/from) and +[through2](http://github.com/rvagg/through2). + +## Usage ## + +[![from2](https://nodei.co/npm/from2.png?mini=true)](https://nodei.co/npm/from2) + +### `stream = from2([opts], read)` ### + +Where `opts` are the options to pass on to the `ReadableStream` constructor, +and `read(size, next)` is called when data is requested from the stream. + +* `size` is the recommended amount of data (in bytes) to retrieve. +* `next(err)` should be called when you're ready to emit more data. + +For example, here's a readable stream that emits the contents of a given +string: + +``` javascript +var from = require('from2') + +function fromString(string) { + return from(function(size, next) { + // if there's no more content + // left in the string, close the stream. + if (string.length <= 0) return next(null, null) + + // Pull in a new chunk of text, + // removing it from the string. + var chunk = string.slice(0, size) + string = string.slice(size) + + // Emit "chunk" from the stream. + next(null, chunk) + }) +} + +// pipe "hello world" out +// to stdout. +fromString('hello world').pipe(process.stdout) +``` + +### `stream = from2.obj([opts], read)` ### + +Shorthand for `from2({ objectMode: true }, read)`. + +### `createStream = from2.ctor([opts], read)` ### + +If you're creating similar streams in quick succession you can improve +performance by generating a stream **constructor** that you can reuse instead +of creating one-off streams on each call. + +Takes the same options as `from2`, instead returning a constructor which you +can use to create new streams. + +### See Also + +- [from2-array](https://github.com/binocarlos/from2-array) - Create a from2 stream based on an array of source values. +- [from2-string](https://github.com/yoshuawuyts/from2-string) - Create a stream from a string. Sugary wrapper around from2. + +## License ## + +MIT. See [LICENSE.md](http://github.com/hughsk/from2/blob/master/LICENSE.md) for details. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/index.js new file mode 100644 index 000000000..cb200c610 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/index.js @@ -0,0 +1,103 @@ +var Readable = require('readable-stream').Readable +var inherits = require('inherits') + +module.exports = from2 + +from2.ctor = ctor +from2.obj = obj + +var Proto = ctor() + +function toFunction(list) { + list = list.slice() + return function (_, cb) { + var err = null + var item = list.length ? list.shift() : null + if (item instanceof Error) { + err = item + item = null + } + + cb(err, item) + } +} + +function from2(opts, read) { + if (typeof opts !== 'object' || Array.isArray(opts)) { + read = opts + opts = {} + } + + var rs = new Proto(opts) + rs._from = Array.isArray(read) ? toFunction(read) : (read || noop) + return rs +} + +function ctor(opts, read) { + if (typeof opts === 'function') { + read = opts + opts = {} + } + + opts = defaults(opts) + + inherits(Class, Readable) + function Class(override) { + if (!(this instanceof Class)) return new Class(override) + this._reading = false + this._callback = check + this.destroyed = false + Readable.call(this, override || opts) + + var self = this + var hwm = this._readableState.highWaterMark + + function check(err, data) { + if (self.destroyed) return + if (err) return self.destroy(err) + if (data === null) return self.push(null) + self._reading = false + if (self.push(data)) self._read(hwm) + } + } + + Class.prototype._from = read || noop + Class.prototype._read = function(size) { + if (this._reading || this.destroyed) return + this._reading = true + this._from(size, this._callback) + } + + Class.prototype.destroy = function(err) { + if (this.destroyed) return + this.destroyed = true + + var self = this + process.nextTick(function() { + if (err) self.emit('error', err) + self.emit('close') + }) + } + + return Class +} + +function obj(opts, read) { + if (typeof opts === 'function' || Array.isArray(opts)) { + read = opts + opts = {} + } + + opts = defaults(opts) + opts.objectMode = true + opts.highWaterMark = 16 + + return from2(opts, read) +} + +function noop () {} + +function defaults(opts) { + opts = opts || {} + return opts +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/package.json new file mode 100644 index 000000000..9bc6992e6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/package.json @@ -0,0 +1,69 @@ +{ + "_from": "from2@^2.1.0", + "_id": "from2@2.3.0", + "_inBundle": false, + "_integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", + "_location": "/npm-profile/make-fetch-happen/mississippi/from2", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "from2@^2.1.0", + "name": "from2", + "escapedName": "from2", + "rawSpec": "^2.1.0", + "saveSpec": null, + "fetchSpec": "^2.1.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", + "_shasum": "8bfb5502bde4a4d36cfdeea007fcca21d7e382af", + "_spec": "from2@^2.1.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Hugh Kennedy", + "email": "hughskennedy@gmail.com", + "url": "http://hughsk.io/" + }, + "bugs": { + "url": "https://github.com/hughsk/from2/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Mathias Buus", + "email": "mathiasbuus@gmail.com" + } + ], + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.0" + }, + "deprecated": false, + "description": "Convenience wrapper for ReadableStream, with an API lifted from \"from\" and \"through2\"", + "devDependencies": { + "tape": "^4.0.0" + }, + "homepage": "https://github.com/hughsk/from2", + "keywords": [ + "from", + "stream", + "readable", + "pull", + "convenience", + "wrapper" + ], + "license": "MIT", + "main": "index.js", + "name": "from2", + "repository": { + "type": "git", + "url": "git://github.com/hughsk/from2.git" + }, + "scripts": { + "test": "node test" + }, + "version": "2.3.0" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/test.js new file mode 100644 index 000000000..b11bd6cd8 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/from2/test.js @@ -0,0 +1,123 @@ +var test = require('tape') +var path = require('path') +var from = require('./') +var fs = require('fs') + +var tmp = path.resolve( + __dirname, 'tmp.txt' +) + +function fromString(string) { + return from(function(size, next) { + if (string.length <= 0) return next(null, null) + var chunk = string.slice(0, size) + string = string.slice(size) + next(null, chunk) + }) +} + +test('from2', function(t) { + var contents = fs.readFileSync(__filename, 'utf8') + var stream = fromString(contents) + + stream + .pipe(fs.createWriteStream(tmp)) + .on('close', function() { + t.equal(fs.readFileSync(tmp, 'utf8'), contents) + fs.unlinkSync(tmp) + t.end() + }) +}) + +test('old mode', function(t) { + var contents = fs.readFileSync(__filename, 'utf8') + var stream = fromString(contents) + var buffer = '' + + stream.on('data', function(data) { + buffer += data + }).on('end', function() { + t.equal(buffer, contents) + t.end() + }) +}) + +test('destroy', function(t) { + var stream = from(function(size, next) { + process.nextTick(function() { + next(null, 'no') + }) + }) + + stream.on('data', function(data) { + t.ok(false) + }).on('close', function() { + t.ok(true) + t.end() + }) + + stream.destroy() +}) + +test('arrays', function (t) { + var input = ['a', 'b', 'c'] + var stream = from(input) + var output = [] + stream.on('data', function (letter) { + output.push(letter.toString()) + }) + stream.on('end', function () { + t.deepEqual(input, output) + t.end() + }) +}) + +test('obj arrays', function (t) { + var input = [{foo:'a'}, {foo:'b'}, {foo:'c'}] + var stream = from.obj(input) + var output = [] + stream.on('data', function (letter) { + output.push(letter) + }) + stream.on('end', function () { + t.deepEqual(input, output) + t.end() + }) +}) + + +test('arrays can emit errors', function (t) { + var input = ['a', 'b', new Error('ooops'), 'c'] + var stream = from(input) + var output = [] + stream.on('data', function (letter) { + output.push(letter.toString()) + }) + stream.on('error', function(e){ + t.deepEqual(['a', 'b'], output) + t.equal('ooops', e.message) + t.end() + }) + stream.on('end', function () { + t.fail('the stream should have errored') + }) +}) + +test('obj arrays can emit errors', function (t) { + var input = [{foo:'a'}, {foo:'b'}, new Error('ooops'), {foo:'c'}] + var stream = from.obj(input) + var output = [] + stream.on('data', function (letter) { + output.push(letter) + }) + stream.on('error', function(e){ + t.deepEqual([{foo:'a'}, {foo:'b'}], output) + t.equal('ooops', e.message) + t.end() + }) + stream.on('end', function () { + t.fail('the stream should have errored') + }) +}) + + diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/LICENSE new file mode 100644 index 000000000..4b30ed5d9 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/LICENSE @@ -0,0 +1,20 @@ +Copyright 2013 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/README.md new file mode 100644 index 000000000..f53e13084 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/README.md @@ -0,0 +1,54 @@ +# parallel-transform + +[Transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform_1) for Node.js that allows you to run your transforms +in parallel without changing the order of the output. + + npm install parallel-transform + +It is easy to use + +``` js +var transform = require('parallel-transform'); + +var stream = transform(10, function(data, callback) { // 10 is the parallism level + setTimeout(function() { + callback(null, data); + }, Math.random() * 1000); +}); + +for (var i = 0; i < 10; i++) { + stream.write(''+i); +} +stream.end(); + +stream.on('data', function(data) { + console.log(data); // prints 0,1,2,... +}); +stream.on('end', function() { + console.log('stream has ended'); +}); +``` + +If you run the above example you'll notice that it runs in parallel +(does not take ~1 second between each print) and that the order is preserved + +## Stream options + +All transforms are Node 0.10 streams. Per default they are created with the options `{objectMode:true}`. +If you want to use your own stream options pass them as the second parameter + +``` js +var stream = transform(10, {objectMode:false}, function(data, callback) { + // data is now a buffer + callback(null, data); +}); + +fs.createReadStream('filename').pipe(stream).pipe(process.stdout); +``` + +### Unordered +Passing the option `{ordered:false}` will output the data as soon as it's processed by a transform, without waiting to respect the order. + +## License + +MIT
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/index.js new file mode 100644 index 000000000..77329e4cc --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/index.js @@ -0,0 +1,105 @@ +var Transform = require('readable-stream').Transform; +var inherits = require('inherits'); +var cyclist = require('cyclist'); +var util = require('util'); + +var ParallelTransform = function(maxParallel, opts, ontransform) { + if (!(this instanceof ParallelTransform)) return new ParallelTransform(maxParallel, opts, ontransform); + + if (typeof maxParallel === 'function') { + ontransform = maxParallel; + opts = null; + maxParallel = 1; + } + if (typeof opts === 'function') { + ontransform = opts; + opts = null; + } + + if (!opts) opts = {}; + if (!opts.highWaterMark) opts.highWaterMark = Math.max(maxParallel, 16); + if (opts.objectMode !== false) opts.objectMode = true; + + Transform.call(this, opts); + + this._maxParallel = maxParallel; + this._ontransform = ontransform; + this._destroyed = false; + this._flushed = false; + this._ordered = opts.ordered !== false; + this._buffer = this._ordered ? cyclist(maxParallel) : []; + this._top = 0; + this._bottom = 0; + this._ondrain = null; +}; + +inherits(ParallelTransform, Transform); + +ParallelTransform.prototype.destroy = function() { + if (this._destroyed) return; + this._destroyed = true; + this.emit('close'); +}; + +ParallelTransform.prototype._transform = function(chunk, enc, callback) { + var self = this; + var pos = this._top++; + + this._ontransform(chunk, function(err, data) { + if (self._destroyed) return; + if (err) { + self.emit('error', err); + self.push(null); + self.destroy(); + return; + } + if (self._ordered) { + self._buffer.put(pos, (data === undefined || data === null) ? null : data); + } + else { + self._buffer.push(data); + } + self._drain(); + }); + + if (this._top - this._bottom < this._maxParallel) return callback(); + this._ondrain = callback; +}; + +ParallelTransform.prototype._flush = function(callback) { + this._flushed = true; + this._ondrain = callback; + this._drain(); +}; + +ParallelTransform.prototype._drain = function() { + if (this._ordered) { + while (this._buffer.get(this._bottom) !== undefined) { + var data = this._buffer.del(this._bottom++); + if (data === null) continue; + this.push(data); + } + } + else { + while (this._buffer.length > 0) { + var data = this._buffer.pop(); + this._bottom++; + if (data === null) continue; + this.push(data); + } + } + + + if (!this._drained() || !this._ondrain) return; + + var ondrain = this._ondrain; + this._ondrain = null; + ondrain(); +}; + +ParallelTransform.prototype._drained = function() { + var diff = this._top - this._bottom; + return this._flushed ? !diff : diff < this._maxParallel; +}; + +module.exports = ParallelTransform; diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/.npmignore new file mode 100644 index 000000000..ba99195ba --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/.npmignore @@ -0,0 +1 @@ +bench diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/README.md new file mode 100644 index 000000000..50c35cc5f --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/README.md @@ -0,0 +1,39 @@ +# Cyclist + +Cyclist is an efficient [cyclic list](http://en.wikipedia.org/wiki/Circular_buffer) implemention for Javascript. +It is available through npm + + npm install cyclist + +## What? + +Cyclist allows you to create a list of fixed size that is cyclic. +In a cyclist list the element following the last one is the first one. +This property can be really useful when for example trying to order data +packets that can arrive out of order over a network stream. + +## Usage + +``` js +var cyclist = require('cyclist'); +var list = cyclist(4); // if size (4) is not a power of 2 it will be the follwing power of 2 + // this buffer can now hold 4 elements in total + +list.put(42, 'hello 42'); // store something and index 42 +list.put(43, 'hello 43'); // store something and index 43 + +console.log(list.get(42)); // prints hello 42 +console.log(list.get(46)); // prints hello 42 again since 46 - 42 == list.size +``` + +## API + +* `cyclist(size)` creates a new buffer +* `cyclist#get(index)` get an object stored in the buffer +* `cyclist#put(index,value)` insert an object into the buffer +* `cyclist#del(index)` delete an object from an index +* `cyclist#size` property containing current size of buffer + +## License + +MIT diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/index.js new file mode 100644 index 000000000..baf710c3a --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/index.js @@ -0,0 +1,33 @@ +var ensureTwoPower = function(n) { + if (n && !(n & (n - 1))) return n; + var p = 1; + while (p < n) p <<= 1; + return p; +}; + +var Cyclist = function(size) { + if (!(this instanceof Cyclist)) return new Cyclist(size); + size = ensureTwoPower(size); + this.mask = size-1; + this.size = size; + this.values = new Array(size); +}; + +Cyclist.prototype.put = function(index, val) { + var pos = index & this.mask; + this.values[pos] = val; + return pos; +}; + +Cyclist.prototype.get = function(index) { + return this.values[index & this.mask]; +}; + +Cyclist.prototype.del = function(index) { + var pos = index & this.mask; + var val = this.values[pos]; + this.values[pos] = undefined; + return val; +}; + +module.exports = Cyclist;
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/package.json new file mode 100644 index 000000000..c97340390 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/node_modules/cyclist/package.json @@ -0,0 +1,50 @@ +{ + "_from": "cyclist@~0.2.2", + "_id": "cyclist@0.2.2", + "_inBundle": false, + "_integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=", + "_location": "/npm-profile/make-fetch-happen/mississippi/parallel-transform/cyclist", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "cyclist@~0.2.2", + "name": "cyclist", + "escapedName": "cyclist", + "rawSpec": "~0.2.2", + "saveSpec": null, + "fetchSpec": "~0.2.2" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi/parallel-transform" + ], + "_resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", + "_shasum": "1b33792e11e914a2fd6d6ed6447464444e5fa640", + "_spec": "cyclist@~0.2.2", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform", + "author": { + "name": "Mathias Buus Madsen", + "email": "mathiasbuus@gmail.com" + }, + "bugs": { + "url": "https://github.com/mafintosh/cyclist/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "Cyclist is an efficient cyclic list implemention.", + "homepage": "https://github.com/mafintosh/cyclist#readme", + "keywords": [ + "circular", + "buffer", + "ring", + "cyclic", + "data" + ], + "name": "cyclist", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/cyclist.git" + }, + "version": "0.2.2" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/package.json new file mode 100644 index 000000000..3cee8c65c --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/parallel-transform/package.json @@ -0,0 +1,55 @@ +{ + "_from": "parallel-transform@^1.1.0", + "_id": "parallel-transform@1.1.0", + "_inBundle": false, + "_integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", + "_location": "/npm-profile/make-fetch-happen/mississippi/parallel-transform", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "parallel-transform@^1.1.0", + "name": "parallel-transform", + "escapedName": "parallel-transform", + "rawSpec": "^1.1.0", + "saveSpec": null, + "fetchSpec": "^1.1.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", + "_shasum": "d410f065b05da23081fcd10f28854c29bda33b06", + "_spec": "parallel-transform@^1.1.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus Madsen", + "email": "mathiasbuus@gmail.com" + }, + "bugs": { + "url": "https://github.com/mafintosh/parallel-transform/issues" + }, + "bundleDependencies": false, + "dependencies": { + "cyclist": "~0.2.2", + "inherits": "^2.0.3", + "readable-stream": "^2.1.5" + }, + "deprecated": false, + "description": "Transform stream that allows you to run your transforms in parallel without changing the order", + "homepage": "https://github.com/mafintosh/parallel-transform#readme", + "keywords": [ + "transform", + "stream", + "parallel", + "preserve", + "order" + ], + "license": "MIT", + "name": "parallel-transform", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/parallel-transform.git" + }, + "version": "1.1.0" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/.travis.yml new file mode 100644 index 000000000..17f94330e --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.10" + +script: "npm test" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/LICENSE new file mode 100644 index 000000000..757562ec5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/README.md new file mode 100644 index 000000000..5029b27d6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/README.md @@ -0,0 +1,56 @@ +# pump + +pump is a small node module that pipes streams together and destroys all of them if one of them closes. + +``` +npm install pump +``` + +[![build status](http://img.shields.io/travis/mafintosh/pump.svg?style=flat)](http://travis-ci.org/mafintosh/pump) + +## What problem does it solve? + +When using standard `source.pipe(dest)` source will _not_ be destroyed if dest emits close or an error. +You are also not able to provide a callback to tell when then pipe has finished. + +pump does these two things for you + +## Usage + +Simply pass the streams you want to pipe together to pump and add an optional callback + +``` js +var pump = require('pump') +var fs = require('fs') + +var source = fs.createReadStream('/dev/random') +var dest = fs.createWriteStream('/dev/null') + +pump(source, dest, function(err) { + console.log('pipe finished', err) +}) + +setTimeout(function() { + dest.destroy() // when dest is closed pump will destroy source +}, 1000) +``` + +You can use pump to pipe more than two streams together as well + +``` js +var transform = someTransformStream() + +pump(source, transform, anotherTransform, dest, function(err) { + console.log('pipe finished', err) +}) +``` + +If `source`, `transform`, `anotherTransform` or `dest` closes all of them will be destroyed. + +## License + +MIT + +## Related + +`pump` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/index.js new file mode 100644 index 000000000..f0c639a8c --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/index.js @@ -0,0 +1,80 @@ +var once = require('once') +var eos = require('end-of-stream') +var fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes + +var noop = function () {} + +var isFn = function (fn) { + return typeof fn === 'function' +} + +var isFS = function (stream) { + if (!fs) return false // browser + return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) +} + +var isRequest = function (stream) { + return stream.setHeader && isFn(stream.abort) +} + +var destroyer = function (stream, reading, writing, callback) { + callback = once(callback) + + var closed = false + stream.on('close', function () { + closed = true + }) + + eos(stream, {readable: reading, writable: writing}, function (err) { + if (err) return callback(err) + closed = true + callback() + }) + + var destroyed = false + return function (err) { + if (closed) return + if (destroyed) return + destroyed = true + + if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks + if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want + + if (isFn(stream.destroy)) return stream.destroy() + + callback(err || new Error('stream was destroyed')) + } +} + +var call = function (fn) { + fn() +} + +var pipe = function (from, to) { + return from.pipe(to) +} + +var pump = function () { + var streams = Array.prototype.slice.call(arguments) + var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop + + if (Array.isArray(streams[0])) streams = streams[0] + if (streams.length < 2) throw new Error('pump requires two streams per minimum') + + var error + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1 + var writing = i > 0 + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err + if (err) destroys.forEach(call) + if (reading) return + destroys.forEach(call) + callback(error) + }) + }) + + return streams.reduce(pipe) +} + +module.exports = pump diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/package.json new file mode 100644 index 000000000..2a5e62972 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/package.json @@ -0,0 +1,59 @@ +{ + "_from": "pump@^1.0.0", + "_id": "pump@1.0.3", + "_inBundle": false, + "_integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "_location": "/npm-profile/make-fetch-happen/mississippi/pump", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "pump@^1.0.0", + "name": "pump", + "escapedName": "pump", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "_shasum": "5dfe8311c33bbf6fc18261f9f34702c47c08a954", + "_spec": "pump@^1.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus Madsen", + "email": "mathiasbuus@gmail.com" + }, + "browser": { + "fs": false + }, + "bugs": { + "url": "https://github.com/mafintosh/pump/issues" + }, + "bundleDependencies": false, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + }, + "deprecated": false, + "description": "pipe streams together and close all of them if one of them closes", + "homepage": "https://github.com/mafintosh/pump#readme", + "keywords": [ + "streams", + "pipe", + "destroy", + "callback" + ], + "license": "MIT", + "name": "pump", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/pump.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.3" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/test-browser.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/test-browser.js new file mode 100644 index 000000000..80e852c7d --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/test-browser.js @@ -0,0 +1,58 @@ +var stream = require('stream') +var pump = require('./index') + +var rs = new stream.Readable() +var ws = new stream.Writable() + +rs._read = function (size) { + this.push(Buffer(size).fill('abc')) +} + +ws._write = function (chunk, encoding, cb) { + setTimeout(function () { + cb() + }, 100) +} + +var toHex = function () { + var reverse = new (require('stream').Transform)() + + reverse._transform = function (chunk, enc, callback) { + reverse.push(chunk.toString('hex')) + callback() + } + + return reverse +} + +var wsClosed = false +var rsClosed = false +var callbackCalled = false + +var check = function () { + if (wsClosed && rsClosed && callbackCalled) console.log('done') +} + +ws.on('finish', function () { + wsClosed = true + check() +}) + +rs.on('end', function () { + rsClosed = true + check() +}) + +pump(rs, toHex(), toHex(), toHex(), ws, function () { + callbackCalled = true + check() +}) + +setTimeout(function () { + rs.push(null) + rs.emit('close') +}, 1000) + +setTimeout(function () { + if (!check()) throw new Error('timeout') +}, 5000) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/test.js new file mode 100644 index 000000000..64e772ca5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pump/test.js @@ -0,0 +1,46 @@ +var pump = require('./index') + +var rs = require('fs').createReadStream('/dev/random') +var ws = require('fs').createWriteStream('/dev/null') + +var toHex = function () { + var reverse = new (require('stream').Transform)() + + reverse._transform = function (chunk, enc, callback) { + reverse.push(chunk.toString('hex')) + callback() + } + + return reverse +} + +var wsClosed = false +var rsClosed = false +var callbackCalled = false + +var check = function () { + if (wsClosed && rsClosed && callbackCalled) process.exit(0) +} + +ws.on('close', function () { + wsClosed = true + check() +}) + +rs.on('close', function () { + rsClosed = true + check() +}) + +pump(rs, toHex(), toHex(), toHex(), ws, function () { + callbackCalled = true + check() +}) + +setTimeout(function () { + rs.destroy() +}, 1000) + +setTimeout(function () { + throw new Error('timeout') +}, 5000) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/.travis.yml new file mode 100644 index 000000000..32e71a6b5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/.travis.yml @@ -0,0 +1,8 @@ +language: node_js + +node_js: + - "0.10" + - "4" + - "5" + +sudo: false diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/LICENSE new file mode 100644 index 000000000..757562ec5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/README.md new file mode 100644 index 000000000..4988f7b12 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/README.md @@ -0,0 +1,56 @@ +# pumpify + +Combine an array of streams into a single duplex stream using [pump](https://github.com/mafintosh/pump) and [duplexify](https://github.com/mafintosh/duplexify). +If one of the streams closes/errors all streams in the pipeline will be destroyed. + +``` +npm install pumpify +``` + +[![build status](http://img.shields.io/travis/mafintosh/pumpify.svg?style=flat)](http://travis-ci.org/mafintosh/pumpify) + +## Usage + +Pass the streams you want to pipe together to pumpify `pipeline = pumpify(s1, s2, s3, ...)`. +`pipeline` is a duplex stream that writes to the first streams and reads from the last one. +Streams are piped together using [pump](https://github.com/mafintosh/pump) so if one of them closes +all streams will be destroyed. + +``` js +var pumpify = require('pumpify') +var tar = require('tar-fs') +var zlib = require('zlib') +var fs = require('fs') + +var untar = pumpify(zlib.createGunzip(), tar.extract('output-folder')) +// you can also pass an array instead +// var untar = pumpify([zlib.createGunzip(), tar.extract('output-folder')]) + +fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar) +``` + +If you are pumping object streams together use `pipeline = pumpify.obj(s1, s2, ...)`. +Call `pipeline.destroy()` to destroy the pipeline (including the streams passed to pumpify). + +### Using `setPipeline(s1, s2, ...)` + +Similar to [duplexify](https://github.com/mafintosh/duplexify) you can also define the pipeline asynchronously using `setPipeline(s1, s2, ...)` + +``` js +var untar = pumpify() + +setTimeout(function() { + // will start draining the input now + untar.setPipeline(zlib.createGunzip(), tar.extract('output-folder')) +}, 1000) + +fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar) +``` + +## License + +MIT + +## Related + +`pumpify` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/index.js new file mode 100644 index 000000000..45bb987e8 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/index.js @@ -0,0 +1,56 @@ +var pump = require('pump') +var inherits = require('inherits') +var Duplexify = require('duplexify') + +var toArray = function(args) { + if (!args.length) return [] + return Array.isArray(args[0]) ? args[0] : Array.prototype.slice.call(args) +} + +var define = function(opts) { + var Pumpify = function() { + var streams = toArray(arguments) + if (!(this instanceof Pumpify)) return new Pumpify(streams) + Duplexify.call(this, null, null, opts) + if (streams.length) this.setPipeline(streams) + } + + inherits(Pumpify, Duplexify) + + Pumpify.prototype.setPipeline = function() { + var streams = toArray(arguments) + var self = this + var ended = false + var w = streams[0] + var r = streams[streams.length-1] + + r = r.readable ? r : null + w = w.writable ? w : null + + var onclose = function() { + streams[0].emit('error', new Error('stream was destroyed')) + } + + this.on('close', onclose) + this.on('prefinish', function() { + if (!ended) self.cork() + }) + + pump(streams, function(err) { + self.removeListener('close', onclose) + if (err) return self.destroy(err) + ended = true + self.uncork() + }) + + if (this.destroyed) return onclose() + this.setWritable(w) + this.setReadable(r) + } + + return Pumpify +} + +module.exports = define({destroy:false}) +module.exports.obj = define({destroy:false, objectMode:true, highWaterMark:16}) +module.exports.ctor = define diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/.travis.yml new file mode 100644 index 000000000..17f94330e --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.10" + +script: "npm test" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/LICENSE new file mode 100644 index 000000000..757562ec5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/README.md new file mode 100644 index 000000000..5029b27d6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/README.md @@ -0,0 +1,56 @@ +# pump + +pump is a small node module that pipes streams together and destroys all of them if one of them closes. + +``` +npm install pump +``` + +[![build status](http://img.shields.io/travis/mafintosh/pump.svg?style=flat)](http://travis-ci.org/mafintosh/pump) + +## What problem does it solve? + +When using standard `source.pipe(dest)` source will _not_ be destroyed if dest emits close or an error. +You are also not able to provide a callback to tell when then pipe has finished. + +pump does these two things for you + +## Usage + +Simply pass the streams you want to pipe together to pump and add an optional callback + +``` js +var pump = require('pump') +var fs = require('fs') + +var source = fs.createReadStream('/dev/random') +var dest = fs.createWriteStream('/dev/null') + +pump(source, dest, function(err) { + console.log('pipe finished', err) +}) + +setTimeout(function() { + dest.destroy() // when dest is closed pump will destroy source +}, 1000) +``` + +You can use pump to pipe more than two streams together as well + +``` js +var transform = someTransformStream() + +pump(source, transform, anotherTransform, dest, function(err) { + console.log('pipe finished', err) +}) +``` + +If `source`, `transform`, `anotherTransform` or `dest` closes all of them will be destroyed. + +## License + +MIT + +## Related + +`pump` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/index.js new file mode 100644 index 000000000..d9ca0335c --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/index.js @@ -0,0 +1,82 @@ +var once = require('once') +var eos = require('end-of-stream') +var fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes + +var noop = function () {} +var ancient = /^v?\.0/.test(process.version) + +var isFn = function (fn) { + return typeof fn === 'function' +} + +var isFS = function (stream) { + if (!ancient) return false // newer node version do not need to care about fs is a special way + if (!fs) return false // browser + return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) +} + +var isRequest = function (stream) { + return stream.setHeader && isFn(stream.abort) +} + +var destroyer = function (stream, reading, writing, callback) { + callback = once(callback) + + var closed = false + stream.on('close', function () { + closed = true + }) + + eos(stream, {readable: reading, writable: writing}, function (err) { + if (err) return callback(err) + closed = true + callback() + }) + + var destroyed = false + return function (err) { + if (closed) return + if (destroyed) return + destroyed = true + + if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks + if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want + + if (isFn(stream.destroy)) return stream.destroy() + + callback(err || new Error('stream was destroyed')) + } +} + +var call = function (fn) { + fn() +} + +var pipe = function (from, to) { + return from.pipe(to) +} + +var pump = function () { + var streams = Array.prototype.slice.call(arguments) + var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop + + if (Array.isArray(streams[0])) streams = streams[0] + if (streams.length < 2) throw new Error('pump requires two streams per minimum') + + var error + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1 + var writing = i > 0 + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err + if (err) destroys.forEach(call) + if (reading) return + destroys.forEach(call) + callback(error) + }) + }) + + streams.reduce(pipe) +} + +module.exports = pump diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/package.json new file mode 100644 index 000000000..50380d4b5 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/package.json @@ -0,0 +1,59 @@ +{ + "_from": "pump@^2.0.0", + "_id": "pump@2.0.1", + "_inBundle": false, + "_integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", + "_location": "/npm-profile/make-fetch-happen/mississippi/pumpify/pump", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "pump@^2.0.0", + "name": "pump", + "escapedName": "pump", + "rawSpec": "^2.0.0", + "saveSpec": null, + "fetchSpec": "^2.0.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi/pumpify" + ], + "_resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "_shasum": "12399add6e4cf7526d973cbc8b5ce2e2908b3909", + "_spec": "pump@^2.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify", + "author": { + "name": "Mathias Buus Madsen", + "email": "mathiasbuus@gmail.com" + }, + "browser": { + "fs": false + }, + "bugs": { + "url": "https://github.com/mafintosh/pump/issues" + }, + "bundleDependencies": false, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + }, + "deprecated": false, + "description": "pipe streams together and close all of them if one of them closes", + "homepage": "https://github.com/mafintosh/pump#readme", + "keywords": [ + "streams", + "pipe", + "destroy", + "callback" + ], + "license": "MIT", + "name": "pump", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/pump.git" + }, + "scripts": { + "test": "node test-browser.js && node test-node.js" + }, + "version": "2.0.1" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-browser.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-browser.js new file mode 100644 index 000000000..75ea4a292 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-browser.js @@ -0,0 +1,62 @@ +var stream = require('stream') +var pump = require('./index') + +var rs = new stream.Readable() +var ws = new stream.Writable() + +rs._read = function (size) { + this.push(Buffer(size).fill('abc')) +} + +ws._write = function (chunk, encoding, cb) { + setTimeout(function () { + cb() + }, 100) +} + +var toHex = function () { + var reverse = new (require('stream').Transform)() + + reverse._transform = function (chunk, enc, callback) { + reverse.push(chunk.toString('hex')) + callback() + } + + return reverse +} + +var wsClosed = false +var rsClosed = false +var callbackCalled = false + +var check = function () { + if (wsClosed && rsClosed && callbackCalled) { + console.log('test-browser.js passes') + clearTimeout(timeout) + } +} + +ws.on('finish', function () { + wsClosed = true + check() +}) + +rs.on('end', function () { + rsClosed = true + check() +}) + +pump(rs, toHex(), toHex(), toHex(), ws, function () { + callbackCalled = true + check() +}) + +setTimeout(function () { + rs.push(null) + rs.emit('close') +}, 1000) + +var timeout = setTimeout(function () { + check() + throw new Error('timeout') +}, 5000) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-node.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-node.js new file mode 100644 index 000000000..034a65414 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-node.js @@ -0,0 +1,53 @@ +var pump = require('./index') + +var rs = require('fs').createReadStream('/dev/random') +var ws = require('fs').createWriteStream('/dev/null') + +var toHex = function () { + var reverse = new (require('stream').Transform)() + + reverse._transform = function (chunk, enc, callback) { + reverse.push(chunk.toString('hex')) + callback() + } + + return reverse +} + +var wsClosed = false +var rsClosed = false +var callbackCalled = false + +var check = function () { + if (wsClosed && rsClosed && callbackCalled) { + console.log('test-node.js passes') + clearTimeout(timeout) + } +} + +ws.on('close', function () { + wsClosed = true + check() +}) + +rs.on('close', function () { + rsClosed = true + check() +}) + +var res = pump(rs, toHex(), toHex(), toHex(), ws, function () { + callbackCalled = true + check() +}) + +if (res) { + process.exit(1) +} + +setTimeout(function () { + rs.destroy() +}, 1000) + +var timeout = setTimeout(function () { + throw new Error('timeout') +}, 5000) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/package.json new file mode 100644 index 000000000..f4a1caffb --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/package.json @@ -0,0 +1,67 @@ +{ + "_from": "pumpify@^1.3.3", + "_id": "pumpify@1.4.0", + "_inBundle": false, + "_integrity": "sha512-2kmNR9ry+Pf45opRVirpNuIFotsxUGLaYqxIwuR77AYrYRMuFCz9eryHBS52L360O+NcR383CL4QYlMKPq4zYA==", + "_location": "/npm-profile/make-fetch-happen/mississippi/pumpify", + "_phantomChildren": { + "end-of-stream": "1.4.1", + "once": "1.4.0" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "pumpify@^1.3.3", + "name": "pumpify", + "escapedName": "pumpify", + "rawSpec": "^1.3.3", + "saveSpec": null, + "fetchSpec": "^1.3.3" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.4.0.tgz", + "_shasum": "80b7c5df7e24153d03f0e7ac8a05a5d068bd07fb", + "_spec": "pumpify@^1.3.3", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus" + }, + "bugs": { + "url": "https://github.com/mafintosh/pumpify/issues" + }, + "bundleDependencies": false, + "dependencies": { + "duplexify": "^3.5.3", + "inherits": "^2.0.3", + "pump": "^2.0.0" + }, + "deprecated": false, + "description": "Combine an array of streams into a single duplex stream using pump and duplexify", + "devDependencies": { + "tape": "^4.8.0", + "through2": "^2.0.3" + }, + "homepage": "https://github.com/mafintosh/pumpify", + "keywords": [ + "pump", + "duplexify", + "duplex", + "streams", + "stream", + "pipeline", + "combine" + ], + "license": "MIT", + "main": "index.js", + "name": "pumpify", + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/pumpify.git" + }, + "scripts": { + "test": "tape test.js" + }, + "version": "1.4.0" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/test.js new file mode 100644 index 000000000..de6b16e34 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/test.js @@ -0,0 +1,181 @@ +var tape = require('tape') +var through = require('through2') +var pumpify = require('./') +var stream = require('stream') + +tape('basic', function(t) { + t.plan(3) + + var pipeline = pumpify( + through(function(data, enc, cb) { + t.same(data.toString(), 'hello') + cb(null, data.toString().toUpperCase()) + }), + through(function(data, enc, cb) { + t.same(data.toString(), 'HELLO') + cb(null, data.toString().toLowerCase()) + }) + ) + + pipeline.write('hello') + pipeline.on('data', function(data) { + t.same(data.toString(), 'hello') + t.end() + }) +}) + +tape('3 times', function(t) { + t.plan(4) + + var pipeline = pumpify( + through(function(data, enc, cb) { + t.same(data.toString(), 'hello') + cb(null, data.toString().toUpperCase()) + }), + through(function(data, enc, cb) { + t.same(data.toString(), 'HELLO') + cb(null, data.toString().toLowerCase()) + }), + through(function(data, enc, cb) { + t.same(data.toString(), 'hello') + cb(null, data.toString().toUpperCase()) + }) + ) + + pipeline.write('hello') + pipeline.on('data', function(data) { + t.same(data.toString(), 'HELLO') + t.end() + }) +}) + +tape('destroy', function(t) { + var test = through() + test.destroy = function() { + t.ok(true) + t.end() + } + + var pipeline = pumpify(through(), test) + + pipeline.destroy() +}) + +tape('close', function(t) { + var test = through() + var pipeline = pumpify(through(), test) + + pipeline.on('error', function(err) { + t.same(err.message, 'lol') + t.end() + }) + + test.emit('error', new Error('lol')) +}) + +tape('end waits for last one', function(t) { + var ran = false + + var a = through() + var b = through() + var c = through(function(data, enc, cb) { + setTimeout(function() { + ran = true + cb() + }, 100) + }) + + var pipeline = pumpify(a, b, c) + + pipeline.write('foo') + pipeline.end(function() { + t.ok(ran) + t.end() + }) + + t.ok(!ran) +}) + +tape('always wait for finish', function(t) { + var a = new stream.Readable() + a._read = function() {} + a.push('hello') + + var pipeline = pumpify(a, through(), through()) + var ran = false + + pipeline.on('finish', function() { + t.ok(ran) + t.end() + }) + + setTimeout(function() { + ran = true + a.push(null) + }, 100) +}) + +tape('async', function(t) { + var pipeline = pumpify() + + t.plan(4) + + pipeline.write('hello') + pipeline.on('data', function(data) { + t.same(data.toString(), 'HELLO') + t.end() + }) + + setTimeout(function() { + pipeline.setPipeline( + through(function(data, enc, cb) { + t.same(data.toString(), 'hello') + cb(null, data.toString().toUpperCase()) + }), + through(function(data, enc, cb) { + t.same(data.toString(), 'HELLO') + cb(null, data.toString().toLowerCase()) + }), + through(function(data, enc, cb) { + t.same(data.toString(), 'hello') + cb(null, data.toString().toUpperCase()) + }) + ) + }, 100) +}) + +tape('early destroy', function(t) { + var a = through() + var b = through() + var c = through() + + b.destroy = function() { + t.ok(true) + t.end() + } + + var pipeline = pumpify() + + pipeline.destroy() + setTimeout(function() { + pipeline.setPipeline(a, b, c) + }, 100) +}) + +tape('preserves error', function (t) { + var a = through() + var b = through(function (data, enc, cb) { + cb(new Error('stop')) + }) + var c = through() + var s = pumpify() + + s.on('error', function (err) { + t.same(err.message, 'stop') + t.end() + }) + + s.setPipeline(a, b, c) + s.resume() + s.write('hi') +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/.travis.yml new file mode 100644 index 000000000..aa89858a8 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - '0.10' + - '0.12' + - 'stable' diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/LICENSE new file mode 100644 index 000000000..66a4d2a14 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/README.md new file mode 100644 index 000000000..e0832d55b --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/README.md @@ -0,0 +1,41 @@ +# stream-each + +Iterate all the data in a stream + +``` +npm install stream-each +``` + +[![build status](http://img.shields.io/travis/mafintosh/stream-each.svg?style=flat)](http://travis-ci.org/mafintosh/stream-each) + +## Usage + +``` js +var each = require('stream-each') + +each(stream, function (data, next) { + console.log('data from stream', data) + // when ready to consume next chunk + next() +}, function (err) { + console.log('no more data') +}) +``` + +## API + +#### `each(stream, iterator, cb)` + +Iterate the data in the stream by calling the iterator function with `(data, next)` +where data is a data chunk and next is a callback. Call next when you are ready to +consume the next chunk. Optionally you can call next with an error to destroy the stream + +When the stream ends/errors the callback is called if provided + +## License + +MIT + +## Related + +`stream-each` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/collaborators.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/collaborators.md new file mode 100644 index 000000000..fc16de25f --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/collaborators.md @@ -0,0 +1,7 @@ +## Collaborators + +stream-each is only possible due to the excellent work of the following collaborators: + +<table><tbody><tr><th align="left">maxogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td></tr> +<tr><th align="left">mafintosh</th><td><a href="https://github.com/mafintosh">GitHub/mafintosh</a></td></tr> +</tbody></table> diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/index.js new file mode 100644 index 000000000..7e67f7337 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/index.js @@ -0,0 +1,58 @@ +var eos = require('end-of-stream') +var shift = require('stream-shift') + +module.exports = each + +function each (stream, fn, cb) { + var want = true + var error = null + var ended = false + var running = false + var calling = false + + stream.on('readable', onreadable) + onreadable() + + if (cb) eos(stream, {readable: true, writable: false}, done) + return stream + + function done (err) { + if (!error) error = err + ended = true + if (!running) cb(error) + } + + function onreadable () { + if (want) read() + } + + function afterRead (err) { + running = false + + if (err) { + error = err + if (ended) return cb(error) + stream.destroy(err) + return + } + if (ended) return cb(error) + if (!calling) read() + } + + function read () { + while (!running && !ended) { + want = false + + var data = shift(stream) + if (data === null) { + want = true + return + } + + running = true + calling = true + fn(data, afterRead) + calling = false + } + } +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/.travis.yml b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/.travis.yml new file mode 100644 index 000000000..ecd4193f6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "4" + - "6" diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/LICENSE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/LICENSE new file mode 100644 index 000000000..bae9da7bf --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Mathias Buus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/README.md new file mode 100644 index 000000000..d9cc2d945 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/README.md @@ -0,0 +1,25 @@ +# stream-shift + +Returns the next buffer/object in a stream's readable queue + +``` +npm install stream-shift +``` + +[![build status](http://img.shields.io/travis/mafintosh/stream-shift.svg?style=flat)](http://travis-ci.org/mafintosh/stream-shift) + +## Usage + +``` js +var shift = require('stream-shift') + +console.log(shift(someStream)) // first item in its buffer +``` + +## Credit + +Thanks [@dignifiedquire](https://github.com/dignifiedquire) for making this work on node 6 + +## License + +MIT diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/index.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/index.js new file mode 100644 index 000000000..c4b18b9c2 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/index.js @@ -0,0 +1,20 @@ +module.exports = shift + +function shift (stream) { + var rs = stream._readableState + if (!rs) return null + return rs.objectMode ? stream.read() : stream.read(getStateLength(rs)) +} + +function getStateLength (state) { + if (state.buffer.length) { + // Since node 6.3.0 state.buffer is a BufferList not an array + if (state.buffer.head) { + return state.buffer.head.data.length + } + + return state.buffer[0].length + } + + return state.length +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/package.json new file mode 100644 index 000000000..65033786c --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/package.json @@ -0,0 +1,53 @@ +{ + "_from": "stream-shift@^1.0.0", + "_id": "stream-shift@1.0.0", + "_inBundle": false, + "_integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", + "_location": "/npm-profile/make-fetch-happen/mississippi/stream-each/stream-shift", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "stream-shift@^1.0.0", + "name": "stream-shift", + "escapedName": "stream-shift", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi/stream-each" + ], + "_resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "_shasum": "d5c752825e5367e786f78e18e445ea223a155952", + "_spec": "stream-shift@^1.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each", + "author": { + "name": "Mathias Buus", + "url": "@mafintosh" + }, + "bugs": { + "url": "https://github.com/mafintosh/stream-shift/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "Returns the next buffer/object in a stream's readable queue", + "devDependencies": { + "standard": "^7.1.2", + "tape": "^4.6.0", + "through2": "^2.0.1" + }, + "homepage": "https://github.com/mafintosh/stream-shift", + "license": "MIT", + "main": "index.js", + "name": "stream-shift", + "repository": { + "type": "git", + "url": "git+https://github.com/mafintosh/stream-shift.git" + }, + "scripts": { + "test": "standard && tape test.js" + }, + "version": "1.0.0" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/test.js new file mode 100644 index 000000000..c0222c37d --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/node_modules/stream-shift/test.js @@ -0,0 +1,48 @@ +var tape = require('tape') +var through = require('through2') +var stream = require('stream') +var shift = require('./') + +tape('shifts next', function (t) { + var passthrough = through() + + passthrough.write('hello') + passthrough.write('world') + + t.same(shift(passthrough), Buffer('hello')) + t.same(shift(passthrough), Buffer('world')) + t.end() +}) + +tape('shifts next with core', function (t) { + var passthrough = stream.PassThrough() + + passthrough.write('hello') + passthrough.write('world') + + t.same(shift(passthrough), Buffer('hello')) + t.same(shift(passthrough), Buffer('world')) + t.end() +}) + +tape('shifts next with object mode', function (t) { + var passthrough = through({objectMode: true}) + + passthrough.write({hello: 1}) + passthrough.write({world: 1}) + + t.same(shift(passthrough), {hello: 1}) + t.same(shift(passthrough), {world: 1}) + t.end() +}) + +tape('shifts next with object mode with core', function (t) { + var passthrough = stream.PassThrough({objectMode: true}) + + passthrough.write({hello: 1}) + passthrough.write({world: 1}) + + t.same(shift(passthrough), {hello: 1}) + t.same(shift(passthrough), {world: 1}) + t.end() +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/package.json new file mode 100644 index 000000000..376fd9d23 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/package.json @@ -0,0 +1,56 @@ +{ + "_from": "stream-each@^1.1.0", + "_id": "stream-each@1.2.2", + "_inBundle": false, + "_integrity": "sha512-mc1dbFhGBxvTM3bIWmAAINbqiuAk9TATcfIQC8P+/+HJefgaiTlMn2dHvkX8qlI12KeYKSQ1Ua9RrIqrn1VPoA==", + "_location": "/npm-profile/make-fetch-happen/mississippi/stream-each", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "stream-each@^1.1.0", + "name": "stream-each", + "escapedName": "stream-each", + "rawSpec": "^1.1.0", + "saveSpec": null, + "fetchSpec": "^1.1.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.2.tgz", + "_shasum": "8e8c463f91da8991778765873fe4d960d8f616bd", + "_spec": "stream-each@^1.1.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Mathias Buus", + "url": "@mafintosh" + }, + "bugs": { + "url": "https://github.com/mafintosh/stream-each/issues" + }, + "bundleDependencies": false, + "dependencies": { + "end-of-stream": "^1.1.0", + "stream-shift": "^1.0.0" + }, + "deprecated": false, + "description": "Iterate all the data in a stream", + "devDependencies": { + "standard": "^5.3.1", + "tape": "^4.2.1", + "through2": "^2.0.0" + }, + "homepage": "https://github.com/mafintosh/stream-each", + "license": "MIT", + "main": "index.js", + "name": "stream-each", + "repository": { + "type": "git", + "url": "git+https://github.com/mafintosh/stream-each.git" + }, + "scripts": { + "test": "standard && tape test.js" + }, + "version": "1.2.2" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/test.js new file mode 100644 index 000000000..277634cd0 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each/test.js @@ -0,0 +1,122 @@ +var tape = require('tape') +var through = require('through2') +var each = require('./') + +tape('each', function (t) { + var s = through.obj() + s.write('a') + s.write('b') + s.write('c') + s.end() + + s.on('end', function () { + t.end() + }) + + var expected = ['a', 'b', 'c'] + each(s, function (data, next) { + t.same(data, expected.shift()) + next() + }) +}) + +tape('each and callback', function (t) { + var s = through.obj() + s.write('a') + s.write('b') + s.write('c') + s.end() + + var expected = ['a', 'b', 'c'] + each(s, function (data, next) { + t.same(data, expected.shift()) + next() + }, function () { + t.end() + }) +}) + +tape('each (write after)', function (t) { + var s = through.obj() + s.on('end', function () { + t.end() + }) + + var expected = ['a', 'b', 'c'] + each(s, function (data, next) { + t.same(data, expected.shift()) + next() + }) + + setTimeout(function () { + s.write('a') + s.write('b') + s.write('c') + s.end() + }, 100) +}) + +tape('each error', function (t) { + var s = through.obj() + s.write('hello') + s.on('error', function (err) { + t.same(err.message, 'stop') + t.end() + }) + + each(s, function (data, next) { + next(new Error('stop')) + }) +}) + +tape('each error and callback', function (t) { + var s = through.obj() + s.write('hello') + + each(s, function (data, next) { + next(new Error('stop')) + }, function (err) { + t.same(err.message, 'stop') + t.end() + }) +}) + +tape('each with falsey values', function (t) { + var s = through.obj() + s.write(0) + s.write(false) + s.write(undefined) + s.end() + + s.on('end', function () { + t.end() + }) + + var expected = [0, false] + var count = 0 + each(s, function (data, next) { + count++ + t.same(data, expected.shift()) + next() + }, function () { + t.same(count, 2) + }) +}) + +tape('huge stack', function (t) { + var s = through.obj() + + for (var i = 0; i < 5000; i++) { + s.write('foo') + } + + s.end() + + each(s, function (data, cb) { + if (data !== 'foo') t.fail('bad data') + cb() + }, function (err) { + t.error(err, 'no error') + t.end() + }) +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/.npmignore new file mode 100644 index 000000000..1e1dcab34 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/.npmignore @@ -0,0 +1,3 @@ +test +.jshintrc +.travis.yml
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/LICENSE.html b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/LICENSE.html new file mode 100644 index 000000000..ac478189e --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/LICENSE.html @@ -0,0 +1,336 @@ +<!doctype html> +<!-- Created with GFM2HTML: https://github.com/rvagg/gfm2html --> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <title></title> + <meta name="description" content=""> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <meta name="created-with" content="https://github.com/rvagg/gfm2html"> + + <style type="text/css"> +/* most of normalize.css */ +article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block;}[hidden],template{display:none;}html{font-family:sans-serif;/*1*/-ms-text-size-adjust:100%;/*2*/-webkit-text-size-adjust:100%;/*2*/}body{margin:0;}a{background:transparent;}a:focus{outline:thindotted;}a:active,a:hover{outline:0;}h1{font-size:2em;margin:0.67em0;}abbr[title]{border-bottom:1pxdotted;}b,strong{font-weight:bold;}dfn{font-style:italic;}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0;}mark{background:#ff0;color:#000;}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em;}pre{white-space:pre-wrap;}q{quotes:"\201C""\201D""\2018""\2019";}small{font-size:80%;}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}sup{top:-0.5em;}sub{bottom:-0.25em;}img{border:0;}svg:not(:root){overflow:hidden;}table{border-collapse:collapse;border-spacing:0;} + +html { + font: 14px 'Helvetica Neue', Helvetica, arial, freesans, clean, sans-serif; +} + +.container { + line-height: 1.6; + color: #333; + background: #eee; + border-radius: 3px; + padding: 3px; + width: 790px; + margin: 10px auto; +} + +.body-content { + background-color: #fff; + border: 1px solid #CACACA; + padding: 30px; +} + +.body-content > *:first-child { + margin-top: 0 !important; +} + +a, a:visited { + color: #4183c4; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +p, blockquote, ul, ol, dl, table, pre { + margin: 15px 0; +} + + .markdown-body h1 +, .markdown-body h2 +, .markdown-body h3 +, .markdown-body h4 +, .markdown-body h5 +, .markdown-body h6 { + margin: 20px 0 10px; + padding: 0; + font-weight: bold; +} + +h1 { + font-size: 2.5em; + color: #000; + border-bottom: 1px solid #ddd; +} + +h2 { + font-size: 2em; + border-bottom: 1px solid #eee; + color: #000; +} + +img { + max-width: 100%; +} + +hr { + background: transparent url("/img/hr.png") repeat-x 0 0; + border: 0 none; + color: #ccc; + height: 4px; + padding: 0; +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +tr:nth-child(2n) { + background-color: #f8f8f8; +} + +.markdown-body tr { + border-top: 1px solid #ccc; + background-color: #fff; +} + +td, th { + border: 1px solid #ccc; + padding: 6px 13px; +} + +th { + font-weight: bold; +} + +blockquote { + border-left: 4px solid #ddd; + padding: 0 15px; + color: #777; +} + +blockquote > :last-child, blockquote > :first-child { + margin-bottom: 0px; +} + +pre, code { + font-size: 13px; + font-family: 'UbuntuMono', monospace; + white-space: nowrap; + margin: 0 2px; + padding: 0px 5px; + border: 1px solid #eaeaea; + background-color: #f8f8f8; + border-radius: 3px; +} + +pre > code { + white-space: pre; +} + +pre { + overflow-x: auto; + white-space: pre; + padding: 10px; + line-height: 150%; + background-color: #f8f8f8; + border-color: #ccc; +} + +pre code, pre tt { + margin: 0; + padding: 0; + border: 0; + background-color: transparent; + border: none; +} + + .highlight .c +, .highlight .cm +, .highlight .cp +, .highlight .c1 { + color:#999988; + font-style:italic; +} + +.highlight .err { + color:#a61717; + background-color:#e3d2d2 +} + + .highlight .o +, .highlight .gs +, .highlight .kc +, .highlight .kd +, .highlight .kn +, .highlight .kp +, .highlight .kr { + font-weight:bold +} + +.highlight .cs { + color:#999999; + font-weight:bold; + font-style:italic +} + +.highlight .gd { + color:#000000; + background-color:#ffdddd +} + +.highlight .gd .x { + color:#000000; + background-color:#ffaaaa +} + +.highlight .ge { + font-style:italic +} + + .highlight .gr +, .highlight .gt { + color:#aa0000 +} + + .highlight .gh +, .highlight .bp { + color:#999999 +} + +.highlight .gi { + color:#000000; + background-color:#ddffdd +} + +.highlight .gi .x { + color:#000000; + background-color:#aaffaa +} + +.highlight .go { + color:#888888 +} + + .highlight .gp +, .highlight .nn { + color:#555555 +} + + +.highlight .gu { + color:#800080; + font-weight:bold +} + + +.highlight .kt { + color:#445588; + font-weight:bold +} + + .highlight .m +, .highlight .mf +, .highlight .mh +, .highlight .mi +, .highlight .mo +, .highlight .il { + color:#009999 +} + + .highlight .s +, .highlight .sb +, .highlight .sc +, .highlight .sd +, .highlight .s2 +, .highlight .se +, .highlight .sh +, .highlight .si +, .highlight .sx +, .highlight .s1 { + color:#d14 +} + +.highlight .n { + color:#333333 +} + + .highlight .na +, .highlight .no +, .highlight .nv +, .highlight .vc +, .highlight .vg +, .highlight .vi +, .highlight .nb { + color:#0086B3 +} + +.highlight .nc { + color:#445588; + font-weight:bold +} + +.highlight .ni { + color:#800080 +} + + .highlight .ne +, .highlight .nf { + color:#990000; + font-weight:bold +} + +.highlight .nt { + color:#000080 +} + +.highlight .ow { + font-weight:bold +} + +.highlight .w { + color:#bbbbbb +} + +.highlight .sr { + color:#009926 +} + +.highlight .ss { + color:#990073 +} + +.highlight .gc { + color:#999; + background-color:#EAF2F5 +} + +@media print { + .container { + background: transparent; + border-radius: 0; + padding: 0; + } + + .body-content { + border: none; + } +} +</style> + </head> + <body> + <div class="container"> + <div class="body-content"><h1 id="the-mit-license-mit-">The MIT License (MIT)</h1> +<p><strong>Copyright (c) 2016 Rod Vagg (the "Original Author") and additional contributors</strong></p> +<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p> +<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p> +<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p> +</div> + </div> + </body> +</html>
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/LICENSE.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/LICENSE.md new file mode 100644 index 000000000..7f0b93daa --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/LICENSE.md @@ -0,0 +1,9 @@ +# The MIT License (MIT) + +**Copyright (c) 2016 Rod Vagg (the "Original Author") and additional contributors** + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/README.md new file mode 100644 index 000000000..a916f15ef --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/README.md @@ -0,0 +1,136 @@ +# through2 + +[![NPM](https://nodei.co/npm/through2.png?downloads&downloadRank)](https://nodei.co/npm/through2/) + +**A tiny wrapper around Node streams.Transform (Streams2) to avoid explicit subclassing noise** + +Inspired by [Dominic Tarr](https://github.com/dominictarr)'s [through](https://github.com/dominictarr/through) in that it's so much easier to make a stream out of a function than it is to set up the prototype chain properly: `through(function (chunk) { ... })`. + +Note: As 2.x.x this module starts using **Streams3** instead of Stream2. To continue using a Streams2 version use `npm install through2@0` to fetch the latest version of 0.x.x. More information about Streams2 vs Streams3 and recommendations see the article **[Why I don't use Node's core 'stream' module](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html)**. + +```js +fs.createReadStream('ex.txt') + .pipe(through2(function (chunk, enc, callback) { + for (var i = 0; i < chunk.length; i++) + if (chunk[i] == 97) + chunk[i] = 122 // swap 'a' for 'z' + + this.push(chunk) + + callback() + })) + .pipe(fs.createWriteStream('out.txt')) + .on('finish', function () { + doSomethingSpecial() + }) +``` + +Or object streams: + +```js +var all = [] + +fs.createReadStream('data.csv') + .pipe(csv2()) + .pipe(through2.obj(function (chunk, enc, callback) { + var data = { + name : chunk[0] + , address : chunk[3] + , phone : chunk[10] + } + this.push(data) + + callback() + })) + .on('data', function (data) { + all.push(data) + }) + .on('end', function () { + doSomethingSpecial(all) + }) +``` + +Note that `through2.obj(fn)` is a convenience wrapper around `through2({ objectMode: true }, fn)`. + +## API + +<b><code>through2([ options, ] [ transformFunction ] [, flushFunction ])</code></b> + +Consult the **[stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform)** documentation for the exact rules of the `transformFunction` (i.e. `this._transform`) and the optional `flushFunction` (i.e. `this._flush`). + +### options + +The options argument is optional and is passed straight through to `stream.Transform`. So you can use `objectMode:true` if you are processing non-binary streams (or just use `through2.obj()`). + +The `options` argument is first, unlike standard convention, because if I'm passing in an anonymous function then I'd prefer for the options argument to not get lost at the end of the call: + +```js +fs.createReadStream('/tmp/important.dat') + .pipe(through2({ objectMode: true, allowHalfOpen: false }, + function (chunk, enc, cb) { + cb(null, 'wut?') // note we can use the second argument on the callback + // to provide data as an alternative to this.push('wut?') + } + ) + .pipe(fs.createWriteStream('/tmp/wut.txt')) +``` + +### transformFunction + +The `transformFunction` must have the following signature: `function (chunk, encoding, callback) {}`. A minimal implementation should call the `callback` function to indicate that the transformation is done, even if that transformation means discarding the chunk. + +To queue a new chunk, call `this.push(chunk)`—this can be called as many times as required before the `callback()` if you have multiple pieces to send on. + +Alternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error. + +If you **do not provide a `transformFunction`** then you will get a simple pass-through stream. + +### flushFunction + +The optional `flushFunction` is provided as the last argument (2nd or 3rd, depending on whether you've supplied options) is called just prior to the stream ending. Can be used to finish up any processing that may be in progress. + +```js +fs.createReadStream('/tmp/important.dat') + .pipe(through2( + function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop + function (cb) { // flush function + this.push('tacking on an extra buffer to the end'); + cb(); + } + )) + .pipe(fs.createWriteStream('/tmp/wut.txt')); +``` + +<b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b> + +Instead of returning a `stream.Transform` instance, `through2.ctor()` returns a **constructor** for a custom Transform. This is useful when you want to use the same transform logic in multiple instances. + +```js +var FToC = through2.ctor({objectMode: true}, function (record, encoding, callback) { + if (record.temp != null && record.unit == "F") { + record.temp = ( ( record.temp - 32 ) * 5 ) / 9 + record.unit = "C" + } + this.push(record) + callback() +}) + +// Create instances of FToC like so: +var converter = new FToC() +// Or: +var converter = FToC() +// Or specify/override options when you instantiate, if you prefer: +var converter = FToC({objectMode: true}) +``` + +## See Also + + - [through2-map](https://github.com/brycebaril/through2-map) - Array.prototype.map analog for streams. + - [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams. + - [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams. + - [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies. + - the [mississippi stream utility collection](https://github.com/maxogden/mississippi) includes `through2` as well as many more useful stream modules similar to this one + +## License + +**through2** is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/.npmignore b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/LICENCE b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/LICENCE new file mode 100644 index 000000000..1a14b437e --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/LICENCE @@ -0,0 +1,19 @@ +Copyright (c) 2012-2014 Raynos. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/Makefile b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/Makefile new file mode 100644 index 000000000..d583fcf49 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/Makefile @@ -0,0 +1,4 @@ +browser: + node ./support/compile + +.PHONY: browser
\ No newline at end of file diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/README.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/README.md new file mode 100644 index 000000000..093cb2978 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/README.md @@ -0,0 +1,32 @@ +# xtend + +[![browser support][3]][4] + +[![locked](http://badges.github.io/stability-badges/dist/locked.svg)](http://github.com/badges/stability-badges) + +Extend like a boss + +xtend is a basic utility library which allows you to extend an object by appending all of the properties from each object in a list. When there are identical properties, the right-most property takes precedence. + +## Examples + +```js +var extend = require("xtend") + +// extend returns a new object. Does not mutate arguments +var combination = extend({ + a: "a", + b: 'c' +}, { + b: "b" +}) +// { a: "a", b: "b" } +``` + +## Stability status: Locked + +## MIT Licenced + + + [3]: http://ci.testling.com/Raynos/xtend.png + [4]: http://ci.testling.com/Raynos/xtend diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/immutable.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/immutable.js new file mode 100644 index 000000000..94889c9de --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/immutable.js @@ -0,0 +1,19 @@ +module.exports = extend + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +function extend() { + var target = {} + + for (var i = 0; i < arguments.length; i++) { + var source = arguments[i] + + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + target[key] = source[key] + } + } + } + + return target +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/mutable.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/mutable.js new file mode 100644 index 000000000..72debede6 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/mutable.js @@ -0,0 +1,17 @@ +module.exports = extend + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +function extend(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] + + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + target[key] = source[key] + } + } + } + + return target +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/package.json new file mode 100644 index 000000000..b9d12f7b2 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/package.json @@ -0,0 +1,86 @@ +{ + "_from": "xtend@~4.0.1", + "_id": "xtend@4.0.1", + "_inBundle": false, + "_integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "_location": "/npm-profile/make-fetch-happen/mississippi/through2/xtend", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "xtend@~4.0.1", + "name": "xtend", + "escapedName": "xtend", + "rawSpec": "~4.0.1", + "saveSpec": null, + "fetchSpec": "~4.0.1" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi/through2" + ], + "_resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "_shasum": "a5c6d532be656e23db820efb943a1f04998d63af", + "_spec": "xtend@~4.0.1", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2", + "author": { + "name": "Raynos", + "email": "raynos2@gmail.com" + }, + "bugs": { + "url": "https://github.com/Raynos/xtend/issues", + "email": "raynos2@gmail.com" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Jake Verbaten" + }, + { + "name": "Matt Esch" + } + ], + "dependencies": {}, + "deprecated": false, + "description": "extend like a boss", + "devDependencies": { + "tape": "~1.1.0" + }, + "engines": { + "node": ">=0.4" + }, + "homepage": "https://github.com/Raynos/xtend", + "keywords": [ + "extend", + "merge", + "options", + "opts", + "object", + "array" + ], + "license": "MIT", + "main": "immutable", + "name": "xtend", + "repository": { + "type": "git", + "url": "git://github.com/Raynos/xtend.git" + }, + "scripts": { + "test": "node test" + }, + "testling": { + "files": "test.js", + "browsers": [ + "ie/7..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest" + ] + }, + "version": "4.0.1" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/test.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/test.js new file mode 100644 index 000000000..093a2b061 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/node_modules/xtend/test.js @@ -0,0 +1,83 @@ +var test = require("tape") +var extend = require("./") +var mutableExtend = require("./mutable") + +test("merge", function(assert) { + var a = { a: "foo" } + var b = { b: "bar" } + + assert.deepEqual(extend(a, b), { a: "foo", b: "bar" }) + assert.end() +}) + +test("replace", function(assert) { + var a = { a: "foo" } + var b = { a: "bar" } + + assert.deepEqual(extend(a, b), { a: "bar" }) + assert.end() +}) + +test("undefined", function(assert) { + var a = { a: undefined } + var b = { b: "foo" } + + assert.deepEqual(extend(a, b), { a: undefined, b: "foo" }) + assert.deepEqual(extend(b, a), { a: undefined, b: "foo" }) + assert.end() +}) + +test("handle 0", function(assert) { + var a = { a: "default" } + var b = { a: 0 } + + assert.deepEqual(extend(a, b), { a: 0 }) + assert.deepEqual(extend(b, a), { a: "default" }) + assert.end() +}) + +test("is immutable", function (assert) { + var record = {} + + extend(record, { foo: "bar" }) + assert.equal(record.foo, undefined) + assert.end() +}) + +test("null as argument", function (assert) { + var a = { foo: "bar" } + var b = null + var c = void 0 + + assert.deepEqual(extend(b, a, c), { foo: "bar" }) + assert.end() +}) + +test("mutable", function (assert) { + var a = { foo: "bar" } + + mutableExtend(a, { bar: "baz" }) + + assert.equal(a.bar, "baz") + assert.end() +}) + +test("null prototype", function(assert) { + var a = { a: "foo" } + var b = Object.create(null) + b.b = "bar"; + + assert.deepEqual(extend(a, b), { a: "foo", b: "bar" }) + assert.end() +}) + +test("null prototype mutable", function (assert) { + var a = { foo: "bar" } + var b = Object.create(null) + b.bar = "baz"; + + mutableExtend(a, b) + + assert.equal(a.bar, "baz") + assert.end() +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/package.json new file mode 100644 index 000000000..5d6541fa4 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/package.json @@ -0,0 +1,65 @@ +{ + "_from": "through2@^2.0.0", + "_id": "through2@2.0.3", + "_inBundle": false, + "_integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "_location": "/npm-profile/make-fetch-happen/mississippi/through2", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "through2@^2.0.0", + "name": "through2", + "escapedName": "through2", + "rawSpec": "^2.0.0", + "saveSpec": null, + "fetchSpec": "^2.0.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen/mississippi" + ], + "_resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "_shasum": "0004569b37c7c74ba39c43f3ced78d1ad94140be", + "_spec": "through2@^2.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi", + "author": { + "name": "Rod Vagg", + "email": "r@va.gg", + "url": "https://github.com/rvagg" + }, + "bugs": { + "url": "https://github.com/rvagg/through2/issues" + }, + "bundleDependencies": false, + "dependencies": { + "readable-stream": "^2.1.5", + "xtend": "~4.0.1" + }, + "deprecated": false, + "description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise", + "devDependencies": { + "bl": "~1.1.2", + "faucet": "0.0.1", + "stream-spigot": "~3.0.5", + "tape": "~4.6.2" + }, + "homepage": "https://github.com/rvagg/through2#readme", + "keywords": [ + "stream", + "streams2", + "through", + "transform" + ], + "license": "MIT", + "main": "through2.js", + "name": "through2", + "repository": { + "type": "git", + "url": "git+https://github.com/rvagg/through2.git" + }, + "scripts": { + "test": "node test/test.js | faucet", + "test-local": "brtapsauce-local test/basic-test.js" + }, + "version": "2.0.3" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/through2.js b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/through2.js new file mode 100644 index 000000000..5b7a880e8 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/through2/through2.js @@ -0,0 +1,96 @@ +var Transform = require('readable-stream/transform') + , inherits = require('util').inherits + , xtend = require('xtend') + +function DestroyableTransform(opts) { + Transform.call(this, opts) + this._destroyed = false +} + +inherits(DestroyableTransform, Transform) + +DestroyableTransform.prototype.destroy = function(err) { + if (this._destroyed) return + this._destroyed = true + + var self = this + process.nextTick(function() { + if (err) + self.emit('error', err) + self.emit('close') + }) +} + +// a noop _transform function +function noop (chunk, enc, callback) { + callback(null, chunk) +} + + +// create a new export function, used by both the main export and +// the .ctor export, contains common logic for dealing with arguments +function through2 (construct) { + return function (options, transform, flush) { + if (typeof options == 'function') { + flush = transform + transform = options + options = {} + } + + if (typeof transform != 'function') + transform = noop + + if (typeof flush != 'function') + flush = null + + return construct(options, transform, flush) + } +} + + +// main export, just make me a transform stream! +module.exports = through2(function (options, transform, flush) { + var t2 = new DestroyableTransform(options) + + t2._transform = transform + + if (flush) + t2._flush = flush + + return t2 +}) + + +// make me a reusable prototype that I can `new`, or implicitly `new` +// with a constructor call +module.exports.ctor = through2(function (options, transform, flush) { + function Through2 (override) { + if (!(this instanceof Through2)) + return new Through2(override) + + this.options = xtend(options, override) + + DestroyableTransform.call(this, this.options) + } + + inherits(Through2, DestroyableTransform) + + Through2.prototype._transform = transform + + if (flush) + Through2.prototype._flush = flush + + return Through2 +}) + + +module.exports.obj = through2(function (options, transform, flush) { + var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options)) + + t2._transform = transform + + if (flush) + t2._flush = flush + + return t2 +}) diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/package.json b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/package.json new file mode 100644 index 000000000..1d98db313 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/package.json @@ -0,0 +1,64 @@ +{ + "_from": "mississippi@^1.2.0", + "_id": "mississippi@1.3.1", + "_inBundle": false, + "_integrity": "sha512-/6rB8YXFbAtsUVRphIRQqB0+9c7VaPHCjVtvto+JqwVxgz8Zz+I+f68/JgQ+Pb4VlZb2svA9OtdXnHHsZz7ltg==", + "_location": "/npm-profile/make-fetch-happen/mississippi", + "_phantomChildren": { + "inherits": "2.0.3", + "once": "1.4.0", + "readable-stream": "2.3.3" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "mississippi@^1.2.0", + "name": "mississippi", + "escapedName": "mississippi", + "rawSpec": "^1.2.0", + "saveSpec": null, + "fetchSpec": "^1.2.0" + }, + "_requiredBy": [ + "/npm-profile/make-fetch-happen", + "/npm-profile/make-fetch-happen/cacache" + ], + "_resolved": "https://registry.npmjs.org/mississippi/-/mississippi-1.3.1.tgz", + "_shasum": "2a8bb465e86550ac8b36a7b6f45599171d78671e", + "_spec": "mississippi@^1.2.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-profile/node_modules/make-fetch-happen", + "author": { + "name": "max ogden" + }, + "bugs": { + "url": "https://github.com/maxogden/mississippi/issues" + }, + "bundleDependencies": false, + "dependencies": { + "concat-stream": "^1.5.0", + "duplexify": "^3.4.2", + "end-of-stream": "^1.1.0", + "flush-write-stream": "^1.0.0", + "from2": "^2.1.0", + "parallel-transform": "^1.1.0", + "pump": "^1.0.0", + "pumpify": "^1.3.3", + "stream-each": "^1.1.0", + "through2": "^2.0.0" + }, + "deprecated": false, + "description": "a collection of useful streams", + "devDependencies": {}, + "homepage": "https://github.com/maxogden/mississippi#readme", + "license": "BSD-2-Clause", + "main": "index.js", + "name": "mississippi", + "repository": { + "type": "git", + "url": "git+https://github.com/maxogden/mississippi.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.3.1" +} diff --git a/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/readme.md b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/readme.md new file mode 100644 index 000000000..8a70a7a26 --- /dev/null +++ b/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/readme.md @@ -0,0 +1,399 @@ +# mississippi + +a collection of useful stream utility modules. learn how the modules work using this and then pick the ones you want and use them individually + +the goal of the modules included in mississippi is to make working with streams easy without sacrificing speed, error handling or composability. + +## usage + +```js +var miss = require('mississippi') +``` + +## methods + +- [pipe](#pipe) +- [each](#each) +- [pipeline](#pipeline) +- [duplex](#duplex) +- [through](#through) +- [from](#from) +- [to](#to) +- [concat](#concat) +- [finished](#finished) +- [parallel](#parallel) + +### pipe + +##### `miss.pipe(stream1, stream2, stream3, ..., cb)` + +Pipes streams together and destroys all of them if one of them closes. Calls `cb` with `(error)` if there was an error in any of the streams. + +When using standard `source.pipe(destination)` the source will _not_ be destroyed if the destination emits close or error. You are also not able to provide a callback to tell when the pipe has finished. + +`miss.pipe` does these two things for you, ensuring you handle stream errors 100% of the time (unhandled errors are probably the most common bug in most node streams code) + +#### original module + +`miss.pipe` is provided by [`require('pump')`](https://www.npmjs.com/package/pump) + +#### example + +```js +// lets do a simple file copy +var fs = require('fs') + +var read = fs.createReadStream('./original.zip') +var write = fs.createWriteStream('./copy.zip') + +// use miss.pipe instead of read.pipe(write) +miss.pipe(read, write, function (err) { + if (err) return console.error('Copy error!', err) + console.log('Copied successfully') +}) +``` + +### each + +##### `miss.each(stream, each, [done])` + +Iterate the data in `stream` one chunk at a time. Your `each` function will be called with `(data, next)` where data is a data chunk and next is a callback. Call `next` when you are ready to consume the next chunk. + +Optionally you can call `next` with an error to destroy the stream. You can also pass the optional third argument, `done`, which is a function that will be called with `(err)` when the stream ends. The `err` argument will be populated with an error if the stream emitted an error. + +#### original module + +`miss.each` is provided by [`require('stream-each')`](https://www.npmjs.com/package/stream-each) + +#### example + +```js +var fs = require('fs') +var split = require('split2') + +var newLineSeparatedNumbers = fs.createReadStream('numbers.txt') + +var pipeline = miss.pipeline(newLineSeparatedNumbers, split()) +miss.each(pipeline, eachLine, done) +var sum = 0 + +function eachLine (line, next) { + sum += parseInt(line.toString()) + next() +} + +function done (err) { + if (err) throw err + console.log('sum is', sum) +} +``` + +### pipeline + +##### `var pipeline = miss.pipeline(stream1, stream2, stream3, ...)` + +Builds a pipeline from all the transform streams passed in as arguments by piping them together and returning a single stream object that lets you write to the first stream and read from the last stream. + +If any of the streams in the pipeline emits an error or gets destroyed, or you destroy the stream it returns, all of the streams will be destroyed and cleaned up for you. + +#### original module + +`miss.pipeline` is provided by [`require('pumpify')`](https://www.npmjs.com/package/pumpify) + +#### example + +```js +// first create some transform streams (note: these two modules are fictional) +var imageResize = require('image-resizer-stream')({width: 400}) +var pngOptimizer = require('png-optimizer-stream')({quality: 60}) + +// instead of doing a.pipe(b), use pipelin +var resizeAndOptimize = miss.pipeline(imageResize, pngOptimizer) +// `resizeAndOptimize` is a transform stream. when you write to it, it writes +// to `imageResize`. when you read from it, it reads from `pngOptimizer`. +// it handles piping all the streams together for you + +// use it like any other transform stream +var fs = require('fs') + +var read = fs.createReadStream('./image.png') +var write = fs.createWriteStream('./resized-and-optimized.png') + +miss.pipe(read, resizeAndOptimize, write, function (err) { + if (err) return console.error('Image processing error!', err) + console.log('Image processed successfully') +}) +``` + +### duplex + +##### `var duplex = miss.duplex([writable, readable, opts])` + +Take two separate streams, a writable and a readable, and turn them into a single [duplex (readable and writable) stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex). + +The returned stream will emit data from the readable. When you write to it it writes to the writable. + +You can either choose to supply the writable and the readable at the time you create the stream, or you can do it later using the `.setWritable` and `.setReadable` methods and data written to the stream in the meantime will be buffered for you. + +#### original module + +`miss.duplex` is provided by [`require('duplexify')`](https://www.npmjs.com/package/duplexify) + +#### example + +```js +// lets spawn a process and take its stdout and stdin and combine them into 1 stream +var child = require('child_process') + +// @- tells it to read from stdin, --data-binary sets 'raw' binary mode +var curl = child.spawn('curl -X POST --data-binary @- http://foo.com') + +// duplexCurl will write to stdin and read from stdout +var duplexCurl = miss.duplex(curl.stdin, curl.stdout) +``` + +### through + +##### `var transformer = miss.through([options, transformFunction, flushFunction])` + +Make a custom [transform stream](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform). + +The `options` object is passed to the internal transform stream and can be used to create an `objectMode` stream (or use the shortcut `miss.through.obj([...])`) + +The `transformFunction` is called when data is available for the writable side and has the signature `(chunk, encoding, cb)`. Within the function, add data to the readable side any number of times with `this.push(data)`. Call `cb()` to indicate processing of the `chunk` is complete. Or to easily emit a single error or chunk, call `cb(err, chunk)` + +The `flushFunction`, with signature `(cb)`, is called just before the stream is complete and should be used to wrap up stream processing. + +#### original module + +`miss.through` is provided by [`require('through2')`](https://www.npmjs.com/package/through2) + +#### example + +```js +var fs = require('fs') + +var read = fs.createReadStream('./boring_lowercase.txt') +var write = fs.createWriteStream('./AWESOMECASE.TXT') + +// Leaving out the options object +var uppercaser = miss.through( + function (chunk, enc, cb) { + cb(null, chunk.toString().toUpperCase()) + }, + function (cb) { + cb(null, 'ONE LAST BIT OF UPPERCASE') + } +) + +miss.pipe(read, uppercaser, write, function (err) { + if (err) return console.error('Trouble uppercasing!') + console.log('Splendid uppercasing!') +}) +``` + +### from + +##### `miss.from([opts], read)` + +Make a custom [readable stream](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_readable). + +`opts` contains the options to pass on to the ReadableStream constructor e.g. for creating a readable object stream (or use the shortcut `miss.from.obj([...])`). + +Returns a readable stream that calls `read(size, next)` when data is requested from the stream. + +- `size` is the recommended amount of data (in bytes) to retrieve. +- `next(err, chunk)` should be called when you're ready to emit more data. + +#### original module + +`miss.from` is provided by [`require('from2')`](https://www.npmjs.com/package/from2) + +#### example + +```js + + +function fromString(string) { + return miss.from(function(size, next) { + // if there's no more content + // left in the string, close the stream. + if (string.length <= 0) return next(null, null) + + // Pull in a new chunk of text, + // removing it from the string. + var chunk = string.slice(0, size) + string = string.slice(size) + + // Emit "chunk" from the stream. + next(null, chunk) + }) +} + +// pipe "hello world" out +// to stdout. +fromString('hello world').pipe(process.stdout) +``` + +### to + +##### `miss.to([options], write, [flush])` + +Make a custom [writable stream](https://nodejs.org/docs/latest/api/stream.html#stream_class_stream_writable). + +`opts` contains the options to pass on to the WritableStream constructor e.g. for creating a writable object stream (or use the shortcut `miss.to.obj([...])`). + +Returns a writable stream that calls `write(data, enc, cb)` when data is written to the stream. + +- `data` is the received data to write the destination. +- `enc` encoding of the piece of data received. +- `cb(err, data)` should be called when you're ready to write more data, or encountered an error. + +`flush(cb)` is called before `finish` is emitted and allows for cleanup steps to occur. + +#### original module + +`miss.to` is provided by [`require('flush-write-stream')`](https://www.npmjs.com/package/flush-write-stream) + +#### example + +```js +var ws = miss.to(write, flush) + +ws.on('finish', function () { + console.log('finished') +}) + +ws.write('hello') +ws.write('world') +ws.end() + +function write (data, enc, cb) { + // i am your normal ._write method + console.log('writing', data.toString()) + cb() +} + +function flush (cb) { + // i am called before finish is emitted + setTimeout(cb, 1000) // wait 1 sec +} +``` + +If you run the above it will produce the following output + +``` +writing hello +writing world +(nothing happens for 1 sec) +finished +``` + +### concat + +##### `var concat = miss.concat(cb)` + +Returns a writable stream that concatenates all data written to the stream and calls a callback with the single result. + +Calling `miss.concat(cb)` returns a writable stream. `cb` is called when the writable stream is finished, e.g. when all data is done being written to it. `cb` is called with a single argument, `(data)`, which will contain the result of concatenating all the data written to the stream. + +Note that `miss.concat` will not handle stream errors for you. To handle errors, use `miss.pipe` or handle the `error` event manually. + +#### original module + +`miss.concat` is provided by [`require('concat-stream')`](https://www.npmjs.com/package/concat-stream) + +#### example + +```js +var fs = require('fs') + +var readStream = fs.createReadStream('cat.png') +var concatStream = miss.concat(gotPicture) + +function callback (err) { + if (err) { + console.error(err) + process.exit(1) + } +} + +miss.pipe(readStream, concatStream, callback) + +function gotPicture(imageBuffer) { + // imageBuffer is all of `cat.png` as a node.js Buffer +} + +function handleError(err) { + // handle your error appropriately here, e.g.: + console.error(err) // print the error to STDERR + process.exit(1) // exit program with non-zero exit code +} +``` + +### finished + +##### `miss.finished(stream, cb)` + +Waits for `stream` to finish or error and then calls `cb` with `(err)`. `cb` will only be called once. `err` will be null if the stream finished without error, or else it will be populated with the error from the streams `error` event. + +This function is useful for simplifying stream handling code as it lets you handle success or error conditions in a single code path. It's used internally `miss.pipe`. + +#### original module + +`miss.finished` is provided by [`require('end-of-stream')`](https://www.npmjs.com/package/end-of-stream) + +#### example + +```js +var copySource = fs.createReadStream('./movie.mp4') +var copyDest = fs.createWriteStream('./movie-copy.mp4') + +copySource.pipe(copyDest) + +miss.finished(copyDest, function(err) { + if (err) return console.log('write failed', err) + console.log('write success') +}) +``` + +### parallel + +##### `miss.parallel(concurrency, each)` + +This works like `through` except you can process items in parallel, while still preserving the original input order. + +This is handy if you wanna take advantage of node's async I/O and process streams of items in batches. With this module you can build your very own streaming parallel job queue. + +Note that `miss.parallel` preserves input ordering, if you don't need that then you can use [through2-concurrent](https://github.com/almost/through2-concurrent) instead, which is very similar to this otherwise. + +#### original module + +`miss.parallel` is provided by [`require('parallel-transform')`](https://npmjs.org/parallel-transform) + +#### example + +This example fetches the GET HTTP headers for a stream of input URLs 5 at a time in parallel. + +```js +function getResponse (item, cb) { + var r = request(item.url) + r.on('error', function (err) { + cb(err) + }) + r.on('response', function (re) { + cb(null, {url: item.url, date: new Date(), status: re.statusCode, headers: re.headers}) + r.abort() + }) +} + +miss.pipe( + fs.createReadStream('./urls.txt'), // one url per line + split(), + miss.parallel(5, getResponse), + miss.through(function (row, enc, next) { + console.log(JSON.stringify(row)) + next() + }) +) +``` |