diff --git a/dist/workfront.js b/dist/workfront.js index 9060e302..8d6fa286 100644 --- a/dist/workfront.js +++ b/dist/workfront.js @@ -48,9 +48,11 @@ module.exports = { ApiConstants: ApiConstants }; -},{"./src/Api":36,"./src/ApiConstants":37,"./src/ApiFactory":38,"./src/ApiUtil":39,"promise/polyfill":2}],2:[function(require,module,exports){ +},{"./src/Api":37,"./src/ApiConstants":38,"./src/ApiFactory":39,"./src/ApiUtil":40,"promise/polyfill":2}],2:[function(require,module,exports){ },{}],3:[function(require,module,exports){ +module.exports=require(2) +},{"/Users/ryanmiller/Desktop/WFAPI/workfront-api/node_modules/browserify/lib/_empty.js":2}],4:[function(require,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -97,7 +99,7 @@ Buffer.TYPED_ARRAY_SUPPORT = (function () { var buf = new ArrayBuffer(0) var arr = new Uint8Array(buf) arr.foo = function () { return 42 } - return 42 === arr.foo() && // typed array instances can be augmented + return arr.foo() === 42 && // typed array instances can be augmented typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { @@ -117,97 +119,192 @@ Buffer.TYPED_ARRAY_SUPPORT = (function () { * By augmenting the instances, we can avoid modifying the `Uint8Array` * prototype. */ -function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) - return new Buffer(subject, encoding, noZero) - - var type = typeof subject - - // Find the length - var length - if (type === 'number') - length = subject > 0 ? subject >>> 0 : 0 - else if (type === 'string') { - length = Buffer.byteLength(subject, encoding) - } else if (type === 'object' && subject !== null) { // assume object is array-like - if (subject.type === 'Buffer' && isArray(subject.data)) - subject = subject.data - length = +subject.length > 0 ? Math.floor(+subject.length) : 0 - } else +function Buffer (arg) { + if (!(this instanceof Buffer)) { + // Avoid going through an ArgumentsAdaptorTrampoline in the common case. + if (arguments.length > 1) return new Buffer(arg, arguments[1]) + return new Buffer(arg) + } + + this.length = 0 + this.parent = undefined + + // Common case. + if (typeof arg === 'number') { + return fromNumber(this, arg) + } + + // Slightly less common case. + if (typeof arg === 'string') { + return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') + } + + // Unusual. + return fromObject(this, arg) +} + +function fromNumber (that, length) { + that = allocate(that, length < 0 ? 0 : checked(length) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < length; i++) { + that[i] = 0 + } + } + return that +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' + + // Assumption: byteLength() return value is always < kMaxLength. + var length = byteLength(string, encoding) | 0 + that = allocate(that, length) + + that.write(string, encoding) + return that +} + +function fromObject (that, object) { + if (Buffer.isBuffer(object)) return fromBuffer(that, object) + + if (isArray(object)) return fromArray(that, object) + + if (object == null) { throw new TypeError('must start with number, buffer, array or string') + } - if (length > kMaxLength) - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength.toString(16) + ' bytes') + if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) { + return fromTypedArray(that, object) + } + + if (object.length) return fromArrayLike(that, object) - var buf + return fromJsonObject(that, object) +} + +function fromBuffer (that, buffer) { + var length = checked(buffer.length) | 0 + that = allocate(that, length) + buffer.copy(that, 0, 0, length) + return that +} + +function fromArray (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +// Duplicate of fromArray() to keep fromArray() monomorphic. +function fromTypedArray (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + // Truncating the elements is probably not what people expect from typed + // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior + // of the old Buffer constructor. + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayLike (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. +// Returns a zero-length buffer for inputs that don't conform to the spec. +function fromJsonObject (that, object) { + var array + var length = 0 + + if (object.type === 'Buffer' && isArray(object.data)) { + array = object.data + length = checked(array.length) | 0 + } + that = allocate(that, length) + + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function allocate (that, length) { if (Buffer.TYPED_ARRAY_SUPPORT) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = Buffer._augment(new Uint8Array(length)) + // Return an augmented `Uint8Array` instance, for best performance + that = Buffer._augment(new Uint8Array(length)) } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true + // Fallback: Return an object instance of the Buffer class + that.length = length + that._isBuffer = true } - var i - if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { - // Speed optimization -- use set if we're copying from a typed array - buf._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - if (Buffer.isBuffer(subject)) { - for (i = 0; i < length; i++) - buf[i] = subject.readUInt8(i) - } else { - for (i = 0; i < length; i++) - buf[i] = ((subject[i] % 256) + 256) % 256 - } - } else if (type === 'string') { - buf.write(subject, 0, encoding) - } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) { - for (i = 0; i < length; i++) { - buf[i] = 0 - } - } + var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 + if (fromPool) that.parent = rootParent - if (length > 0 && length <= Buffer.poolSize) - buf.parent = rootParent + return that +} - return buf +function checked (length) { + // Note: cannot use `length < kMaxLength` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength.toString(16) + ' bytes') + } + return length | 0 } -function SlowBuffer(subject, encoding, noZero) { - if (!(this instanceof SlowBuffer)) - return new SlowBuffer(subject, encoding, noZero) +function SlowBuffer (subject, encoding) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) - var buf = new Buffer(subject, encoding, noZero) + var buf = new Buffer(subject, encoding) delete buf.parent return buf } -Buffer.isBuffer = function (b) { +Buffer.isBuffer = function isBuffer (b) { return !!(b != null && b._isBuffer) } -Buffer.compare = function (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 var x = a.length var y = b.length - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} + + var i = 0 + var len = Math.min(x, y) + while (i < len) { + if (a[i] !== b[i]) break + + ++i + } + if (i !== len) { x = a[i] y = b[i] } + if (x < y) return -1 if (y < x) return 1 return 0 } -Buffer.isEncoding = function (encoding) { +Buffer.isEncoding = function isEncoding (encoding) { switch (String(encoding).toLowerCase()) { case 'hex': case 'utf8': @@ -226,8 +323,8 @@ Buffer.isEncoding = function (encoding) { } } -Buffer.concat = function (list, totalLength) { - if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])') +Buffer.concat = function concat (list, length) { + if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') if (list.length === 0) { return new Buffer(0) @@ -236,14 +333,14 @@ Buffer.concat = function (list, totalLength) { } var i - if (totalLength === undefined) { - totalLength = 0 + if (length === undefined) { + length = 0 for (i = 0; i < list.length; i++) { - totalLength += list[i].length + length += list[i].length } } - var buf = new Buffer(totalLength) + var buf = new Buffer(length) var pos = 0 for (i = 0; i < list.length; i++) { var item = list[i] @@ -253,47 +350,44 @@ Buffer.concat = function (list, totalLength) { return buf } -Buffer.byteLength = function (str, encoding) { - var ret - str = str + '' +function byteLength (string, encoding) { + if (typeof string !== 'string') string = String(string) + + if (string.length === 0) return 0 + switch (encoding || 'utf8') { case 'ascii': case 'binary': case 'raw': - ret = str.length - break + return string.length case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': - ret = str.length * 2 - break + return string.length * 2 case 'hex': - ret = str.length >>> 1 - break + return string.length >>> 1 case 'utf8': case 'utf-8': - ret = utf8ToBytes(str).length - break + return utf8ToBytes(string).length case 'base64': - ret = base64ToBytes(str).length - break + return base64ToBytes(string).length default: - ret = str.length + return string.length } - return ret } +Buffer.byteLength = byteLength // pre-set for values that may exist in the future Buffer.prototype.length = undefined Buffer.prototype.parent = undefined // toString(encoding, start=0, end=buffer.length) -Buffer.prototype.toString = function (encoding, start, end) { +Buffer.prototype.toString = function toString (encoding, start, end) { var loweredCase = false - start = start >>> 0 - end = end === undefined || end === Infinity ? this.length : end >>> 0 + start = start | 0 + end = end === undefined || end === Infinity ? this.length : end | 0 if (!encoding) encoding = 'utf8' if (start < 0) start = 0 @@ -325,43 +419,84 @@ Buffer.prototype.toString = function (encoding, start, end) { return utf16leSlice(this, start, end) default: - if (loweredCase) - throw new TypeError('Unknown encoding: ' + encoding) + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) encoding = (encoding + '').toLowerCase() loweredCase = true } } } -Buffer.prototype.equals = function (b) { +Buffer.prototype.equals = function equals (b) { if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true return Buffer.compare(this, b) === 0 } -Buffer.prototype.inspect = function () { +Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES if (this.length > 0) { str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) - str += ' ... ' + if (this.length > max) str += ' ... ' } return '' } -Buffer.prototype.compare = function (b) { +Buffer.prototype.compare = function compare (b) { if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return 0 return Buffer.compare(this, b) } +Buffer.prototype.indexOf = function indexOf (val, byteOffset) { + if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff + else if (byteOffset < -0x80000000) byteOffset = -0x80000000 + byteOffset >>= 0 + + if (this.length === 0) return -1 + if (byteOffset >= this.length) return -1 + + // Negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) + + if (typeof val === 'string') { + if (val.length === 0) return -1 // special case: looking for empty string always fails + return String.prototype.indexOf.call(this, val, byteOffset) + } + if (Buffer.isBuffer(val)) { + return arrayIndexOf(this, val, byteOffset) + } + if (typeof val === 'number') { + if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { + return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + } + return arrayIndexOf(this, [ val ], byteOffset) + } + + function arrayIndexOf (arr, val, byteOffset) { + var foundIndex = -1 + for (var i = 0; byteOffset + i < arr.length; i++) { + if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + } else { + foundIndex = -1 + } + } + return -1 + } + + throw new TypeError('val must be string, number or Buffer') +} + // `get` will be removed in Node 0.13+ -Buffer.prototype.get = function (offset) { +Buffer.prototype.get = function get (offset) { console.log('.get() is deprecated. Access using array indexes instead.') return this.readUInt8(offset) } // `set` will be removed in Node 0.13+ -Buffer.prototype.set = function (v, offset) { +Buffer.prototype.set = function set (v, offset) { console.log('.set() is deprecated. Access using array indexes instead.') return this.writeUInt8(v, offset) } @@ -386,21 +521,19 @@ function hexWrite (buf, string, offset, length) { length = strLen / 2 } for (var i = 0; i < length; i++) { - var byte = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(byte)) throw new Error('Invalid hex string') - buf[offset + i] = byte + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) throw new Error('Invalid hex string') + buf[offset + i] = parsed } return i } function utf8Write (buf, string, offset, length) { - var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) - return charsWritten + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } function asciiWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten + return blitBuffer(asciiToBytes(string), buf, offset, length) } function binaryWrite (buf, string, offset, length) { @@ -408,77 +541,86 @@ function binaryWrite (buf, string, offset, length) { } function base64Write (buf, string, offset, length) { - var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten + return blitBuffer(base64ToBytes(string), buf, offset, length) } -function utf16leWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length, 2) - return charsWritten +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) } -Buffer.prototype.write = function (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { encoding = length length = undefined } - } else { // legacy + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { var swap = encoding encoding = offset - offset = length + offset = length | 0 length = swap } - offset = Number(offset) || 0 - - if (length < 0 || offset < 0 || offset > this.length) - throw new RangeError('attempt to write outside buffer bounds'); - var remaining = this.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('attempt to write outside buffer bounds') } - encoding = String(encoding || 'utf8').toLowerCase() - var ret - switch (encoding) { - case 'hex': - ret = hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = utf8Write(this, string, offset, length) - break - case 'ascii': - ret = asciiWrite(this, string, offset, length) - break - case 'binary': - ret = binaryWrite(this, string, offset, length) - break - case 'base64': - ret = base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = utf16leWrite(this, string, offset, length) - break - default: - throw new TypeError('Unknown encoding: ' + encoding) + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'binary': + return binaryWrite(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } } - return ret } -Buffer.prototype.toJSON = function () { +Buffer.prototype.toJSON = function toJSON () { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) @@ -552,43 +694,39 @@ function utf16leSlice (buf, start, end) { return res } -Buffer.prototype.slice = function (start, end) { +Buffer.prototype.slice = function slice (start, end) { var len = this.length start = ~~start end = end === undefined ? len : ~~end if (start < 0) { - start += len; - if (start < 0) - start = 0 + start += len + if (start < 0) start = 0 } else if (start > len) { start = len } if (end < 0) { end += len - if (end < 0) - end = 0 + if (end < 0) end = 0 } else if (end > len) { end = len } - if (end < start) - end = start + if (end < start) end = start var newBuf if (Buffer.TYPED_ARRAY_SUPPORT) { newBuf = Buffer._augment(this.subarray(start, end)) } else { var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined, true) + newBuf = new Buffer(sliceLen, undefined) for (var i = 0; i < sliceLen; i++) { newBuf[i] = this[i + start] } } - if (newBuf.length) - newBuf.parent = this.parent || this + if (newBuf.length) newBuf.parent = this.parent || this return newBuf } @@ -597,62 +735,58 @@ Buffer.prototype.slice = function (start, end) { * Need to make sure that buffer isn't trying to write out of bounds. */ function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) - throw new RangeError('offset is not uint') - if (offset + ext > length) - throw new RangeError('Trying to access beyond buffer length') + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') } -Buffer.prototype.readUIntLE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkOffset(offset, byteLength, this.length) +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] var mul = 1 var i = 0 - while (++i < byteLength && (mul *= 0x100)) + while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul + } return val } -Buffer.prototype.readUIntBE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { checkOffset(offset, byteLength, this.length) + } var val = this[offset + --byteLength] var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) - val += this[offset + --byteLength] * mul; + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } return val } -Buffer.prototype.readUInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) return this[offset] } -Buffer.prototype.readUInt16LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) return this[offset] | (this[offset + 1] << 8) } -Buffer.prototype.readUInt16BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) return (this[offset] << 8) | this[offset + 1] } -Buffer.prototype.readUInt32LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return ((this[offset]) | (this[offset + 1] << 8) | @@ -660,117 +794,104 @@ Buffer.prototype.readUInt32LE = function (offset, noAssert) { (this[offset + 3] * 0x1000000) } -Buffer.prototype.readUInt32BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) } -Buffer.prototype.readIntLE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkOffset(offset, byteLength, this.length) +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] var mul = 1 var i = 0 - while (++i < byteLength && (mul *= 0x100)) + while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul + } mul *= 0x80 - if (val >= mul) - val -= Math.pow(2, 8 * byteLength) + if (val >= mul) val -= Math.pow(2, 8 * byteLength) return val } -Buffer.prototype.readIntBE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkOffset(offset, byteLength, this.length) +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) var i = byteLength var mul = 1 var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) + while (i > 0 && (mul *= 0x100)) { val += this[offset + --i] * mul + } mul *= 0x80 - if (val >= mul) - val -= Math.pow(2, 8 * byteLength) + if (val >= mul) val -= Math.pow(2, 8 * byteLength) return val } -Buffer.prototype.readInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) - return (this[offset]) +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) return ((0xff - this[offset] + 1) * -1) } -Buffer.prototype.readInt16LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset] | (this[offset + 1] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } -Buffer.prototype.readInt16BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset + 1] | (this[offset] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } -Buffer.prototype.readInt32LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) } -Buffer.prototype.readInt32BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) } -Buffer.prototype.readFloatLE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, true, 23, 4) } -Buffer.prototype.readFloatBE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, false, 23, 4) } -Buffer.prototype.readDoubleLE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 8, this.length) +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, true, 52, 8) } -Buffer.prototype.readDoubleBE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 8, this.length) +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, false, 52, 8) } @@ -780,43 +901,42 @@ function checkInt (buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError('index out of range') } -Buffer.prototype.writeUIntLE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) var mul = 1 var i = 0 this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) - this[offset + i] = (value / mul) >>> 0 & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } return offset + byteLength } -Buffer.prototype.writeUIntBE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) var i = byteLength - 1 var mul = 1 this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) - this[offset + i] = (value / mul) >>> 0 & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } return offset + byteLength } -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0xff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) this[offset] = value return offset + 1 @@ -830,27 +950,29 @@ function objectWriteUInt16 (buf, value, offset, littleEndian) { } } -Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0xffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = value this[offset + 1] = (value >>> 8) - } else objectWriteUInt16(this, value, offset, true) + } else { + objectWriteUInt16(this, value, offset, true) + } return offset + 2 } -Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0xffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) this[offset + 1] = value - } else objectWriteUInt16(this, value, offset, false) + } else { + objectWriteUInt16(this, value, offset, false) + } return offset + 2 } @@ -861,139 +983,140 @@ function objectWriteUInt32 (buf, value, offset, littleEndian) { } } -Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0xffffffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset + 3] = (value >>> 24) this[offset + 2] = (value >>> 16) this[offset + 1] = (value >>> 8) this[offset] = value - } else objectWriteUInt32(this, value, offset, true) + } else { + objectWriteUInt32(this, value, offset, true) + } return offset + 4 } -Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0xffffffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) this[offset + 3] = value - } else objectWriteUInt32(this, value, offset, false) + } else { + objectWriteUInt32(this, value, offset, false) + } return offset + 4 } -Buffer.prototype.writeIntLE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 + offset = offset | 0 if (!noAssert) { - checkInt(this, - value, - offset, - byteLength, - Math.pow(2, 8 * byteLength - 1) - 1, - -Math.pow(2, 8 * byteLength - 1)) + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) } var i = 0 var mul = 1 var sub = value < 0 ? 1 : 0 this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) + while (++i < byteLength && (mul *= 0x100)) { this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } return offset + byteLength } -Buffer.prototype.writeIntBE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 + offset = offset | 0 if (!noAssert) { - checkInt(this, - value, - offset, - byteLength, - Math.pow(2, 8 * byteLength - 1) - 1, - -Math.pow(2, 8 * byteLength - 1)) + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) } var i = byteLength - 1 var mul = 1 var sub = value < 0 ? 1 : 0 this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) + while (--i >= 0 && (mul *= 0x100)) { this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } return offset + byteLength } -Buffer.prototype.writeInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0x7f, -0x80) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) if (value < 0) value = 0xff + value + 1 this[offset] = value return offset + 1 } -Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0x7fff, -0x8000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = value this[offset + 1] = (value >>> 8) - } else objectWriteUInt16(this, value, offset, true) + } else { + objectWriteUInt16(this, value, offset, true) + } return offset + 2 } -Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0x7fff, -0x8000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) this[offset + 1] = value - } else objectWriteUInt16(this, value, offset, false) + } else { + objectWriteUInt16(this, value, offset, false) + } return offset + 2 } -Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = value this[offset + 1] = (value >>> 8) this[offset + 2] = (value >>> 16) this[offset + 3] = (value >>> 24) - } else objectWriteUInt32(this, value, offset, true) + } else { + objectWriteUInt32(this, value, offset, true) + } return offset + 4 } -Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (value < 0) value = 0xffffffff + value + 1 if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) this[offset + 3] = value - } else objectWriteUInt32(this, value, offset, false) + } else { + objectWriteUInt32(this, value, offset, false) + } return offset + 4 } @@ -1004,76 +1127,77 @@ function checkIEEE754 (buf, value, offset, ext, max, min) { } function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) + if (!noAssert) { checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } ieee754.write(buf, value, offset, littleEndian, 23, 4) return offset + 4 } -Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert) } -Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert) } function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) + if (!noAssert) { checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } ieee754.write(buf, value, offset, littleEndian, 52, 8) return offset + 8 } -Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert) } -Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert) } // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this - +Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (!start) start = 0 if (!end && end !== 0) end = this.length - if (target_start >= target.length) target_start = target.length - if (!target_start) target_start = 0 + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 if (end > 0 && end < start) end = start // Copy 0 bytes; we're done if (end === start) return 0 - if (target.length === 0 || source.length === 0) return 0 + if (target.length === 0 || this.length === 0) return 0 // Fatal error conditions - if (target_start < 0) + if (targetStart < 0) { throw new RangeError('targetStart out of bounds') - if (start < 0 || start >= source.length) throw new RangeError('sourceStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') if (end < 0) throw new RangeError('sourceEnd out of bounds') // Are we oob? - if (end > this.length) - end = this.length - if (target.length - target_start < end - start) - end = target.length - target_start + start + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } var len = end - start if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { for (var i = 0; i < len; i++) { - target[i + target_start] = this[i + start] + target[i + targetStart] = this[i + start] } } else { - target._set(this.subarray(start, start + len), target_start) + target._set(this.subarray(start, start + len), targetStart) } return len } // fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function (value, start, end) { +Buffer.prototype.fill = function fill (value, start, end) { if (!value) value = 0 if (!start) start = 0 if (!end) end = this.length @@ -1107,7 +1231,7 @@ Buffer.prototype.fill = function (value, start, end) { * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. * Added in Node 0.12. Only available in browsers that support ArrayBuffer. */ -Buffer.prototype.toArrayBuffer = function () { +Buffer.prototype.toArrayBuffer = function toArrayBuffer () { if (typeof Uint8Array !== 'undefined') { if (Buffer.TYPED_ARRAY_SUPPORT) { return (new Buffer(this)).buffer @@ -1131,12 +1255,11 @@ var BP = Buffer.prototype /** * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods */ -Buffer._augment = function (arr) { +Buffer._augment = function _augment (arr) { arr.constructor = Buffer arr._isBuffer = true - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get + // save reference to original Uint8Array set method before overwriting arr._set = arr.set // deprecated, will be removed in node 0.13+ @@ -1149,6 +1272,7 @@ Buffer._augment = function (arr) { arr.toJSON = BP.toJSON arr.equals = BP.equals arr.compare = BP.compare + arr.indexOf = BP.indexOf arr.copy = BP.copy arr.slice = BP.slice arr.readUIntLE = BP.readUIntLE @@ -1213,72 +1337,55 @@ function stringtrim (str) { return str.replace(/^\s+|\s+$/g, '') } -function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' -} - function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16) } -function utf8ToBytes(string, units) { - var codePoint, length = string.length - var leadSurrogate = null +function utf8ToBytes (string, units) { units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null var bytes = [] var i = 0 - for (; i 0xD7FF && codePoint < 0xE000) { - // last char was a lead if (leadSurrogate) { - // 2 leads in a row if (codePoint < 0xDC00) { if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) leadSurrogate = codePoint continue - } - - // valid surrogate pair - else { + } else { + // valid surrogate pair codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 leadSurrogate = null } - } - - // no lead yet - else { + } else { + // no lead yet - // unexpected trail if (codePoint > 0xDBFF) { + // unexpected trail if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue - } - - // unpaired lead - else if (i + 1 === length) { + } else if (i + 1 === length) { + // unpaired lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue - } - - // valid lead - else { + } else { + // valid lead leadSurrogate = codePoint continue } } - } - - // valid bmp char, but last char was a lead - else if (leadSurrogate) { + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) leadSurrogate = null } @@ -1287,32 +1394,28 @@ function utf8ToBytes(string, units) { if (codePoint < 0x80) { if ((units -= 1) < 0) break bytes.push(codePoint) - } - else if (codePoint < 0x800) { + } else if (codePoint < 0x800) { if ((units -= 2) < 0) break bytes.push( codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80 - ); - } - else if (codePoint < 0x10000) { + ) + } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break bytes.push( codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 - ); - } - else if (codePoint < 0x200000) { + ) + } else if (codePoint < 0x200000) { if ((units -= 4) < 0) break bytes.push( codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 - ); - } - else { + ) + } else { throw new Error('Invalid code point') } } @@ -1333,7 +1436,6 @@ function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] for (var i = 0; i < str.length; i++) { - if ((units -= 2) < 0) break c = str.charCodeAt(i) @@ -1350,11 +1452,9 @@ function base64ToBytes (str) { return base64.toByteArray(base64clean(str)) } -function blitBuffer (src, dst, offset, length, unitSize) { - if (unitSize) length -= length % unitSize; +function blitBuffer (src, dst, offset, length) { for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) - break + if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } return i @@ -1368,7 +1468,7 @@ function decodeUtf8Char (str) { } } -},{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(require,module,exports){ +},{"base64-js":5,"ieee754":6,"is-array":7}],5:[function(require,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; ;(function (exports) { @@ -1494,93 +1594,93 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; exports.fromByteArray = uint8ToBase64 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) -},{}],5:[function(require,module,exports){ -exports.read = function(buffer, offset, isLE, mLen, nBytes) { - var e, m, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - nBits = -7, - i = isLE ? (nBytes - 1) : 0, - d = isLE ? -1 : 1, - s = buffer[offset + i]; - - i += d; - - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); - nBits += mLen; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); +},{}],6:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { - e = 1 - eBias; + e = 1 - eBias } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); + return m ? NaN : ((s ? -1 : 1) * Infinity) } else { - m = m + Math.pow(2, mLen); - e = e - eBias; + m = m + Math.pow(2, mLen) + e = e - eBias } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); -}; + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} -exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), - i = isLE ? 0 : (nBytes - 1), - d = isLE ? 1 : -1, - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - value = Math.abs(value); + value = Math.abs(value) if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; + m = isNaN(value) ? 1 : 0 + e = eMax } else { - e = Math.floor(Math.log(value) / Math.LN2); + e = Math.floor(Math.log(value) / Math.LN2) if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; + e-- + c *= 2 } if (e + eBias >= 1) { - value += rt / c; + value += rt / c } else { - value += rt * Math.pow(2, 1 - eBias); + value += rt * Math.pow(2, 1 - eBias) } if (value * c >= 2) { - e++; - c /= 2; + e++ + c /= 2 } if (e + eBias >= eMax) { - m = 0; - e = eMax; + m = 0 + e = eMax } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 } } - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - buffer[offset + i - d] |= s * 128; -}; + buffer[offset + i - d] |= s * 128 +} -},{}],6:[function(require,module,exports){ +},{}],7:[function(require,module,exports){ /** * isArray @@ -1615,7 +1715,7 @@ module.exports = isArray || function (val) { return !! val && '[object Array]' == str.call(val); }; -},{}],7:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -1918,7 +2018,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],8:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ var http = module.exports; var EventEmitter = require('events').EventEmitter; var Request = require('./lib/request'); @@ -2064,7 +2164,7 @@ http.STATUS_CODES = { 510 : 'Not Extended', // RFC 2774 511 : 'Network Authentication Required' // RFC 6585 }; -},{"./lib/request":9,"events":7,"url":33}],9:[function(require,module,exports){ +},{"./lib/request":10,"events":8,"url":34}],10:[function(require,module,exports){ var Stream = require('stream'); var Response = require('./response'); var Base64 = require('Base64'); @@ -2275,7 +2375,7 @@ var isXHR2Compatible = function (obj) { if (typeof FormData !== 'undefined' && obj instanceof FormData) return true; }; -},{"./response":10,"Base64":11,"inherits":13,"stream":31}],10:[function(require,module,exports){ +},{"./response":11,"Base64":12,"inherits":14,"stream":32}],11:[function(require,module,exports){ var Stream = require('stream'); var util = require('util'); @@ -2397,7 +2497,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{"stream":31,"util":35}],11:[function(require,module,exports){ +},{"stream":32,"util":36}],12:[function(require,module,exports){ ;(function () { var object = typeof exports != 'undefined' ? exports : this; // #8: web workers @@ -2459,7 +2559,7 @@ var isArray = Array.isArray || function (xs) { }()); -},{}],12:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ var http = require('http'); var https = module.exports; @@ -2474,7 +2574,7 @@ https.request = function (params, cb) { return http.request.call(this, params, cb); } -},{"http":8}],13:[function(require,module,exports){ +},{"http":9}],14:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -2499,12 +2599,12 @@ if (typeof Object.create === 'function') { } } -},{}],14:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ module.exports = Array.isArray || function (arr) { return Object.prototype.toString.call(arr) == '[object Array]'; }; -},{}],15:[function(require,module,exports){ +},{}],16:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -2592,7 +2692,7 @@ process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; -},{}],16:[function(require,module,exports){ +},{}],17:[function(require,module,exports){ (function (global){ /*! http://mths.be/punycode v1.2.4 by @mathias */ ;(function(root) { @@ -3103,7 +3203,7 @@ process.chdir = function (dir) { }(this)); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],17:[function(require,module,exports){ +},{}],18:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -3189,7 +3289,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],18:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -3276,16 +3376,16 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],19:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":17,"./encode":18}],20:[function(require,module,exports){ +},{"./decode":18,"./encode":19}],21:[function(require,module,exports){ module.exports = require("./lib/_stream_duplex.js") -},{"./lib/_stream_duplex.js":21}],21:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":22}],22:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -3378,7 +3478,7 @@ function forEach (xs, f) { } }).call(this,require('_process')) -},{"./_stream_readable":23,"./_stream_writable":25,"_process":15,"core-util-is":26,"inherits":13}],22:[function(require,module,exports){ +},{"./_stream_readable":24,"./_stream_writable":26,"_process":16,"core-util-is":27,"inherits":14}],23:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -3426,7 +3526,7 @@ PassThrough.prototype._transform = function(chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":24,"core-util-is":26,"inherits":13}],23:[function(require,module,exports){ +},{"./_stream_transform":25,"core-util-is":27,"inherits":14}],24:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -3479,15 +3579,29 @@ util.inherits = require('inherits'); var StringDecoder; + +/**/ +var debug = require('util'); +if (debug && debug.debuglog) { + debug = debug.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + + util.inherits(Readable, Stream); function ReadableState(options, stream) { + var Duplex = require('./_stream_duplex'); + options = options || {}; // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" var hwm = options.highWaterMark; - this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; + var defaultHwm = options.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; // cast to ints. this.highWaterMark = ~~this.highWaterMark; @@ -3496,19 +3610,13 @@ function ReadableState(options, stream) { this.length = 0; this.pipes = null; this.pipesCount = 0; - this.flowing = false; + this.flowing = null; this.ended = false; this.endEmitted = false; this.reading = false; - // In streams that never have any data, and do push(null) right away, - // the consumer can miss the 'end' event if they do some I/O before - // consuming the stream. So, we don't emit('end') until some reading - // happens. - this.calledRead = false; - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, becuase any + // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. this.sync = true; @@ -3524,6 +3632,9 @@ function ReadableState(options, stream) { // make all the buffer merging and length checks go away this.objectMode = !!options.objectMode; + if (stream instanceof Duplex) + this.objectMode = this.objectMode || !!options.readableObjectMode; + // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. @@ -3550,6 +3661,8 @@ function ReadableState(options, stream) { } function Readable(options) { + var Duplex = require('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); @@ -3568,7 +3681,7 @@ function Readable(options) { Readable.prototype.push = function(chunk, encoding) { var state = this._readableState; - if (typeof chunk === 'string' && !state.objectMode) { + if (util.isString(chunk) && !state.objectMode) { encoding = encoding || state.defaultEncoding; if (encoding !== state.encoding) { chunk = new Buffer(chunk, encoding); @@ -3589,7 +3702,7 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { var er = chunkInvalid(state, chunk); if (er) { stream.emit('error', er); - } else if (chunk === null || chunk === undefined) { + } else if (util.isNullOrUndefined(chunk)) { state.reading = false; if (!state.ended) onEofChunk(stream, state); @@ -3604,17 +3717,24 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { if (state.decoder && !addToFront && !encoding) chunk = state.decoder.write(chunk); - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) { - state.buffer.unshift(chunk); - } else { + if (!addToFront) state.reading = false; - state.buffer.push(chunk); - } - if (state.needReadable) - emitReadable(stream); + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) + state.buffer.unshift(chunk); + else + state.buffer.push(chunk); + + if (state.needReadable) + emitReadable(stream); + } maybeReadMore(stream, state); } @@ -3647,6 +3767,7 @@ Readable.prototype.setEncoding = function(enc) { StringDecoder = require('string_decoder/').StringDecoder; this._readableState.decoder = new StringDecoder(enc); this._readableState.encoding = enc; + return this; }; // Don't raise the hwm > 128MB @@ -3670,7 +3791,7 @@ function howMuchToRead(n, state) { if (state.objectMode) return n === 0 ? 0 : 1; - if (n === null || isNaN(n)) { + if (isNaN(n) || util.isNull(n)) { // only flow one buffer at a time if (state.flowing && state.buffer.length) return state.buffer[0].length; @@ -3702,12 +3823,11 @@ function howMuchToRead(n, state) { // you can override either this method, or the async _read(n) below. Readable.prototype.read = function(n) { + debug('read', n); var state = this._readableState; - state.calledRead = true; var nOrig = n; - var ret; - if (typeof n !== 'number' || n > 0) + if (!util.isNumber(n) || n > 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we @@ -3716,7 +3836,11 @@ Readable.prototype.read = function(n) { if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - emitReadable(this); + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) + endReadable(this); + else + emitReadable(this); return null; } @@ -3724,28 +3848,9 @@ Readable.prototype.read = function(n) { // if we've ended, and we're now clear, then finish it up. if (n === 0 && state.ended) { - ret = null; - - // In cases where the decoder did not receive enough data - // to produce a full chunk, then immediately received an - // EOF, state.buffer will contain [, ]. - // howMuchToRead will see this and coerce the amount to - // read to zero (because it's looking at the length of the - // first in state.buffer), and we'll end up here. - // - // This can only happen via state.decoder -- no other venue - // exists for pushing a zero-length chunk into state.buffer - // and triggering this behavior. In this case, we return our - // remaining data and end the stream, if appropriate. - if (state.length > 0 && state.decoder) { - ret = fromList(n, state); - state.length -= ret.length; - } - if (state.length === 0) endReadable(this); - - return ret; + return null; } // All the actual chunk generation logic needs to be @@ -3772,17 +3877,23 @@ Readable.prototype.read = function(n) { // if we need a readable event, then we need to do some reading. var doRead = state.needReadable; + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some - if (state.length - n <= state.highWaterMark) + if (state.length === 0 || state.length - n < state.highWaterMark) { doRead = true; + debug('length less than watermark', doRead); + } // however, if we've ended, then there's no point, and if we're already // reading, then it's unnecessary. - if (state.ended || state.reading) + if (state.ended || state.reading) { doRead = false; + debug('reading or ended', doRead); + } if (doRead) { + debug('do read'); state.reading = true; state.sync = true; // if the length is currently zero, then we *need* a readable event. @@ -3793,18 +3904,18 @@ Readable.prototype.read = function(n) { state.sync = false; } - // If _read called its callback synchronously, then `reading` - // will be false, and we need to re-evaluate how much data we - // can return to the user. + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. if (doRead && !state.reading) n = howMuchToRead(nOrig, state); + var ret; if (n > 0) ret = fromList(n, state); else ret = null; - if (ret === null) { + if (util.isNull(ret)) { state.needReadable = true; n = 0; } @@ -3816,21 +3927,21 @@ Readable.prototype.read = function(n) { if (state.length === 0 && !state.ended) state.needReadable = true; - // If we happened to read() exactly the remaining amount in the - // buffer, and the EOF has been seen at this point, then make sure - // that we emit 'end' on the very next tick. - if (state.ended && !state.endEmitted && state.length === 0) + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended && state.length === 0) endReadable(this); + if (!util.isNull(ret)) + this.emit('data', ret); + return ret; }; function chunkInvalid(state, chunk) { var er = null; - if (!Buffer.isBuffer(chunk) && - 'string' !== typeof chunk && - chunk !== null && - chunk !== undefined && + if (!util.isBuffer(chunk) && + !util.isString(chunk) && + !util.isNullOrUndefined(chunk) && !state.objectMode) { er = new TypeError('Invalid non-string/buffer chunk'); } @@ -3848,12 +3959,8 @@ function onEofChunk(stream, state) { } state.ended = true; - // if we've ended and we have some data left, then emit - // 'readable' now to make sure it gets picked up. - if (state.length > 0) - emitReadable(stream); - else - endReadable(stream); + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); } // Don't emit readable right away in sync mode, because this can trigger @@ -3862,20 +3969,22 @@ function onEofChunk(stream, state) { function emitReadable(stream) { var state = stream._readableState; state.needReadable = false; - if (state.emittedReadable) - return; - - state.emittedReadable = true; - if (state.sync) - process.nextTick(function() { + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) + process.nextTick(function() { + emitReadable_(stream); + }); + else emitReadable_(stream); - }); - else - emitReadable_(stream); + } } function emitReadable_(stream) { + debug('emit readable'); stream.emit('readable'); + flow(stream); } @@ -3898,6 +4007,7 @@ function maybeReadMore_(stream, state) { var len = state.length; while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); stream.read(0); if (len === state.length) // didn't get any data, stop spinning. @@ -3932,6 +4042,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { break; } state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && @@ -3945,11 +4056,14 @@ Readable.prototype.pipe = function(dest, pipeOpts) { dest.on('unpipe', onunpipe); function onunpipe(readable) { - if (readable !== src) return; - cleanup(); + debug('onunpipe'); + if (readable === src) { + cleanup(); + } } function onend() { + debug('onend'); dest.end(); } @@ -3961,6 +4075,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { dest.on('drain', ondrain); function cleanup() { + debug('cleanup'); // cleanup event handlers once the pipe is broken dest.removeListener('close', onclose); dest.removeListener('finish', onfinish); @@ -3969,19 +4084,34 @@ Readable.prototype.pipe = function(dest, pipeOpts) { dest.removeListener('unpipe', onunpipe); src.removeListener('end', onend); src.removeListener('end', cleanup); + src.removeListener('data', ondata); // if the reader is waiting for a drain event from this // specific writer, then it would cause it to never start // flowing again. // So, if this is awaiting a drain, then we just call it now. // If we don't know, then assume that we are waiting for one. - if (!dest._writableState || dest._writableState.needDrain) + if (state.awaitDrain && + (!dest._writableState || dest._writableState.needDrain)) ondrain(); } + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + if (false === ret) { + debug('false write response, pause', + src._readableState.awaitDrain); + src._readableState.awaitDrain++; + src.pause(); + } + } + // if the dest has an error, then stop piping into it. // however, don't suppress the throwing behavior for this. function onerror(er) { + debug('onerror', er); unpipe(); dest.removeListener('error', onerror); if (EE.listenerCount(dest, 'error') === 0) @@ -4005,12 +4135,14 @@ Readable.prototype.pipe = function(dest, pipeOpts) { } dest.once('close', onclose); function onfinish() { + debug('onfinish'); dest.removeListener('close', onclose); unpipe(); } dest.once('finish', onfinish); function unpipe() { + debug('unpipe'); src.unpipe(dest); } @@ -4019,16 +4151,8 @@ Readable.prototype.pipe = function(dest, pipeOpts) { // start the flow if it hasn't been started already. if (!state.flowing) { - // the handler that waits for readable events after all - // the data gets sucked out in flow. - // This would be easier to follow with a .once() handler - // in flow(), but that is too slow. - this.on('readable', pipeOnReadable); - - state.flowing = true; - process.nextTick(function() { - flow(src); - }); + debug('pipe resume'); + src.resume(); } return dest; @@ -4036,63 +4160,15 @@ Readable.prototype.pipe = function(dest, pipeOpts) { function pipeOnDrain(src) { return function() { - var dest = this; var state = src._readableState; - state.awaitDrain--; - if (state.awaitDrain === 0) + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) + state.awaitDrain--; + if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { + state.flowing = true; flow(src); - }; -} - -function flow(src) { - var state = src._readableState; - var chunk; - state.awaitDrain = 0; - - function write(dest, i, list) { - var written = dest.write(chunk); - if (false === written) { - state.awaitDrain++; } - } - - while (state.pipesCount && null !== (chunk = src.read())) { - - if (state.pipesCount === 1) - write(state.pipes, 0, null); - else - forEach(state.pipes, write); - - src.emit('data', chunk); - - // if anyone needs a drain, then we have to wait for that. - if (state.awaitDrain > 0) - return; - } - - // if every destination was unpiped, either before entering this - // function, or in the while loop, then stop flowing. - // - // NB: This is a pretty rare edge case. - if (state.pipesCount === 0) { - state.flowing = false; - - // if there were data event listeners added, then switch to old mode. - if (EE.listenerCount(src, 'data') > 0) - emitDataEvents(src); - return; - } - - // at this point, no one needed a drain, so we just ran out of data - // on the next readable event, start it over again. - state.ranOut = true; -} - -function pipeOnReadable() { - if (this._readableState.ranOut) { - this._readableState.ranOut = false; - flow(this); - } + }; } @@ -4115,7 +4191,6 @@ Readable.prototype.unpipe = function(dest) { // got a match. state.pipes = null; state.pipesCount = 0; - this.removeListener('readable', pipeOnReadable); state.flowing = false; if (dest) dest.emit('unpipe', this); @@ -4130,7 +4205,6 @@ Readable.prototype.unpipe = function(dest) { var len = state.pipesCount; state.pipes = null; state.pipesCount = 0; - this.removeListener('readable', pipeOnReadable); state.flowing = false; for (var i = 0; i < len; i++) @@ -4158,8 +4232,11 @@ Readable.prototype.unpipe = function(dest) { Readable.prototype.on = function(ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); - if (ev === 'data' && !this._readableState.flowing) - emitDataEvents(this); + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } if (ev === 'readable' && this.readable) { var state = this._readableState; @@ -4168,7 +4245,11 @@ Readable.prototype.on = function(ev, fn) { state.emittedReadable = false; state.needReadable = true; if (!state.reading) { - this.read(0); + var self = this; + process.nextTick(function() { + debug('readable nexttick read 0'); + self.read(0); + }); } else if (state.length) { emitReadable(this, state); } @@ -4182,63 +4263,54 @@ Readable.prototype.addListener = Readable.prototype.on; // pause() and resume() are remnants of the legacy readable stream API // If the user uses them, then switch into old mode. Readable.prototype.resume = function() { - emitDataEvents(this); - this.read(0); - this.emit('resume'); + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + if (!state.reading) { + debug('resume read 0'); + this.read(0); + } + resume(this, state); + } + return this; }; +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(function() { + resume_(stream, state); + }); + } +} + +function resume_(stream, state) { + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) + stream.read(0); +} + Readable.prototype.pause = function() { - emitDataEvents(this, true); - this.emit('pause'); + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; }; -function emitDataEvents(stream, startPaused) { +function flow(stream) { var state = stream._readableState; - + debug('flow', state.flowing); if (state.flowing) { - // https://github.com/isaacs/readable-stream/issues/16 - throw new Error('Cannot switch to old mode now.'); + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); } - - var paused = startPaused || false; - var readable = false; - - // convert to an old-style stream. - stream.readable = true; - stream.pipe = Stream.prototype.pipe; - stream.on = stream.addListener = Stream.prototype.on; - - stream.on('readable', function() { - readable = true; - - var c; - while (!paused && (null !== (c = stream.read()))) - stream.emit('data', c); - - if (c === null) { - readable = false; - stream._readableState.needReadable = true; - } - }); - - stream.pause = function() { - paused = true; - this.emit('pause'); - }; - - stream.resume = function() { - paused = false; - if (readable) - process.nextTick(function() { - stream.emit('readable'); - }); - else - this.read(0); - this.emit('resume'); - }; - - // now make it start, just in case it hadn't already. - stream.emit('readable'); } // wrap an old-style stream as the async data source. @@ -4250,6 +4322,7 @@ Readable.prototype.wrap = function(stream) { var self = this; stream.on('end', function() { + debug('wrapped end'); if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) @@ -4260,14 +4333,10 @@ Readable.prototype.wrap = function(stream) { }); stream.on('data', function(chunk) { + debug('wrapped data'); if (state.decoder) chunk = state.decoder.write(chunk); - - // don't skip over falsy values in objectMode - //if (state.objectMode && util.isNullOrUndefined(chunk)) - if (state.objectMode && (chunk === null || chunk === undefined)) - return; - else if (!state.objectMode && (!chunk || !chunk.length)) + if (!chunk || !state.objectMode && !chunk.length) return; var ret = self.push(chunk); @@ -4280,8 +4349,7 @@ Readable.prototype.wrap = function(stream) { // proxy all the other methods. // important when wrapping filters and duplexes. for (var i in stream) { - if (typeof stream[i] === 'function' && - typeof this[i] === 'undefined') { + if (util.isFunction(stream[i]) && util.isUndefined(this[i])) { this[i] = function(method) { return function() { return stream[method].apply(stream, arguments); }}(i); @@ -4297,6 +4365,7 @@ Readable.prototype.wrap = function(stream) { // when we try to consume some more bytes, simply unpause the // underlying stream. self._read = function(n) { + debug('wrapped _read', n); if (paused) { paused = false; stream.resume(); @@ -4385,7 +4454,7 @@ function endReadable(stream) { if (state.length > 0) throw new Error('endReadable called on non-empty stream'); - if (!state.endEmitted && state.calledRead) { + if (!state.endEmitted) { state.ended = true; process.nextTick(function() { // Check that we didn't get one last unshift. @@ -4412,7 +4481,7 @@ function indexOf (xs, x) { } }).call(this,require('_process')) -},{"_process":15,"buffer":3,"core-util-is":26,"events":7,"inherits":13,"isarray":14,"stream":31,"string_decoder/":32}],24:[function(require,module,exports){ +},{"./_stream_duplex":22,"_process":16,"buffer":4,"core-util-is":27,"events":8,"inherits":14,"isarray":15,"stream":32,"string_decoder/":33,"util":3}],25:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -4512,7 +4581,7 @@ function afterTransform(stream, er, data) { ts.writechunk = null; ts.writecb = null; - if (data !== null && data !== undefined) + if (!util.isNullOrUndefined(data)) stream.push(data); if (cb) @@ -4532,7 +4601,7 @@ function Transform(options) { Duplex.call(this, options); - var ts = this._transformState = new TransformState(options, this); + this._transformState = new TransformState(options, this); // when the writable side finishes, then flush out anything remaining. var stream = this; @@ -4545,8 +4614,8 @@ function Transform(options) { // sync guard flag. this._readableState.sync = false; - this.once('finish', function() { - if ('function' === typeof this._flush) + this.once('prefinish', function() { + if (util.isFunction(this._flush)) this._flush(function(er) { done(stream, er); }); @@ -4594,7 +4663,7 @@ Transform.prototype._write = function(chunk, encoding, cb) { Transform.prototype._read = function(n) { var ts = this._transformState; - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) { ts.transforming = true; this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); } else { @@ -4612,7 +4681,6 @@ function done(stream, er) { // if there's nothing in the write buffer, then that means // that nothing more will ever be provided var ws = stream._writableState; - var rs = stream._readableState; var ts = stream._transformState; if (ws.length) @@ -4624,7 +4692,7 @@ function done(stream, er) { return stream.push(null); } -},{"./_stream_duplex":21,"core-util-is":26,"inherits":13}],25:[function(require,module,exports){ +},{"./_stream_duplex":22,"core-util-is":27,"inherits":14}],26:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -4676,18 +4744,24 @@ function WriteReq(chunk, encoding, cb) { } function WritableState(options, stream) { + var Duplex = require('./_stream_duplex'); + options = options || {}; // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() var hwm = options.highWaterMark; - this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; + var defaultHwm = options.objectMode ? 16 : 16 * 1024; + this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; // object stream flag to indicate whether or not this stream // contains buffers or objects. this.objectMode = !!options.objectMode; + if (stream instanceof Duplex) + this.objectMode = this.objectMode || !!options.writableObjectMode; + // cast to ints. this.highWaterMark = ~~this.highWaterMark; @@ -4718,8 +4792,11 @@ function WritableState(options, stream) { // a flag to see when we're in the middle of a write. this.writing = false; + // when true all writes will be buffered until .uncork() call + this.corked = 0; + // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, becuase any + // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. this.sync = true; @@ -4742,6 +4819,14 @@ function WritableState(options, stream) { this.buffer = []; + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + // True if the error was already emitted and should not be thrown again this.errorEmitted = false; } @@ -4784,10 +4869,9 @@ function writeAfterEnd(stream, state, cb) { // how many bytes or characters. function validChunk(stream, state, chunk, cb) { var valid = true; - if (!Buffer.isBuffer(chunk) && - 'string' !== typeof chunk && - chunk !== null && - chunk !== undefined && + if (!util.isBuffer(chunk) && + !util.isString(chunk) && + !util.isNullOrUndefined(chunk) && !state.objectMode) { var er = new TypeError('Invalid non-string/buffer chunk'); stream.emit('error', er); @@ -4803,31 +4887,54 @@ Writable.prototype.write = function(chunk, encoding, cb) { var state = this._writableState; var ret = false; - if (typeof encoding === 'function') { + if (util.isFunction(encoding)) { cb = encoding; encoding = null; } - if (Buffer.isBuffer(chunk)) + if (util.isBuffer(chunk)) encoding = 'buffer'; else if (!encoding) encoding = state.defaultEncoding; - if (typeof cb !== 'function') + if (!util.isFunction(cb)) cb = function() {}; if (state.ended) writeAfterEnd(this, state, cb); - else if (validChunk(this, state, chunk, cb)) + else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; ret = writeOrBuffer(this, state, chunk, encoding, cb); + } return ret; }; +Writable.prototype.cork = function() { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function() { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && + !state.corked && + !state.finished && + !state.bufferProcessing && + state.buffer.length) + clearBuffer(this, state); + } +}; + function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && - typeof chunk === 'string') { + util.isString(chunk)) { chunk = new Buffer(chunk, encoding); } return chunk; @@ -4838,7 +4945,7 @@ function decodeChunk(state, chunk, encoding) { // If we return false, then we need a drain event, so set that flag. function writeOrBuffer(stream, state, chunk, encoding, cb) { chunk = decodeChunk(state, chunk, encoding); - if (Buffer.isBuffer(chunk)) + if (util.isBuffer(chunk)) encoding = 'buffer'; var len = state.objectMode ? 1 : chunk.length; @@ -4849,30 +4956,36 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) { if (!ret) state.needDrain = true; - if (state.writing) + if (state.writing || state.corked) state.buffer.push(new WriteReq(chunk, encoding, cb)); else - doWrite(stream, state, len, chunk, encoding, cb); + doWrite(stream, state, false, len, chunk, encoding, cb); return ret; } -function doWrite(stream, state, len, chunk, encoding, cb) { +function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writelen = len; state.writecb = cb; state.writing = true; state.sync = true; - stream._write(chunk, encoding, state.onwrite); + if (writev) + stream._writev(chunk, state.onwrite); + else + stream._write(chunk, encoding, state.onwrite); state.sync = false; } function onwriteError(stream, state, sync, er, cb) { if (sync) process.nextTick(function() { + state.pendingcb--; cb(er); }); - else + else { + state.pendingcb--; cb(er); + } stream._writableState.errorEmitted = true; stream.emit('error', er); @@ -4898,8 +5011,12 @@ function onwrite(stream, er) { // Check if we're actually ready to finish, but don't emit yet var finished = needFinish(stream, state); - if (!finished && !state.bufferProcessing && state.buffer.length) + if (!finished && + !state.corked && + !state.bufferProcessing && + state.buffer.length) { clearBuffer(stream, state); + } if (sync) { process.nextTick(function() { @@ -4914,9 +5031,9 @@ function onwrite(stream, er) { function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); + state.pendingcb--; cb(); - if (finished) - finishMaybe(stream, state); + finishMaybe(stream, state); } // Must force callback to be called on nextTick, so that we don't @@ -4934,51 +5051,82 @@ function onwriteDrain(stream, state) { function clearBuffer(stream, state) { state.bufferProcessing = true; - for (var c = 0; c < state.buffer.length; c++) { - var entry = state.buffer[c]; - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, len, chunk, encoding, cb); - - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - c++; - break; + if (stream._writev && state.buffer.length > 1) { + // Fast case, write everything using _writev() + var cbs = []; + for (var c = 0; c < state.buffer.length; c++) + cbs.push(state.buffer[c].callback); + + // count the one we are adding, as well. + // TODO(isaacs) clean this up + state.pendingcb++; + doWrite(stream, state, true, state.length, state.buffer, '', function(err) { + for (var i = 0; i < cbs.length; i++) { + state.pendingcb--; + cbs[i](err); + } + }); + + // Clear buffer + state.buffer = []; + } else { + // Slow case, write chunks one-by-one + for (var c = 0; c < state.buffer.length; c++) { + var entry = state.buffer[c]; + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + c++; + break; + } } + + if (c < state.buffer.length) + state.buffer = state.buffer.slice(c); + else + state.buffer.length = 0; } state.bufferProcessing = false; - if (c < state.buffer.length) - state.buffer = state.buffer.slice(c); - else - state.buffer.length = 0; } Writable.prototype._write = function(chunk, encoding, cb) { cb(new Error('not implemented')); + }; +Writable.prototype._writev = null; + Writable.prototype.end = function(chunk, encoding, cb) { var state = this._writableState; - if (typeof chunk === 'function') { + if (util.isFunction(chunk)) { cb = chunk; chunk = null; encoding = null; - } else if (typeof encoding === 'function') { + } else if (util.isFunction(encoding)) { cb = encoding; encoding = null; } - if (typeof chunk !== 'undefined' && chunk !== null) + if (!util.isNullOrUndefined(chunk)) this.write(chunk, encoding); + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + // ignore unnecessary end() calls. if (!state.ending && !state.finished) endWritable(this, state, cb); @@ -4992,11 +5140,22 @@ function needFinish(stream, state) { !state.writing); } +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + function finishMaybe(stream, state) { var need = needFinish(stream, state); if (need) { - state.finished = true; - stream.emit('finish'); + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else + prefinish(stream, state); } return need; } @@ -5014,7 +5173,7 @@ function endWritable(stream, state, cb) { } }).call(this,require('_process')) -},{"./_stream_duplex":21,"_process":15,"buffer":3,"core-util-is":26,"inherits":13,"stream":31}],26:[function(require,module,exports){ +},{"./_stream_duplex":22,"_process":16,"buffer":4,"core-util-is":27,"inherits":14,"stream":32}],27:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -5124,26 +5283,25 @@ function objectToString(o) { return Object.prototype.toString.call(o); } }).call(this,require("buffer").Buffer) -},{"buffer":3}],27:[function(require,module,exports){ +},{"buffer":4}],28:[function(require,module,exports){ module.exports = require("./lib/_stream_passthrough.js") -},{"./lib/_stream_passthrough.js":22}],28:[function(require,module,exports){ -var Stream = require('stream'); // hack to fix a circular dependency issue when used with browserify +},{"./lib/_stream_passthrough.js":23}],29:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); -exports.Stream = Stream; +exports.Stream = require('stream'); exports.Readable = exports; exports.Writable = require('./lib/_stream_writable.js'); exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":21,"./lib/_stream_passthrough.js":22,"./lib/_stream_readable.js":23,"./lib/_stream_transform.js":24,"./lib/_stream_writable.js":25,"stream":31}],29:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":22,"./lib/_stream_passthrough.js":23,"./lib/_stream_readable.js":24,"./lib/_stream_transform.js":25,"./lib/_stream_writable.js":26,"stream":32}],30:[function(require,module,exports){ module.exports = require("./lib/_stream_transform.js") -},{"./lib/_stream_transform.js":24}],30:[function(require,module,exports){ +},{"./lib/_stream_transform.js":25}],31:[function(require,module,exports){ module.exports = require("./lib/_stream_writable.js") -},{"./lib/_stream_writable.js":25}],31:[function(require,module,exports){ +},{"./lib/_stream_writable.js":26}],32:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -5272,7 +5430,7 @@ Stream.prototype.pipe = function(dest, options) { return dest; }; -},{"events":7,"inherits":13,"readable-stream/duplex.js":20,"readable-stream/passthrough.js":27,"readable-stream/readable.js":28,"readable-stream/transform.js":29,"readable-stream/writable.js":30}],32:[function(require,module,exports){ +},{"events":8,"inherits":14,"readable-stream/duplex.js":21,"readable-stream/passthrough.js":28,"readable-stream/readable.js":29,"readable-stream/transform.js":30,"readable-stream/writable.js":31}],33:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -5495,7 +5653,7 @@ function base64DetectIncompleteChar(buffer) { this.charLength = this.charReceived ? 3 : 0; } -},{"buffer":3}],33:[function(require,module,exports){ +},{"buffer":4}],34:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -6204,14 +6362,14 @@ function isNullOrUndefined(arg) { return arg == null; } -},{"punycode":16,"querystring":19}],34:[function(require,module,exports){ +},{"punycode":17,"querystring":20}],35:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],35:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -6801,7 +6959,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":34,"_process":15,"inherits":13}],36:[function(require,module,exports){ +},{"./support/isBuffer":35,"_process":16,"inherits":14}],37:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -6830,8 +6988,9 @@ var url = require('url'), /** * Creates new Api instance. * @param {Object} config An object with the following keys:
- * url {String} - Required. An url to Workfront server (for example: http://localhost:8080)
+ * url {String} - Required. A url to Workfront server (for example: http://localhost:8080)
* version {String} - Optional. Which version of api to use. At the moment of writing can be 1.0, 2.0, 3.0, 4.0. Pass 'unsupported' to use Workfront latest API (maybe unstable).
+ * alwaysUseGet {Boolean} - Optional. Defaults to false. Will cause the api to make every request as a GET with params in the query string and add method=DESIRED_METHOD_TYPE in the query string. Some Workfront urls will have issues with PUT and DELETE calls if this value is false.
* secureProtocol {String} - Optional. Used only in https. The SSL method to use, e.g. TLSv1_method to force TLS version 1. The possible values depend on your installation of OpenSSL and are defined in the constant {@link http://www.openssl.org/docs/ssl/ssl.html#DEALING_WITH_PROTOCOL_METHODS|SSL_METHODS}. * @constructor * @memberOf Workfront @@ -6848,7 +7007,9 @@ function Api(config) { host: parsed.hostname, port: parsed.port || (isHttps ? 443 : 80), withCredentials: false, - headers: {} + headers: {}, + //=== true to make undefined result in false + alwaysUseGet : config.alwaysUseGet === true }; // These params will be sent with each request @@ -6898,7 +7059,7 @@ require('./plugins/metadata')(Api); require('./plugins/apiKey')(Api); module.exports = Api; -},{"./plugins/apiKey":40,"./plugins/copy":41,"./plugins/count":42,"./plugins/create":43,"./plugins/edit":44,"./plugins/execute":45,"./plugins/get":46,"./plugins/login":47,"./plugins/logout":48,"./plugins/metadata":49,"./plugins/namedQuery":50,"./plugins/remove":51,"./plugins/report":52,"./plugins/request":53,"./plugins/search":54,"./plugins/upload":55,"http":8,"https":12,"url":33}],37:[function(require,module,exports){ +},{"./plugins/apiKey":41,"./plugins/copy":42,"./plugins/count":43,"./plugins/create":44,"./plugins/edit":45,"./plugins/execute":46,"./plugins/get":47,"./plugins/login":48,"./plugins/logout":49,"./plugins/metadata":50,"./plugins/namedQuery":51,"./plugins/remove":52,"./plugins/report":53,"./plugins/request":54,"./plugins/search":55,"./plugins/upload":56,"http":9,"https":13,"url":34}],38:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7430,7 +7591,7 @@ var ApiConstants = { module.exports = ApiConstants; -},{}],38:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7494,7 +7655,7 @@ module.exports = { _instance = undefined; } }; -},{"./Api":36}],39:[function(require,module,exports){ +},{"./Api":37}],40:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7524,7 +7685,7 @@ module.exports = { }; -},{}],40:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7591,7 +7752,7 @@ module.exports = function(Api) { }); } }; -},{}],41:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7632,7 +7793,7 @@ module.exports = function(Api) { return this.request(objCode, params, fields, Api.Methods.POST); }; }; -},{}],42:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7670,7 +7831,7 @@ module.exports = function(Api) { }); }; }; -},{}],43:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7704,7 +7865,7 @@ module.exports = function(Api) { return this.request(objCode, params, fields, Api.Methods.POST); }; }; -},{}],44:[function(require,module,exports){ +},{}],45:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7741,7 +7902,7 @@ module.exports = function(Api) { return this.request(objCode + '/' + objID, params, fields, Api.Methods.PUT); }; }; -},{}],45:[function(require,module,exports){ +},{}],46:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7784,7 +7945,7 @@ module.exports = function(Api) { return this.request(endPoint, actionArgs, null, Api.Methods.PUT); }; }; -},{}],46:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7836,7 +7997,7 @@ module.exports = function(Api) { return this.request(endPoint, params, fields, Api.Methods.GET); }; }; -},{"./../ApiConstants":37}],47:[function(require,module,exports){ +},{"./../ApiConstants":38}],48:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7877,7 +8038,7 @@ module.exports = function(Api) { }); }; }; -},{}],48:[function(require,module,exports){ +},{}],49:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7918,7 +8079,7 @@ module.exports = function(Api) { }); }; }; -},{}],49:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7953,7 +8114,7 @@ module.exports = function(Api) { return this.request(path, null, null, Api.Methods.GET); }; }; -},{}],50:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -7988,7 +8149,7 @@ module.exports = function(Api) { return this.request(objCode + '/' + query, queryArgs, fields, Api.Methods.GET); }; }; -},{}],51:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -8032,7 +8193,7 @@ module.exports = function(Api) { }); }; }; -},{}],52:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -8064,7 +8225,7 @@ module.exports = function(Api) { return this.request(objCode + '/report', query, null, Api.Methods.GET); }; }; -},{}],53:[function(require,module,exports){ +},{}],54:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -8101,11 +8262,17 @@ module.exports = function(Api) { } params = params || {}; - util._extend(params, this.httpParams); + var options = {}, + alwaysUseGet = this.httpOptions.alwaysUseGet; + + util._extend(options, this.httpOptions); + if (alwaysUseGet) { + params.method = method; + } else { + options.method = method; + } - var options = {}; util._extend(options, this.httpOptions); - options.method = method; if (path.indexOf('/') === 0) { options.path = this.httpOptions.path + path; } @@ -8119,7 +8286,7 @@ module.exports = function(Api) { params = queryString.stringify(params); if (params) { - if (requestHasData(options.method)) { + if (!alwaysUseGet && requestHasData(options.method)) { options.headers['Content-Type'] = 'application/x-www-form-urlencoded'; options.headers['Content-Length'] = params.length; } @@ -8156,7 +8323,7 @@ module.exports = function(Api) { }); }); request.on('error', reject); - if (params && requestHasData(options.method)) { + if (!alwaysUseGet && params && requestHasData(options.method)) { request.write(params); } request.end(); @@ -8165,7 +8332,7 @@ module.exports = function(Api) { }; -},{"querystring":19,"util":35}],54:[function(require,module,exports){ +},{"querystring":20,"util":36}],55:[function(require,module,exports){ /** * Copyright 2015 Workfront * @@ -8199,7 +8366,7 @@ module.exports = function(Api) { return this.request(objCode + '/search', query, fields, Api.Methods.GET); }; }; -},{}],55:[function(require,module,exports){ +},{}],56:[function(require,module,exports){ /** * Copyright 2015 Workfront * diff --git a/dist/workfront.min.js b/dist/workfront.min.js index 68cad97c..11d20bec 100644 --- a/dist/workfront.min.js +++ b/dist/workfront.min.js @@ -1,3 +1,4 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Workfront=t()}}(function(){var t;return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var c=r[s]={exports:{}};t[s][0].call(c.exports,function(e){var r=t[s][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s0?t>>>0:0;else if("string"===o)i=n.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&N(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}if(i>P)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+P.toString(16)+" bytes");var s;n.TYPED_ARRAY_SUPPORT?s=n._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var a;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)s._set(t);else if(L(t))if(n.isBuffer(t))for(a=0;i>a;a++)s[a]=t.readUInt8(a);else for(a=0;i>a;a++)s[a]=(t[a]%256+256)%256;else if("string"===o)s.write(t,0,e);else if("number"===o&&!n.TYPED_ARRAY_SUPPORT&&!r)for(a=0;i>a;a++)s[a]=0;return i>0&&i<=n.poolSize&&(s.parent=k),s}function i(t,e,r){if(!(this instanceof i))return new i(t,e,r);var o=new n(t,e,r);return delete o.parent,o}function o(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function s(t,e,r,n){var i=U(I(e,t.length-r),t,r,n);return i}function a(t,e,r,n){var i=U(x(e),t,r,n);return i}function u(t,e,r,n){return a(t,e,r,n)}function h(t,e,r,n){var i=U(C(e),t,r,n);return i}function c(t,e,r,n){var i=U(O(e,t.length-r),t,r,n,2);return i}function f(t,e,r){return M.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function l(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=j(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+j(i)}function p(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function d(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function g(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=R(t[o]);return i}function v(t,e,r){for(var n=t.slice(e,r),i="",o=0;ot)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function m(t,e,r,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||s>e)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function w(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function b(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function E(t,e,r,n,i,o){if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function _(t,e,r,n,i){return i||E(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),B.write(t,e,r,n,23,4),r+4}function A(t,e,r,n,i){return i||E(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),B.write(t,e,r,n,52,8),r+8}function S(t){if(t=T(t).replace(q,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function T(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function L(t){return N(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function R(t){return 16>t?"0"+t.toString(16):t.toString(16)}function I(t,e){var r,n=t.length,i=null;e=e||1/0;for(var o=[],s=0;n>s;s++){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((e-=3)>-1&&o.push(239,191,189),i=null);if(128>r){if((e-=1)<0)break;o.push(r)}else if(2048>r){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function x(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function C(t){return M.toByteArray(S(t))}function U(t,e,r,n,i){i&&(n-=n%i);for(var o=0;n>o&&!(o+r>=e.length||o>=t.length);o++)e[o+r]=t[o];return o}function j(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var M=t("base64-js"),B=t("ieee754"),N=t("is-array");r.Buffer=n,r.SlowBuffer=i,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var P=1073741823,k={};n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,e){if(!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError("Arguments must be Buffers");for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);s>o&&t[o]===e[o];o++);return o!==s&&(r=t[o],i=e[o]),i>r?-1:r>i?1:0},n.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(t,e){if(!N(t))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===t.length)return new n(0);if(1===t.length)return t[0];var r;if(void 0===e)for(e=0,r=0;r>>1;break;case"utf8":case"utf-8":r=I(t).length;break;case"base64":r=C(t).length;break;default:r=t.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(t,e,r){var n=!1;if(e>>>=0,r=void 0===r||1/0===r?this.length:r>>>0,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return g(this,e,r);case"utf8":case"utf-8":return l(this,e,r);case"ascii":return p(this,e,r);case"binary":return d(this,e,r);case"base64":return f(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return 0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return n.compare(this,t)},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},n.prototype.write=function(t,e,r,n){if(isFinite(e))isFinite(r)||(n=r,r=void 0);else{var i=n;n=e,e=r,r=i}if(e=Number(e)||0,0>r||0>e||e>this.length)throw new RangeError("attempt to write outside buffer bounds");var f=this.length-e;r?(r=Number(r),r>f&&(r=f)):r=f,n=String(n||"utf8").toLowerCase();var l;switch(n){case"hex":l=o(this,t,e,r);break;case"utf8":case"utf-8":l=s(this,t,e,r);break;case"ascii":l=a(this,t,e,r);break;case"binary":l=u(this,t,e,r);break;case"base64":l=h(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=c(this,t,e,r);break;default:throw new TypeError("Unknown encoding: "+n)}return l},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var i;if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(t,e));else{var o=e-t;i=new n(o,void 0,!0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||y(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||y(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},n.prototype.readUInt8=function(t,e){return e||y(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||y(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||y(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return e||y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||y(t,e,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*e)),n},n.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||y(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},n.prototype.readInt8=function(t,e){return e||y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||y(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){e||y(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return e||y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return e||y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return e||y(t,4,this.length),B.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||y(t,4,this.length),B.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||y(t,8,this.length),B.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||y(t,8,this.length),B.read(this,t,!1,52,8)},n.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||m(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o>>0&255;return e+r},n.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||m(this,t,e,r,Math.pow(2,8*r),0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o>>>0&255;return e+r},n.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):w(this,t,e,!0),e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):w(this,t,e,!1),e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):b(this,t,e,!0),e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):b(this,t,e,!1),e+4},n.prototype.writeIntLE=function(t,e,r,n){t=+t,e>>>=0,n||m(this,t,e,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=0,o=1,s=0>t?1:0;for(this[e]=255&t;++i>0)-s&255;return e+r},n.prototype.writeIntBE=function(t,e,r,n){t=+t,e>>>=0,n||m(this,t,e,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=r-1,o=1,s=0>t?1:0;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=(t/o>>0)-s&255;return e+r},n.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):w(this,t,e,!0),e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):w(this,t,e,!1),e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):b(this,t,e,!0),e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||m(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):b(this,t,e,!1),e+4},n.prototype.writeFloatLE=function(t,e,r){return _(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return _(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return A(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return A(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,i){var o=this;if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===o.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=o.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-es||!n.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)t[a+e]=this[a+r];else t._set(this.subarray(r,r+s),e);return s},n.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=I(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var D=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=D.get,t.set=D.set,t.write=D.write,t.toString=D.toString,t.toLocaleString=D.toString,t.toJSON=D.toJSON,t.equals=D.equals,t.compare=D.compare,t.copy=D.copy,t.slice=D.slice,t.readUIntLE=D.readUIntLE,t.readUIntBE=D.readUIntBE,t.readUInt8=D.readUInt8,t.readUInt16LE=D.readUInt16LE,t.readUInt16BE=D.readUInt16BE,t.readUInt32LE=D.readUInt32LE,t.readUInt32BE=D.readUInt32BE,t.readIntLE=D.readIntLE,t.readIntBE=D.readIntBE,t.readInt8=D.readInt8,t.readInt16LE=D.readInt16LE,t.readInt16BE=D.readInt16BE,t.readInt32LE=D.readInt32LE,t.readInt32BE=D.readInt32BE,t.readFloatLE=D.readFloatLE,t.readFloatBE=D.readFloatBE,t.readDoubleLE=D.readDoubleLE,t.readDoubleBE=D.readDoubleBE,t.writeUInt8=D.writeUInt8,t.writeUIntLE=D.writeUIntLE,t.writeUIntBE=D.writeUIntBE,t.writeUInt16LE=D.writeUInt16LE,t.writeUInt16BE=D.writeUInt16BE,t.writeUInt32LE=D.writeUInt32LE,t.writeUInt32BE=D.writeUInt32BE,t.writeIntLE=D.writeIntLE,t.writeIntBE=D.writeIntBE,t.writeInt8=D.writeInt8,t.writeInt16LE=D.writeInt16LE,t.writeInt16BE=D.writeInt16BE,t.writeInt32LE=D.writeInt32LE,t.writeInt32BE=D.writeInt32BE,t.writeFloatLE=D.writeFloatLE,t.writeFloatBE=D.writeFloatBE,t.writeDoubleLE=D.writeDoubleLE,t.writeDoubleBE=D.writeDoubleBE,t.fill=D.fill,t.inspect=D.inspect,t.toArrayBuffer=D.toArrayBuffer,t};var q=/[^+\/0-9A-z\-]/g},{"base64-js":4,ieee754:5,"is-array":6}],4:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===f?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:c+26>e?e-c:h+26>e?e-h+26:void 0}function r(t){function r(t){h[f++]=t}var n,i,s,a,u,h;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=t.length;u="="===t.charAt(c-2)?2:"="===t.charAt(c-1)?1:0,h=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var f=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),h}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=r(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),h="a".charCodeAt(0),c="A".charCodeAt(0),f="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],5:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,c=-7,f=r?i-1:0,l=r?-1:1,p=t[e+f];for(f+=l,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+t[e+f],f+=l,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+f],f+=l,c-=8);if(0===o)o=1-h;else{if(o===u)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,c=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+f>=1?l/u:l*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,h-=8);t[r+p-d]|=128*g}},{}],6:[function(t,e){var r=Array.isArray,n=Object.prototype.toString;e.exports=r||function(t){return!!t&&"[object Array]"==n.call(t)}},{}],7:[function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(h=r.slice(),i=h.length,u=0;i>u;u++)h[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},{}],8:[function(t,e){var r=e.exports,n=(t("events").EventEmitter,t("./lib/request")),i=t("url");r.request=function(t,e){"string"==typeof t&&(t=i.parse(t)),t||(t={}),t.host||t.port||(t.port=parseInt(window.location.port,10)),!t.host&&t.hostname&&(t.host=t.hostname),t.protocol||(t.protocol=t.scheme?t.scheme+":":window.location.protocol),t.host||(t.host=window.location.hostname||window.location.host),/:/.test(t.host)&&(t.port||(t.port=t.host.split(":")[1]),t.host=t.host.split(":")[0]),t.port||(t.port="https:"==t.protocol?443:80);var r=new n(new o,t);return e&&r.on("response",e),r},r.get=function(t,e){t.method="GET";var n=r.request(t,e);return n.end(),n},r.Agent=function(){},r.Agent.defaultMaxSockets=4;var o=function(){if("undefined"==typeof window)throw new Error("no window object present");if(window.XMLHttpRequest)return window.XMLHttpRequest;if(window.ActiveXObject){for(var t=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"],e=0;ethis.offset&&(this.emit("data",e.slice(this.offset)),this.offset=e.length))};var a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{stream:31,util:35}],11:[function(t,e,r){!function(){function t(t){this.message=t}var e="undefined"!=typeof r?r:this,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=new Error,t.prototype.name="InvalidCharacterError",e.btoa||(e.btoa=function(e){for(var r,i,o=0,s=n,a="";e.charAt(0|o)||(s="=",o%1);a+=s.charAt(63&r>>8-o%1*8)){if(i=e.charCodeAt(o+=.75),i>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|i}return a}),e.atob||(e.atob=function(e){if(e=e.replace(/=+$/,""),e.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(r=o%4?64*r+i:i,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)i=n.indexOf(i);return a})}()},{}],12:[function(t,e){var r=t("http"),n=e.exports;for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);n.request=function(t,e){return t||(t={}),t.scheme="https",r.request.call(this,t,e)}},{http:8}],13:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],14:[function(t,e){e.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}},{}],15:[function(t,e){function r(){}var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.MutationObserver,r="undefined"!=typeof window&&window.postMessage&&window.addEventListener; -if(t)return function(t){return window.setImmediate(t)};var n=[];if(e){var i=document.createElement("div"),o=new MutationObserver(function(){var t=n.slice();n.length=0,t.forEach(function(t){t()})});return o.observe(i,{attributes:!0}),function(t){n.length||i.setAttribute("yes","no"),n.push(t)}}return r?(window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.on=r,n.addListener=r,n.once=r,n.off=r,n.removeListener=r,n.removeAllListeners=r,n.emit=r,n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],16:[function(e,r,n){(function(e){!function(i){function o(t){throw RangeError(M[t])}function s(t,e){for(var r=t.length;r--;)t[r]=e(t[r]);return t}function a(t,e){return s(t.split(j),e).join(".")}function u(t){for(var e,r,n=[],i=0,o=t.length;o>i;)e=t.charCodeAt(i++),e>=55296&&56319>=e&&o>i?(r=t.charCodeAt(i++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--)):n.push(e);return n}function h(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=P(t>>>10&1023|55296),t=56320|1023&t),e+=P(t)}).join("")}function c(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:A}function f(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function l(t,e,r){var n=0;for(t=r?N(t/R):t>>1,t+=N(t/e);t>B*T>>1;n+=A)t=N(t/B);return N(n+(B+1)*t/(t+L))}function p(t){var e,r,n,i,s,a,u,f,p,d,g=[],v=t.length,y=0,m=x,w=I;for(r=t.lastIndexOf(O),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&o("not-basic"),g.push(t.charCodeAt(n));for(i=r>0?r+1:0;v>i;){for(s=y,a=1,u=A;i>=v&&o("invalid-input"),f=c(t.charCodeAt(i++)),(f>=A||f>N((_-y)/a))&&o("overflow"),y+=f*a,p=w>=u?S:u>=w+T?T:u-w,!(p>f);u+=A)d=A-p,a>N(_/d)&&o("overflow"),a*=d;e=g.length+1,w=l(y-s,e,0==s),N(y/e)>_-m&&o("overflow"),m+=N(y/e),y%=e,g.splice(y++,0,m)}return h(g)}function d(t){var e,r,n,i,s,a,h,c,p,d,g,v,y,m,w,b=[];for(t=u(t),v=t.length,e=x,r=0,s=I,a=0;v>a;++a)g=t[a],128>g&&b.push(P(g));for(n=i=b.length,i&&b.push(O);v>n;){for(h=_,a=0;v>a;++a)g=t[a],g>=e&&h>g&&(h=g);for(y=n+1,h-e>N((_-r)/y)&&o("overflow"),r+=(h-e)*y,e=h,a=0;v>a;++a)if(g=t[a],e>g&&++r>_&&o("overflow"),g==e){for(c=r,p=A;d=s>=p?S:p>=s+T?T:p-s,!(d>c);p+=A)w=c-d,m=A-d,b.push(P(f(d+w%m,0))),c=N(w/m);b.push(P(f(c,0))),s=l(r,y,n==i),r=0,++n}++r,++e}return b.join("")}function g(t){return a(t,function(t){return C.test(t)?p(t.slice(4).toLowerCase()):t})}function v(t){return a(t,function(t){return U.test(t)?"xn--"+d(t):t})}var y="object"==typeof n&&n,m="object"==typeof r&&r&&r.exports==y&&r,w="object"==typeof e&&e;(w.global===w||w.window===w)&&(i=w);var b,E,_=2147483647,A=36,S=1,T=26,L=38,R=700,I=72,x=128,O="-",C=/^xn--/,U=/[^ -~]/,j=/\x2E|\u3002|\uFF0E|\uFF61/g,M={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},B=A-S,N=Math.floor,P=String.fromCharCode;if(b={version:"1.2.4",ucs2:{decode:u,encode:h},decode:p,encode:d,toASCII:v,toUnicode:g},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return b});else if(y&&!y.nodeType)if(m)m.exports=b;else for(E in b)b.hasOwnProperty(E)&&(y[E]=b[E]);else i.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],17:[function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,i,o){e=e||"&",i=i||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var h=t.length;u>0&&h>u&&(h=u);for(var c=0;h>c;++c){var f,l,p,d,g=t[c].replace(a,"%20"),v=g.indexOf(i);v>=0?(f=g.substr(0,v),l=g.substr(v+1)):(f=g,l=""),p=decodeURIComponent(f),d=decodeURIComponent(l),r(s,p)?n(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],18:[function(t,e){"use strict";function r(t,e){if(t.map)return t.map(e);for(var r=[],n=0;nr;r++)e(t[r],r)}e.exports=n;var s=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e},a=t("core-util-is");a.inherits=t("inherits");var u=t("./_stream_readable"),h=t("./_stream_writable");a.inherits(n,u),o(s(h.prototype),function(t){n.prototype[t]||(n.prototype[t]=h.prototype[t])})}).call(this,t("_process"))},{"./_stream_readable":23,"./_stream_writable":25,_process:15,"core-util-is":26,inherits:13}],22:[function(t,e){function r(t){return this instanceof r?void n.call(this,t):new r(t)}e.exports=r;var n=t("./_stream_transform"),i=t("core-util-is");i.inherits=t("inherits"),i.inherits(r,n),r.prototype._transform=function(t,e,r){r(null,t)}},{"./_stream_transform":24,"core-util-is":26,inherits:13}],23:[function(t,e){(function(r){function n(e){e=e||{};var r=e.highWaterMark;this.highWaterMark=r||0===r?r:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!e.objectMode,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(I||(I=t("string_decoder/").StringDecoder),this.decoder=new I(e.encoding),this.encoding=e.encoding)}function i(t){return this instanceof i?(this._readableState=new n(t,this),this.readable=!0,void L.call(this)):new i(t)}function o(t,e,r,n,i){var o=h(e,r);if(o)t.emit("error",o);else if(null===r||void 0===r)e.reading=!1,e.ended||c(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||n||(r=e.decoder.write(r)),e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):(e.reading=!1,e.buffer.push(r)),e.needReadable&&f(t),p(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length=x)t=x;else{t--;for(var e=1;32>e;e<<=1)t|=t>>e;t++}return t}function u(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:null===t||isNaN(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:0>=t?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function h(t,e){var r=null;return S.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function c(t,e){if(e.decoder&&!e.ended){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.length>0?f(t):b(t)}function f(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,e.sync?r.nextTick(function(){l(t)}):l(t))}function l(t){t.emit("readable")}function p(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(function(){d(t,e)}))}function d(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length0)return;return 0===n.pipesCount?(n.flowing=!1,void(T.listenerCount(t,"data")>0&&m(t))):void(n.ranOut=!0)}function y(){this._readableState.ranOut&&(this._readableState.ranOut=!1,v(this))}function m(t,e){var n=t._readableState;if(n.flowing)throw new Error("Cannot switch to old mode now.");var i=e||!1,o=!1;t.readable=!0,t.pipe=L.prototype.pipe,t.on=t.addListener=L.prototype.on,t.on("readable",function(){o=!0;for(var e;!i&&null!==(e=t.read());)t.emit("data",e);null===e&&(o=!1,t._readableState.needReadable=!0)}),t.pause=function(){i=!0,this.emit("pause")},t.resume=function(){i=!1,o?r.nextTick(function(){t.emit("readable")}):this.read(0),this.emit("resume")},t.emit("readable")}function w(t,e){var r,n=e.buffer,i=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===n.length)return null;if(0===i)r=null;else if(s)r=n.shift();else if(!t||t>=i)r=o?n.join(""):S.concat(n,i),n.length=0;else if(th&&t>u;h++){var a=n[0],f=Math.min(t-u,a.length);o?r+=a.slice(0,f):a.copy(r,u,0,f),f0)throw new Error("endReadable called on non-empty stream");!e.endEmitted&&e.calledRead&&(e.ended=!0,r.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function E(t,e){for(var r=0,n=t.length;n>r;r++)e(t[r],r)}function _(t,e){for(var r=0,n=t.length;n>r;r++)if(t[r]===e)return r;return-1}e.exports=i;var A=t("isarray"),S=t("buffer").Buffer;i.ReadableState=n;var T=t("events").EventEmitter;T.listenerCount||(T.listenerCount=function(t,e){return t.listeners(e).length});var L=t("stream"),R=t("core-util-is");R.inherits=t("inherits");var I;R.inherits(i,L),i.prototype.push=function(t,e){var r=this._readableState;return"string"!=typeof t||r.objectMode||(e=e||r.defaultEncoding,e!==r.encoding&&(t=new S(t,e),e="")),o(this,r,t,e,!1)},i.prototype.unshift=function(t){var e=this._readableState;return o(this,e,t,"",!0)},i.prototype.setEncoding=function(e){I||(I=t("string_decoder/").StringDecoder),this._readableState.decoder=new I(e),this._readableState.encoding=e};var x=8388608;i.prototype.read=function(t){var e=this._readableState;e.calledRead=!0;var r,n=t;if(("number"!=typeof t||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return f(this),null;if(t=u(t,e),0===t&&e.ended)return r=null,e.length>0&&e.decoder&&(r=w(t,e),e.length-=r.length),0===e.length&&b(this),r;var i=e.needReadable;return e.length-t<=e.highWaterMark&&(i=!0),(e.ended||e.reading)&&(i=!1),i&&(e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1),i&&!e.reading&&(t=u(n,e)),r=t>0?w(t,e):null,null===r&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),e.ended&&!e.endEmitted&&0===e.length&&b(this),r},i.prototype._read=function(){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,e){function n(t){t===c&&o()}function i(){t.end()}function o(){t.removeListener("close",a),t.removeListener("finish",u),t.removeListener("drain",d),t.removeListener("error",s),t.removeListener("unpipe",n),c.removeListener("end",i),c.removeListener("end",o),(!t._writableState||t._writableState.needDrain)&&d()}function s(e){h(),t.removeListener("error",s),0===T.listenerCount(t,"error")&&t.emit("error",e)}function a(){t.removeListener("finish",u),h()}function u(){t.removeListener("close",a),h()}function h(){c.unpipe(t)}var c=this,f=this._readableState;switch(f.pipesCount){case 0:f.pipes=t;break;case 1:f.pipes=[f.pipes,t];break;default:f.pipes.push(t)}f.pipesCount+=1;var l=(!e||e.end!==!1)&&t!==r.stdout&&t!==r.stderr,p=l?i:o;f.endEmitted?r.nextTick(p):c.once("end",p),t.on("unpipe",n);var d=g(c);return t.on("drain",d),t._events&&t._events.error?A(t._events.error)?t._events.error.unshift(s):t._events.error=[s,t._events.error]:t.on("error",s),t.once("close",a),t.once("finish",u),t.emit("pipe",c),f.flowing||(this.on("readable",y),f.flowing=!0,r.nextTick(function(){v(c)})),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,this.removeListener("readable",y),e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,this.removeListener("readable",y),e.flowing=!1;for(var i=0;n>i;i++)r[i].emit("unpipe",this);return this}var i=_(e.pipes,t);return-1===i?this:(e.pipes.splice(i,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},i.prototype.on=function(t,e){var r=L.prototype.on.call(this,t,e);if("data"!==t||this._readableState.flowing||m(this),"readable"===t&&this.readable){var n=this._readableState;n.readableListening||(n.readableListening=!0,n.emittedReadable=!1,n.needReadable=!0,n.reading?n.length&&f(this,n):this.read(0))}return r},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){m(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){m(this,!0),this.emit("pause")},i.prototype.wrap=function(t){var e=this._readableState,r=!1,n=this;t.on("end",function(){if(e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(i){if(e.decoder&&(i=e.decoder.write(i)),(!e.objectMode||null!==i&&void 0!==i)&&(e.objectMode||i&&i.length)){var o=n.push(i);o||(r=!0,t.pause())}});for(var i in t)"function"==typeof t[i]&&"undefined"==typeof this[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return E(o,function(e){t.on(e,n.emit.bind(n,e))}),n._read=function(){r&&(r=!1,t.resume())},n},i._fromList=w}).call(this,t("_process"))},{_process:15,buffer:3,"core-util-is":26,events:7,inherits:13,isarray:14,stream:31,"string_decoder/":32}],24:[function(t,e){function r(t,e){this.afterTransform=function(t,r){return n(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function n(t,e,r){var n=t._transformState;n.transforming=!1;var i=n.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!==r&&void 0!==r&&t.push(r),i&&i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.length=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&56319>=n)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,n=e.charCodeAt(i);if(n>=55296&&56319>=n){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},h.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(2>=e&&r>>4==14){this.charLength=3;break}if(3>=e&&r>>3==30){this.charLength=4;break}}this.charReceived=e},h.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},{buffer:3}],33:[function(t,e,r){function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(t,e,r){if(t&&h(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return u(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)}function s(t,e){return i(t,!1,!0).resolve(e)}function a(t,e){return t?i(t,!1,!0).resolveObject(e):e}function u(t){return"string"==typeof t}function h(t){return"object"==typeof t&&null!==t}function c(t){return null===t}function f(t){return null==t}var l=t("punycode");r.parse=i,r.resolve=s,r.resolveObject=a,r.format=o,r.Url=n;var p=/^([a-z0-9.+-]+:)/i,d=/:[0-9]*$/,g=["<",">",'"',"`"," ","\r","\n"," "],v=["{","}","|","\\","^","`"].concat(g),y=["'"].concat(v),m=["%","/","?",";","#"].concat(y),w=["/","?","#"],b=255,E=/^[a-z0-9A-Z_-]{0,63}$/,_=/^([a-z0-9A-Z_-]{0,63})(.*)$/,A={javascript:!0,"javascript:":!0},S={javascript:!0,"javascript:":!0},T={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},L=t("querystring");n.prototype.parse=function(t,e,r){if(!u(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var i=p.exec(n);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var s="//"===n.substr(0,2);!s||i&&S[i]||(n=n.substr(2),this.slashes=!0)}if(!S[i]&&(s||i&&!T[i])){for(var a=-1,h=0;hc)&&(a=c)}var f,d;d=-1===a?n.lastIndexOf("@"):n.lastIndexOf("@",a),-1!==d&&(f=n.slice(0,d),n=n.slice(d+1),this.auth=decodeURIComponent(f)),a=-1;for(var h=0;hc)&&(a=c)}-1===a&&(a=n.length),this.host=n.slice(0,a),n=n.slice(a),this.parseHost(),this.hostname=this.hostname||"";var g="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!g)for(var v=this.hostname.split(/\./),h=0,R=v.length;R>h;h++){var I=v[h];if(I&&!I.match(E)){for(var x="",O=0,C=I.length;C>O;O++)x+=I.charCodeAt(O)>127?"x":I[O];if(!x.match(E)){var U=v.slice(0,h),j=v.slice(h+1),M=I.match(_);M&&(U.push(M[1]),j.unshift(M[2])),j.length&&(n="/"+j.join(".")+n),this.hostname=U.join(".");break}}}if(this.hostname=this.hostname.length>b?"":this.hostname.toLowerCase(),!g){for(var B=this.hostname.split("."),N=[],h=0;hh;h++){var q=y[h],F=encodeURIComponent(q);F===q&&(F=escape(q)),n=n.split(q).join(F)}var Y=n.indexOf("#");-1!==Y&&(this.hash=n.substr(Y),n=n.slice(0,Y));var H=n.indexOf("?");if(-1!==H?(this.search=n.substr(H),this.query=n.substr(H+1),e&&(this.query=L.parse(this.query)),n=n.slice(0,H)):e&&(this.search="",this.query={}),n&&(this.pathname=n),T[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var k=this.pathname||"",P=this.search||"";this.path=k+P}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&h(this.query)&&Object.keys(this.query).length&&(o=L.stringify(this.query));var s=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||T[e])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),s=s.replace("#","%23"),e+i+r+s+n},n.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(u(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),T[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!T[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||S[t.protocol])r.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var o=r.pathname||"",s=r.search||"";r.path=o+s}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var a=r.pathname&&"/"===r.pathname.charAt(0),h=t.host||t.pathname&&"/"===t.pathname.charAt(0),l=h||a||r.host&&t.pathname,p=l,d=r.pathname&&r.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],g=r.protocol&&!T[r.protocol];if(g&&(r.hostname="",r.port=null,r.host&&(""===d[0]?d[0]=r.host:d.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),l=l&&(""===i[0]||""===d[0])),h)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,d=i;else if(i.length)d||(d=[]),d.pop(),d=d.concat(i),r.search=t.search,r.query=t.query;else if(!f(t.search)){if(g){r.hostname=r.host=d.shift();var v=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;v&&(r.auth=v.shift(),r.host=r.hostname=v.shift())}return r.search=t.search,r.query=t.query,c(r.pathname)&&c(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!d.length)return r.pathname=null,r.path=r.search?"/"+r.search:null,r.href=r.format(),r;for(var y=d.slice(-1)[0],m=(r.host||t.host)&&("."===y||".."===y)||""===y,w=0,b=d.length;b>=0;b--)y=d[b],"."==y?d.splice(b,1):".."===y?(d.splice(b,1),w++):w&&(d.splice(b,1),w--); -if(!l&&!p)for(;w--;w)d.unshift("..");!l||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),m&&"/"!==d.join("/").substr(-1)&&d.push("");var E=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(g){r.hostname=r.host=E?"":d.length?d.shift():"";var v=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;v&&(r.auth=v.shift(),r.host=r.hostname=v.shift())}return l=l||r.host&&d.length,l&&!E&&d.unshift(""),d.length?r.pathname=d.join("/"):(r.pathname=null,r.path=null),c(r.pathname)&&c(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=d.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{punycode:16,querystring:19}],34:[function(t,e){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],35:[function(t,e,r){(function(e,n){function i(t,e){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(e)?n.showHidden=e:e&&r._extend(n,e),E(n.showHidden)&&(n.showHidden=!1),E(n.depth)&&(n.depth=2),E(n.colors)&&(n.colors=!1),E(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t){return t}function a(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function u(t,e,n){if(t.customInspect&&e&&L(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return w(i)||(i=u(t,i,n)),i}var o=h(t,e);if(o)return o;var s=Object.keys(e),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),T(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return c(e);if(0===s.length){if(L(e)){var v=e.name?": "+e.name:"";return t.stylize("[Function"+v+"]","special")}if(_(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(S(e))return t.stylize(Date.prototype.toString.call(e),"date");if(T(e))return c(e)}var y="",m=!1,b=["{","}"];if(d(e)&&(m=!0,b=["[","]"]),L(e)){var E=e.name?": "+e.name:"";y=" [Function"+E+"]"}if(_(e)&&(y=" "+RegExp.prototype.toString.call(e)),S(e)&&(y=" "+Date.prototype.toUTCString.call(e)),T(e)&&(y=" "+c(e)),0===s.length&&(!m||0==e.length))return b[0]+y+b[1];if(0>n)return _(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var A;return A=m?f(t,e,n,g,s):s.map(function(r){return l(t,e,n,g,r,m)}),t.seen.pop(),p(A,y,b)}function h(t,e){if(E(e))return t.stylize("undefined","undefined");if(w(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return m(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):v(e)?t.stylize("null","null"):void 0}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)o.push(C(e,String(s))?l(t,e,r,n,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(t,e,r,n,i,!0))}),o}function l(t,e,r,n,i,o){var s,a,h;if(h=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},h.get?a=h.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):h.set&&(a=t.stylize("[Setter]","special")),C(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(h.value)<0?(a=v(r)?u(t,h.value,null):u(t,h.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),E(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function v(t){return null===t}function y(t){return null==t}function m(t){return"number"==typeof t}function w(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function E(t){return void 0===t}function _(t){return A(t)&&"[object RegExp]"===I(t)}function A(t){return"object"==typeof t&&null!==t}function S(t){return A(t)&&"[object Date]"===I(t)}function T(t){return A(t)&&("[object Error]"===I(t)||t instanceof Error)}function L(t){return"function"==typeof t}function R(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function I(t){return Object.prototype.toString.call(t)}function x(t){return 10>t?"0"+t.toString(10):t.toString(10)}function O(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),B[t.getMonth()],e].join(" ")}function C(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var U=/%[sdj%]/g;r.format=function(t){if(!w(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=v(a)||!A(a)?" "+a:" "+i(a);return s},r.deprecate=function(t,i){function o(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}if(E(n.process))return function(){return r.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var s=!1;return o};var j,M={};r.debuglog=function(t){if(E(j)&&(j=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!M[t])if(new RegExp("\\b"+t+"\\b","i").test(j)){var n=e.pid;M[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else M[t]=function(){};return M[t]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=g,r.isNull=v,r.isNullOrUndefined=y,r.isNumber=m,r.isString=w,r.isSymbol=b,r.isUndefined=E,r.isRegExp=_,r.isObject=A,r.isDate=S,r.isError=T,r.isFunction=L,r.isPrimitive=R,r.isBuffer=t("./support/isBuffer");var B=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",O(),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!A(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":34,_process:15,inherits:13}],36:[function(t,e){function r(t){var e=n.parse(t.url),r="https:"===e.protocol;this.httpTransport=r?o:i,this.httpOptions={protocol:e.protocol,host:e.hostname,port:e.port||(r?443:80),withCredentials:!1,headers:{}},this.httpParams={},r&&(this.httpOptions.secureProtocol=t.secureProtocol||"TLSv1_method",this.httpOptions.agent=!1);var s;"internal"===t.version||"unsupported"===t.version?s="/attask/api-"+t.version:(s="/attask/api",t.version&&(s=s+"/v"+t.version)),this.httpOptions.path=s}var n=t("url"),i=t("http"),o=t("https");r.Methods={GET:"GET",PUT:"PUT",DELETE:"DELETE",POST:"POST"},t("./plugins/request")(r),t("./plugins/login")(r),t("./plugins/logout")(r),t("./plugins/search")(r),t("./plugins/get")(r),t("./plugins/create")(r),t("./plugins/edit")(r),t("./plugins/remove")(r),t("./plugins/report")(r),t("./plugins/count")(r),t("./plugins/copy")(r),t("./plugins/upload")(r),t("./plugins/execute")(r),t("./plugins/namedQuery")(r),t("./plugins/metadata")(r),t("./plugins/apiKey")(r),e.exports=r},{"./plugins/apiKey":40,"./plugins/copy":41,"./plugins/count":42,"./plugins/create":43,"./plugins/edit":44,"./plugins/execute":45,"./plugins/get":46,"./plugins/login":47,"./plugins/logout":48,"./plugins/metadata":49,"./plugins/namedQuery":50,"./plugins/remove":51,"./plugins/report":52,"./plugins/request":53,"./plugins/search":54,"./plugins/upload":55,http:8,https:12,url:33}],37:[function(t,e){var r={SORT:"_Sort",MOD:"_Mod",ORDERDOT:"_",FIRST:"$$FIRST",LIMIT:"$$LIMIT",DATAEXTENSION:"DE:",GROUPBY:"_GroupBy",FORCE_GROUPBY:"$$_ForceGroupBy",AGGFUNC:"_AggFunc",AGGCURRENCY_FIELDS:"$$AggCurr",GROUPCURRENCY_FIELDS:"$$GroupCurr",SORTCURRENCY_FIELDS:"$$SortCurr",FILTERCURRENCY_FIELDS:"$$FilterCurr",ROLLUP:"$$ROLLUP",INTERNAL_PREFIX:"$$",WildCards:{TODAY:"$$TODAY",NOW:"$$NOW",USER:"$$USER",CUSTOMER:"$$CUSTOMER",ACCOUNTREP:"$$AR"},SortOrder:{ASC:"asc",DESC:"desc",CIASC:"ciasc",CIDESC:"cidesc"},Operators:{LESSTHAN:"lt",LESSTHANEQUAL:"lte",GREATERTHAN:"gt",GREATERTHANEQUAL:"gte",EQUAL:"eq",CIEQUAL:"cieq",NOTEQUAL:"ne",NOTEQUALEXACT:"nee",CINOTEQUAL:"cine",CONTAINS:"contains",CICONTAINS:"cicontains",CICONTAINSANY:"cicontainsany",CICONTAINSALL:"cicontainsall",CINOTCONTAINSALL:"cinotcontainsall",CINOTCONTAINSANY:"cinotcontainsany",NOTCONTAINS:"notcontains",CINOTCONTAINS:"cinotcontains",LIKE:"like",CILIKE:"cilike",STARTSWITH:"startswith",SOUNDEX:"soundex",BETWEEN:"between",CIBETWEEN:"cibetween",NOTBETWEEN:"notbetween",CINOTBETWEEN:"cinotbetween",IN:"in",CIIN:"ciin",NOTIN:"notin",CINOTIN:"cinotin",BITWISE_OR:"bitwiseor",BITWISE_AND:"bitwiseand",BITWISE_NAND:"bitwisenand",EXACT_TIME:"exacttime",LENGTH_LT:"length_lt",LENGTH_EQ:"length_eq",LENGTH_GT:"length_gt",ALLOF:"allof",ISNULL:"isnull",NOTNULL:"notnull",ISBLANK:"isblank",NOTBLANK:"notblank"},Functions:{MAX:"max",MIN:"min",AVG:"avg",SUM:"sum",COUNT:"count",STD:"std",VAR:"var",DMAX:"dmax",DMIN:"dmin",DAVG:"davg",DSUM:"dsum",DCOUNT:"dcount",DSTD:"dstd",DVAR:"dvar"}};e.exports=r},{}],38:[function(t,e){var r,n=t("./Api");e.exports={getInstance:function(t,e){if(e)return new n(t);if(!r){if("object"!=typeof t)throw new Error("Please provide configuration as an object.");r=new n(t)}return r},deleteInstance:function(){r=void 0}}},{"./Api":36}],39:[function(t,e){e.exports={}},{}],40:[function(t,e){e.exports=function(t){t.prototype.getApiKey=function(t,e){var r=this;return new Promise(function(n,i){"undefined"!=typeof r.httpParams.apiKey?n(r.httpParams.apiKey):r.execute("USER",null,"getApiKey",{username:t,password:e}).then(function(t){r.httpParams.apiKey=t.result,n(r.httpParams.apiKey)},i)})},t.prototype.clearApiKey=function(){var t=this;return new Promise(function(e,r){t.execute("USER",null,"clearApiKey").then(function(n){n?(delete t.httpParams.apiKey,e()):r()})})}}},{}],41:[function(t,e){e.exports=function(t){t.prototype.copy=function(e,r,n,i){var o={copySourceID:r};return n&&(o.updates=JSON.stringify(n)),this.request(e,o,i,t.Methods.POST)}}},{}],42:[function(t,e){e.exports=function(t){t.prototype.count=function(e,r){var n=this;return new Promise(function(i,o){n.request(e+"/count",r,null,t.Methods.GET).then(function(t){i(t.count)},o)})}}},{}],43:[function(t,e){e.exports=function(t){t.prototype.create=function(e,r,n){return this.request(e,r,n,t.Methods.POST)}}},{}],44:[function(t,e){e.exports=function(t){t.prototype.edit=function(e,r,n,i){var o={updates:JSON.stringify(n)};return this.request(e+"/"+r,o,i,t.Methods.PUT)}}},{}],45:[function(t,e){e.exports=function(t){t.prototype.execute=function(e,r,n,i){var o=e;return r?o+="/"+r+"/"+n:(i=i||{},i.action=n),this.request(o,i,null,t.Methods.PUT)}}},{}],46:[function(t,e){var r=t("./../ApiConstants");e.exports=function(t){t.prototype.get=function(e,n,i){"string"==typeof n&&(n=[n]);var o=e,s=null;return 1===n.length?0===n[0].indexOf(r.INTERNAL_PREFIX)?s={id:n[0]}:o+="/"+n[0]:s={id:n},this.request(o,s,i,t.Methods.GET)}}},{"./../ApiConstants":37}],47:[function(t,e){e.exports=function(t){t.prototype.login=function(e,r){var n=this;return new Promise(function(i,o){n.request("login",{username:e,password:r},null,t.Methods.POST).then(function(t){n.httpOptions.headers.sessionID=t.sessionID,i(t)},o)})}}},{}],48:[function(t,e){e.exports=function(t){t.prototype.logout=function(){var e=this;return new Promise(function(r,n){e.request("logout",null,null,t.Methods.GET).then(function(t){t&&t.success?(delete e.httpOptions.headers.sessionID,r()):n()})})}}},{}],49:[function(t,e){e.exports=function(t){t.prototype.metadata=function(e){var r="/metadata";return e&&(r=e+r),this.request(r,null,null,t.Methods.GET)}}},{}],50:[function(t,e){e.exports=function(t){t.prototype.namedQuery=function(e,r,n,i){return this.request(e+"/"+r,n,i,t.Methods.GET)}}},{}],51:[function(t,e){e.exports=function(t){t.prototype.remove=function(e,r,n){var i=this;return new Promise(function(o,s){var a=n?{force:!0}:null;i.request(e+"/"+r,a,null,t.Methods.DELETE).then(function(t){t&&t.success?o():s()},s)})}}},{}],52:[function(t,e){e.exports=function(t){t.prototype.report=function(e,r){return this.request(e+"/report",r,null,t.Methods.GET)}}},{}],53:[function(t,e){var r=t("querystring"),n=t("util");e.exports=function(t){var e=function(e){return e!==t.Methods.GET&&e!==t.Methods.PUT};t.prototype.request=function(t,i,o,s){o=o||[],"string"==typeof o&&(o=[o]),i=i||{},n._extend(i,this.httpParams);var a={};n._extend(a,this.httpOptions),a.method=s,a.path=0===t.indexOf("/")?this.httpOptions.path+t:this.httpOptions.path+"/"+t,0!==o.length&&(i.fields=o.join()),i=r.stringify(i),i&&(e(a.method)?(a.headers["Content-Type"]="application/x-www-form-urlencoded",a.headers["Content-Length"]=i.length):a.path+="?"+i);var u=this.httpTransport;return new Promise(function(t,r){var n=u.request(a,function(e){var n="";"function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",function(t){n+=t}),e.on("end",function(){var e;try{e=JSON.parse(n)}catch(i){return void r(n)}e.error?r(e):t(e.data)})});n.on("error",r),i&&e(a.method)&&n.write(i),n.end()})}}},{querystring:19,util:35}],54:[function(t,e){e.exports=function(t){t.prototype.search=function(e,r,n){return this.request(e+"/search",r,n,t.Methods.GET)}}},{}],55:[function(t,e){e.exports=function(t){t.prototype.upload=function(){throw new Error("Not implemented")}}},{}]},{},[1])(1)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Workfront=t()}}(function(){var t;return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){var r=t[s][1][e];return i(r?r:e)},f,f.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s1?arguments[1]:"utf8"):s(this,t)):arguments.length>1?new n(t,arguments[1]):new n(t)}function i(t,e){if(t=l(t,0>e?0:0|p(e)),!n.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function o(t,e,r){("string"!=typeof r||""===r)&&(r="utf8");var n=0|g(e,r);return t=l(t,n),t.write(e,r),t}function s(t,e){if(n.isBuffer(e))return a(t,e);if($(e))return u(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");return"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer?h(t,e):e.length?f(t,e):c(t,e)}function a(t,e){var r=0|p(e.length);return t=l(t,r),e.copy(t,0,0,r),t}function u(t,e){var r=0|p(e.length);t=l(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){var r=0|p(e.length);t=l(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r=0|p(e.length);t=l(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function c(t,e){var r,n=0;"Buffer"===e.type&&$(e.data)&&(r=e.data,n=0|p(r.length)),t=l(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function l(t,e){n.TYPED_ARRAY_SUPPORT?t=n._augment(new Uint8Array(e)):(t.length=e,t._isBuffer=!0);var r=0!==e&&e<=n.poolSize>>>1;return r&&(t.parent=K),t}function p(t){if(t>=z)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+z.toString(16)+" bytes");return 0|t}function d(t,e){if(!(this instanceof d))return new d(t,e);var r=new n(t,e);return delete r.parent,r}function g(t,e){if("string"!=typeof t&&(t=String(t)),0===t.length)return 0;switch(e||"utf8"){case"ascii":case"binary":case"raw":return t.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t.length;case"hex":return t.length>>>1;case"utf8":case"utf-8":return k(t).length;case"base64":return F(t).length;default:return t.length}}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function m(t,e,r,n){return Y(k(e,t.length-r),t,r,n)}function y(t,e,r,n){return Y(D(e),t,r,n)}function w(t,e,r,n){return y(t,e,r,n)}function b(t,e,r,n){return Y(F(e),t,r,n)}function E(t,e,r,n){return Y(q(e,t.length-r),t,r,n)}function _(t,e,r){return H.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function A(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=G(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+G(i)}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function L(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=P(t[o]);return i}function R(t,e,r){for(var n=t.slice(e,r),i="",o=0;ot)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||s>e)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function O(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function C(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function U(t,e,r,n,i,o){if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function j(t,e,r,n,i){return i||U(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),W.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return i||U(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),W.write(t,e,r,n,52,8),r+8}function B(t){if(t=N(t).replace(J,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function N(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function P(t){return 16>t?"0"+t.toString(16):t.toString(16)}function k(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;n>s;s++){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((e-=3)>-1&&o.push(239,191,189),i=null);if(128>r){if((e-=1)<0)break;o.push(r)}else if(2048>r){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function F(t){return H.toByteArray(B(t))}function Y(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function G(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var H=t("base64-js"),W=t("ieee754"),$=t("is-array");r.Buffer=n,r.SlowBuffer=d,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var z=1073741823,K={};n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,e){if(!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);s>o&&t[o]===e[o];)++o;return o!==s&&(r=t[o],i=e[o]),i>r?-1:r>i?1:0},n.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(t,e){if(!$(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new n(0);if(1===t.length)return t[0];var r;if(void 0===e)for(e=0,r=0;re&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return L(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return S(this,e,r);case"binary":return T(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:n.compare(this,t)},n.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(n.isBuffer(t))return r(this,t,e);if("number"==typeof t)return n.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},n.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":return y(this,t,e,r);case"binary":return w(this,t,e,r);case"base64":return b(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var i;if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(t,e));else{var o=e-t;i=new n(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=this[t],i=1,o=0;++o0&&(i*=256);)n+=this[t+--e]*i;return n},n.prototype.readUInt8=function(t,e){return e||I(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||I(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||I(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*e)),n},n.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||I(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},n.prototype.readInt8=function(t,e){return e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return e||I(t,4,this.length),W.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||I(t,4,this.length),W.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||I(t,8,this.length),W.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||I(t,8,this.length),W.read(this,t,!1,52,8)},n.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||x(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+r},n.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):O(this,t,e,!1),e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):C(this,t,e,!0),e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):C(this,t,e,!1),e+4},n.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);x(this,t,e,r,i-1,-i)}var o=0,s=1,a=0>t?1:0;for(this[e]=255&t;++o>0)-a&255;return e+r},n.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);x(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0>t?1:0;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=(t/s>>0)-a&255;return e+r},n.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):O(this,t,e,!1),e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):C(this,t,e,!0),e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||x(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):C(this,t,e,!1),e+4},n.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-eo||!n.TYPED_ARRAY_SUPPORT)for(var s=0;o>s;s++)t[s+e]=this[s+r];else t._set(this.subarray(r,r+o),e);return o},n.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=k(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var X=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._set=t.set,t.get=X.get,t.set=X.set,t.write=X.write,t.toString=X.toString,t.toLocaleString=X.toString,t.toJSON=X.toJSON,t.equals=X.equals,t.compare=X.compare,t.indexOf=X.indexOf,t.copy=X.copy,t.slice=X.slice,t.readUIntLE=X.readUIntLE,t.readUIntBE=X.readUIntBE,t.readUInt8=X.readUInt8,t.readUInt16LE=X.readUInt16LE,t.readUInt16BE=X.readUInt16BE,t.readUInt32LE=X.readUInt32LE,t.readUInt32BE=X.readUInt32BE,t.readIntLE=X.readIntLE,t.readIntBE=X.readIntBE,t.readInt8=X.readInt8,t.readInt16LE=X.readInt16LE,t.readInt16BE=X.readInt16BE,t.readInt32LE=X.readInt32LE,t.readInt32BE=X.readInt32BE,t.readFloatLE=X.readFloatLE,t.readFloatBE=X.readFloatBE,t.readDoubleLE=X.readDoubleLE,t.readDoubleBE=X.readDoubleBE,t.writeUInt8=X.writeUInt8,t.writeUIntLE=X.writeUIntLE,t.writeUIntBE=X.writeUIntBE,t.writeUInt16LE=X.writeUInt16LE,t.writeUInt16BE=X.writeUInt16BE,t.writeUInt32LE=X.writeUInt32LE,t.writeUInt32BE=X.writeUInt32BE,t.writeIntLE=X.writeIntLE,t.writeIntBE=X.writeIntBE,t.writeInt8=X.writeInt8,t.writeInt16LE=X.writeInt16LE,t.writeInt16BE=X.writeInt16BE,t.writeInt32LE=X.writeInt32LE,t.writeInt32BE=X.writeInt32BE,t.writeFloatLE=X.writeFloatLE,t.writeFloatBE=X.writeFloatBE,t.writeDoubleLE=X.writeDoubleLE,t.writeDoubleBE=X.writeDoubleBE,t.fill=X.fill,t.inspect=X.inspect,t.toArrayBuffer=X.toArrayBuffer,t};var J=/[^+\/0-9A-z\-]/g},{"base64-js":5,ieee754:6,"is-array":7}],5:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===c?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:h+26>e?e-h+26:void 0}function r(t){function r(t){h[c++]=t}var n,i,s,a,u,h;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,h=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var c=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),h}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=r(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),h="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],6:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+c],c+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+c],c+=l,f-=8);if(0===o)o=1-h;else{if(o===u)return s?0/0:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+c>=1?l/u:l*Math.pow(2,1-c),e*u>=2&&(s++,u/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,h-=8);t[r+p-d]|=128*g}},{}],7:[function(t,e,r){var n=Array.isArray,i=Object.prototype.toString;e.exports=n||function(t){return!!t&&"[object Array]"==i.call(t)}},{}],8:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"number"==typeof t}function s(t){return"object"==typeof t&&null!==t}function a(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!o(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,o,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],a(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];r.apply(this,o)}else if(s(r)){for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];for(h=r.slice(),n=h.length,u=0;n>u;u++)h[u].apply(this,o)}return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,o,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(r)){for(a=o;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?i(t._events[e])?1:t._events[e].length:0}},{}],9:[function(t,e,r){var n=e.exports,i=(t("events").EventEmitter,t("./lib/request")),o=t("url");n.request=function(t,e){"string"==typeof t&&(t=o.parse(t)),t||(t={}),t.host||t.port||(t.port=parseInt(window.location.port,10)),!t.host&&t.hostname&&(t.host=t.hostname),t.protocol||(t.protocol=t.scheme?t.scheme+":":window.location.protocol),t.host||(t.host=window.location.hostname||window.location.host),/:/.test(t.host)&&(t.port||(t.port=t.host.split(":")[1]),t.host=t.host.split(":")[0]),t.port||(t.port="https:"==t.protocol?443:80);var r=new i(new s,t);return e&&r.on("response",e),r},n.get=function(t,e){t.method="GET";var r=n.request(t,e);return r.end(),r},n.Agent=function(){},n.Agent.defaultMaxSockets=4;var s=function(){if("undefined"==typeof window)throw new Error("no window object present");if(window.XMLHttpRequest)return window.XMLHttpRequest;if(window.ActiveXObject){for(var t=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"],e=0;ethis.offset&&(this.emit("data",e.slice(this.offset)),this.offset=e.length))};var u=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{stream:32,util:36}],12:[function(t,e,r){!function(){function t(t){this.message=t}var e="undefined"!=typeof r?r:this,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + +t.prototype=new Error,t.prototype.name="InvalidCharacterError",e.btoa||(e.btoa=function(e){for(var r,i,o=0,s=n,a="";e.charAt(0|o)||(s="=",o%1);a+=s.charAt(63&r>>8-o%1*8)){if(i=e.charCodeAt(o+=.75),i>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|i}return a}),e.atob||(e.atob=function(e){if(e=e.replace(/=+$/,""),e.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(r=o%4?64*r+i:i,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)i=n.indexOf(i);return a})}()},{}],13:[function(t,e,r){var n=t("http"),i=e.exports;for(var o in n)n.hasOwnProperty(o)&&(i[o]=n[o]);i.request=function(t,e){return t||(t={}),t.scheme="https",n.request.call(this,t,e)}},{http:9}],14:[function(t,e,r){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],15:[function(t,e,r){e.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}},{}],16:[function(t,e,r){function n(){}var i=e.exports={};i.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.MutationObserver,r="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};var n=[];if(e){var i=document.createElement("div"),o=new MutationObserver(function(){var t=n.slice();n.length=0,t.forEach(function(t){t()})});return o.observe(i,{attributes:!0}),function(t){n.length||i.setAttribute("yes","no"),n.push(t)}}return r?(window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}}(),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")}},{}],17:[function(e,r,n){(function(e){!function(i){function o(t){throw RangeError(M[t])}function s(t,e){for(var r=t.length;r--;)t[r]=e(t[r]);return t}function a(t,e){return s(t.split(j),e).join(".")}function u(t){for(var e,r,n=[],i=0,o=t.length;o>i;)e=t.charCodeAt(i++),e>=55296&&56319>=e&&o>i?(r=t.charCodeAt(i++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--)):n.push(e);return n}function h(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=P(t>>>10&1023|55296),t=56320|1023&t),e+=P(t)}).join("")}function f(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:A}function c(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function l(t,e,r){var n=0;for(t=r?N(t/R):t>>1,t+=N(t/e);t>B*T>>1;n+=A)t=N(t/B);return N(n+(B+1)*t/(t+L))}function p(t){var e,r,n,i,s,a,u,c,p,d,g=[],v=t.length,m=0,y=x,w=I;for(r=t.lastIndexOf(O),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&o("not-basic"),g.push(t.charCodeAt(n));for(i=r>0?r+1:0;v>i;){for(s=m,a=1,u=A;i>=v&&o("invalid-input"),c=f(t.charCodeAt(i++)),(c>=A||c>N((_-m)/a))&&o("overflow"),m+=c*a,p=w>=u?S:u>=w+T?T:u-w,!(p>c);u+=A)d=A-p,a>N(_/d)&&o("overflow"),a*=d;e=g.length+1,w=l(m-s,e,0==s),N(m/e)>_-y&&o("overflow"),y+=N(m/e),m%=e,g.splice(m++,0,y)}return h(g)}function d(t){var e,r,n,i,s,a,h,f,p,d,g,v,m,y,w,b=[];for(t=u(t),v=t.length,e=x,r=0,s=I,a=0;v>a;++a)g=t[a],128>g&&b.push(P(g));for(n=i=b.length,i&&b.push(O);v>n;){for(h=_,a=0;v>a;++a)g=t[a],g>=e&&h>g&&(h=g);for(m=n+1,h-e>N((_-r)/m)&&o("overflow"),r+=(h-e)*m,e=h,a=0;v>a;++a)if(g=t[a],e>g&&++r>_&&o("overflow"),g==e){for(f=r,p=A;d=s>=p?S:p>=s+T?T:p-s,!(d>f);p+=A)w=f-d,y=A-d,b.push(P(c(d+w%y,0))),f=N(w/y);b.push(P(c(f,0))),s=l(r,m,n==i),r=0,++n}++r,++e}return b.join("")}function g(t){return a(t,function(t){return C.test(t)?p(t.slice(4).toLowerCase()):t})}function v(t){return a(t,function(t){return U.test(t)?"xn--"+d(t):t})}var m="object"==typeof n&&n,y="object"==typeof r&&r&&r.exports==m&&r,w="object"==typeof e&&e;(w.global===w||w.window===w)&&(i=w);var b,E,_=2147483647,A=36,S=1,T=26,L=38,R=700,I=72,x=128,O="-",C=/^xn--/,U=/[^ -~]/,j=/\x2E|\u3002|\uFF0E|\uFF61/g,M={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},B=A-S,N=Math.floor,P=String.fromCharCode;if(b={version:"1.2.4",ucs2:{decode:u,encode:h},decode:p,encode:d,toASCII:v,toUnicode:g},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return b});else if(m&&!m.nodeType)if(y)y.exports=b;else for(E in b)b.hasOwnProperty(E)&&(m[E]=b[E]);else i.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],18:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var h=t.length;u>0&&h>u&&(h=u);for(var f=0;h>f;++f){var c,l,p,d,g=t[f].replace(a,"%20"),v=g.indexOf(r);v>=0?(c=g.substr(0,v),l=g.substr(v+1)):(c=g,l=""),p=decodeURIComponent(c),d=decodeURIComponent(l),n(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],19:[function(t,e,r){"use strict";function n(t,e){if(t.map)return t.map(e);for(var r=[],n=0;nr;r++)e(t[r],r)}e.exports=n;var s=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e},a=t("core-util-is");a.inherits=t("inherits");var u=t("./_stream_readable"),h=t("./_stream_writable");a.inherits(n,u),o(s(h.prototype),function(t){n.prototype[t]||(n.prototype[t]=h.prototype[t])})}).call(this,t("_process"))},{"./_stream_readable":24,"./_stream_writable":26,_process:16,"core-util-is":27,inherits:14}],23:[function(t,e,r){function n(t){return this instanceof n?void i.call(this,t):new n(t)}e.exports=n;var i=t("./_stream_transform"),o=t("core-util-is");o.inherits=t("inherits"),o.inherits(n,i),n.prototype._transform=function(t,e,r){r(null,t)}},{"./_stream_transform":25,"core-util-is":27,inherits:14}],24:[function(t,e,r){(function(r){function n(e,r){var n=t("./_stream_duplex");e=e||{};var i=e.highWaterMark,o=e.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!e.objectMode,r instanceof n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(I||(I=t("string_decoder/").StringDecoder),this.decoder=new I(e.encoding),this.encoding=e.encoding)}function i(e){t("./_stream_duplex");return this instanceof i?(this._readableState=new n(e,this),this.readable=!0,void L.call(this)):new i(e)}function o(t,e,r,n,i){var o=h(e,r);if(o)t.emit("error",o);else if(R.isNullOrUndefined(r))e.reading=!1,e.ended||f(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||n||(r=e.decoder.write(r)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&c(t)),p(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length=O)t=O;else{t--;for(var e=1;32>e;e<<=1)t|=t>>e;t++}return t}function u(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:isNaN(t)||R.isNull(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:0>=t?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function h(t,e){var r=null;return R.isBuffer(e)||R.isString(e)||R.isNullOrUndefined(e)||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function f(t,e){if(e.decoder&&!e.ended){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,c(t)}function c(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(x("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?r.nextTick(function(){l(t)}):l(t))}function l(t){x("emit readable"),t.emit("readable"),y(t)}function p(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(function(){d(t,e)}))}function d(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=i)r=o?n.join(""):S.concat(n,i),n.length=0;else if(th&&t>u;h++){var a=n[0],c=Math.min(t-u,a.length);o?r+=a.slice(0,c):a.copy(r,u,0,c),c0)throw new Error("endReadable called on non-empty stream");e.endEmitted||(e.ended=!0,r.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function E(t,e){for(var r=0,n=t.length;n>r;r++)e(t[r],r)}function _(t,e){for(var r=0,n=t.length;n>r;r++)if(t[r]===e)return r;return-1}e.exports=i;var A=t("isarray"),S=t("buffer").Buffer;i.ReadableState=n;var T=t("events").EventEmitter;T.listenerCount||(T.listenerCount=function(t,e){return t.listeners(e).length});var L=t("stream"),R=t("core-util-is");R.inherits=t("inherits");var I,x=t("util");x=x&&x.debuglog?x.debuglog("stream"):function(){},R.inherits(i,L),i.prototype.push=function(t,e){var r=this._readableState;return R.isString(t)&&!r.objectMode&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=new S(t,e),e="")),o(this,r,t,e,!1)},i.prototype.unshift=function(t){var e=this._readableState;return o(this,e,t,"",!0)},i.prototype.setEncoding=function(e){return I||(I=t("string_decoder/").StringDecoder),this._readableState.decoder=new I(e),this._readableState.encoding=e,this};var O=8388608;i.prototype.read=function(t){x("read",t);var e=this._readableState,r=t;if((!R.isNumber(t)||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return x("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?b(this):c(this),null;if(t=u(t,e),0===t&&e.ended)return 0===e.length&&b(this),null;var n=e.needReadable;x("need readable",n),(0===e.length||e.length-t0?w(t,e):null,R.isNull(i)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),r!==t&&e.ended&&0===e.length&&b(this),R.isNull(i)||this.emit("data",i),i},i.prototype._read=function(t){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(t,e){function n(t){x("onunpipe"),t===c&&o()}function i(){x("onend"),t.end()}function o(){x("cleanup"),t.removeListener("close",u),t.removeListener("finish",h),t.removeListener("drain",v),t.removeListener("error",a),t.removeListener("unpipe",n),c.removeListener("end",i),c.removeListener("end",o),c.removeListener("data",s),!l.awaitDrain||t._writableState&&!t._writableState.needDrain||v()}function s(e){x("ondata");var r=t.write(e);!1===r&&(x("false write response, pause",c._readableState.awaitDrain),c._readableState.awaitDrain++,c.pause())}function a(e){x("onerror",e),f(),t.removeListener("error",a),0===T.listenerCount(t,"error")&&t.emit("error",e)}function u(){t.removeListener("finish",h),f()}function h(){x("onfinish"),t.removeListener("close",u),f()}function f(){x("unpipe"),c.unpipe(t)}var c=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=t;break;case 1:l.pipes=[l.pipes,t];break;default:l.pipes.push(t)}l.pipesCount+=1,x("pipe count=%d opts=%j",l.pipesCount,e);var p=(!e||e.end!==!1)&&t!==r.stdout&&t!==r.stderr,d=p?i:o;l.endEmitted?r.nextTick(d):c.once("end",d),t.on("unpipe",n);var v=g(c);return t.on("drain",v),c.on("data",s),t._events&&t._events.error?A(t._events.error)?t._events.error.unshift(a):t._events.error=[a,t._events.error]:t.on("error",a),t.once("close",u),t.once("finish",h),t.emit("pipe",c),l.flowing||(x("pipe resume"),c.resume()),t},i.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;n>i;i++)r[i].emit("unpipe",this);return this}var i=_(e.pipes,t);return-1===i?this:(e.pipes.splice(i,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this),this)},i.prototype.on=function(t,e){var n=L.prototype.on.call(this,t,e);if("data"===t&&!1!==this._readableState.flowing&&this.resume(),"readable"===t&&this.readable){var i=this._readableState;if(!i.readableListening)if(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading)i.length&&c(this,i);else{var o=this;r.nextTick(function(){x("readable nexttick read 0"),o.read(0)})}}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var t=this._readableState;return t.flowing||(x("resume"),t.flowing=!0,t.reading||(x("resume read 0"),this.read(0)),v(this,t)),this},i.prototype.pause=function(){return x("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(x("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(t){var e=this._readableState,r=!1,n=this;t.on("end",function(){if(x("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)}),t.on("data",function(i){if(x("wrapped data"),e.decoder&&(i=e.decoder.write(i)),i&&(e.objectMode||i.length)){var o=n.push(i);o||(r=!0,t.pause())}});for(var i in t)R.isFunction(t[i])&&R.isUndefined(this[i])&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return E(o,function(e){t.on(e,n.emit.bind(n,e))}),n._read=function(e){x("wrapped _read",e),r&&(r=!1,t.resume())},n},i._fromList=w}).call(this,t("_process"))},{"./_stream_duplex":22,_process:16,buffer:4,"core-util-is":27,events:8,inherits:14,isarray:15,stream:32,"string_decoder/":33,util:3}],25:[function(t,e,r){function n(t,e){this.afterTransform=function(t,r){return i(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(t,e,r){var n=t._transformState;n.transforming=!1;var i=n.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,u.isNullOrUndefined(r)||t.push(r),i&&i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.length1){for(var r=[],n=0;n=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&56319>=n)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,n=e.charCodeAt(i);if(n>=55296&&56319>=n){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},h.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(2>=e&&r>>4==14){this.charLength=3;break}if(3>=e&&r>>3==30){this.charLength=4;break}}this.charReceived=e},h.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},{buffer:4}],34:[function(t,e,r){function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(t,e,r){if(t&&h(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return u(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)}function s(t,e){return i(t,!1,!0).resolve(e)}function a(t,e){return t?i(t,!1,!0).resolveObject(e):e}function u(t){return"string"==typeof t}function h(t){return"object"==typeof t&&null!==t}function f(t){return null===t}function c(t){return null==t}var l=t("punycode");r.parse=i,r.resolve=s,r.resolveObject=a,r.format=o,r.Url=n;var p=/^([a-z0-9.+-]+:)/i,d=/:[0-9]*$/,g=["<",">",'"',"`"," ","\r","\n"," "],v=["{","}","|","\\","^","`"].concat(g),m=["'"].concat(v),y=["%","/","?",";","#"].concat(m),w=["/","?","#"],b=255,E=/^[a-z0-9A-Z_-]{0,63}$/,_=/^([a-z0-9A-Z_-]{0,63})(.*)$/,A={javascript:!0,"javascript:":!0},S={javascript:!0,"javascript:":!0},T={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},L=t("querystring");n.prototype.parse=function(t,e,r){if(!u(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var i=p.exec(n);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var s="//"===n.substr(0,2);!s||i&&S[i]||(n=n.substr(2),this.slashes=!0)}if(!S[i]&&(s||i&&!T[i])){for(var a=-1,h=0;hf)&&(a=f)}var c,d;d=-1===a?n.lastIndexOf("@"):n.lastIndexOf("@",a),-1!==d&&(c=n.slice(0,d),n=n.slice(d+1),this.auth=decodeURIComponent(c)),a=-1;for(var h=0;hf)&&(a=f)}-1===a&&(a=n.length),this.host=n.slice(0,a),n=n.slice(a),this.parseHost(),this.hostname=this.hostname||"";var g="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!g)for(var v=this.hostname.split(/\./),h=0,R=v.length;R>h;h++){var I=v[h];if(I&&!I.match(E)){for(var x="",O=0,C=I.length;C>O;O++)x+=I.charCodeAt(O)>127?"x":I[O];if(!x.match(E)){var U=v.slice(0,h),j=v.slice(h+1),M=I.match(_);M&&(U.push(M[1]),j.unshift(M[2])),j.length&&(n="/"+j.join(".")+n),this.hostname=U.join(".");break}}}if(this.hostname=this.hostname.length>b?"":this.hostname.toLowerCase(),!g){for(var B=this.hostname.split("."),N=[],h=0;hh;h++){var q=m[h],F=encodeURIComponent(q);F===q&&(F=escape(q)),n=n.split(q).join(F)}var Y=n.indexOf("#");-1!==Y&&(this.hash=n.substr(Y),n=n.slice(0,Y));var G=n.indexOf("?");if(-1!==G?(this.search=n.substr(G),this.query=n.substr(G+1),e&&(this.query=L.parse(this.query)),n=n.slice(0,G)):e&&(this.search="",this.query={}),n&&(this.pathname=n),T[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var k=this.pathname||"",P=this.search||"";this.path=k+P}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t), +t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&h(this.query)&&Object.keys(this.query).length&&(o=L.stringify(this.query));var s=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||T[e])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),s=s.replace("#","%23"),e+i+r+s+n},n.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(u(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),T[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!T[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||S[t.protocol])r.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var o=r.pathname||"",s=r.search||"";r.path=o+s}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var a=r.pathname&&"/"===r.pathname.charAt(0),h=t.host||t.pathname&&"/"===t.pathname.charAt(0),l=h||a||r.host&&t.pathname,p=l,d=r.pathname&&r.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],g=r.protocol&&!T[r.protocol];if(g&&(r.hostname="",r.port=null,r.host&&(""===d[0]?d[0]=r.host:d.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),l=l&&(""===i[0]||""===d[0])),h)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,d=i;else if(i.length)d||(d=[]),d.pop(),d=d.concat(i),r.search=t.search,r.query=t.query;else if(!c(t.search)){if(g){r.hostname=r.host=d.shift();var v=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;v&&(r.auth=v.shift(),r.host=r.hostname=v.shift())}return r.search=t.search,r.query=t.query,f(r.pathname)&&f(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!d.length)return r.pathname=null,r.path=r.search?"/"+r.search:null,r.href=r.format(),r;for(var m=d.slice(-1)[0],y=(r.host||t.host)&&("."===m||".."===m)||""===m,w=0,b=d.length;b>=0;b--)m=d[b],"."==m?d.splice(b,1):".."===m?(d.splice(b,1),w++):w&&(d.splice(b,1),w--);if(!l&&!p)for(;w--;w)d.unshift("..");!l||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),y&&"/"!==d.join("/").substr(-1)&&d.push("");var E=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(g){r.hostname=r.host=E?"":d.length?d.shift():"";var v=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;v&&(r.auth=v.shift(),r.host=r.hostname=v.shift())}return l=l||r.host&&d.length,l&&!E&&d.unshift(""),d.length?r.pathname=d.join("/"):(r.pathname=null,r.path=null),f(r.pathname)&&f(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=d.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{punycode:17,querystring:20}],35:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],36:[function(t,e,r){(function(e,n){function i(t,e){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(e)?n.showHidden=e:e&&r._extend(n,e),E(n.showHidden)&&(n.showHidden=!1),E(n.depth)&&(n.depth=2),E(n.colors)&&(n.colors=!1),E(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function u(t,e,n){if(t.customInspect&&e&&L(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return w(i)||(i=u(t,i,n)),i}var o=h(t,e);if(o)return o;var s=Object.keys(e),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),T(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(L(e)){var v=e.name?": "+e.name:"";return t.stylize("[Function"+v+"]","special")}if(_(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(S(e))return t.stylize(Date.prototype.toString.call(e),"date");if(T(e))return f(e)}var m="",y=!1,b=["{","}"];if(d(e)&&(y=!0,b=["[","]"]),L(e)){var E=e.name?": "+e.name:"";m=" [Function"+E+"]"}if(_(e)&&(m=" "+RegExp.prototype.toString.call(e)),S(e)&&(m=" "+Date.prototype.toUTCString.call(e)),T(e)&&(m=" "+f(e)),0===s.length&&(!y||0==e.length))return b[0]+m+b[1];if(0>n)return _(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var A;return A=y?c(t,e,n,g,s):s.map(function(r){return l(t,e,n,g,r,y)}),t.seen.pop(),p(A,m,b)}function h(t,e){if(E(e))return t.stylize("undefined","undefined");if(w(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return y(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):v(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function c(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)o.push(C(e,String(s))?l(t,e,r,n,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(t,e,r,n,i,!0))}),o}function l(t,e,r,n,i,o){var s,a,h;if(h=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},h.get?a=h.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):h.set&&(a=t.stylize("[Setter]","special")),C(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(h.value)<0?(a=v(r)?u(t,h.value,null):u(t,h.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),E(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function v(t){return null===t}function m(t){return null==t}function y(t){return"number"==typeof t}function w(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function E(t){return void 0===t}function _(t){return A(t)&&"[object RegExp]"===I(t)}function A(t){return"object"==typeof t&&null!==t}function S(t){return A(t)&&"[object Date]"===I(t)}function T(t){return A(t)&&("[object Error]"===I(t)||t instanceof Error)}function L(t){return"function"==typeof t}function R(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function I(t){return Object.prototype.toString.call(t)}function x(t){return 10>t?"0"+t.toString(10):t.toString(10)}function O(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),B[t.getMonth()],e].join(" ")}function C(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var U=/%[sdj%]/g;r.format=function(t){if(!w(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=v(a)||!A(a)?" "+a:" "+i(a);return s},r.deprecate=function(t,i){function o(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}if(E(n.process))return function(){return r.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var s=!1;return o};var j,M={};r.debuglog=function(t){if(E(j)&&(j=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!M[t])if(new RegExp("\\b"+t+"\\b","i").test(j)){var n=e.pid;M[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else M[t]=function(){};return M[t]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=g,r.isNull=v,r.isNullOrUndefined=m,r.isNumber=y,r.isString=w,r.isSymbol=b,r.isUndefined=E,r.isRegExp=_,r.isObject=A,r.isDate=S,r.isError=T,r.isFunction=L,r.isPrimitive=R,r.isBuffer=t("./support/isBuffer");var B=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",O(),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!A(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":35,_process:16,inherits:14}],37:[function(t,e,r){function n(t){var e=i.parse(t.url),r="https:"===e.protocol;this.httpTransport=r?s:o,this.httpOptions={protocol:e.protocol,host:e.hostname,port:e.port||(r?443:80),withCredentials:!1,headers:{},alwaysUseGet:t.alwaysUseGet===!0},this.httpParams={},r&&(this.httpOptions.secureProtocol=t.secureProtocol||"TLSv1_method",this.httpOptions.agent=!1);var n;"internal"===t.version||"unsupported"===t.version?n="/attask/api-"+t.version:(n="/attask/api",t.version&&(n=n+"/v"+t.version)),this.httpOptions.path=n}var i=t("url"),o=t("http"),s=t("https");n.Methods={GET:"GET",PUT:"PUT",DELETE:"DELETE",POST:"POST"},t("./plugins/request")(n),t("./plugins/login")(n),t("./plugins/logout")(n),t("./plugins/search")(n),t("./plugins/get")(n),t("./plugins/create")(n),t("./plugins/edit")(n),t("./plugins/remove")(n),t("./plugins/report")(n),t("./plugins/count")(n),t("./plugins/copy")(n),t("./plugins/upload")(n),t("./plugins/execute")(n),t("./plugins/namedQuery")(n),t("./plugins/metadata")(n),t("./plugins/apiKey")(n),e.exports=n},{"./plugins/apiKey":41,"./plugins/copy":42,"./plugins/count":43,"./plugins/create":44,"./plugins/edit":45,"./plugins/execute":46,"./plugins/get":47,"./plugins/login":48,"./plugins/logout":49,"./plugins/metadata":50,"./plugins/namedQuery":51,"./plugins/remove":52,"./plugins/report":53,"./plugins/request":54,"./plugins/search":55,"./plugins/upload":56,http:9,https:13,url:34}],38:[function(t,e,r){var n={SORT:"_Sort",MOD:"_Mod",ORDERDOT:"_",FIRST:"$$FIRST",LIMIT:"$$LIMIT",DATAEXTENSION:"DE:",GROUPBY:"_GroupBy",FORCE_GROUPBY:"$$_ForceGroupBy",AGGFUNC:"_AggFunc",AGGCURRENCY_FIELDS:"$$AggCurr",GROUPCURRENCY_FIELDS:"$$GroupCurr",SORTCURRENCY_FIELDS:"$$SortCurr",FILTERCURRENCY_FIELDS:"$$FilterCurr",ROLLUP:"$$ROLLUP",INTERNAL_PREFIX:"$$",WildCards:{TODAY:"$$TODAY",NOW:"$$NOW",USER:"$$USER",CUSTOMER:"$$CUSTOMER",ACCOUNTREP:"$$AR"},SortOrder:{ASC:"asc",DESC:"desc",CIASC:"ciasc",CIDESC:"cidesc"},Operators:{LESSTHAN:"lt",LESSTHANEQUAL:"lte",GREATERTHAN:"gt",GREATERTHANEQUAL:"gte",EQUAL:"eq",CIEQUAL:"cieq",NOTEQUAL:"ne",NOTEQUALEXACT:"nee",CINOTEQUAL:"cine",CONTAINS:"contains",CICONTAINS:"cicontains",CICONTAINSANY:"cicontainsany",CICONTAINSALL:"cicontainsall",CINOTCONTAINSALL:"cinotcontainsall",CINOTCONTAINSANY:"cinotcontainsany",NOTCONTAINS:"notcontains",CINOTCONTAINS:"cinotcontains",LIKE:"like",CILIKE:"cilike",STARTSWITH:"startswith",SOUNDEX:"soundex",BETWEEN:"between",CIBETWEEN:"cibetween",NOTBETWEEN:"notbetween",CINOTBETWEEN:"cinotbetween",IN:"in",CIIN:"ciin",NOTIN:"notin",CINOTIN:"cinotin",BITWISE_OR:"bitwiseor",BITWISE_AND:"bitwiseand",BITWISE_NAND:"bitwisenand",EXACT_TIME:"exacttime",LENGTH_LT:"length_lt",LENGTH_EQ:"length_eq",LENGTH_GT:"length_gt",ALLOF:"allof",ISNULL:"isnull",NOTNULL:"notnull",ISBLANK:"isblank",NOTBLANK:"notblank"},Functions:{MAX:"max",MIN:"min",AVG:"avg",SUM:"sum",COUNT:"count",STD:"std",VAR:"var",DMAX:"dmax",DMIN:"dmin",DAVG:"davg",DSUM:"dsum",DCOUNT:"dcount",DSTD:"dstd",DVAR:"dvar"}};e.exports=n},{}],39:[function(t,e,r){var n,i=t("./Api");e.exports={getInstance:function(t,e){if(e)return new i(t);if(!n){if("object"!=typeof t)throw new Error("Please provide configuration as an object.");n=new i(t)}return n},deleteInstance:function(){n=void 0}}},{"./Api":37}],40:[function(t,e,r){e.exports={}},{}],41:[function(t,e,r){e.exports=function(t){t.prototype.getApiKey=function(t,e){var r=this;return new Promise(function(n,i){"undefined"!=typeof r.httpParams.apiKey?n(r.httpParams.apiKey):r.execute("USER",null,"getApiKey",{username:t,password:e}).then(function(t){r.httpParams.apiKey=t.result,n(r.httpParams.apiKey)},i)})},t.prototype.clearApiKey=function(){var t=this;return new Promise(function(e,r){t.execute("USER",null,"clearApiKey").then(function(n){n?(delete t.httpParams.apiKey,e()):r()})})}}},{}],42:[function(t,e,r){e.exports=function(t){t.prototype.copy=function(e,r,n,i){var o={copySourceID:r};return n&&(o.updates=JSON.stringify(n)),this.request(e,o,i,t.Methods.POST)}}},{}],43:[function(t,e,r){e.exports=function(t){t.prototype.count=function(e,r){var n=this;return new Promise(function(i,o){n.request(e+"/count",r,null,t.Methods.GET).then(function(t){i(t.count)},o)})}}},{}],44:[function(t,e,r){e.exports=function(t){t.prototype.create=function(e,r,n){return this.request(e,r,n,t.Methods.POST)}}},{}],45:[function(t,e,r){e.exports=function(t){t.prototype.edit=function(e,r,n,i){var o={updates:JSON.stringify(n)};return this.request(e+"/"+r,o,i,t.Methods.PUT)}}},{}],46:[function(t,e,r){e.exports=function(t){t.prototype.execute=function(e,r,n,i){var o=e;return r?o+="/"+r+"/"+n:(i=i||{},i.action=n),this.request(o,i,null,t.Methods.PUT)}}},{}],47:[function(t,e,r){var n=t("./../ApiConstants");e.exports=function(t){t.prototype.get=function(e,r,i){"string"==typeof r&&(r=[r]);var o=e,s=null;return 1===r.length?0===r[0].indexOf(n.INTERNAL_PREFIX)?s={id:r[0]}:o+="/"+r[0]:s={id:r},this.request(o,s,i,t.Methods.GET)}}},{"./../ApiConstants":38}],48:[function(t,e,r){e.exports=function(t){t.prototype.login=function(e,r){var n=this;return new Promise(function(i,o){n.request("login",{username:e,password:r},null,t.Methods.POST).then(function(t){n.httpOptions.headers.sessionID=t.sessionID,i(t)},o)})}}},{}],49:[function(t,e,r){e.exports=function(t){t.prototype.logout=function(){var e=this;return new Promise(function(r,n){e.request("logout",null,null,t.Methods.GET).then(function(t){t&&t.success?(delete e.httpOptions.headers.sessionID,r()):n()})})}}},{}],50:[function(t,e,r){e.exports=function(t){t.prototype.metadata=function(e){var r="/metadata";return e&&(r=e+r),this.request(r,null,null,t.Methods.GET)}}},{}],51:[function(t,e,r){e.exports=function(t){t.prototype.namedQuery=function(e,r,n,i){return this.request(e+"/"+r,n,i,t.Methods.GET)}}},{}],52:[function(t,e,r){e.exports=function(t){t.prototype.remove=function(e,r,n){var i=this;return new Promise(function(o,s){var a=n?{force:!0}:null;i.request(e+"/"+r,a,null,t.Methods.DELETE).then(function(t){t&&t.success?o():s()},s)})}}},{}],53:[function(t,e,r){e.exports=function(t){t.prototype.report=function(e,r){return this.request(e+"/report",r,null,t.Methods.GET)}}},{}],54:[function(t,e,r){var n=t("querystring"),i=t("util");e.exports=function(t){var e=function(e){return e!==t.Methods.GET&&e!==t.Methods.PUT};t.prototype.request=function(t,r,o,s){o=o||[],"string"==typeof o&&(o=[o]),r=r||{};var a={},u=this.httpOptions.alwaysUseGet;i._extend(a,this.httpOptions),u?r.method=s:a.method=s,i._extend(a,this.httpOptions),a.path=0===t.indexOf("/")?this.httpOptions.path+t:this.httpOptions.path+"/"+t,0!==o.length&&(r.fields=o.join()),r=n.stringify(r),r&&(!u&&e(a.method)?(a.headers["Content-Type"]="application/x-www-form-urlencoded",a.headers["Content-Length"]=r.length):a.path+="?"+r);var h=this.httpTransport;return new Promise(function(t,n){var i=h.request(a,function(e){var r="";"function"==typeof e.setEncoding&&e.setEncoding("utf8"),e.on("data",function(t){r+=t}),e.on("end",function(){var e;try{e=JSON.parse(r)}catch(i){return void n(r)}e.error?n(e):t(e.data)})});i.on("error",n),!u&&r&&e(a.method)&&i.write(r),i.end()})}}},{querystring:20,util:36}],55:[function(t,e,r){e.exports=function(t){t.prototype.search=function(e,r,n){return this.request(e+"/search",r,n,t.Methods.GET)}}},{}],56:[function(t,e,r){e.exports=function(t){t.prototype.upload=function(){throw new Error("Not implemented")}}},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/examples/node/always-use-get.js b/examples/node/always-use-get.js new file mode 100644 index 00000000..98a1b19b --- /dev/null +++ b/examples/node/always-use-get.js @@ -0,0 +1,51 @@ +/** + * Copyright 2015 Workfront + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Creates a project using a get request + */ +'use strict'; +var ApiFactory = require('./../../').ApiFactory; +var ApiConstants = require('./../../').ApiConstants; +var util = require('util'); + +var instance = ApiFactory.getInstance({ + url: 'http://localhost:8080', + version: 'internal', + alwaysUseGet: true +}); + +console.log('Logs in, then creates a new project with name "API Project using a GET request"\n'); +util.log('Logging in ...'); +instance.login('new@user.attask', 'user').then( + function (data) { + util.log('Creating new project using a GET request...'); + instance.create('proj', {name: 'API Project', description: 'This project has been created using API'}).then( + function (data) { + util.log('Create success. Received data:'); + console.log(util.inspect(data, {colors: true})); + }, + function (error) { + util.log('Create failure. Received data:'); + console.log(util.inspect(error, {colors: true})); + } + ); + }, + function (error) { + util.log('Login failure. Received data:'); + console.log(util.inspect(error, {colors: true})); + } +); \ No newline at end of file diff --git a/src/Api.js b/src/Api.js index 8b85d612..7e42b2cf 100644 --- a/src/Api.js +++ b/src/Api.js @@ -26,8 +26,9 @@ var url = require('url'), /** * Creates new Api instance. * @param {Object} config An object with the following keys:
- * url {String} - Required. An url to Workfront server (for example: http://localhost:8080)
+ * url {String} - Required. A url to Workfront server (for example: http://localhost:8080)
* version {String} - Optional. Which version of api to use. At the moment of writing can be 1.0, 2.0, 3.0, 4.0. Pass 'unsupported' to use Workfront latest API (maybe unstable).
+ * alwaysUseGet {Boolean} - Optional. Defaults to false. Will cause the api to make every request as a GET with params in the query string and add method=DESIRED_METHOD_TYPE in the query string. Some Workfront urls will have issues with PUT and DELETE calls if this value is false.
* secureProtocol {String} - Optional. Used only in https. The SSL method to use, e.g. TLSv1_method to force TLS version 1. The possible values depend on your installation of OpenSSL and are defined in the constant {@link http://www.openssl.org/docs/ssl/ssl.html#DEALING_WITH_PROTOCOL_METHODS|SSL_METHODS}. * @constructor * @memberOf Workfront @@ -44,7 +45,9 @@ function Api(config) { host: parsed.hostname, port: parsed.port || (isHttps ? 443 : 80), withCredentials: false, - headers: {} + headers: {}, + //=== true to make undefined result in false + alwaysUseGet : config.alwaysUseGet === true }; // These params will be sent with each request diff --git a/src/plugins/request.js b/src/plugins/request.js index 003224d6..7c99f2a4 100644 --- a/src/plugins/request.js +++ b/src/plugins/request.js @@ -34,11 +34,17 @@ module.exports = function(Api) { } params = params || {}; - util._extend(params, this.httpParams); + var options = {}, + alwaysUseGet = this.httpOptions.alwaysUseGet; + + util._extend(options, this.httpOptions); + if (alwaysUseGet) { + params.method = method; + } else { + options.method = method; + } - var options = {}; util._extend(options, this.httpOptions); - options.method = method; if (path.indexOf('/') === 0) { options.path = this.httpOptions.path + path; } @@ -52,7 +58,7 @@ module.exports = function(Api) { params = queryString.stringify(params); if (params) { - if (requestHasData(options.method)) { + if (!alwaysUseGet && requestHasData(options.method)) { options.headers['Content-Type'] = 'application/x-www-form-urlencoded'; options.headers['Content-Length'] = params.length; } @@ -89,7 +95,7 @@ module.exports = function(Api) { }); }); request.on('error', reject); - if (params && requestHasData(options.method)) { + if (!alwaysUseGet && params && requestHasData(options.method)) { request.write(params); } request.end(); diff --git a/test/plugins/request.spec.js b/test/plugins/request.spec.js index 74e0f370..f874da66 100644 --- a/test/plugins/request.spec.js +++ b/test/plugins/request.spec.js @@ -212,4 +212,23 @@ describe('Api.request() method', function() { var promise = api.request(path, params, fields, method); expect(promise).to.be.rejectedWith({'message': 'fail'}).and.notify(done); }); + + it('should only use get if alwaysUseGet is true', function(done) { + var url = 'http://foobar:8080', + path = '/test', + method = 'DELETE', + params = {force: true}; + + nock(url) + .get('/attask/api' + path + '?force=true&method=DELETE') + .reply(200, { + data: { + 'got': 'ok' + } + }); + + var api = new Api({url: url, alwaysUseGet: true}); + var promise = api.request(path, params, undefined, method); + expect(promise).to.eventually.deep.equal({'got': 'ok'}).and.notify(done); + }); }); \ No newline at end of file