diff --git a/dist/buffer.js b/dist/buffer.js index 4ef0f32..dd34e77 100644 --- a/dist/buffer.js +++ b/dist/buffer.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.FilerBuffer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) return new Buffer(arg, arguments[1]) + return new Buffer(arg) + } - var type = typeof subject + this.length = 0 + this.parent = undefined - // Find the length - var length - if (type === 'number') - length = subject > 0 ? subject >>> 0 : 0 - else if (type === 'string') { - if (encoding === 'base64') - subject = base64clean(subject) - 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 + // 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 (this.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) + } - var buf + if (object.length) return fromArrayLike(that, object) + + 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 + return that +} + +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) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) + + 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': @@ -163,8 +269,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) @@ -173,14 +279,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] @@ -190,47 +296,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 @@ -262,43 +365,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) { - if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') +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) } @@ -323,21 +467,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, 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) { @@ -345,73 +487,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, 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 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') + } + + 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 } } - 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) - } - return ret } -Buffer.prototype.toJSON = function () { +Buffer.prototype.toJSON = function toJSON () { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) @@ -448,13 +603,19 @@ function asciiSlice (buf, start, end) { end = Math.min(buf.length, end) for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) + ret += String.fromCharCode(buf[i] & 0x7F) } return ret } function binarySlice (buf, start, end) { - return asciiSlice(buf, start, end) + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret } function hexSlice (buf, start, end) { @@ -479,73 +640,99 @@ 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) { - return Buffer._augment(this.subarray(start, end)) + newBuf = Buffer._augment(this.subarray(start, end)) } else { var sliceLen = end - start - var newBuf = new Buffer(sliceLen, undefined, true) + newBuf = new Buffer(sliceLen, undefined) for (var i = 0; i < sliceLen; i++) { newBuf[i] = this[i + start] } - return newBuf } + + if (newBuf.length) newBuf.parent = this.parent || this + + return newBuf } /* * 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.readUInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, 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)) { + val += this[offset + i] * mul + } + + return val +} + +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 + } + + return val +} + +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) | @@ -553,93 +740,149 @@ 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.readInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) - return (this[offset]) +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)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +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)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +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) } function checkInt (buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new TypeError('value is out of bounds') - if (offset + ext > buf.length) throw new TypeError('index out of range') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') } -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0xff, 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) & 0xFF + } + + return offset + byteLength +} + +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) + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + 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 @@ -653,27 +896,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 } @@ -684,183 +929,233 @@ 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.writeInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0x7f, -0x80) + offset = offset | 0 + if (!noAssert) { + 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)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + 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)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + 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 } function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new TypeError('value is out of bounds') - if (offset + ext > buf.length) throw new TypeError('index out of range') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + if (offset < 0) throw new RangeError('index out of range') } 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_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 - if (target.length === 0 || source.length === 0) return + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 // Fatal error conditions - if (end < start) throw new TypeError('sourceEnd < sourceStart') - if (target_start < 0 || target_start >= target.length) - throw new TypeError('targetStart out of bounds') - if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds') - if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds') + if (targetStart < 0) { + throw new RangeError('targetStart 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 - if (end < start) throw new TypeError('end < start') + if (end < start) throw new RangeError('end < start') // Fill 0 bytes; we're done if (end === start) return if (this.length === 0) return - if (start < 0 || start >= this.length) throw new TypeError('start out of bounds') - if (end < 0 || end > this.length) throw new TypeError('end out of bounds') + if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') + if (end < 0 || end > this.length) throw new RangeError('end out of bounds') var i if (typeof value === 'number') { @@ -882,7 +1177,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 @@ -906,12 +1201,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+ @@ -924,13 +1218,18 @@ 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 + arr.readUIntBE = BP.readUIntBE arr.readUInt8 = BP.readUInt8 arr.readUInt16LE = BP.readUInt16LE arr.readUInt16BE = BP.readUInt16BE arr.readUInt32LE = BP.readUInt32LE arr.readUInt32BE = BP.readUInt32BE + arr.readIntLE = BP.readIntLE + arr.readIntBE = BP.readIntBE arr.readInt8 = BP.readInt8 arr.readInt16LE = BP.readInt16LE arr.readInt16BE = BP.readInt16BE @@ -941,10 +1240,14 @@ Buffer._augment = function (arr) { arr.readDoubleLE = BP.readDoubleLE arr.readDoubleBE = BP.readDoubleBE arr.writeUInt8 = BP.writeUInt8 + arr.writeUIntLE = BP.writeUIntLE + arr.writeUIntBE = BP.writeUIntBE arr.writeUInt16LE = BP.writeUInt16LE arr.writeUInt16BE = BP.writeUInt16BE arr.writeUInt32LE = BP.writeUInt32LE arr.writeUInt32BE = BP.writeUInt32BE + arr.writeIntLE = BP.writeIntLE + arr.writeIntBE = BP.writeIntBE arr.writeInt8 = BP.writeInt8 arr.writeInt16LE = BP.writeInt16LE arr.writeInt16BE = BP.writeInt16BE @@ -961,11 +1264,13 @@ Buffer._augment = function (arr) { return arr } -var INVALID_BASE64_RE = /[^+\/0-9A-z]/g +var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not while (str.length % 4 !== 0) { str = str + '=' @@ -978,33 +1283,90 @@ 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 (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - var b = str.charCodeAt(i) - if (b <= 0x7F) { - byteArray.push(b) - } else { - var start = i - if (b >= 0xD800 && b <= 0xDFFF) i++ - var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') - for (var j = 0; j < h.length; j++) { - byteArray.push(parseInt(h[j], 16)) +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + var i = 0 + + for (; i < length; i++) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 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 + } else { + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 + leadSurrogate = null + } + } else { + // no lead yet + + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else { + // valid lead + leadSurrogate = codePoint + continue + } } + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = null + } + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } 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) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') } } - return byteArray + + return bytes } function asciiToBytes (str) { @@ -1016,10 +1378,12 @@ function asciiToBytes (str) { return byteArray } -function utf16leToBytes (str) { +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) hi = c >> 8 lo = c % 256 @@ -1031,14 +1395,12 @@ function utf16leToBytes (str) { } function base64ToBytes (str) { - return base64.toByteArray(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 @@ -1052,7 +1414,7 @@ function decodeUtf8Char (str) { } } -},{"base64-js":2,"ieee754":3,"is-array":4}],2:[function(_dereq_,module,exports){ +},{"base64-js":2,"ieee754":3,"is-array":4}],2:[function(require,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; ;(function (exports) { @@ -1067,12 +1429,16 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var NUMBER = '0'.charCodeAt(0) var LOWER = 'a'.charCodeAt(0) var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) function decode (elt) { var code = elt.charCodeAt(0) - if (code === PLUS) + if (code === PLUS || + code === PLUS_URL_SAFE) return 62 // '+' - if (code === SLASH) + if (code === SLASH || + code === SLASH_URL_SAFE) return 63 // '/' if (code < NUMBER) return -1 //no match @@ -1174,93 +1540,93 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; exports.fromByteArray = uint8ToBase64 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) -},{}],3:[function(_dereq_,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]; +},{}],3:[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; + i += d - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); + 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); + 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 +} -},{}],4:[function(_dereq_,module,exports){ +},{}],4:[function(require,module,exports){ /** * isArray @@ -1295,7 +1661,7 @@ module.exports = isArray || function (val) { return !! val && '[object Array]' == str.call(val); }; -},{}],5:[function(_dereq_,module,exports){ +},{}],5:[function(require,module,exports){ (function (Buffer){ function FilerBuffer (subject, encoding, nonZero) { @@ -1321,7 +1687,6 @@ Object.keys(Buffer).forEach(function (p) { module.exports = FilerBuffer; -}).call(this,_dereq_("buffer").Buffer) -},{"buffer":1}]},{},[5]) -(5) +}).call(this,require("buffer").Buffer) +},{"buffer":1}]},{},[5])(5) }); \ No newline at end of file diff --git a/dist/buffer.min.js b/dist/buffer.min.js index 9e3b659..58ef6e2 100644 --- a/dist/buffer.min.js +++ b/dist/buffer.min.js @@ -1,2 +1,2 @@ -/*! filer 0.0.41 2015-06-01 */ -!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.FilerBuffer=t()}}(function(){return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var f=n[a]={exports:{}};e[a][0].call(f.exports,function(t){var n=e[a][1][t];return i(n?n:t)},f,f.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i,o=typeof t;if("number"===o)i=t>0?t>>>0:0;else if("string"===o)"base64"===e&&(t=A(t)),i=r.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&P(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}if(this.length>M)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M.toString(16)+" bytes");var a;r.TYPED_ARRAY_SUPPORT?a=r._augment(new Uint8Array(i)):(a=this,a.length=i,a._isBuffer=!0);var s;if(r.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)a._set(t);else if(T(t))if(r.isBuffer(t))for(s=0;i>s;s++)a[s]=t.readUInt8(s);else for(s=0;i>s;s++)a[s]=(t[s]%256+256)%256;else if("string"===o)a.write(t,0,e);else if("number"===o&&!r.TYPED_ARRAY_SUPPORT&&!n)for(s=0;i>s;s++)a[s]=0;return a}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;if(0!==o%2)throw Error("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;r>a;a++){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))throw Error("Invalid hex string");t[n+a]=s}return a}function o(t,e,n,r){var i=D(j(e),t,n,r);return i}function a(t,e,n,r){var i=D(S(e),t,n,r);return i}function s(t,e,n,r){return a(t,e,n,r)}function u(t,e,n,r){var i=D(x(e),t,n,r);return i}function f(t,e,n,r){var i=D(_(e),t,n,r,2);return i}function c(t,e,n){return 0===e&&n===t.length?N.fromByteArray(t):N.fromByteArray(t.slice(e,n))}function h(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)127>=t[o]?(r+=B(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+B(i)}function l(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,e,n){return l(t,e,n)}function d(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=R(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,e,n){if(0!==t%1||0>t)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function E(t,e,n,i,o,a){if(!r.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||a>e)throw new TypeError("value is out of bounds");if(n+i>t.length)throw new TypeError("index out of range")}function y(t,e,n,r){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);o>i;i++)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function m(t,e,n,r){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);o>i;i++)t[n+i]=255&e>>>8*(r?i:3-i)}function w(t,e,n,r,i,o){if(e>i||o>e)throw new TypeError("value is out of bounds");if(n+r>t.length)throw new TypeError("index out of range")}function b(t,e,n,r,i){return i||w(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),L.write(t,e,n,r,23,4),n+4}function I(t,e,n,r,i){return i||w(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),L.write(t,e,n,r,52,8),n+8}function A(t){for(t=O(t).replace(C,"");0!==t.length%4;)t+="=";return t}function O(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function T(t){return P(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function R(t){return 16>t?"0"+t.toString(16):t.toString(16)}function j(t){for(var e=[],n=0;t.length>n;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),a=0;o.length>a;a++)e.push(parseInt(o[a],16))}}return e}function S(t){for(var e=[],n=0;t.length>n;n++)e.push(255&t.charCodeAt(n));return e}function _(t){for(var e,n,r,i=[],o=0;t.length>o;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function x(t){return N.toByteArray(t)}function D(t,e,n,r,i){i&&(r-=r%i);for(var o=0;r>o&&!(o+n>=e.length||o>=t.length);o++)e[o+n]=t[o];return o}function B(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var N=t("base64-js"),L=t("ieee754"),P=t("is-array");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var M=1073741823;r.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(n){return!1}}(),r.isBuffer=function(t){return!(null==t||!t._isBuffer)},r.compare=function(t,e){if(!r.isBuffer(t)||!r.isBuffer(e))throw new TypeError("Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,a=Math.min(n,i);a>o&&t[o]===e[o];o++);return o!==a&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.isEncoding=function(t){switch((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}},r.concat=function(t,e){if(!P(t))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;t.length>n;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;t.length>n;n++){var a=t[n];a.copy(i,o),o+=a.length}return i},r.byteLength=function(t,e){var n;switch(t+="",e||"utf8"){case"ascii":case"binary":case"raw":n=t.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;case"hex":n=t.length>>>1;break;case"utf8":case"utf-8":n=j(t).length;break;case"base64":n=x(t).length;break;default:n=t.length}return n},r.prototype.length=void 0,r.prototype.parent=void 0,r.prototype.toString=function(t,e,n){var r=!1;if(e>>>=0,n=void 0===n||1/0===n?this.length:n>>>0,t||(t="utf8"),0>e&&(e=0),n>this.length&&(n=this.length),e>=n)return"";for(;;)switch(t){case"hex":return d(this,e,n);case"utf8":case"utf-8":return h(this,e,n);case"ascii":return l(this,e,n);case"binary":return p(this,e,n);case"base64":return c(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return g(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}},r.prototype.equals=function(t){if(!r.isBuffer(t))throw new TypeError("Argument must be a Buffer");return 0===r.compare(this,t)},r.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},r.prototype.compare=function(t){if(!r.isBuffer(t))throw new TypeError("Argument must be a Buffer");return r.compare(this,t)},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var c=r;r=e,e=n,n=c}e=Number(e)||0;var h=this.length-e;n?(n=Number(n),n>h&&(n=h)):n=h,r=((r||"utf8")+"").toLowerCase();var l;switch(r){case"hex":l=i(this,t,e,n);break;case"utf8":case"utf-8":l=o(this,t,e,n);break;case"ascii":l=a(this,t,e,n);break;case"binary":l=s(this,t,e,n);break;case"base64":l=u(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=f(this,t,e,n);break;default:throw new TypeError("Unknown encoding: "+r)}return l},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.slice=function(t,e){var n=this.length;if(t=~~t,e=void 0===e?n:~~e,0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),t>e&&(e=t),r.TYPED_ARRAY_SUPPORT)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,e){return e||v(t,1,this.length),this[t]},r.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8},r.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]},r.prototype.readUInt32LE=function(t,e){return e||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},r.prototype.readUInt32BE=function(t,e){return e||v(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},r.prototype.readInt8=function(t,e){return e||v(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},r.prototype.readInt16LE=function(t,e){e||v(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt16BE=function(t,e){e||v(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt32LE=function(t,e){return e||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},r.prototype.readInt32BE=function(t,e){return e||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},r.prototype.readFloatLE=function(t,e){return e||v(t,4,this.length),L.read(this,t,!0,23,4)},r.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),L.read(this,t,!1,23,4)},r.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),L.read(this,t,!0,52,8)},r.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),L.read(this,t,!1,52,8)},r.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,1,255,0),r.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},r.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):y(this,t,e,!0),e+2},r.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):y(this,t,e,!1),e+2},r.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):m(this,t,e,!0),e+4},r.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):m(this,t,e,!1),e+4},r.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,1,127,-128),r.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},r.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):y(this,t,e,!0),e+2},r.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):y(this,t,e,!1),e+2},r.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,4,2147483647,-2147483648),r.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):m(this,t,e,!0),e+4},r.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||E(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):m(this,t,e,!1),e+4},r.prototype.writeFloatLE=function(t,e,n){return b(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return b(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.copy=function(t,e,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),e||(e=0),i!==n&&0!==t.length&&0!==o.length){if(n>i)throw new TypeError("sourceEnd < sourceStart");if(0>e||e>=t.length)throw new TypeError("targetStart out of bounds");if(0>n||n>=o.length)throw new TypeError("sourceStart out of bounds");if(0>i||i>o.length)throw new TypeError("sourceEnd out of bounds");i>this.length&&(i=this.length),i-n>t.length-e&&(i=t.length-e+n);var a=i-n;if(1e3>a||!r.TYPED_ARRAY_SUPPORT)for(var s=0;a>s;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+a),e)}},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),e>n)throw new TypeError("end < start");if(n!==e&&0!==this.length){if(0>e||e>=this.length)throw new TypeError("start out of bounds");if(0>n||n>this.length)throw new TypeError("end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=j(""+t),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r.TYPED_ARRAY_SUPPORT)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var U=r.prototype;r._augment=function(t){return t.constructor=r,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=U.get,t.set=U.set,t.write=U.write,t.toString=U.toString,t.toLocaleString=U.toString,t.toJSON=U.toJSON,t.equals=U.equals,t.compare=U.compare,t.copy=U.copy,t.slice=U.slice,t.readUInt8=U.readUInt8,t.readUInt16LE=U.readUInt16LE,t.readUInt16BE=U.readUInt16BE,t.readUInt32LE=U.readUInt32LE,t.readUInt32BE=U.readUInt32BE,t.readInt8=U.readInt8,t.readInt16LE=U.readInt16LE,t.readInt16BE=U.readInt16BE,t.readInt32LE=U.readInt32LE,t.readInt32BE=U.readInt32BE,t.readFloatLE=U.readFloatLE,t.readFloatBE=U.readFloatBE,t.readDoubleLE=U.readDoubleLE,t.readDoubleBE=U.readDoubleBE,t.writeUInt8=U.writeUInt8,t.writeUInt16LE=U.writeUInt16LE,t.writeUInt16BE=U.writeUInt16BE,t.writeUInt32LE=U.writeUInt32LE,t.writeUInt32BE=U.writeUInt32BE,t.writeInt8=U.writeInt8,t.writeInt16LE=U.writeInt16LE,t.writeInt16BE=U.writeInt16BE,t.writeInt32LE=U.writeInt32LE,t.writeInt32BE=U.writeInt32BE,t.writeFloatLE=U.writeFloatLE,t.writeFloatBE=U.writeFloatBE,t.writeDoubleLE=U.writeDoubleLE,t.writeDoubleBE=U.writeDoubleBE,t.fill=U.fill,t.inspect=U.inspect,t.toArrayBuffer=U.toArrayBuffer,t};var C=/[^+\/0-9A-z]/g},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===a?62:e===s?63:u>e?-1:u+10>e?e-u+26+26:c+26>e?e-c:f+26>e?e-f+26:void 0}function n(t){function n(t){f[h++]=t}var r,i,a,s,u,f;if(t.length%4>0)throw 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,f=new o(3*t.length/4-u),a=u>0?t.length-4:t.length;var h=0;for(r=0,i=0;a>r;r+=4,i+=3)s=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&s)>>16),n((65280&s)>>8),n(255&s);return 2===u?(s=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&s)):1===u&&(s=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(255&s>>8),n(255&s)),f}function i(t){function e(t){return r.charAt(t)}function n(t){return e(63&t>>18)+e(63&t>>12)+e(63&t>>6)+e(63&t)}var i,o,a,s=t.length%3,u="";for(i=0,a=t.length-s;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=n(o);switch(s){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(63&o<<4),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(63&o>>4),u+=e(63&o<<2),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),s="/".charCodeAt(0),u="0".charCodeAt(0),f="a".charCodeAt(0),c="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i})(n===void 0?this.base64js={}:n)},{}],3:[function(t,e,n){n.read=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,c=-7,h=n?i-1:0,l=n?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-c)-1,p>>=-c,c+=s;c>0;o=256*o+t[e+h],h+=l,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[e+h],h+=l,c-=8);if(0===o)o=1-f;else{if(o===u)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=f}return(p?-1:1)*a*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),1>e*(u=Math.pow(2,-a))&&(a--,u*=2),e+=a+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(a++,u/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&s,p+=d,s/=256,i-=8);for(a=a<0;t[n+p]=255&a,p+=d,a/=256,f-=8);t[n+p-d]|=128*g}},{}],4:[function(t,e){var n=Array.isArray,r=Object.prototype.toString;e.exports=n||function(t){return!!t&&"[object Array]"==r.call(t)}},{}],5:[function(t,e){(function(t){function n(e,n,r){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),new t(e,n,r)}n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.keys(t).forEach(function(e){t.hasOwnProperty(e)&&(n[e]=t[e])}),e.exports=n}).call(this,t("buffer").Buffer)},{buffer:1}]},{},[5])(5)}); \ No newline at end of file +/*! filer 0.0.41 2015-06-29 */ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.FilerBuffer=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g1?arguments[1]:"utf8"):g(this,a)):arguments.length>1?new d(a,arguments[1]):new d(a)}function e(a,b){if(a=m(a,0>b?0:0|n(b)),!d.TYPED_ARRAY_SUPPORT)for(var c=0;b>c;c++)a[c]=0;return a}function f(a,b,c){("string"!=typeof c||""===c)&&(c="utf8");var d=0|p(b,c);return a=m(a,d),a.write(b,c),a}function g(a,b){if(d.isBuffer(b))return h(a,b);if(U(b))return i(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");return"undefined"!=typeof ArrayBuffer&&b.buffer instanceof ArrayBuffer?j(a,b):b.length?k(a,b):l(a,b)}function h(a,b){var c=0|n(b.length);return a=m(a,c),b.copy(a,0,0,c),a}function i(a,b){var c=0|n(b.length);a=m(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function j(a,b){var c=0|n(b.length);a=m(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function k(a,b){var c=0|n(b.length);a=m(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function l(a,b){var c,d=0;"Buffer"===b.type&&U(b.data)&&(c=b.data,d=0|n(c.length)),a=m(a,d);for(var e=0;d>e;e+=1)a[e]=255&c[e];return a}function m(a,b){d.TYPED_ARRAY_SUPPORT?a=d._augment(new Uint8Array(b)):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=d.poolSize>>>1;return c&&(a.parent=W),a}function n(a){if(a>=V)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+V.toString(16)+" bytes");return 0|a}function o(a,b){if(!(this instanceof o))return new o(a,b);var c=new d(a,b);return delete c.parent,c}function p(a,b){if("string"!=typeof a&&(a=String(a)),0===a.length)return 0;switch(b||"utf8"){case"ascii":case"binary":case"raw":return a.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a.length;case"hex":return a.length>>>1;case"utf8":case"utf-8":return M(a).length;case"base64":return P(a).length;default:return a.length}}function q(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function r(a,b,c,d){return Q(M(b,a.length-c),a,c,d)}function s(a,b,c,d){return Q(N(b),a,c,d)}function t(a,b,c,d){return s(a,b,c,d)}function u(a,b,c,d){return Q(P(b),a,c,d)}function v(a,b,c,d){return Q(O(b,a.length-c),a,c,d)}function w(a,b,c){return 0===b&&c===a.length?S.fromByteArray(a):S.fromByteArray(a.slice(b,c))}function x(a,b,c){var d="",e="";c=Math.min(a.length,c);for(var f=b;c>f;f++)a[f]<=127?(d+=R(e)+String.fromCharCode(a[f]),e=""):e+="%"+a[f].toString(16);return d+R(e)}function y(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(127&a[e]);return d}function z(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function A(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=L(a[f]);return e}function B(a,b,c){for(var d=a.slice(b,c),e="",f=0;fa)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function D(a,b,c,e,f,g){if(!d.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>f||g>b)throw new RangeError("value is out of bounds");if(c+e>a.length)throw new RangeError("index out of range")}function E(a,b,c,d){0>b&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);f>e;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function F(a,b,c,d){0>b&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);f>e;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function G(a,b,c,d,e,f){if(b>e||f>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(0>c)throw new RangeError("index out of range")}function H(a,b,c,d,e){return e||G(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),T.write(a,b,c,d,23,4),c+4}function I(a,b,c,d,e){return e||G(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),T.write(a,b,c,d,52,8),c+8}function J(a){if(a=K(a).replace(Y,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function K(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function L(a){return 16>a?"0"+a.toString(16):a.toString(16)}function M(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;d>g;g++){if(c=a.charCodeAt(g),c>55295&&57344>c){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(56320>c){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=e-55296<<10|c-56320|65536,e=null}else e&&((b-=3)>-1&&f.push(239,191,189),e=null);if(128>c){if((b-=1)<0)break;f.push(c)}else if(2048>c){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(65536>c){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(2097152>c))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function N(a){for(var b=[],c=0;c>8,e=c%256,f.push(e),f.push(d);return f}function P(a){return S.toByteArray(J(a))}function Q(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function R(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}var S=a("base64-js"),T=a("ieee754"),U=a("is-array");c.Buffer=d,c.SlowBuffer=o,c.INSPECT_MAX_BYTES=50,d.poolSize=8192;var V=1073741823,W={};d.TYPED_ARRAY_SUPPORT=function(){try{var a=new ArrayBuffer(0),b=new Uint8Array(a);return b.foo=function(){return 42},42===b.foo()&&"function"==typeof b.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(c){return!1}}(),d.isBuffer=function(a){return!(null==a||!a._isBuffer)},d.compare=function(a,b){if(!d.isBuffer(a)||!d.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,e=b.length,f=0,g=Math.min(c,e);g>f&&a[f]===b[f];)++f;return f!==g&&(c=a[f],e=b[f]),e>c?-1:c>e?1:0},d.isEncoding=function(a){switch(String(a).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}},d.concat=function(a,b){if(!U(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new d(0);if(1===a.length)return a[0];var c;if(void 0===b)for(b=0,c=0;cb&&(b=0),c>this.length&&(c=this.length),b>=c)return"";for(;;)switch(a){case"hex":return A(this,b,c);case"utf8":case"utf-8":return x(this,b,c);case"ascii":return y(this,b,c);case"binary":return z(this,b,c);case"base64":return w(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}},d.prototype.equals=function(a){if(!d.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:0===d.compare(this,a)},d.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),""},d.prototype.compare=function(a){if(!d.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:d.compare(this,a)},d.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e2147483647?b=2147483647:-2147483648>b&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(0>b&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(d.isBuffer(a))return c(this,a,b);if("number"==typeof a)return d.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},d.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},d.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},d.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(0>c||0>b)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return q(this,a,b,c);case"utf8":case"utf-8":return r(this,a,b,c);case"ascii":return s(this,a,b,c);case"binary":return t(this,a,b,c);case"base64":return u(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a);var e;if(d.TYPED_ARRAY_SUPPORT)e=d._augment(this.subarray(a,b));else{var f=b-a;e=new d(f,void 0);for(var g=0;f>g;g++)e[g]=this[g+a]}return e.length&&(e.parent=this.parent||this),e},d.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||C(a,b,this.length);for(var d=this[a],e=1,f=0;++f0&&(e*=256);)d+=this[a+--b]*e;return d},d.prototype.readUInt8=function(a,b){return b||C(a,1,this.length),this[a]},d.prototype.readUInt16LE=function(a,b){return b||C(a,2,this.length),this[a]|this[a+1]<<8},d.prototype.readUInt16BE=function(a,b){return b||C(a,2,this.length),this[a]<<8|this[a+1]},d.prototype.readUInt32LE=function(a,b){return b||C(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},d.prototype.readUInt32BE=function(a,b){return b||C(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},d.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||C(a,b,this.length);for(var d=this[a],e=1,f=0;++f=e&&(d-=Math.pow(2,8*b)),d},d.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||C(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},d.prototype.readInt8=function(a,b){return b||C(a,1,this.length),128&this[a]?-1*(255-this[a]+1):this[a]},d.prototype.readInt16LE=function(a,b){b||C(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},d.prototype.readInt16BE=function(a,b){b||C(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},d.prototype.readInt32LE=function(a,b){return b||C(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},d.prototype.readInt32BE=function(a,b){return b||C(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},d.prototype.readFloatLE=function(a,b){return b||C(a,4,this.length),T.read(this,a,!0,23,4)},d.prototype.readFloatBE=function(a,b){return b||C(a,4,this.length),T.read(this,a,!1,23,4)},d.prototype.readDoubleLE=function(a,b){return b||C(a,8,this.length),T.read(this,a,!0,52,8)},d.prototype.readDoubleBE=function(a,b){return b||C(a,8,this.length),T.read(this,a,!1,52,8)},d.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||D(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f=0&&(f*=256);)this[b+e]=a/f&255;return b+c},d.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,1,255,0),d.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=a,b+1},d.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8):E(this,a,b,!0),b+2},d.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=a):E(this,a,b,!1),b+2},d.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=a):F(this,a,b,!0),b+4},d.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=a):F(this,a,b,!1),b+4},d.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);D(this,a,b,c,e-1,-e)}var f=0,g=1,h=0>a?1:0;for(this[b]=255&a;++f>0)-h&255;return b+c},d.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);D(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=0>a?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},d.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,1,127,-128),d.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),0>a&&(a=255+a+1),this[b]=a,b+1},d.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8):E(this,a,b,!0),b+2},d.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=a):E(this,a,b,!1),b+2},d.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,2147483647,-2147483648),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):F(this,a,b,!0),b+4},d.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,2147483647,-2147483648),0>a&&(a=4294967295+a+1),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=a):F(this,a,b,!1),b+4},d.prototype.writeFloatLE=function(a,b,c){return H(this,a,b,!0,c)},d.prototype.writeFloatBE=function(a,b,c){return H(this,a,b,!1,c)},d.prototype.writeDoubleLE=function(a,b,c){return I(this,a,b,!0,c)},d.prototype.writeDoubleBE=function(a,b,c){return I(this,a,b,!1,c)},d.prototype.copy=function(a,b,c,e){if(c||(c=0),e||0===e||(e=this.length),b>=a.length&&(b=a.length),b||(b=0),e>0&&c>e&&(e=c),e===c)return 0;if(0===a.length||0===this.length)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>c||c>=this.length)throw new RangeError("sourceStart out of bounds");if(0>e)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),a.length-bf||!d.TYPED_ARRAY_SUPPORT)for(var g=0;f>g;g++)a[g+b]=this[g+c];else a._set(this.subarray(c,c+f),b);return f},d.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),b>c)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(0>b||b>=this.length)throw new RangeError("start out of bounds");if(0>c||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=M(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},d.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(d.TYPED_ARRAY_SUPPORT)return new d(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var X=d.prototype;d._augment=function(a){return a.constructor=d,a._isBuffer=!0,a._set=a.set,a.get=X.get,a.set=X.set,a.write=X.write,a.toString=X.toString,a.toLocaleString=X.toString,a.toJSON=X.toJSON,a.equals=X.equals,a.compare=X.compare,a.indexOf=X.indexOf,a.copy=X.copy,a.slice=X.slice,a.readUIntLE=X.readUIntLE,a.readUIntBE=X.readUIntBE,a.readUInt8=X.readUInt8,a.readUInt16LE=X.readUInt16LE,a.readUInt16BE=X.readUInt16BE,a.readUInt32LE=X.readUInt32LE,a.readUInt32BE=X.readUInt32BE,a.readIntLE=X.readIntLE,a.readIntBE=X.readIntBE,a.readInt8=X.readInt8,a.readInt16LE=X.readInt16LE,a.readInt16BE=X.readInt16BE,a.readInt32LE=X.readInt32LE,a.readInt32BE=X.readInt32BE,a.readFloatLE=X.readFloatLE,a.readFloatBE=X.readFloatBE,a.readDoubleLE=X.readDoubleLE,a.readDoubleBE=X.readDoubleBE,a.writeUInt8=X.writeUInt8,a.writeUIntLE=X.writeUIntLE,a.writeUIntBE=X.writeUIntBE,a.writeUInt16LE=X.writeUInt16LE,a.writeUInt16BE=X.writeUInt16BE,a.writeUInt32LE=X.writeUInt32LE,a.writeUInt32BE=X.writeUInt32BE,a.writeIntLE=X.writeIntLE,a.writeIntBE=X.writeIntBE,a.writeInt8=X.writeInt8,a.writeInt16LE=X.writeInt16LE,a.writeInt16BE=X.writeInt16BE,a.writeInt32LE=X.writeInt32LE,a.writeInt32BE=X.writeInt32BE,a.writeFloatLE=X.writeFloatLE,a.writeFloatBE=X.writeFloatBE,a.writeDoubleLE=X.writeDoubleLE,a.writeDoubleBE=X.writeDoubleBE,a.fill=X.fill,a.inspect=X.inspect,a.toArrayBuffer=X.toArrayBuffer,a};var Y=/[^+\/0-9A-z\-]/g},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],3:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],4:[function(a,b,c){var d=Array.isArray,e=Object.prototype.toString;b.exports=d||function(a){return!!a&&"[object Array]"==e.call(a)}},{}],5:[function(a,b,c){(function(a){function c(b,c,d){return b instanceof ArrayBuffer&&(b=new Uint8Array(b)),new a(b,c,d)}c.prototype=Object.create(a.prototype),c.prototype.constructor=c,Object.keys(a).forEach(function(b){a.hasOwnProperty(b)&&(c[b]=a[b])}),b.exports=c}).call(this,a("buffer").Buffer)},{buffer:1}]},{},[5])(5)}); \ No newline at end of file diff --git a/dist/filer.js b/dist/filer.js index 227bc45..0b3af93 100644 --- a/dist/filer.js +++ b/dist/filer.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Filer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) return new Buffer(arg, arguments[1]) + return new Buffer(arg) + } - var type = typeof subject + this.length = 0 + this.parent = undefined - // Find the length - var length - if (type === 'number') - length = subject > 0 ? subject >>> 0 : 0 - else if (type === 'string') { - if (encoding === 'base64') - subject = base64clean(subject) - 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 + // 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 (this.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) + } - var buf + if (object.length) return fromArrayLike(that, object) + + 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 + return that +} + +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) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) + + 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': @@ -805,8 +911,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) @@ -815,14 +921,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] @@ -832,47 +938,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 @@ -904,43 +1007,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) { - if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') +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) } @@ -965,21 +1109,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, 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) { @@ -987,73 +1129,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, 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 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') + } + + 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 } } - 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) - } - return ret } -Buffer.prototype.toJSON = function () { +Buffer.prototype.toJSON = function toJSON () { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) @@ -1090,13 +1245,19 @@ function asciiSlice (buf, start, end) { end = Math.min(buf.length, end) for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) + ret += String.fromCharCode(buf[i] & 0x7F) } return ret } function binarySlice (buf, start, end) { - return asciiSlice(buf, start, end) + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret } function hexSlice (buf, start, end) { @@ -1121,73 +1282,99 @@ 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) { - return Buffer._augment(this.subarray(start, end)) + newBuf = Buffer._augment(this.subarray(start, end)) } else { var sliceLen = end - start - var newBuf = new Buffer(sliceLen, undefined, true) + newBuf = new Buffer(sliceLen, undefined) for (var i = 0; i < sliceLen; i++) { newBuf[i] = this[i + start] } - return newBuf } + + if (newBuf.length) newBuf.parent = this.parent || this + + return newBuf } /* * 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.readUInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, 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)) { + val += this[offset + i] * mul + } + + return val +} + +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 + } + + return val +} + +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) | @@ -1195,93 +1382,149 @@ 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.readInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) - return (this[offset]) +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)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +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)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +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) } function checkInt (buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new TypeError('value is out of bounds') - if (offset + ext > buf.length) throw new TypeError('index out of range') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') } -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0xff, 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) & 0xFF + } + + return offset + byteLength +} + +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) + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + 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 @@ -1295,27 +1538,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 } @@ -1326,183 +1571,233 @@ 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.writeInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0x7f, -0x80) + offset = offset | 0 + if (!noAssert) { + 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)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + 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)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + 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 } function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new TypeError('value is out of bounds') - if (offset + ext > buf.length) throw new TypeError('index out of range') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + if (offset < 0) throw new RangeError('index out of range') } 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_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 - if (target.length === 0 || source.length === 0) return + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 // Fatal error conditions - if (end < start) throw new TypeError('sourceEnd < sourceStart') - if (target_start < 0 || target_start >= target.length) - throw new TypeError('targetStart out of bounds') - if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds') - if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds') + if (targetStart < 0) { + throw new RangeError('targetStart 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 - if (end < start) throw new TypeError('end < start') + if (end < start) throw new RangeError('end < start') // Fill 0 bytes; we're done if (end === start) return if (this.length === 0) return - if (start < 0 || start >= this.length) throw new TypeError('start out of bounds') - if (end < 0 || end > this.length) throw new TypeError('end out of bounds') + if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') + if (end < 0 || end > this.length) throw new RangeError('end out of bounds') var i if (typeof value === 'number') { @@ -1524,7 +1819,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 @@ -1548,12 +1843,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+ @@ -1566,13 +1860,18 @@ 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 + arr.readUIntBE = BP.readUIntBE arr.readUInt8 = BP.readUInt8 arr.readUInt16LE = BP.readUInt16LE arr.readUInt16BE = BP.readUInt16BE arr.readUInt32LE = BP.readUInt32LE arr.readUInt32BE = BP.readUInt32BE + arr.readIntLE = BP.readIntLE + arr.readIntBE = BP.readIntBE arr.readInt8 = BP.readInt8 arr.readInt16LE = BP.readInt16LE arr.readInt16BE = BP.readInt16BE @@ -1583,10 +1882,14 @@ Buffer._augment = function (arr) { arr.readDoubleLE = BP.readDoubleLE arr.readDoubleBE = BP.readDoubleBE arr.writeUInt8 = BP.writeUInt8 + arr.writeUIntLE = BP.writeUIntLE + arr.writeUIntBE = BP.writeUIntBE arr.writeUInt16LE = BP.writeUInt16LE arr.writeUInt16BE = BP.writeUInt16BE arr.writeUInt32LE = BP.writeUInt32LE arr.writeUInt32BE = BP.writeUInt32BE + arr.writeIntLE = BP.writeIntLE + arr.writeIntBE = BP.writeIntBE arr.writeInt8 = BP.writeInt8 arr.writeInt16LE = BP.writeInt16LE arr.writeInt16BE = BP.writeInt16BE @@ -1603,11 +1906,13 @@ Buffer._augment = function (arr) { return arr } -var INVALID_BASE64_RE = /[^+\/0-9A-z]/g +var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not while (str.length % 4 !== 0) { str = str + '=' @@ -1620,33 +1925,90 @@ 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 (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - var b = str.charCodeAt(i) - if (b <= 0x7F) { - byteArray.push(b) - } else { - var start = i - if (b >= 0xD800 && b <= 0xDFFF) i++ - var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%') - for (var j = 0; j < h.length; j++) { - byteArray.push(parseInt(h[j], 16)) +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + var i = 0 + + for (; i < length; i++) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 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 + } else { + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 + leadSurrogate = null + } + } else { + // no lead yet + + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else { + // valid lead + leadSurrogate = codePoint + continue + } } + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = null + } + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } 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) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') } } - return byteArray + + return bytes } function asciiToBytes (str) { @@ -1658,10 +2020,12 @@ function asciiToBytes (str) { return byteArray } -function utf16leToBytes (str) { +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) hi = c >> 8 lo = c % 256 @@ -1673,14 +2037,12 @@ function utf16leToBytes (str) { } function base64ToBytes (str) { - return base64.toByteArray(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 @@ -1694,7 +2056,7 @@ function decodeUtf8Char (str) { } } -},{"base64-js":7,"ieee754":8,"is-array":9}],7:[function(_dereq_,module,exports){ +},{"base64-js":7,"ieee754":8,"is-array":9}],7:[function(require,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; ;(function (exports) { @@ -1709,12 +2071,16 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var NUMBER = '0'.charCodeAt(0) var LOWER = 'a'.charCodeAt(0) var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) function decode (elt) { var code = elt.charCodeAt(0) - if (code === PLUS) + if (code === PLUS || + code === PLUS_URL_SAFE) return 62 // '+' - if (code === SLASH) + if (code === SLASH || + code === SLASH_URL_SAFE) return 63 // '/' if (code < NUMBER) return -1 //no match @@ -1816,93 +2182,93 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; exports.fromByteArray = uint8ToBase64 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) -},{}],8:[function(_dereq_,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]; +},{}],8:[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; + i += d - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); + 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); + 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 +} -},{}],9:[function(_dereq_,module,exports){ +},{}],9:[function(require,module,exports){ /** * isArray @@ -1937,7 +2303,7 @@ module.exports = isArray || function (val) { return !! val && '[object Array]' == str.call(val); }; -},{}],10:[function(_dereq_,module,exports){ +},{}],10:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -2163,40 +2529,69 @@ var substr = 'ab'.substr(-1) === 'b' } ; -},{}],11:[function(_dereq_,module,exports){ -module.exports = minimatch +},{}],11:[function(require,module,exports){ +;(function (require, exports, module, platform) { + +if (module) module.exports = minimatch +else exports.minimatch = minimatch + +if (!require) { + require = function (id) { + switch (id) { + case "sigmund": return function sigmund (obj) { + return JSON.stringify(obj) + } + case "path": return { basename: function (f) { + f = f.split(/[\/\\]/) + var e = f.pop() + if (!e) e = f.pop() + return e + }} + case "lru-cache": return function LRUCache () { + // not quite an LRU, but still space-limited. + var cache = {} + var cnt = 0 + this.set = function (k, v) { + cnt ++ + if (cnt >= 100) cache = {} + cache[k] = v + } + this.get = function (k) { return cache[k] } + } + } + } +} + minimatch.Minimatch = Minimatch -var path = { sep: '/' } -try { - path = _dereq_('path') -} catch (er) {} +var LRU = require("lru-cache") + , cache = minimatch.cache = new LRU({max: 100}) + , GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} + , sigmund = require("sigmund") -var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} -var expand = _dereq_('brace-expansion') +var path = require("path") + // any single thing other than / + // don't need to escape / when using new RegExp() + , qmark = "[^/]" -// any single thing other than / -// don't need to escape / when using new RegExp() -var qmark = '[^/]' + // * => any number of characters + , star = qmark + "*?" -// * => any number of characters -var star = qmark + '*?' + // ** when dots are allowed. Anything goes, except .. and . + // not (^ or / followed by one or two dots followed by $ or /), + // followed by anything, any number of times. + , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" -// ** when dots are allowed. Anything goes, except .. and . -// not (^ or / followed by one or two dots followed by $ or /), -// followed by anything, any number of times. -var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' + // not a ^ or / followed by a dot, + // followed by anything, any number of times. + , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" -// not a ^ or / followed by a dot, -// followed by anything, any number of times. -var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' - -// characters that need to be escaped in RegExp. -var reSpecials = charSet('().*{}+?[]^$\\!') + // characters that need to be escaped in RegExp. + , reSpecials = charSet("().*{}+?[]^$\\!") // "abc" -> { a:true, b:true, c:true } function charSet (s) { - return s.split('').reduce(function (set, c) { + return s.split("").reduce(function (set, c) { set[c] = true return set }, {}) @@ -2247,41 +2642,51 @@ Minimatch.defaults = function (def) { return minimatch.defaults(def).Minimatch } + function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') + if (typeof pattern !== "string") { + throw new TypeError("glob pattern string required") } if (!options) options = {} // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { + if (!options.nocomment && pattern.charAt(0) === "#") { return false } // "" only matches "" - if (pattern.trim() === '') return p === '' + if (pattern.trim() === "") return p === "" return new Minimatch(pattern, options).match(p) } function Minimatch (pattern, options) { if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options) + return new Minimatch(pattern, options, cache) } - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') + if (typeof pattern !== "string") { + throw new TypeError("glob pattern string required") } if (!options) options = {} pattern = pattern.trim() - // windows support: need to use /, not \ - if (path.sep !== '/') { - pattern = pattern.split(path.sep).join('/') + // windows: need to use /, not \ + // On other platforms, \ is a valid (albeit bad) filename char. + if (platform === "win32") { + pattern = pattern.split("\\").join("/") } + // lru storage. + // these things aren't particularly big, but walking down the string + // and turning it into a regexp can get pretty costly. + var cacheKey = pattern + "\n" + sigmund(options) + var cached = minimatch.cache.get(cacheKey) + if (cached) return cached + minimatch.cache.set(cacheKey, this) + this.options = options this.set = [] this.pattern = pattern @@ -2294,7 +2699,7 @@ function Minimatch (pattern, options) { this.make() } -Minimatch.prototype.debug = function () {} +Minimatch.prototype.debug = function() {} Minimatch.prototype.make = make function make () { @@ -2305,7 +2710,7 @@ function make () { var options = this.options // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { + if (!options.nocomment && pattern.charAt(0) === "#") { this.comment = true return } @@ -2344,7 +2749,7 @@ function make () { // filter out everything that didn't compile properly. set = set.filter(function (s) { - return s.indexOf(false) === -1 + return -1 === s.indexOf(false) }) this.debug(this.pattern, set) @@ -2355,17 +2760,17 @@ function make () { Minimatch.prototype.parseNegate = parseNegate function parseNegate () { var pattern = this.pattern - var negate = false - var options = this.options - var negateOffset = 0 + , negate = false + , options = this.options + , negateOffset = 0 if (options.nonegate) return - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { + for ( var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === "!" + ; i ++) { negate = !negate - negateOffset++ + negateOffset ++ } if (negateOffset) this.pattern = pattern.substr(negateOffset) @@ -2383,34 +2788,213 @@ function parseNegate () { // a{2..}b -> a{2..}b // a{b}c -> a{b}c minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) + return new Minimatch(pattern, options).braceExpand() } Minimatch.prototype.braceExpand = braceExpand -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options - } else { - options = {} - } - } +function pad(n, width, z) { + z = z || '0'; + n = n + ''; + return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; +} - pattern = typeof pattern === 'undefined' +function braceExpand (pattern, options) { + options = options || this.options + pattern = typeof pattern === "undefined" ? this.pattern : pattern - if (typeof pattern === 'undefined') { - throw new Error('undefined pattern') + if (typeof pattern === "undefined") { + throw new Error("undefined pattern") } if (options.nobrace || - !pattern.match(/\{.*\}/)) { + !pattern.match(/\{.*\}/)) { // shortcut. no need to expand. return [pattern] } - return expand(pattern) + var escaping = false + + // examples and comments refer to this crazy pattern: + // a{b,c{d,e},{f,g}h}x{y,z} + // expected: + // abxy + // abxz + // acdxy + // acdxz + // acexy + // acexz + // afhxy + // afhxz + // aghxy + // aghxz + + // everything before the first \{ is just a prefix. + // So, we pluck that off, and work with the rest, + // and then prepend it to everything we find. + if (pattern.charAt(0) !== "{") { + this.debug(pattern) + var prefix = null + for (var i = 0, l = pattern.length; i < l; i ++) { + var c = pattern.charAt(i) + this.debug(i, c) + if (c === "\\") { + escaping = !escaping + } else if (c === "{" && !escaping) { + prefix = pattern.substr(0, i) + break + } + } + + // actually no sets, all { were escaped. + if (prefix === null) { + this.debug("no sets") + return [pattern] + } + + var tail = braceExpand.call(this, pattern.substr(i), options) + return tail.map(function (t) { + return prefix + t + }) + } + + // now we have something like: + // {b,c{d,e},{f,g}h}x{y,z} + // walk through the set, expanding each part, until + // the set ends. then, we'll expand the suffix. + // If the set only has a single member, then'll put the {} back + + // first, handle numeric sets, since they're easier + var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/) + if (numset) { + this.debug("numset", numset[1], numset[2]) + var suf = braceExpand.call(this, pattern.substr(numset[0].length), options) + , start = +numset[1] + , needPadding = numset[1][0] === '0' + , startWidth = numset[1].length + , padded + , end = +numset[2] + , inc = start > end ? -1 : 1 + , set = [] + + for (var i = start; i != (end + inc); i += inc) { + padded = needPadding ? pad(i, startWidth) : i + '' + // append all the suffixes + for (var ii = 0, ll = suf.length; ii < ll; ii ++) { + set.push(padded + suf[ii]) + } + } + return set + } + + // ok, walk through the set + // We hope, somewhat optimistically, that there + // will be a } at the end. + // If the closing brace isn't found, then the pattern is + // interpreted as braceExpand("\\" + pattern) so that + // the leading \{ will be interpreted literally. + var i = 1 // skip the \{ + , depth = 1 + , set = [] + , member = "" + , sawEnd = false + , escaping = false + + function addMember () { + set.push(member) + member = "" + } + + this.debug("Entering for") + FOR: for (i = 1, l = pattern.length; i < l; i ++) { + var c = pattern.charAt(i) + this.debug("", i, c) + + if (escaping) { + escaping = false + member += "\\" + c + } else { + switch (c) { + case "\\": + escaping = true + continue + + case "{": + depth ++ + member += "{" + continue + + case "}": + depth -- + // if this closes the actual set, then we're done + if (depth === 0) { + addMember() + // pluck off the close-brace + i ++ + break FOR + } else { + member += c + continue + } + + case ",": + if (depth === 1) { + addMember() + } else { + member += c + } + continue + + default: + member += c + continue + } // switch + } // else + } // for + + // now we've either finished the set, and the suffix is + // pattern.substr(i), or we have *not* closed the set, + // and need to escape the leading brace + if (depth !== 0) { + this.debug("didn't close", pattern) + return braceExpand.call(this, "\\" + pattern, options) + } + + // x{y,z} -> ["xy", "xz"] + this.debug("set", set) + this.debug("suffix", pattern.substr(i)) + var suf = braceExpand.call(this, pattern.substr(i), options) + // ["b", "c{d,e}","{f,g}h"] -> + // [["b"], ["cd", "ce"], ["fh", "gh"]] + var addBraces = set.length === 1 + this.debug("set pre-expanded", set) + set = set.map(function (p) { + return braceExpand.call(this, p, options) + }, this) + this.debug("set expanded", set) + + + // [["b"], ["cd", "ce"], ["fh", "gh"]] -> + // ["b", "cd", "ce", "fh", "gh"] + set = set.reduce(function (l, r) { + return l.concat(r) + }) + + if (addBraces) { + set = set.map(function (s) { + return "{" + s + "}" + }) + } + + // now attach the suffixes. + var ret = [] + for (var i = 0, l = set.length; i < l; i ++) { + for (var ii = 0, ll = suf.length; ii < ll; ii ++) { + ret.push(set[i] + suf[ii]) + } + } + return ret } // parse a component of the expanded set. @@ -2430,86 +3014,87 @@ function parse (pattern, isSub) { var options = this.options // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR - if (pattern === '') return '' + if (!options.noglobstar && pattern === "**") return GLOBSTAR + if (pattern === "") return "" - var re = '' - var hasMagic = !!options.nocase - var escaping = false - // ? => one single character - var patternListStack = [] - var plType - var stateChar - var inClass = false - var reClassStart = -1 - var classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)' - var self = this + var re = "" + , hasMagic = !!options.nocase + , escaping = false + // ? => one single character + , patternListStack = [] + , plType + , stateChar + , inClass = false + , reClassStart = -1 + , classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + , patternStart = pattern.charAt(0) === "." ? "" // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" + : "(?!\\.)" + , self = this function clearStateChar () { if (stateChar) { // we had some state-tracking character // that wasn't consumed by this pass. switch (stateChar) { - case '*': + case "*": re += star hasMagic = true - break - case '?': + break + case "?": re += qmark hasMagic = true - break + break default: - re += '\\' + stateChar - break + re += "\\"+stateChar + break } self.debug('clearStateChar %j %j', stateChar, re) stateChar = false } } - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c) + for ( var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i ++ ) { + + this.debug("%s\t%s %s %j", pattern, i, re, c) // skip over any that are escaped. if (escaping && reSpecials[c]) { - re += '\\' + c + re += "\\" + c escaping = false continue } - switch (c) { - case '/': + SWITCH: switch (c) { + case "/": // completely not allowed, even escaped. // Should already be path-split by now. return false - case '\\': + case "\\": clearStateChar() escaping = true - continue + continue // the various stateChar values // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) + case "?": + case "*": + case "+": + case "@": + case "!": + this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c) // all of those are literals inside a class, except that // the glob [!a] means [^a] in regexp if (inClass) { this.debug(' in class') - if (c === '!' && i === classStart + 1) c = '^' + if (c === "!" && i === classStart + 1) c = "^" re += c continue } @@ -2524,70 +3109,70 @@ function parse (pattern, isSub) { // just clear the statechar *now*, rather than even diving into // the patternList stuff. if (options.noext) clearStateChar() - continue + continue - case '(': + case "(": if (inClass) { - re += '(' + re += "(" continue } if (!stateChar) { - re += '\\(' + re += "\\(" continue } plType = stateChar - patternListStack.push({ type: plType, start: i - 1, reStart: re.length }) + patternListStack.push({ type: plType + , start: i - 1 + , reStart: re.length }) // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!' : '(?:' + re += stateChar === "!" ? "(?:(?!" : "(?:" this.debug('plType %j %j', stateChar, re) stateChar = false - continue + continue - case ')': + case ")": if (inClass || !patternListStack.length) { - re += '\\)' + re += "\\)" continue } clearStateChar() hasMagic = true - re += ')' + re += ")" plType = patternListStack.pop().type // negation is (?:(?!js)[^/]*) // The others are (?:) switch (plType) { - case '!': - re += '[^/]*?)' + case "!": + re += "[^/]*?)" break - case '?': - case '+': - case '*': - re += plType - break - case '@': break // the default anyway + case "?": + case "+": + case "*": re += plType + case "@": break // the default anyway } - continue + continue - case '|': + case "|": if (inClass || !patternListStack.length || escaping) { - re += '\\|' + re += "\\|" escaping = false continue } clearStateChar() - re += '|' - continue + re += "|" + continue // these are mostly the same in regexp and glob - case '[': + case "[": // swallow any state-tracking char before the [ clearStateChar() if (inClass) { - re += '\\' + c + re += "\\" + c continue } @@ -2595,47 +3180,24 @@ function parse (pattern, isSub) { classStart = i reClassStart = re.length re += c - continue + continue - case ']': + case "]": // a right bracket shall lose its special // meaning and represent itself in // a bracket expression if it occurs // first in the list. -- POSIX.2 2.8.3.2 if (i === classStart + 1 || !inClass) { - re += '\\' + c + re += "\\" + c escaping = false continue } - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } - // finish up the class. hasMagic = true inClass = false re += c - continue + continue default: // swallow any state char that wasn't consumed @@ -2645,8 +3207,8 @@ function parse (pattern, isSub) { // no need escaping = false } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\' + && !(c === "^" && inClass)) { + re += "\\" } re += c @@ -2654,6 +3216,7 @@ function parse (pattern, isSub) { } // switch } // for + // handle the case where we left a class open. // "[abc" is valid, equivalent to "\[abc" if (inClass) { @@ -2661,9 +3224,9 @@ function parse (pattern, isSub) { // this is a huge pita. We now have to re-walk // the contents of the would-be class to re-translate // any characters that were passed through as-is - cs = pattern.substr(classStart + 1) - sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + var cs = pattern.substr(classStart + 1) + , sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + "\\[" + sp[0] hasMagic = hasMagic || sp[1] } @@ -2673,13 +3236,14 @@ function parse (pattern, isSub) { // and escape any | chars that were passed through as-is for the regexp. // Go through and escape them, taking care not to double-escape any // | chars that were already escaped. - for (var pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var pl + while (pl = patternListStack.pop()) { var tail = re.slice(pl.reStart + 3) // maybe some even number of \, then maybe 1 \, followed by a | tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { if (!$2) { // the | isn't already escaped, so escape it. - $2 = '\\' + $2 = "\\" } // need to escape all those slashes *again*, without escaping the @@ -2688,44 +3252,46 @@ function parse (pattern, isSub) { // it exactly after itself. That's why this trick works. // // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' + return $1 + $1 + $2 + "|" }) - this.debug('tail=%j\n %s', tail, tail) - var t = pl.type === '*' ? star - : pl.type === '?' ? qmark - : '\\' + pl.type + this.debug("tail=%j\n %s", tail, tail) + var t = pl.type === "*" ? star + : pl.type === "?" ? qmark + : "\\" + pl.type hasMagic = true - re = re.slice(0, pl.reStart) + t + '\\(' + tail + re = re.slice(0, pl.reStart) + + t + "\\(" + + tail } // handle trailing things that only matter at the very end. clearStateChar() if (escaping) { // trailing \\ - re += '\\\\' + re += "\\\\" } // only need to apply the nodot start if the re starts with // something that could conceivably capture a dot var addPatternStart = false switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true + case ".": + case "[": + case "(": addPatternStart = true } // if the re is not "" at this point, then we need to make sure // it doesn't match against an empty path part. // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) re = '(?=.)' + re + if (re !== "" && hasMagic) re = "(?=.)" + re if (addPatternStart) re = patternStart + re // parsing just a piece of a larger pattern. if (isSub === SUBPARSE) { - return [re, hasMagic] + return [ re, hasMagic ] } // skip the regexp for non-magical patterns @@ -2735,8 +3301,8 @@ function parse (pattern, isSub) { return globUnescape(pattern) } - var flags = options.nocase ? 'i' : '' - var regExp = new RegExp('^' + re + '$', flags) + var flags = options.nocase ? "i" : "" + , regExp = new RegExp("^" + re + "$", flags) regExp._glob = pattern regExp._src = re @@ -2760,38 +3326,34 @@ function makeRe () { // when you just want to work with a regex. var set = this.set - if (!set.length) { - this.regexp = false - return this.regexp - } + if (!set.length) return this.regexp = false var options = this.options var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - var flags = options.nocase ? 'i' : '' + : options.dot ? twoStarDot + : twoStarNoDot + , flags = options.nocase ? "i" : "" var re = set.map(function (pattern) { return pattern.map(function (p) { return (p === GLOBSTAR) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|') + : (typeof p === "string") ? regExpEscape(p) + : p._src + }).join("\\\/") + }).join("|") // must match entire pattern // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$' + re = "^(?:" + re + ")$" // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$' + if (this.negate) re = "^(?!" + re + ").*$" try { - this.regexp = new RegExp(re, flags) + return this.regexp = new RegExp(re, flags) } catch (ex) { - this.regexp = false + return this.regexp = false } - return this.regexp } minimatch.match = function (list, pattern, options) { @@ -2808,24 +3370,25 @@ minimatch.match = function (list, pattern, options) { Minimatch.prototype.match = match function match (f, partial) { - this.debug('match', f, this.pattern) + this.debug("match", f, this.pattern) // short-circuit in the case of busted things. // comments, etc. if (this.comment) return false - if (this.empty) return f === '' + if (this.empty) return f === "" - if (f === '/' && partial) return true + if (f === "/" && partial) return true var options = this.options // windows: need to use /, not \ - if (path.sep !== '/') { - f = f.split(path.sep).join('/') + // On other platforms, \ is a valid (albeit bad) filename char. + if (platform === "win32") { + f = f.split("\\").join("/") } // treat the test path as a set of pathparts. f = f.split(slashSplit) - this.debug(this.pattern, 'split', f) + this.debug(this.pattern, "split", f) // just ONE of the pattern sets in this.set needs to match // in order for it to be valid. If negating, then just one @@ -2833,19 +3396,17 @@ function match (f, partial) { // Either way, return on the first hit. var set = this.set - this.debug(this.pattern, 'set', set) + this.debug(this.pattern, "set", set) // Find the basename of the path by looking for the last non-empty segment - var filename - var i - for (i = f.length - 1; i >= 0; i--) { + var filename; + for (var i = f.length - 1; i >= 0; i--) { filename = f[i] if (filename) break } - for (i = 0; i < set.length; i++) { - var pattern = set[i] - var file = f + for (var i = 0, l = set.length; i < l; i ++) { + var pattern = set[i], file = f if (options.matchBase && pattern.length === 1) { file = [filename] } @@ -2870,20 +3431,23 @@ function match (f, partial) { Minimatch.prototype.matchOne = function (file, pattern, partial) { var options = this.options - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }) + this.debug("matchOne", + { "this": this + , file: file + , pattern: pattern }) - this.debug('matchOne', file.length, pattern.length) + this.debug("matchOne", file.length, pattern.length) - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length + for ( var fi = 0 + , pi = 0 + , fl = file.length + , pl = pattern.length ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop') + ; fi ++, pi ++ ) { + + this.debug("matchOne loop") var p = pattern[pi] - var f = file[fi] + , f = file[fi] this.debug(pattern, p, f) @@ -2917,7 +3481,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // - matchOne(z/c, c) -> no // - matchOne(c, c) yes, hit var fr = fi - var pr = pi + 1 + , pr = pi + 1 if (pr === pl) { this.debug('** at the end') // a ** at the end will just swallow the rest. @@ -2926,18 +3490,19 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // options.dot is set. // . and .. are *never* matched by **, for explosively // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false + for ( ; fi < fl; fi ++) { + if (file[fi] === "." || file[fi] === ".." || + (!options.dot && file[fi].charAt(0) === ".")) return false } return true } // ok, let's see if we can swallow whatever we can. - while (fr < fl) { + WHILE: while (fr < fl) { var swallowee = file[fr] - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) + this.debug('\nglobstar while', + file, fr, pattern, pr, swallowee) // XXX remove this slice. Just pass the start index. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { @@ -2947,24 +3512,23 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { } else { // can't swallow "." or ".." ever. // can only swallow ".foo" when explicitly asked. - if (swallowee === '.' || swallowee === '..' || - (!options.dot && swallowee.charAt(0) === '.')) { - this.debug('dot detected!', file, fr, pattern, pr) - break + if (swallowee === "." || swallowee === ".." || + (!options.dot && swallowee.charAt(0) === ".")) { + this.debug("dot detected!", file, fr, pattern, pr) + break WHILE } // ** swallows a segment, and continue. this.debug('globstar swallow a segment, and continue') - fr++ + fr ++ } } - // no match was found. // However, in partial mode, we can't say this is necessarily over. // If there's more *pattern* left, then if (partial) { // ran out of file - this.debug('\n>>> no match, partial?', file, fr, pattern, pr) + this.debug("\n>>> no match, partial?", file, fr, pattern, pr) if (fr === fl) return true } return false @@ -2974,16 +3538,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // non-magic patterns just have to match exactly // patterns with magic have been turned into regexps. var hit - if (typeof p === 'string') { + if (typeof p === "string") { if (options.nocase) { hit = f.toLowerCase() === p.toLowerCase() } else { hit = f === p } - this.debug('string match', p, f, hit) + this.debug("string match", p, f, hit) } else { hit = f.match(p) - this.debug('pattern match', p, f, hit) + this.debug("pattern match", p, f, hit) } if (!hit) return false @@ -3015,272 +3579,349 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // this is only acceptable if we're on the very last // empty segment of a file with a trailing slash. // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') + var emptyFileEnd = (fi === fl - 1) && (file[fi] === "") return emptyFileEnd } // should be unreachable. - throw new Error('wtf?') + throw new Error("wtf?") } + // replace stuff like \* with * function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') + return s.replace(/\\(.)/g, "$1") } + function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") } -},{"brace-expansion":12,"path":10}],12:[function(_dereq_,module,exports){ -var concatMap = _dereq_('concat-map'); -var balanced = _dereq_('balanced-match'); +})( typeof require === "function" ? require : null, + this, + typeof module === "object" ? module : null, + typeof process === "object" ? process.platform : "win32" + ) -module.exports = expandTop; +},{"lru-cache":12,"path":10,"sigmund":13}],12:[function(require,module,exports){ +;(function () { // closure for web browsers -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); +if (typeof module === 'object' && module.exports) { + module.exports = LRUCache +} else { + // just set the global for non-node platforms. + this.LRUCache = LRUCache } -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); +function hOP (obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key) } -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); +function naiveLength () { return 1 } + +function LRUCache (options) { + if (!(this instanceof LRUCache)) + return new LRUCache(options) + + if (typeof options === 'number') + options = { max: options } + + if (!options) + options = {} + + this._max = options.max + // Kind of weird to have a default max of Infinity, but oh well. + if (!this._max || !(typeof this._max === "number") || this._max <= 0 ) + this._max = Infinity + + this._lengthCalculator = options.length || naiveLength + if (typeof this._lengthCalculator !== "function") + this._lengthCalculator = naiveLength + + this._allowStale = options.stale || false + this._maxAge = options.maxAge || null + this._dispose = options.dispose + this.reset() } - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - return expand(escapeBraces(str), true).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str, isTop) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = /^(.*,)+(.+)?$/.test(m.body); - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); +// resize the cache when the max changes. +Object.defineProperty(LRUCache.prototype, "max", + { set : function (mL) { + if (!mL || !(typeof mL === "number") || mL <= 0 ) mL = Infinity + this._max = mL + if (this._length > this._max) trim(this) } - return [str]; - } + , get : function () { return this._max } + , enumerable : true + }) - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; +// resize the cache when the lengthCalculator changes. +Object.defineProperty(LRUCache.prototype, "lengthCalculator", + { set : function (lC) { + if (typeof lC !== "function") { + this._lengthCalculator = naiveLength + this._length = this._itemCount + for (var key in this._cache) { + this._cache[key].length = 1 + } } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } + this._lengthCalculator = lC + this._length = 0 + for (var key in this._cache) { + this._cache[key].length = this._lengthCalculator(this._cache[key].value) + this._length += this._cache[key].length } } - N.push(c); + + if (this._length > this._max) trim(this) } + , get : function () { return this._lengthCalculator } + , enumerable : true + }) + +Object.defineProperty(LRUCache.prototype, "length", + { get : function () { return this._length } + , enumerable : true + }) + + +Object.defineProperty(LRUCache.prototype, "itemCount", + { get : function () { return this._itemCount } + , enumerable : true + }) + +LRUCache.prototype.forEach = function (fn, thisp) { + thisp = thisp || this + var i = 0 + var itemCount = this._itemCount + + for (var k = this._mru - 1; k >= 0 && i < itemCount; k--) if (this._lruList[k]) { + i++ + var hit = this._lruList[k] + if (isStale(this, hit)) { + del(this, hit) + if (!this._allowStale) hit = undefined + } + if (hit) { + fn.call(thisp, hit.value, hit.key, this) + } + } +} + +LRUCache.prototype.keys = function () { + var keys = new Array(this._itemCount) + var i = 0 + for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { + var hit = this._lruList[k] + keys[i++] = hit.key + } + return keys +} + +LRUCache.prototype.values = function () { + var values = new Array(this._itemCount) + var i = 0 + for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { + var hit = this._lruList[k] + values[i++] = hit.value + } + return values +} + +LRUCache.prototype.reset = function () { + if (this._dispose && this._cache) { + for (var k in this._cache) { + this._dispose(k, this._cache[k].value) + } + } + + this._cache = Object.create(null) // hash of items by key + this._lruList = Object.create(null) // list of items in order of use recency + this._mru = 0 // most recently used + this._lru = 0 // least recently used + this._length = 0 // number of items in the list + this._itemCount = 0 +} + +// Provided for debugging/dev purposes only. No promises whatsoever that +// this API stays stable. +LRUCache.prototype.dump = function () { + return this._cache +} + +LRUCache.prototype.dumpLru = function () { + return this._lruList +} + +LRUCache.prototype.set = function (key, value, maxAge) { + maxAge = maxAge || this._maxAge + var now = maxAge ? Date.now() : 0 + + if (hOP(this._cache, key)) { + // dispose of the old one before overwriting + if (this._dispose) + this._dispose(key, this._cache[key].value) + + this._cache[key].now = now + this._cache[key].maxAge = maxAge + this._cache[key].value = value + this.get(key) + return true + } + + var len = this._lengthCalculator(value) + var hit = new Entry(key, value, this._mru++, len, now, maxAge) + + // oversized objects fall out of cache automatically. + if (hit.length > this._max) { + if (this._dispose) this._dispose(key, value) + return false + } + + this._length += hit.length + this._lruList[hit.lu] = this._cache[key] = hit + this._itemCount ++ + + if (this._length > this._max) + trim(this) + + return true +} + +LRUCache.prototype.has = function (key) { + if (!hOP(this._cache, key)) return false + var hit = this._cache[key] + if (isStale(this, hit)) { + return false + } + return true +} + +LRUCache.prototype.get = function (key) { + return get(this, key, true) +} + +LRUCache.prototype.peek = function (key) { + return get(this, key, false) +} + +LRUCache.prototype.pop = function () { + var hit = this._lruList[this._lru] + del(this, hit) + return hit || null +} + +LRUCache.prototype.del = function (key) { + del(this, this._cache[key]) +} + +function get (self, key, doUse) { + var hit = self._cache[key] + if (hit) { + if (isStale(self, hit)) { + del(self, hit) + if (!self._allowStale) hit = undefined + } else { + if (doUse) use(self, hit) + } + if (hit) hit = hit.value + } + return hit +} + +function isStale(self, hit) { + if (!hit || (!hit.maxAge && !self._maxAge)) return false + var stale = false; + var diff = Date.now() - hit.now + if (hit.maxAge) { + stale = diff > hit.maxAge } else { - N = concatMap(n, function(el) { return expand(el, false) }); + stale = self._maxAge && (diff > self._maxAge) } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } - - return expansions; + return stale; } +function use (self, hit) { + shiftLU(self, hit) + hit.lu = self._mru ++ + self._lruList[hit.lu] = hit +} -},{"balanced-match":13,"concat-map":14}],13:[function(_dereq_,module,exports){ -module.exports = balanced; -function balanced(a, b, str) { - var bal = 0; - var m = {}; - var ended = false; +function trim (self) { + while (self._lru < self._mru && self._length > self._max) + del(self, self._lruList[self._lru]) +} - for (var i = 0; i < str.length; i++) { - if (a == str.substr(i, a.length)) { - if (!('start' in m)) m.start = i; - bal++; - } - else if (b == str.substr(i, b.length) && 'start' in m) { - ended = true; - bal--; - if (!bal) { - m.end = i; - m.pre = str.substr(0, m.start); - m.body = (m.end - m.start > 1) - ? str.substring(m.start + a.length, m.end) - : ''; - m.post = str.slice(m.end + b.length); - return m; - } - } - } +function shiftLU (self, hit) { + delete self._lruList[ hit.lu ] + while (self._lru < self._mru && !self._lruList[self._lru]) self._lru ++ +} - // if we opened more than we closed, find the one we closed - if (bal && ended) { - var start = m.start + a.length; - m = balanced(a, b, str.substr(start)); - if (m) { - m.start += start; - m.end += start; - m.pre = str.slice(0, start) + m.pre; - } - return m; +function del (self, hit) { + if (hit) { + if (self._dispose) self._dispose(hit.key, hit.value) + self._length -= hit.length + self._itemCount -- + delete self._cache[ hit.key ] + shiftLU(self, hit) } } -},{}],14:[function(_dereq_,module,exports){ -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); +// classy, since V8 prefers predictable objects. +function Entry (key, value, lu, length, now, maxAge) { + this.key = key + this.value = value + this.lu = lu + this.length = length + this.now = now + if (maxAge) this.maxAge = maxAge +} + +})() + +},{}],13:[function(require,module,exports){ +module.exports = sigmund +function sigmund (subject, maxSessions) { + maxSessions = maxSessions || 10; + var notes = []; + var analysis = ''; + var RE = RegExp; + + function psychoAnalyze (subject, session) { + if (session > maxSessions) return; + + if (typeof subject === 'function' || + typeof subject === 'undefined') { + return; + } + + if (typeof subject !== 'object' || !subject || + (subject instanceof RE)) { + analysis += subject; + return; + } + + if (notes.indexOf(subject) !== -1 || session === maxSessions) return; + + notes.push(subject); + analysis += '{'; + Object.keys(subject).forEach(function (issue, _, __) { + // pseudo-private values. skip those. + if (issue.charAt(0) === '_') return; + var to = typeof subject[issue]; + if (to === 'function' || to === 'undefined') return; + analysis += issue; + psychoAnalyze(subject[issue], session + 1); + }); } - return res; -}; + psychoAnalyze(subject, 0); + return analysis; +} -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; +// vim: set softtabstop=4 shiftwidth=4: -},{}],15:[function(_dereq_,module,exports){ +},{}],14:[function(require,module,exports){ (function (Buffer){ function FilerBuffer (subject, encoding, nonZero) { @@ -3306,8 +3947,8 @@ Object.keys(Buffer).forEach(function (p) { module.exports = FilerBuffer; -}).call(this,_dereq_("buffer").Buffer) -},{"buffer":6}],16:[function(_dereq_,module,exports){ +}).call(this,require("buffer").Buffer) +},{"buffer":6}],15:[function(require,module,exports){ var O_READ = 'READ'; var O_WRITE = 'WRITE'; var O_CREATE = 'CREATE'; @@ -3389,15 +4030,15 @@ module.exports = { } }; -},{}],17:[function(_dereq_,module,exports){ -var MODE_FILE = _dereq_('./constants.js').MODE_FILE; +},{}],16:[function(require,module,exports){ +var MODE_FILE = require('./constants.js').MODE_FILE; module.exports = function DirectoryEntry(id, type) { this.id = id; this.type = type || MODE_FILE; }; -},{"./constants.js":16}],18:[function(_dereq_,module,exports){ +},{"./constants.js":15}],17:[function(require,module,exports){ (function (Buffer){ // Adapt encodings to work with Buffer or Uint8Array, they expect the latter function decode(buf) { @@ -3413,8 +4054,8 @@ module.exports = { decode: decode }; -}).call(this,_dereq_("buffer").Buffer) -},{"buffer":6}],19:[function(_dereq_,module,exports){ +}).call(this,require("buffer").Buffer) +},{"buffer":6}],18:[function(require,module,exports){ var errors = {}; [ /** @@ -3520,17 +4161,17 @@ var errors = {}; module.exports = errors; -},{}],20:[function(_dereq_,module,exports){ -var _ = _dereq_('../../lib/nodash.js'); +},{}],19:[function(require,module,exports){ +var _ = require('../../lib/nodash.js'); -var Path = _dereq_('../path.js'); +var Path = require('../path.js'); var normalize = Path.normalize; var dirname = Path.dirname; var basename = Path.basename; var isAbsolutePath = Path.isAbsolute; var isNullPath = Path.isNull; -var Constants = _dereq_('../constants.js'); +var Constants = require('../constants.js'); var MODE_FILE = Constants.MODE_FILE; var MODE_DIRECTORY = Constants.MODE_DIRECTORY; var MODE_SYMBOLIC_LINK = Constants.MODE_SYMBOLIC_LINK; @@ -3553,14 +4194,14 @@ var XATTR_REPLACE = Constants.XATTR_REPLACE; var FS_NOMTIME = Constants.FS_NOMTIME; var FS_NOCTIME = Constants.FS_NOCTIME; -var Encoding = _dereq_('../encoding.js'); -var Errors = _dereq_('../errors.js'); -var DirectoryEntry = _dereq_('../directory-entry.js'); -var OpenFileDescription = _dereq_('../open-file-description.js'); -var SuperNode = _dereq_('../super-node.js'); -var Node = _dereq_('../node.js'); -var Stats = _dereq_('../stats.js'); -var Buffer = _dereq_('../buffer.js'); +var Encoding = require('../encoding.js'); +var Errors = require('../errors.js'); +var DirectoryEntry = require('../directory-entry.js'); +var OpenFileDescription = require('../open-file-description.js'); +var SuperNode = require('../super-node.js'); +var Node = require('../node.js'); +var Stats = require('../stats.js'); +var Buffer = require('../buffer.js'); /** * Update node times. Only passed times are modified (undefined times are ignored) @@ -5694,13 +6335,13 @@ module.exports = { ftruncate: ftruncate }; -},{"../../lib/nodash.js":4,"../buffer.js":15,"../constants.js":16,"../directory-entry.js":17,"../encoding.js":18,"../errors.js":19,"../node.js":24,"../open-file-description.js":25,"../path.js":26,"../stats.js":34,"../super-node.js":35}],21:[function(_dereq_,module,exports){ -var _ = _dereq_('../../lib/nodash.js'); +},{"../../lib/nodash.js":4,"../buffer.js":14,"../constants.js":15,"../directory-entry.js":16,"../encoding.js":17,"../errors.js":18,"../node.js":23,"../open-file-description.js":24,"../path.js":25,"../stats.js":33,"../super-node.js":34}],20:[function(require,module,exports){ +var _ = require('../../lib/nodash.js'); -var isNullPath = _dereq_('../path.js').isNull; -var nop = _dereq_('../shared.js').nop; +var isNullPath = require('../path.js').isNull; +var nop = require('../shared.js').nop; -var Constants = _dereq_('../constants.js'); +var Constants = require('../constants.js'); var FILE_SYSTEM_NAME = Constants.FILE_SYSTEM_NAME; var FS_FORMAT = Constants.FS_FORMAT; var FS_READY = Constants.FS_READY; @@ -5708,13 +6349,13 @@ var FS_PENDING = Constants.FS_PENDING; var FS_ERROR = Constants.FS_ERROR; var FS_NODUPEIDCHECK = Constants.FS_NODUPEIDCHECK; -var providers = _dereq_('../providers/index.js'); +var providers = require('../providers/index.js'); -var Shell = _dereq_('../shell/shell.js'); -var Intercom = _dereq_('../../lib/intercom.js'); -var FSWatcher = _dereq_('../fs-watcher.js'); -var Errors = _dereq_('../errors.js'); -var defaultGuidFn = _dereq_('../shared.js').guid; +var Shell = require('../shell/shell.js'); +var Intercom = require('../../lib/intercom.js'); +var FSWatcher = require('../fs-watcher.js'); +var Errors = require('../errors.js'); +var defaultGuidFn = require('../shared.js').guid; var STDIN = Constants.STDIN; var STDOUT = Constants.STDOUT; @@ -5722,7 +6363,7 @@ var STDERR = Constants.STDERR; var FIRST_DESCRIPTOR = Constants.FIRST_DESCRIPTOR; // The core fs operations live on impl -var impl = _dereq_('./implementation.js'); +var impl = require('./implementation.js'); // node.js supports a calling pattern that leaves off a callback. function maybeCallback(callback) { @@ -6043,10 +6684,10 @@ FileSystem.providers = providers; module.exports = FileSystem; -},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":16,"../errors.js":19,"../fs-watcher.js":22,"../path.js":26,"../providers/index.js":27,"../shared.js":31,"../shell/shell.js":33,"./implementation.js":20}],22:[function(_dereq_,module,exports){ -var EventEmitter = _dereq_('../lib/eventemitter.js'); -var Path = _dereq_('./path.js'); -var Intercom = _dereq_('../lib/intercom.js'); +},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":15,"../errors.js":18,"../fs-watcher.js":21,"../path.js":25,"../providers/index.js":26,"../shared.js":30,"../shell/shell.js":32,"./implementation.js":19}],21:[function(require,module,exports){ +var EventEmitter = require('../lib/eventemitter.js'); +var Path = require('./path.js'); +var Intercom = require('../lib/intercom.js'); /** * FSWatcher based on node.js' FSWatcher @@ -6107,17 +6748,17 @@ FSWatcher.prototype.constructor = FSWatcher; module.exports = FSWatcher; -},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":26}],23:[function(_dereq_,module,exports){ +},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":25}],22:[function(require,module,exports){ module.exports = { - FileSystem: _dereq_('./filesystem/interface.js'), - Buffer: _dereq_('./buffer.js'), - Path: _dereq_('./path.js'), - Errors: _dereq_('./errors.js'), - Shell: _dereq_('./shell/shell.js') + FileSystem: require('./filesystem/interface.js'), + Buffer: require('./buffer.js'), + Path: require('./path.js'), + Errors: require('./errors.js'), + Shell: require('./shell/shell.js') }; -},{"./buffer.js":15,"./errors.js":19,"./filesystem/interface.js":21,"./path.js":26,"./shell/shell.js":33}],24:[function(_dereq_,module,exports){ -var MODE_FILE = _dereq_('./constants.js').MODE_FILE; +},{"./buffer.js":14,"./errors.js":18,"./filesystem/interface.js":20,"./path.js":25,"./shell/shell.js":32}],23:[function(require,module,exports){ +var MODE_FILE = require('./constants.js').MODE_FILE; function Node(options) { var now = Date.now(); @@ -6171,8 +6812,8 @@ Node.create = function(options, callback) { module.exports = Node; -},{"./constants.js":16}],25:[function(_dereq_,module,exports){ -var Errors = _dereq_('./errors.js'); +},{"./constants.js":15}],24:[function(require,module,exports){ +var Errors = require('./errors.js'); function OpenFileDescription(path, id, flags, position) { this.path = path; @@ -6204,7 +6845,7 @@ OpenFileDescription.prototype.getNode = function(context, callback) { module.exports = OpenFileDescription; -},{"./errors.js":19}],26:[function(_dereq_,module,exports){ +},{"./errors.js":18}],25:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -6327,8 +6968,8 @@ function join() { // path.relative(from, to) function relative(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); + from = resolve(from).substr(1); + to = resolve(to).substr(1); function trim(arr) { var start = 0; @@ -6445,10 +7086,10 @@ module.exports = { removeTrailing: removeTrailing }; -},{}],27:[function(_dereq_,module,exports){ -var IndexedDB = _dereq_('./indexeddb.js'); -var WebSQL = _dereq_('./websql.js'); -var Memory = _dereq_('./memory.js'); +},{}],26:[function(require,module,exports){ +var IndexedDB = require('./indexeddb.js'); +var WebSQL = require('./websql.js'); +var Memory = require('./memory.js'); module.exports = { IndexedDB: IndexedDB, @@ -6482,14 +7123,14 @@ module.exports = { }()) }; -},{"./indexeddb.js":28,"./memory.js":29,"./websql.js":30}],28:[function(_dereq_,module,exports){ +},{"./indexeddb.js":27,"./memory.js":28,"./websql.js":29}],27:[function(require,module,exports){ (function (global,Buffer){ -var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; -var FILE_STORE_NAME = _dereq_('../constants.js').FILE_STORE_NAME; -var IDB_RW = _dereq_('../constants.js').IDB_RW; -var IDB_RO = _dereq_('../constants.js').IDB_RO; -var Errors = _dereq_('../errors.js'); -var FilerBuffer = _dereq_('../buffer.js'); +var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME; +var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME; +var IDB_RW = require('../constants.js').IDB_RW; +var IDB_RO = require('../constants.js').IDB_RO; +var Errors = require('../errors.js'); +var FilerBuffer = require('../buffer.js'); var indexedDB = global.indexedDB || global.mozIndexedDB || @@ -6633,12 +7274,12 @@ IndexedDB.prototype.getReadWriteContext = function() { module.exports = IndexedDB; -}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer) -},{"../buffer.js":15,"../constants.js":16,"../errors.js":19,"buffer":6}],29:[function(_dereq_,module,exports){ -var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) +},{"../buffer.js":14,"../constants.js":15,"../errors.js":18,"buffer":6}],28:[function(require,module,exports){ +var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME; // NOTE: prefer setImmediate to nextTick for proper recursion yielding. // see https://github.com/js-platform/filer/pull/24 -var asyncCallback = _dereq_('../../lib/async.js').setImmediate; +var asyncCallback = require('../../lib/async.js').setImmediate; /** * Make shared in-memory DBs possible when using the same name. @@ -6726,16 +7367,16 @@ Memory.prototype.getReadWriteContext = function() { module.exports = Memory; -},{"../../lib/async.js":1,"../constants.js":16}],30:[function(_dereq_,module,exports){ +},{"../../lib/async.js":1,"../constants.js":15}],29:[function(require,module,exports){ (function (global){ -var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; -var FILE_STORE_NAME = _dereq_('../constants.js').FILE_STORE_NAME; -var WSQL_VERSION = _dereq_('../constants.js').WSQL_VERSION; -var WSQL_SIZE = _dereq_('../constants.js').WSQL_SIZE; -var WSQL_DESC = _dereq_('../constants.js').WSQL_DESC; -var Errors = _dereq_('../errors.js'); -var FilerBuffer = _dereq_('../buffer.js'); -var base64ArrayBuffer = _dereq_('base64-arraybuffer'); +var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME; +var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME; +var WSQL_VERSION = require('../constants.js').WSQL_VERSION; +var WSQL_SIZE = require('../constants.js').WSQL_SIZE; +var WSQL_DESC = require('../constants.js').WSQL_DESC; +var Errors = require('../errors.js'); +var FilerBuffer = require('../buffer.js'); +var base64ArrayBuffer = require('base64-arraybuffer'); function WebSQLContext(db, isReadOnly) { var that = this; @@ -6900,8 +7541,8 @@ WebSQL.prototype.getReadWriteContext = function() { module.exports = WebSQL; -}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../buffer.js":15,"../constants.js":16,"../errors.js":19,"base64-arraybuffer":5}],31:[function(_dereq_,module,exports){ +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../buffer.js":14,"../constants.js":15,"../errors.js":18,"base64-arraybuffer":5}],30:[function(require,module,exports){ function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); @@ -6929,8 +7570,8 @@ module.exports = { nop: nop }; -},{}],32:[function(_dereq_,module,exports){ -var defaults = _dereq_('../constants.js').ENVIRONMENT; +},{}],31:[function(require,module,exports){ +var defaults = require('../constants.js').ENVIRONMENT; module.exports = function Environment(env) { env = env || {}; @@ -6946,13 +7587,13 @@ module.exports = function Environment(env) { }; }; -},{"../constants.js":16}],33:[function(_dereq_,module,exports){ -var Path = _dereq_('../path.js'); -var Errors = _dereq_('../errors.js'); -var Environment = _dereq_('./environment.js'); -var async = _dereq_('../../lib/async.js'); -var Encoding = _dereq_('../encoding.js'); -var minimatch = _dereq_('minimatch'); +},{"../constants.js":15}],32:[function(require,module,exports){ +var Path = require('../path.js'); +var Errors = require('../errors.js'); +var Environment = require('./environment.js'); +var async = require('../../lib/async.js'); +var Encoding = require('../encoding.js'); +var minimatch = require('minimatch'); function Shell(fs, options) { options = options || {}; @@ -7494,8 +8135,8 @@ Shell.prototype.mkdirp = function(path, callback) { module.exports = Shell; -},{"../../lib/async.js":1,"../encoding.js":18,"../errors.js":19,"../path.js":26,"./environment.js":32,"minimatch":11}],34:[function(_dereq_,module,exports){ -var Constants = _dereq_('./constants.js'); +},{"../../lib/async.js":1,"../encoding.js":17,"../errors.js":18,"../path.js":25,"./environment.js":31,"minimatch":11}],33:[function(require,module,exports){ +var Constants = require('./constants.js'); function Stats(fileNode, devName) { this.node = fileNode.id; @@ -7531,8 +8172,8 @@ function() { module.exports = Stats; -},{"./constants.js":16}],35:[function(_dereq_,module,exports){ -var Constants = _dereq_('./constants.js'); +},{"./constants.js":15}],34:[function(require,module,exports){ +var Constants = require('./constants.js'); function SuperNode(options) { var now = Date.now(); @@ -7559,6 +8200,5 @@ SuperNode.create = function(options, callback) { module.exports = SuperNode; -},{"./constants.js":16}]},{},[23]) -(23) +},{"./constants.js":15}]},{},[22])(22) }); \ No newline at end of file diff --git a/dist/filer.min.js b/dist/filer.min.js index e3ee5ba..eb79a41 100644 --- a/dist/filer.min.js +++ b/dist/filer.min.js @@ -1,4 +1,4 @@ -/*! filer 0.0.41 2015-06-01 */ -!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.Filer=t()}}(function(){var t;return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(e,n){(function(){var e={};"undefined"!=typeof process&&process.nextTick?(e.nextTick=process.nextTick,e.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:e.nextTick):"function"==typeof setImmediate?(e.nextTick=function(t){setImmediate(t)},e.setImmediate=e.nextTick):(e.nextTick=function(t){setTimeout(t,0)},e.setImmediate=e.nextTick),e.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n():i())})};i()},e.forEachSeries=e.eachSeries,t!==void 0&&t.amd?t([],function(){return e}):n!==void 0&&n.exports?n.exports=e:root.async=e})()},{}],2:[function(t,e){function n(t,e){for(var n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1);return e}var r=function(){};r.createInterface=function(t){var e={};return e.on=function(e,n){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(e)||(this[t][e]=[]),this[t][e].push(n)},e.off=function(e,r){void 0!==this[t]&&this[t].hasOwnProperty(e)&&n(r,this[t][e])},e.trigger=function(e){if(this[t]!==void 0&&this[t].hasOwnProperty(e))for(var n=Array.prototype.slice.call(arguments,1),r=0;this[t][e].length>r;r++)this[t][e][r].apply(this[t][e][r],n)},e.removeAllListeners=function(e){if(void 0!==this[t]){var n=this;n[t][e].forEach(function(t){n.off(e,t)})}},e};var i=r.createInterface("_handlers");r.prototype._on=i.on,r.prototype._off=i.off,r.prototype._trigger=i.trigger;var o=r.createInterface("handlers");r.prototype.on=function(){o.on.apply(this,arguments),Array.prototype.unshift.call(arguments,"on"),this._trigger.apply(this,arguments)},r.prototype.off=o.off,r.prototype.trigger=o.trigger,r.prototype.removeAllListeners=o.removeAllListeners,e.exports=r},{}],3:[function(t,e){(function(n){function r(t,e){var n=0;return function(){var r=Date.now();r-n>t&&(n=r,e.apply(this,arguments))}}function i(t,e){if(void 0!==t&&t||(t={}),"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function o(){var t=this,e=Date.now();this.origin=s(),this.lastMessage=e,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):n.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),s=t("../src/shared.js").guid,u=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(n);o.prototype._transaction=function(t){function e(){if(!a){var f=Date.now(),h=0|u.getItem(l);if(h&&r>f-h)return s||(o._on("storage",e),s=!0),c=setTimeout(e,i),void 0;a=!0,u.setItem(l,f),t(),n()}}function n(){s&&o._off("storage",e),c&&clearTimeout(c),u.removeItem(l)}var r=1e3,i=20,o=this,a=!1,s=!1,c=null;e()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,e=Date.now(),n=e-h,r=0;try{t=JSON.parse(u.getItem(c)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)n>t[o].timestamp&&(t.splice(o,1),r++);r>0&&u.setItem(c,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var e,n;Date.now();var r=0;try{n=JSON.parse(u.getItem(f)||"{}")}catch(i){n={}}for(e in n)t._once_expired(e,n)&&(delete n[e],r++);r>0&&u.setItem(f,JSON.stringify(n))})}),o.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))return!0;if("object"!=typeof e[t])return!0;var n=e[t].ttl||p,r=Date.now(),i=e[t].timestamp;return r-n>i},o.prototype._localStorageChanged=function(t,e){if(t&&t.key)return t.key===e;var n=u.getItem(e);return n===this.previousValues[e]?!1:(this.previousValues[e]=n,!0)},o.prototype._onStorageEvent=function(t){t=t||n.event;var e=this;this._localStorageChanged(t,c)&&this._transaction(function(){var t,n=Date.now(),r=u.getItem(c);try{t=JSON.parse(r||"[]")}catch(i){t=[]}for(var o=0;t.length>o;o++)if(t[o].origin!==e.origin&&!(t[o].timestampr;r++)if(e.call(n,t[r],r,t)===m)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(e.call(n,t[o[r]],o[r],t)===m)return}}function a(t,e,n){e||(e=i);var r=!1;return null==t?r:p&&t.some===p?t.some(e,n):(o(t,function(t,i,o){return r||(r=e.call(n,t,i,o))?m:void 0}),!!r)}function s(t,e){return null==t?!1:h&&t.indexOf===h?-1!=t.indexOf(e):a(t,function(t){return t===e})}function u(t){this.value=t}function c(t){return t&&"object"==typeof t&&!Array.isArray(t)&&g.call(t,"__wrapped__")?t:new u(t)}var f=Array.prototype,l=f.forEach,h=f.indexOf,p=f.some,d=Object.prototype,g=d.hasOwnProperty,v=Object.keys,m={},E=v||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var r in t)n(t,r)&&e.push(r);return e};u.prototype.has=function(t){return n(this.value,t)},u.prototype.contains=function(t){return s(this.value,t)},u.prototype.size=function(){return r(this.value)},e.exports=c},{}],5:[function(t,e,n){(function(t){"use strict";n.encode=function(e){var n,r=new Uint8Array(e),i=r.length,o="";for(n=0;i>n;n+=3)o+=t[r[n]>>2],o+=t[(3&r[n])<<4|r[n+1]>>4],o+=t[(15&r[n+1])<<2|r[n+2]>>6],o+=t[63&r[n+2]];return 2===i%3?o=o.substring(0,o.length-1)+"=":1===i%3&&(o=o.substring(0,o.length-2)+"=="),o},n.decode=function(e){var n,r,i,o,a,s=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var f=new ArrayBuffer(s),l=new Uint8Array(f);for(n=0;u>n;n+=4)r=t.indexOf(e[n]),i=t.indexOf(e[n+1]),o=t.indexOf(e[n+2]),a=t.indexOf(e[n+3]),l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&a;return f}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i,o=typeof t;if("number"===o)i=t>0?t>>>0:0;else if("string"===o)"base64"===e&&(t=I(t)),i=r.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&M(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}if(this.length>P)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+P.toString(16)+" bytes");var a;r.TYPED_ARRAY_SUPPORT?a=r._augment(new Uint8Array(i)):(a=this,a.length=i,a._isBuffer=!0);var s;if(r.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)a._set(t);else if(T(t))if(r.isBuffer(t))for(s=0;i>s;s++)a[s]=t.readUInt8(s);else for(s=0;i>s;s++)a[s]=(t[s]%256+256)%256;else if("string"===o)a.write(t,0,e);else if("number"===o&&!r.TYPED_ARRAY_SUPPORT&&!n)for(s=0;i>s;s++)a[s]=0;return a}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;if(0!==o%2)throw Error("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;r>a;a++){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))throw Error("Invalid hex string");t[n+a]=s}return a}function o(t,e,n,r){var i=_(R(e),t,n,r);return i}function a(t,e,n,r){var i=_(S(e),t,n,r);return i}function s(t,e,n,r){return a(t,e,n,r)}function u(t,e,n,r){var i=_(D(e),t,n,r);return i}function c(t,e,n,r){var i=_(x(e),t,n,r,2);return i}function f(t,e,n){return 0===e&&n===t.length?L.fromByteArray(t):L.fromByteArray(t.slice(e,n))}function l(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)127>=t[o]?(r+=N(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+N(i)}function h(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,e,n){return h(t,e,n)}function d(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=j(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,e,n){if(0!==t%1||0>t)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function m(t,e,n,i,o,a){if(!r.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||a>e)throw new TypeError("value is out of bounds");if(n+i>t.length)throw new TypeError("index out of range")}function E(t,e,n,r){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);o>i;i++)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function y(t,e,n,r){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);o>i;i++)t[n+i]=255&e>>>8*(r?i:3-i)}function b(t,e,n,r,i,o){if(e>i||o>e)throw new TypeError("value is out of bounds");if(n+r>t.length)throw new TypeError("index out of range")}function w(t,e,n,r,i){return i||b(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),B.write(t,e,n,r,23,4),n+4}function O(t,e,n,r,i){return i||b(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),B.write(t,e,n,r,52,8),n+8}function I(t){for(t=A(t).replace(C,"");0!==t.length%4;)t+="=";return t}function A(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function T(t){return M(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function j(t){return 16>t?"0"+t.toString(16):t.toString(16)}function R(t){for(var e=[],n=0;t.length>n;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),a=0;o.length>a;a++)e.push(parseInt(o[a],16))}}return e}function S(t){for(var e=[],n=0;t.length>n;n++)e.push(255&t.charCodeAt(n));return e}function x(t){for(var e,n,r,i=[],o=0;t.length>o;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function D(t){return L.toByteArray(t)}function _(t,e,n,r,i){i&&(r-=r%i);for(var o=0;r>o&&!(o+n>=e.length||o>=t.length);o++)e[o+n]=t[o];return o}function N(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var L=t("base64-js"),B=t("ieee754"),M=t("is-array");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var P=1073741823;r.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(n){return!1}}(),r.isBuffer=function(t){return!(null==t||!t._isBuffer)},r.compare=function(t,e){if(!r.isBuffer(t)||!r.isBuffer(e))throw new TypeError("Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,a=Math.min(n,i);a>o&&t[o]===e[o];o++);return o!==a&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.isEncoding=function(t){switch((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}},r.concat=function(t,e){if(!M(t))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;t.length>n;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;t.length>n;n++){var a=t[n];a.copy(i,o),o+=a.length}return i},r.byteLength=function(t,e){var n;switch(t+="",e||"utf8"){case"ascii":case"binary":case"raw":n=t.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;case"hex":n=t.length>>>1;break;case"utf8":case"utf-8":n=R(t).length;break;case"base64":n=D(t).length;break;default:n=t.length}return n},r.prototype.length=void 0,r.prototype.parent=void 0,r.prototype.toString=function(t,e,n){var r=!1;if(e>>>=0,n=void 0===n||1/0===n?this.length:n>>>0,t||(t="utf8"),0>e&&(e=0),n>this.length&&(n=this.length),e>=n)return"";for(;;)switch(t){case"hex":return d(this,e,n);case"utf8":case"utf-8":return l(this,e,n);case"ascii":return h(this,e,n);case"binary":return p(this,e,n);case"base64":return f(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return g(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}},r.prototype.equals=function(t){if(!r.isBuffer(t))throw new TypeError("Argument must be a Buffer");return 0===r.compare(this,t)},r.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},r.prototype.compare=function(t){if(!r.isBuffer(t))throw new TypeError("Argument must be a Buffer");return r.compare(this,t)},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var f=r;r=e,e=n,n=f}e=Number(e)||0;var l=this.length-e;n?(n=Number(n),n>l&&(n=l)):n=l,r=((r||"utf8")+"").toLowerCase();var h;switch(r){case"hex":h=i(this,t,e,n);break;case"utf8":case"utf-8":h=o(this,t,e,n);break;case"ascii":h=a(this,t,e,n);break;case"binary":h=s(this,t,e,n);break;case"base64":h=u(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=c(this,t,e,n);break;default:throw new TypeError("Unknown encoding: "+r)}return h},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.slice=function(t,e){var n=this.length;if(t=~~t,e=void 0===e?n:~~e,0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),t>e&&(e=t),r.TYPED_ARRAY_SUPPORT)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.readUInt8=function(t,e){return e||v(t,1,this.length),this[t]},r.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8},r.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]},r.prototype.readUInt32LE=function(t,e){return e||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},r.prototype.readUInt32BE=function(t,e){return e||v(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},r.prototype.readInt8=function(t,e){return e||v(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},r.prototype.readInt16LE=function(t,e){e||v(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt16BE=function(t,e){e||v(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt32LE=function(t,e){return e||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},r.prototype.readInt32BE=function(t,e){return e||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},r.prototype.readFloatLE=function(t,e){return e||v(t,4,this.length),B.read(this,t,!0,23,4)},r.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),B.read(this,t,!1,23,4)},r.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),B.read(this,t,!0,52,8)},r.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),B.read(this,t,!1,52,8)},r.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,1,255,0),r.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},r.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):E(this,t,e,!0),e+2},r.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):E(this,t,e,!1),e+2},r.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):y(this,t,e,!0),e+4},r.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):y(this,t,e,!1),e+4},r.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,1,127,-128),r.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},r.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):E(this,t,e,!0),e+2},r.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):E(this,t,e,!1),e+2},r.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,4,2147483647,-2147483648),r.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):y(this,t,e,!0),e+4},r.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||m(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):y(this,t,e,!1),e+4},r.prototype.writeFloatLE=function(t,e,n){return w(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return w(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return O(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return O(this,t,e,!1,n)},r.prototype.copy=function(t,e,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),e||(e=0),i!==n&&0!==t.length&&0!==o.length){if(n>i)throw new TypeError("sourceEnd < sourceStart");if(0>e||e>=t.length)throw new TypeError("targetStart out of bounds");if(0>n||n>=o.length)throw new TypeError("sourceStart out of bounds");if(0>i||i>o.length)throw new TypeError("sourceEnd out of bounds");i>this.length&&(i=this.length),i-n>t.length-e&&(i=t.length-e+n);var a=i-n;if(1e3>a||!r.TYPED_ARRAY_SUPPORT)for(var s=0;a>s;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+a),e)}},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),e>n)throw new TypeError("end < start");if(n!==e&&0!==this.length){if(0>e||e>=this.length)throw new TypeError("start out of bounds");if(0>n||n>this.length)throw new TypeError("end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=R(""+t),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r.TYPED_ARRAY_SUPPORT)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var F=r.prototype;r._augment=function(t){return t.constructor=r,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=F.get,t.set=F.set,t.write=F.write,t.toString=F.toString,t.toLocaleString=F.toString,t.toJSON=F.toJSON,t.equals=F.equals,t.compare=F.compare,t.copy=F.copy,t.slice=F.slice,t.readUInt8=F.readUInt8,t.readUInt16LE=F.readUInt16LE,t.readUInt16BE=F.readUInt16BE,t.readUInt32LE=F.readUInt32LE,t.readUInt32BE=F.readUInt32BE,t.readInt8=F.readInt8,t.readInt16LE=F.readInt16LE,t.readInt16BE=F.readInt16BE,t.readInt32LE=F.readInt32LE,t.readInt32BE=F.readInt32BE,t.readFloatLE=F.readFloatLE,t.readFloatBE=F.readFloatBE,t.readDoubleLE=F.readDoubleLE,t.readDoubleBE=F.readDoubleBE,t.writeUInt8=F.writeUInt8,t.writeUInt16LE=F.writeUInt16LE,t.writeUInt16BE=F.writeUInt16BE,t.writeUInt32LE=F.writeUInt32LE,t.writeUInt32BE=F.writeUInt32BE,t.writeInt8=F.writeInt8,t.writeInt16LE=F.writeInt16LE,t.writeInt16BE=F.writeInt16BE,t.writeInt32LE=F.writeInt32LE,t.writeInt32BE=F.writeInt32BE,t.writeFloatLE=F.writeFloatLE,t.writeFloatBE=F.writeFloatBE,t.writeDoubleLE=F.writeDoubleLE,t.writeDoubleBE=F.writeDoubleBE,t.fill=F.fill,t.inspect=F.inspect,t.toArrayBuffer=F.toArrayBuffer,t};var C=/[^+\/0-9A-z]/g},{"base64-js":7,ieee754:8,"is-array":9}],7:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===a?62:e===s?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function n(t){c[l++]=t}var r,i,a,s,u,c;if(t.length%4>0)throw 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,c=new o(3*t.length/4-u),a=u>0?t.length-4:t.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)s=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&s)>>16),n((65280&s)>>8),n(255&s);return 2===u?(s=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&s)):1===u&&(s=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(255&s>>8),n(255&s)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(63&t>>18)+e(63&t>>12)+e(63&t>>6)+e(63&t)}var i,o,a,s=t.length%3,u="";for(i=0,a=t.length-s;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=n(o);switch(s){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(63&o<<4),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(63&o>>4),u+=e(63&o<<2),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),s="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i})(n===void 0?this.base64js={}:n)},{}],8:[function(t,e,n){n.read=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,f=-7,l=n?i-1:0,h=n?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),1>e*(u=Math.pow(2,-a))&&(a--,u*=2),e+=a+l>=1?h/u:h*Math.pow(2,1-l),e*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&s,p+=d,s/=256,i-=8);for(a=a<0;t[n+p]=255&a,p+=d,a/=256,c-=8);t[n+p-d]|=128*g}},{}],9:[function(t,e){var n=Array.isArray,r=Object.prototype.toString;e.exports=n||function(t){return!!t&&"[object Array]"==r.call(t)}},{}],10:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;t.length>r;r++)e(t[r],r,t)&&n.push(t[r]);return n}var o=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,a=function(t){return o.exec(t).slice(1)};n.resolve=function(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var o=n>=0?arguments[n]:process.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,e="/"===o.charAt(0))}return t=r(i(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."},n.normalize=function(t){var e=n.isAbsolute(t),o="/"===s(t,-1);return t=r(i(t.split("/"),function(t){return!!t}),!e).join("/"),t||e||(t="."),t&&o&&(t+="/"),(e?"/":"")+t},n.isAbsolute=function(t){return"/"===t.charAt(0)},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(i(t,function(t){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},n.relative=function(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var c=[],u=s;i.length>u;u++)c.push("..");return c=c.concat(o.slice(s)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(t){var e=a(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(t,e){var n=a(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){return a(t)[3]};var s="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return 0>e&&(e=t.length+e),t.substr(e,n)}},{}],11:[function(t,e){function n(t){return t.split("").reduce(function(t,e){return t[e]=!0,t},{})}function r(t,e){return e=e||{},function(n){return o(n,t,e)}}function i(t,e){t=t||{},e=e||{};var n={};return Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(e){n[e]=t[e]}),n}function o(t,e,n){if("string"!=typeof e)throw new TypeError("glob pattern string required");return n||(n={}),n.nocomment||"#"!==e.charAt(0)?""===e.trim()?""===t:new a(e,n).match(t):!1}function a(t,e){if(!(this instanceof a))return new a(t,e);if("string"!=typeof t)throw new TypeError("glob pattern string required");e||(e={}),t=t.trim(),"/"!==g.sep&&(t=t.split(g.sep).join("/")),this.options=e,this.set=[],this.pattern=t,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.make()}function s(){if(!this._made){var t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return this.comment=!0,void 0;if(!t)return this.empty=!0,void 0;this.parseNegate();var n=this.globSet=this.braceExpand();e.debug&&(this.debug=console.error),this.debug(this.pattern,n),n=this.globParts=n.map(function(t){return t.split(A)}),this.debug(this.pattern,n),n=n.map(function(t){return t.map(this.parse,this)},this),this.debug(this.pattern,n),n=n.filter(function(t){return-1===t.indexOf(!1)}),this.debug(this.pattern,n),this.set=n}}function u(){var t=this.pattern,e=!1,n=this.options,r=0;if(!n.nonegate){for(var i=0,o=t.length;o>i&&"!"===t.charAt(i);i++)e=!e,r++;r&&(this.pattern=t.substr(r)),this.negate=e}}function c(t,e){if(e||(e=this instanceof a?this.options:{}),t=t===void 0?this.pattern:t,t===void 0)throw Error("undefined pattern");return e.nobrace||!t.match(/\{.*\}/)?[t]:E(t)}function f(t,e){function n(){if(o){switch(o){case"*":s+=b,u=!0;break;case"?":s+=y,u=!0;break;default:s+="\\"+o}v.debug("clearStateChar %j %j",o,s),o=!1}}var r=this.options;if(!r.noglobstar&&"**"===t)return m;if(""===t)return"";for(var i,o,a,s="",u=!!r.nocase,c=!1,f=[],l=!1,h=-1,d=-1,g="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",v=this,E=0,w=t.length;w>E&&(a=t.charAt(E));E++)if(this.debug("%s %s %s %j",t,E,s,a),c&&I[a])s+="\\"+a,c=!1;else switch(a){case"/":return!1;case"\\":n(),c=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",t,E,s,a),l){this.debug(" in class"),"!"===a&&E===d+1&&(a="^"),s+=a;continue}v.debug("call clearStateChar %j",o),n(),o=a,r.noext&&n();continue;case"(":if(l){s+="(";continue}if(!o){s+="\\(";continue}i=o,f.push({type:i,start:E-1,reStart:s.length}),s+="!"===o?"(?:(?!":"(?:",this.debug("plType %j %j",o,s),o=!1;continue;case")":if(l||!f.length){s+="\\)";continue}switch(n(),u=!0,s+=")",i=f.pop().type){case"!":s+="[^/]*?)";break;case"?":case"+":case"*":s+=i;break;case"@":}continue;case"|":if(l||!f.length||c){s+="\\|",c=!1;continue}n(),s+="|";continue;case"[":if(n(),l){s+="\\"+a;continue}l=!0,d=E,h=s.length,s+=a;continue;case"]":if(E===d+1||!l){s+="\\"+a,c=!1;continue}if(l){var O=t.substring(d+1,E);try{RegExp("["+O+"]")}catch(A){var j=this.parse(O,T);s=s.substr(0,h)+"\\["+j[0]+"\\]",u=u||j[1],l=!1;continue}}u=!0,l=!1,s+=a;continue;default:n(),c?c=!1:!I[a]||"^"===a&&l||(s+="\\"),s+=a}l&&(O=t.substr(d+1),j=this.parse(O,T),s=s.substr(0,h)+"\\["+j[0],u=u||j[1]);for(var R=f.pop();R;R=f.pop()){var S=s.slice(R.reStart+3);S=S.replace(/((?:\\{2})*)(\\?)\|/g,function(t,e,n){return n||(n="\\"),e+e+n+"|"}),this.debug("tail=%j\n %s",S,S);var x="*"===R.type?b:"?"===R.type?y:"\\"+R.type;u=!0,s=s.slice(0,R.reStart)+x+"\\("+S}n(),c&&(s+="\\\\");var D=!1;switch(s.charAt(0)){case".":case"[":case"(":D=!0}if(""!==s&&u&&(s="(?=.)"+s),D&&(s=g+s),e===T)return[s,u];if(!u)return p(t);var _=r.nocase?"i":"",N=RegExp("^"+s+"$",_);return N._glob=t,N._src=s,N}function l(){if(this.regexp||this.regexp===!1)return this.regexp;var t=this.set;if(!t.length)return this.regexp=!1,this.regexp;var e=this.options,n=e.noglobstar?b:e.dot?w:O,r=e.nocase?"i":"",i=t.map(function(t){return t.map(function(t){return t===m?n:"string"==typeof t?d(t):t._src}).join("\\/")}).join("|");i="^(?:"+i+")$",this.negate&&(i="^(?!"+i+").*$");try{this.regexp=RegExp(i,r)}catch(o){this.regexp=!1}return this.regexp}function h(t,e){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;var n=this.options;"/"!==g.sep&&(t=t.split(g.sep).join("/")),t=t.split(A),this.debug(this.pattern,"split",t);var r=this.set;this.debug(this.pattern,"set",r);var i,o;for(o=t.length-1;o>=0&&!(i=t[o]);o--);for(o=0;r.length>o;o++){var a=r[o],s=t;n.matchBase&&1===a.length&&(s=[i]);var u=this.matchOne(s,a,e);if(u)return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}function p(t){return t.replace(/\\(.)/g,"$1")}function d(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}e.exports=o,o.Minimatch=a;var g={sep:"/"};try{g=t("path")}catch(v){}var m=o.GLOBSTAR=a.GLOBSTAR={},E=t("brace-expansion"),y="[^/]",b=y+"*?",w="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",O="(?:(?!(?:\\/|^)\\.).)*?",I=n("().*{}+?[]^$\\!"),A=/\/+/;o.filter=r,o.defaults=function(t){if(!t||!Object.keys(t).length)return r;var e=r,n=function r(n,r,o){return e.minimatch(n,r,i(t,o))};return n.Minimatch=function(n,r){return new e.Minimatch(n,i(t,r))},n},a.defaults=function(t){return t&&Object.keys(t).length?o.defaults(t).Minimatch:a},a.prototype.debug=function(){},a.prototype.make=s,a.prototype.parseNegate=u,o.braceExpand=function(t,e){return c(t,e)},a.prototype.braceExpand=c,a.prototype.parse=f;var T={};o.makeRe=function(t,e){return new a(t,e||{}).makeRe()},a.prototype.makeRe=l,o.match=function(t,e,n){n=n||{};var r=new a(e,n);return t=t.filter(function(t){return r.match(t)}),r.options.nonull&&!t.length&&t.push(e),t},a.prototype.match=h,a.prototype.matchOne=function(t,e,n){var r=this.options;this.debug("matchOne",{"this":this,file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var i=0,o=0,a=t.length,s=e.length;a>i&&s>o;i++,o++){this.debug("matchOne loop");var u=e[o],c=t[i];if(this.debug(e,u,c),u===!1)return!1;if(u===m){this.debug("GLOBSTAR",[e,u,c]);var f=i,l=o+1;if(l===s){for(this.debug("** at the end");a>i;i++)if("."===t[i]||".."===t[i]||!r.dot&&"."===t[i].charAt(0))return!1; -return!0}for(;a>f;){var h=t[f];if(this.debug("\nglobstar while",t,f,e,l,h),this.matchOne(t.slice(f),e.slice(l),n))return this.debug("globstar found match!",f,a,h),!0;if("."===h||".."===h||!r.dot&&"."===h.charAt(0)){this.debug("dot detected!",t,f,e,l);break}this.debug("globstar swallow a segment, and continue"),f++}return n&&(this.debug("\n>>> no match, partial?",t,f,e,l),f===a)?!0:!1}var p;if("string"==typeof u?(p=r.nocase?c.toLowerCase()===u.toLowerCase():c===u,this.debug("string match",u,c,p)):(p=c.match(u),this.debug("pattern match",u,c,p)),!p)return!1}if(i===a&&o===s)return!0;if(i===a)return n;if(o===s){var d=i===a-1&&""===t[i];return d}throw Error("wtf?")}},{"brace-expansion":12,path:10}],12:[function(t,e){function n(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function r(t){return t.split("\\\\").join(d).split("\\{").join(g).split("\\}").join(v).split("\\,").join(m).split("\\.").join(E)}function i(t){return t.split(d).join("\\").split(g).join("{").split(v).join("}").split(m).join(",").split(E).join(".")}function o(t){if(!t)return[""];var e=[],n=p("{","}",t);if(!n)return t.split(",");var r=n.pre,i=n.body,a=n.post,s=r.split(",");s[s.length-1]+="{"+i+"}";var u=o(a);return a.length&&(s[s.length-1]+=u.shift(),s.push.apply(s,u)),e.push.apply(e,s),e}function a(t){return t?l(r(t),!0).map(i):[]}function s(t){return"{"+t+"}"}function u(t){return/^-?0\d/.test(t)}function c(t,e){return e>=t}function f(t,e){return t>=e}function l(t,e){var r=[],i=p("{","}",t);if(!i||/\$$/.test(i.pre))return[t];var a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),d=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),g=a||d,m=/^(.*,)+(.+)?$/.test(i.body);if(!g&&!m)return i.post.match(/,.*}/)?(t=i.pre+"{"+i.body+v+i.post,l(t)):[t];var E;if(g)E=i.body.split(/\.\./);else if(E=o(i.body),1===E.length&&(E=l(E[0],!1).map(s),1===E.length)){var y=i.post.length?l(i.post,!1):[""];return y.map(function(t){return i.pre+E[0]+t})}var b,w=i.pre,y=i.post.length?l(i.post,!1):[""];if(g){var O=n(E[0]),I=n(E[1]),A=Math.max(E[0].length,E[1].length),T=3==E.length?Math.abs(n(E[2])):1,j=c,R=O>I;R&&(T*=-1,j=f);var S=E.some(u);b=[];for(var x=O;j(x,I);x+=T){var D;if(d)D=String.fromCharCode(x),"\\"===D&&(D="");else if(D=x+"",S){var _=A-D.length;if(_>0){var N=Array(_+1).join("0");D=0>x?"-"+N+D.slice(1):N+D}}b.push(D)}}else b=h(E,function(t){return l(t,!1)});for(var L=0;b.length>L;L++)for(var B=0;y.length>B;B++){var M=w+b[L]+y[B];(!e||g||M)&&r.push(M)}return r}var h=t("concat-map"),p=t("balanced-match");e.exports=a;var d="\0SLASH"+Math.random()+"\0",g="\0OPEN"+Math.random()+"\0",v="\0CLOSE"+Math.random()+"\0",m="\0COMMA"+Math.random()+"\0",E="\0PERIOD"+Math.random()+"\0"},{"balanced-match":13,"concat-map":14}],13:[function(t,e){function n(t,e,r){for(var i=0,o={},a=!1,s=0;r.length>s;s++)if(t==r.substr(s,t.length))"start"in o||(o.start=s),i++;else if(e==r.substr(s,e.length)&&"start"in o&&(a=!0,i--,!i))return o.end=s,o.pre=r.substr(0,o.start),o.body=o.end-o.start>1?r.substring(o.start+t.length,o.end):"",o.post=r.slice(o.end+e.length),o;if(i&&a){var u=o.start+t.length;return o=n(t,e,r.substr(u)),o&&(o.start+=u,o.end+=u,o.pre=r.slice(0,u)+o.pre),o}}e.exports=n},{}],14:[function(t,e){e.exports=function(t,e){for(var r=[],i=0;t.length>i;i++){var o=e(t[i],i);n(o)?r.push.apply(r,o):r.push(o)}return r};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],15:[function(t,e){(function(t){function n(e,n,r){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),new t(e,n,r)}n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.keys(t).forEach(function(e){t.hasOwnProperty(e)&&(n[e]=t[e])}),e.exports=n}).call(this,t("buffer").Buffer)},{buffer:6}],16:[function(t,e){var n="READ",r="WRITE",i="CREATE",o="EXCLUSIVE",a="TRUNCATE",s="APPEND",u="CREATE",c="REPLACE";e.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:n,O_WRITE:r,O_CREATE:i,O_EXCLUSIVE:o,O_TRUNCATE:a,O_APPEND:s,O_FLAGS:{r:[n],"r+":[n,r],w:[r,i,a],"w+":[r,n,i,a],wx:[r,i,o,a],"wx+":[r,n,i,o,a],a:[r,i,s],"a+":[r,n,i,s],ax:[r,i,o,s],"ax+":[r,n,i,o,s]},XATTR_CREATE:u,XATTR_REPLACE:c,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],17:[function(t,e){var n=t("./constants.js").MODE_FILE;e.exports=function(t,e){this.id=t,this.type=e||n}},{"./constants.js":16}],18:[function(t,e){(function(t){function n(t){return t.toString("utf8")}function r(e){return new t(e,"utf8")}e.exports={encode:r,decode:n}}).call(this,t("buffer").Buffer)},{buffer:6}],19:[function(t,e){var n={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","50:EPERM:operation not permitted","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(t){function e(t,e){Error.call(this),this.name=i,this.code=i,this.errno=r,this.message=t||o,e&&(this.path=e),this.stack=Error(this.message).stack}t=t.split(":");var r=+t[0],i=t[1],o=t[2];e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(){var t=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+t},n[i]=n[r]=e}),e.exports=n},{}],20:[function(t,e){function n(t,e,n,r,i){function o(n){t.changes.push({event:"change",path:e}),i(n)}var a=t.flags;le(a).contains(Me)&&delete r.ctime,le(a).contains(Be)&&delete r.mtime;var s=!1;r.ctime&&(n.ctime=r.ctime,n.atime=r.ctime,s=!0),r.atime&&(n.atime=r.atime,s=!0),r.mtime&&(n.mtime=r.mtime,s=!0),s?t.putObject(n.id,n,o):o()}function r(t,e,r,o){function a(n,r){n?o(n):r.mode!==be?o(new Fe.ENOTDIR("a component of the path prefix is not a directory",e)):(l=r,i(t,e,s))}function s(n,r){!n&&r?o(new Fe.EEXIST("path name already exists",e)):!n||n instanceof Fe.ENOENT?t.getObject(l.data,u):o(n)}function u(e,n){e?o(e):(h=n,Ye.create({guid:t.guid,mode:r},function(e,n){return e?(o(e),void 0):(p=n,p.nlinks+=1,t.putObject(p.id,p,f),void 0)}))}function c(e){if(e)o(e);else{var r=Date.now();n(t,g,p,{mtime:r,ctime:r},o)}}function f(e){e?o(e):(h[d]=new Ce(p.id,r),t.putObject(l.data,h,c))}if(r!==be&&r!==ye)return o(new Fe.EINVAL("mode must be a directory or file",e));e=pe(e);var l,h,p,d=ge(e),g=de(e);i(t,g,a)}function i(t,e,n){function r(e,r){e?n(e):r&&r.mode===Oe&&r.rnode?t.getObject(r.rnode,o):n(new Fe.EFILESYSTEMERROR)}function o(t,e){t?n(t):e?n(null,e):n(new Fe.ENOENT)}function a(r,i){r?n(r):i.mode===be&&i.data?t.getObject(i.data,s):n(new Fe.ENOTDIR("a component of the path prefix is not a directory",e))}function s(r,i){if(r)n(r);else if(le(i).has(f)){var o=i[f].id;t.getObject(o,u)}else n(new Fe.ENOENT(null,e))}function u(t,r){t?n(t):r.mode==we?(h++,h>Te?n(new Fe.ELOOP(null,e)):c(r.data)):n(null,r)}function c(e){e=pe(e),l=de(e),f=ge(e),Ie==f?t.getObject(Ae,r):i(t,l,a)}if(e=pe(e),!e)return n(new Fe.ENOENT("path is an empty string"));var f=ge(e),l=de(e),h=0;Ie==f?t.getObject(Ae,r):i(t,l,a)}function o(t,e,r,i,o,a,s){function u(i){i?s(i):n(t,e,r,{ctime:Date.now()},s)}var c=r.xattrs;a===Ne&&c.hasOwnProperty(i)?s(new Fe.EEXIST("attribute already exists",e)):a!==Le||c.hasOwnProperty(i)?(c[i]=o,t.putObject(r.id,r,u)):s(new Fe.ENOATTR(null,e))}function a(t,e){function n(n,i){!n&&i?e():!n||n instanceof Fe.ENOENT?Ue.create({guid:t.guid},function(n,i){return n?(e(n),void 0):(o=i,t.putObject(o.id,o,r),void 0)}):e(n)}function r(n){n?e(n):Ye.create({guid:t.guid,id:o.rnode,mode:be},function(n,r){return n?(e(n),void 0):(a=r,a.nlinks+=1,t.putObject(a.id,a,i),void 0)})}function i(n){n?e(n):(s={},t.putObject(a.data,s,e))}var o,a,s;t.getObject(Ae,n)}function s(t,e,r){function o(n,o){!n&&o?r(new Fe.EEXIST(null,e)):!n||n instanceof Fe.ENOENT?i(t,v,a):r(n)}function a(e,n){e?r(e):(p=n,t.getObject(p.data,s))}function s(e,n){e?r(e):(d=n,Ye.create({guid:t.guid,mode:be},function(e,n){return e?(r(e),void 0):(l=n,l.nlinks+=1,t.putObject(l.id,l,u),void 0)}))}function u(e){e?r(e):(h={},t.putObject(l.data,h,f))}function c(e){if(e)r(e);else{var i=Date.now();n(t,v,p,{mtime:i,ctime:i},r)}}function f(e){e?r(e):(d[g]=new Ce(l.id,be),t.putObject(p.data,d,c))}e=pe(e);var l,h,p,d,g=ge(e),v=de(e);i(t,e,o)}function u(t,e,r){function o(e,n){e?r(e):(g=n,t.getObject(g.data,a))}function a(n,i){n?r(n):Ie==m?r(new Fe.EBUSY(null,e)):le(i).has(m)?(v=i,p=v[m].id,t.getObject(p,s)):r(new Fe.ENOENT(null,e))}function s(n,i){n?r(n):i.mode!=be?r(new Fe.ENOTDIR(null,e)):(p=i,t.getObject(p.data,u))}function u(t,n){t?r(t):(d=n,le(d).size()>0?r(new Fe.ENOTEMPTY(null,e)):f())}function c(e){if(e)r(e);else{var i=Date.now();n(t,E,g,{mtime:i,ctime:i},l)}}function f(){delete v[m],t.putObject(g.data,v,c)}function l(e){e?r(e):t.delete(p.id,h)}function h(e){e?r(e):t.delete(p.data,r)}e=pe(e);var p,d,g,v,m=ge(e),E=de(e);i(t,E,o)}function c(t,e,r,o){function a(n,r){n?o(n):r.mode!==be?o(new Fe.ENOENT(null,e)):(v=r,t.getObject(v.data,s))}function s(n,i){n?o(n):(m=i,le(m).has(w)?le(r).contains(xe)?o(new Fe.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",e)):(E=m[w],E.type==be&&le(r).contains(Re)?o(new Fe.EISDIR("the named file is a directory and O_WRITE is set",e)):t.getObject(E.id,u)):le(r).contains(Se)?l():o(new Fe.ENOENT("O_CREATE is not set and the named file does not exist",e)))}function u(t,n){if(t)o(t);else{var r=n;r.mode==we?(I++,I>Te?o(new Fe.ELOOP(null,e)):c(r.data)):f(void 0,r)}}function c(n){n=pe(n),O=de(n),w=ge(n),Ie==w&&(le(r).contains(Re)?o(new Fe.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,f)),i(t,O,a)}function f(t,e){t?o(t):(y=e,o(null,y))}function l(){Ye.create({guid:t.guid,mode:ye},function(e,n){return e?(o(e),void 0):(y=n,y.nlinks+=1,t.putObject(y.id,y,h),void 0)})}function h(e){e?o(e):(b=new ze(0),b.fill(0),t.putBuffer(y.data,b,d))}function p(e){if(e)o(e);else{var r=Date.now();n(t,O,v,{mtime:r,ctime:r},g)}}function d(e){e?o(e):(m[w]=new Ce(y.id,ye),t.putObject(v.data,m,p))}function g(t){t?o(t):o(null,y)}e=pe(e);var v,m,E,y,b,w=ge(e),O=de(e),I=0;Ie==w?le(r).contains(Re)?o(new Fe.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,f):i(t,O,a)}function f(t,e,r,i,o,a){function s(t){t?a(t):a(null,o)}function u(r){if(r)a(r);else{var i=Date.now();n(t,e.path,l,{mtime:i,ctime:i},s)}}function c(e){e?a(e):t.putObject(l.id,l,u)}function f(n,s){if(n)a(n);else{l=s;var u=new ze(o);u.fill(0),r.copy(u,0,i,i+o),e.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,u,c)}}var l;t.getObject(e.id,f)}function l(t,e,r,i,o,a,s){function u(t){t?s(t):s(null,o)}function c(r){if(r)s(r);else{var i=Date.now();n(t,e.path,p,{mtime:i,ctime:i},u)}}function f(e){e?s(e):t.putObject(p.id,p,c)}function l(n,u){if(n)s(n);else{if(d=u,!d)return s(new Fe.EIO("Expected Buffer"));var c=void 0!==a&&null!==a?a:e.position,l=Math.max(d.length,c+o),h=new ze(l);h.fill(0),d&&d.copy(h),r.copy(h,c,i,i+o),void 0===a&&(e.position+=o),p.size=l,p.version+=1,t.putBuffer(p.data,h,f)}}function h(e,n){e?s(e):(p=n,t.getBuffer(p.data,l))}var p,d;t.getObject(e.id,h)}function h(t,e,n,r,i,o,a){function s(t,s){if(t)a(t);else{if(f=s,!f)return a(new Fe.EIO("Expected Buffer"));var u=void 0!==o&&null!==o?o:e.position;i=u+i>n.length?i-u:i,f.copy(n,r,u,u+i),void 0===o&&(e.position+=i),a(null,i)}}function u(n,r){n?a(n):"DIRECTORY"===r.mode?a(new Fe.EISDIR("the named file is a directory",e.path)):(c=r,t.getBuffer(c.data,s))}var c,f;t.getObject(e.id,u)}function p(t,e,n){e=pe(e),ge(e),i(t,e,n)}function d(t,e,n){e.getNode(t,n)}function g(t,e,n){function r(e,r){e?n(e):(a=r,t.getObject(a.data,o))}function o(r,i){r?n(r):(s=i,le(s).has(u)?t.getObject(s[u].id,n):n(new Fe.ENOENT("a component of the path does not name an existing file",e)))}e=pe(e);var a,s,u=ge(e),c=de(e);Ie==u?i(t,e,n):i(t,c,r)}function v(t,e,r,o){function a(e){e?o(e):n(t,r,y,{ctime:Date.now()},o)}function s(e,n){e?o(e):(y=n,y.nlinks+=1,t.putObject(y.id,y,a))}function u(e){e?o(e):t.getObject(E[b].id,s)}function c(e,n){e?o(e):(E=n,le(E).has(b)?o(new Fe.EEXIST("newpath resolves to an existing file",b)):(E[b]=v[p],t.putObject(m.data,E,u)))}function f(e,n){e?o(e):(m=n,t.getObject(m.data,c))}function l(e,n){e?o(e):(v=n,le(v).has(p)?"DIRECTORY"===v[p].type?o(new Fe.EPERM("oldpath refers to a directory")):i(t,w,f):o(new Fe.ENOENT("a component of either path prefix does not exist",p)))}function h(e,n){e?o(e):(g=n,t.getObject(g.data,l))}e=pe(e);var p=ge(e),d=de(e);r=pe(r);var g,v,m,E,y,b=ge(r),w=de(r);i(t,d,h)}function m(t,e,r){function o(e){e?r(e):(delete h[d],t.putObject(l.data,h,function(){var e=Date.now();n(t,g,l,{mtime:e,ctime:e},r)}))}function a(e){e?r(e):t.delete(p.data,o)}function s(i,s){i?r(i):(p=s,p.nlinks-=1,1>p.nlinks?t.delete(p.id,a):t.putObject(p.id,p,function(){n(t,e,p,{ctime:Date.now()},o)}))}function u(t,e){t?r(t):"DIRECTORY"===e.mode?r(new Fe.EPERM("unlink not permitted on directories",d)):s(null,e)}function c(e,n){e?r(e):(h=n,le(h).has(d)?t.getObject(h[d].id,u):r(new Fe.ENOENT("a component of the path does not name an existing file",d)))}function f(e,n){e?r(e):(l=n,t.getObject(l.data,c))}e=pe(e);var l,h,p,d=ge(e),g=de(e);i(t,g,f)}function E(t,e,n){function r(t,e){if(t)n(t);else{s=e;var r=Object.keys(s);n(null,r)}}function o(i,o){i?n(i):o.mode!==be?n(new Fe.ENOTDIR(null,e)):(a=o,t.getObject(a.data,r))}e=pe(e),ge(e);var a,s;i(t,e,o)}function y(t,e,r,o){function a(e,n){e?o(e):(l=n,t.getObject(l.data,s))}function s(t,e){t?o(t):(h=e,le(h).has(d)?o(new Fe.EEXIST(null,d)):u())}function u(){Ye.create({guid:t.guid,mode:we},function(n,r){return n?(o(n),void 0):(p=r,p.nlinks+=1,p.size=e.length,p.data=e,t.putObject(p.id,p,f),void 0)})}function c(e){if(e)o(e);else{var r=Date.now();n(t,g,l,{mtime:r,ctime:r},o)}}function f(e){e?o(e):(h[d]=new Ce(p.id,we),t.putObject(l.data,h,c))}r=pe(r);var l,h,p,d=ge(r),g=de(r);Ie==d?o(new Fe.EEXIST(null,d)):i(t,g,a)}function b(t,e,n){function r(e,r){e?n(e):(s=r,t.getObject(s.data,o))}function o(e,r){e?n(e):(u=r,le(u).has(c)?t.getObject(u[c].id,a):n(new Fe.ENOENT("a component of the path does not name an existing file",c)))}function a(t,r){t?n(t):r.mode!=we?n(new Fe.EINVAL("path not a symbolic link",e)):n(null,r.data)}e=pe(e);var s,u,c=ge(e),f=de(e);i(t,f,r)}function w(t,e,r,o){function a(n,r){n?o(n):r.mode==be?o(new Fe.EISDIR(null,e)):(f=r,t.getBuffer(f.data,s))}function s(e,n){if(e)o(e);else{if(!n)return o(new Fe.EIO("Expected Buffer"));var i=new ze(r);i.fill(0),n&&n.copy(i),t.putBuffer(f.data,i,c)}}function u(r){if(r)o(r);else{var i=Date.now();n(t,e,f,{mtime:i,ctime:i},o)}}function c(e){e?o(e):(f.size=r,f.version+=1,t.putObject(f.id,f,u))}e=pe(e);var f;0>r?o(new Fe.EINVAL("length cannot be negative")):i(t,e,a)}function O(t,e,r,i){function o(e,n){e?i(e):n.mode==be?i(new Fe.EISDIR):(c=n,t.getBuffer(c.data,a))}function a(e,n){if(e)i(e);else{var o;if(!n)return i(new Fe.EIO("Expected Buffer"));n?o=n.slice(0,r):(o=new ze(r),o.fill(0)),t.putBuffer(c.data,o,u)}}function s(r){if(r)i(r);else{var o=Date.now();n(t,e.path,c,{mtime:o,ctime:o},i)}}function u(e){e?i(e):(c.size=r,c.version+=1,t.putObject(c.id,c,s))}var c;0>r?i(new Fe.EINVAL("length cannot be negative")):e.getNode(t,o)}function I(t,e,r,o,a){function s(i,s){i?a(i):n(t,e,s,{atime:r,ctime:o,mtime:o},a)}e=pe(e),"number"!=typeof r||"number"!=typeof o?a(new Fe.EINVAL("atime and mtime must be number",e)):0>r||0>o?a(new Fe.EINVAL("atime and mtime must be positive integers",e)):i(t,e,s)}function A(t,e,r,i,o){function a(a,s){a?o(a):n(t,e.path,s,{atime:r,ctime:i,mtime:i},o)}"number"!=typeof r||"number"!=typeof i?o(new Fe.EINVAL("atime and mtime must be a number")):0>r||0>i?o(new Fe.EINVAL("atime and mtime must be positive integers")):e.getNode(t,a)}function T(t,e,n,r,a,s){function u(i,u){return i?s(i):(o(t,e,u,n,r,a,s),void 0)}e=pe(e),"string"!=typeof n?s(new Fe.EINVAL("attribute name must be a string",e)):n?null!==a&&a!==Ne&&a!==Le?s(new Fe.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",e)):i(t,e,u):s(new Fe.EINVAL("attribute name cannot be an empty string",e))}function j(t,e,n,r,i,a){function s(s,u){return s?a(s):(o(t,e.path,u,n,r,i,a),void 0)}"string"!=typeof n?a(new Fe.EINVAL("attribute name must be a string")):n?null!==i&&i!==Ne&&i!==Le?a(new Fe.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):e.getNode(t,s):a(new Fe.EINVAL("attribute name cannot be an empty string"))}function R(t,e,n,r){function o(t,i){if(t)return r(t);var o=i.xattrs;o.hasOwnProperty(n)?r(null,o[n]):r(new Fe.ENOATTR(null,e))}e=pe(e),"string"!=typeof n?r(new Fe.EINVAL("attribute name must be a string",e)):n?i(t,e,o):r(new Fe.EINVAL("attribute name cannot be an empty string",e))}function S(t,e,n,r){function i(t,e){if(t)return r(t);var i=e.xattrs;i.hasOwnProperty(n)?r(null,i[n]):r(new Fe.ENOATTR)}"string"!=typeof n?r(new Fe.EINVAL):n?e.getNode(t,i):r(new Fe.EINVAL("attribute name cannot be an empty string"))}function x(t,e,r,o){function a(i,a){function s(r){r?o(r):n(t,e,a,{ctime:Date.now()},o)}if(i)return o(i);var u=a.xattrs;u.hasOwnProperty(r)?(delete u[r],t.putObject(a.id,a,s)):o(new Fe.ENOATTR(null,e))}e=pe(e),"string"!=typeof r?o(new Fe.EINVAL("attribute name must be a string",e)):r?i(t,e,a):o(new Fe.EINVAL("attribute name cannot be an empty string",e))}function D(t,e,r,i){function o(o,a){function s(r){r?i(r):n(t,e.path,a,{ctime:Date.now()},i)}if(o)return i(o);var u=a.xattrs;u.hasOwnProperty(r)?(delete u[r],t.putObject(a.id,a,s)):i(new Fe.ENOATTR)}"string"!=typeof r?i(new Fe.EINVAL("attribute name must be a string")):r?e.getNode(t,o):i(new Fe.EINVAL("attribute name cannot be an empty string"))}function _(t){return le(_e).has(t)?_e[t]:null}function N(t,e,n){return t?"function"==typeof t?t={encoding:e,flag:n}:"string"==typeof t&&(t={encoding:t,flag:n}):t={encoding:e,flag:n},t}function L(t,e){var n;return t?me(t)?n=new Fe.EINVAL("Path must be a string without null bytes.",t):ve(t)||(n=new Fe.EINVAL("Path must be absolute.",t)):n=new Fe.EINVAL("Path must be a string",t),n?(e(n),!1):!0}function B(t,e,n,r,i,o){function a(e,i){if(e)o(e);else{var a;a=le(r).contains(De)?i.size:0;var s=new ke(n,i.id,r,a),u=t.allocDescriptor(s);o(null,u)}}o=arguments[arguments.length-1],L(n,o)&&(r=_(r),r||o(new Fe.EINVAL("flags is not valid"),n),c(e,n,r,a))}function M(t,e,n,r){le(t.openFiles).has(n)?(t.releaseDescriptor(n),r(null)):r(new Fe.EBADF)}function P(t,e,n,i,o){L(n,o)&&r(e,n,i,o)}function F(t,e,n,r,i){i=arguments[arguments.length-1],L(n,i)&&s(e,n,i)}function C(t,e,n,r){L(n,r)&&u(e,n,r)}function k(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ve(n,t.name);r(null,i)}}L(n,r)&&p(e,n,i)}function U(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ve(n,t.name);r(null,i)}}var o=t.openFiles[n];o?d(e,o,i):r(new Fe.EBADF)}function Y(t,e,n,r,i){L(n,i)&&L(r,i)&&v(e,n,r,i)}function V(t,e,n,r){L(n,r)&&m(e,n,r)}function z(t,e,n,r,i,o,a,s){function u(t,e){s(t,e||0,r)}i=void 0===i?0:i,o=void 0===o?r.length-i:o,s=arguments[arguments.length-1];var c=t.openFiles[n];c?le(c.flags).contains(je)?h(e,c,r,i,o,a,u):s(new Fe.EBADF("descriptor does not permit reading")):s(new Fe.EBADF)}function X(t,e,n,r,i){if(i=arguments[arguments.length-1],r=N(r,null,"r"),L(n,i)){var o=_(r.flag||"r");return o?(c(e,n,o,function(a,s){function u(){t.releaseDescriptor(f)}if(a)return i(a);var c=new ke(n,s.id,o,0),f=t.allocDescriptor(c);d(e,c,function(o,a){if(o)return u(),i(o);var s=new Ve(a,t.name);if(s.isDirectory())return u(),i(new Fe.EISDIR("illegal operation on directory",n));var f=s.size,l=new ze(f);l.fill(0),h(e,c,l,0,f,0,function(t){if(u(),t)return i(t);var e;e="utf8"===r.encoding?Pe.decode(l):l,i(null,e)})})}),void 0):i(new Fe.EINVAL("flags is not valid",n))}}function W(t,e,n,r,i,o,a,s){s=arguments[arguments.length-1],i=void 0===i?0:i,o=void 0===o?r.length-i:o;var u=t.openFiles[n];u?le(u.flags).contains(Re)?o>r.length-i?s(new Fe.EIO("intput buffer is too small")):l(e,u,r,i,o,a,s):s(new Fe.EBADF("descriptor does not permit writing")):s(new Fe.EBADF)}function q(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=N(i,"utf8","w"),L(n,o)){var a=_(i.flag||"w");if(!a)return o(new Fe.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Pe.encode(r)),c(e,n,a,function(i,s){if(i)return o(i);var u=new ke(n,s.id,a,0),c=t.allocDescriptor(u);f(e,u,r,0,r.length,function(e){return t.releaseDescriptor(c),e?o(e):(o(null),void 0)})})}}function $(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=N(i,"utf8","a"),L(n,o)){var a=_(i.flag||"a");if(!a)return o(new Fe.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Pe.encode(r)),c(e,n,a,function(i,s){if(i)return o(i);var u=new ke(n,s.id,a,s.size),c=t.allocDescriptor(u);l(e,u,r,0,r.length,u.position,function(e){return t.releaseDescriptor(c),e?o(e):(o(null),void 0)})})}}function J(t,e,n,r){function i(t){r(t?!1:!0)}k(t,e,n,i)}function H(t,e,n,r,i){L(n,i)&&R(e,n,r,i)}function Q(t,e,n,r,i){var o=t.openFiles[n];o?S(e,o,r,i):i(new Fe.EBADF)}function G(t,e,n,r,i,o,a){"function"==typeof o&&(a=o,o=null),L(n,a)&&T(e,n,r,i,o,a)}function K(t,e,n,r,i,o,a){"function"==typeof o&&(a=o,o=null);var s=t.openFiles[n];s?le(s.flags).contains(Re)?j(e,s,r,i,o,a):a(new Fe.EBADF("descriptor does not permit writing")):a(new Fe.EBADF)}function Z(t,e,n,r,i){L(n,i)&&x(e,n,r,i)}function te(t,e,n,r,i){var o=t.openFiles[n];o?le(o.flags).contains(Re)?D(e,o,r,i):i(new Fe.EBADF("descriptor does not permit writing")):i(new Fe.EBADF)}function ee(t,e,n,r,i,o){function a(t,e){t?o(t):0>e.size+r?o(new Fe.EINVAL("resulting file offset would be negative")):(s.position=e.size+r,o(null,s.position))}var s=t.openFiles[n];s||o(new Fe.EBADF),"SET"===i?0>r?o(new Fe.EINVAL("resulting file offset would be negative")):(s.position=r,o(null,s.position)):"CUR"===i?0>s.position+r?o(new Fe.EINVAL("resulting file offset would be negative")):(s.position+=r,o(null,s.position)):"END"===i?d(e,s,a):o(new Fe.EINVAL("whence argument is not a proper value"))}function ne(t,e,n,r){L(n,r)&&E(e,n,r)}function re(t,e,n,r,i,o){if(L(n,o)){var a=Date.now();r=r?r:a,i=i?i:a,I(e,n,r,i,o)}}function ie(t,e,n,r,i,o){var a=Date.now();r=r?r:a,i=i?i:a;var s=t.openFiles[n];s?le(s.flags).contains(Re)?A(e,s,r,i,o):o(new Fe.EBADF("descriptor does not permit writing")):o(new Fe.EBADF)}function oe(t,e,r,o,a){function s(t,r){t?a(t):n(e,o,r,{ctime:Date.now()},a)}function c(t){t?a(t):e.getObject(I[R].id,s)}function f(t){t?a(t):(b.id===O.id&&(w=I),delete w[j],e.putObject(b.data,w,c))}function l(t){t?a(t):(I[R]=w[j],e.putObject(O.data,I,f))}function h(t,n){t?a(t):(I=n,le(I).has(R)?u(e,o,l):l())}function p(t,n){t?a(t):(O=n,e.getObject(O.data,h))}function d(t,n){t?a(t):(w=n,i(e,T,p))}function g(t,n){t?a(t):(b=n,e.getObject(n.data,d))}function E(t){t?a(t):m(e,r,a)}function y(t,n){t?a(t):"DIRECTORY"===n.mode?i(e,A,g):v(e,r,o,E)}if(L(r,a)&&L(o,a)){r=pe(r),o=pe(o);var b,w,O,I,A=he.dirname(r),T=he.dirname(r),j=he.basename(r),R=he.basename(o);i(e,r,y)}}function ae(t,e,n,r,i,o){o=arguments[arguments.length-1],L(n,o)&&L(r,o)&&y(e,n,r,o)}function se(t,e,n,r){L(n,r)&&b(e,n,r)}function ue(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ve(n,t.name);r(null,i)}}L(n,r)&&g(e,n,i)}function ce(t,e,n,r,i){i=arguments[arguments.length-1],r=r||0,L(n,i)&&w(e,n,r,i)}function fe(t,e,n,r,i){i=arguments[arguments.length-1],r=r||0;var o=t.openFiles[n];o?le(o.flags).contains(Re)?O(e,o,r,i):i(new Fe.EBADF("descriptor does not permit writing")):i(new Fe.EBADF)}var le=t("../../lib/nodash.js"),he=t("../path.js"),pe=he.normalize,de=he.dirname,ge=he.basename,ve=he.isAbsolute,me=he.isNull,Ee=t("../constants.js"),ye=Ee.MODE_FILE,be=Ee.MODE_DIRECTORY,we=Ee.MODE_SYMBOLIC_LINK,Oe=Ee.MODE_META,Ie=Ee.ROOT_DIRECTORY_NAME,Ae=Ee.SUPER_NODE_ID,Te=Ee.SYMLOOP_MAX,je=Ee.O_READ,Re=Ee.O_WRITE,Se=Ee.O_CREATE,xe=Ee.O_EXCLUSIVE;Ee.O_TRUNCATE;var De=Ee.O_APPEND,_e=Ee.O_FLAGS,Ne=Ee.XATTR_CREATE,Le=Ee.XATTR_REPLACE,Be=Ee.FS_NOMTIME,Me=Ee.FS_NOCTIME,Pe=t("../encoding.js"),Fe=t("../errors.js"),Ce=t("../directory-entry.js"),ke=t("../open-file-description.js"),Ue=t("../super-node.js"),Ye=t("../node.js"),Ve=t("../stats.js"),ze=t("../buffer.js");e.exports={ensureRootDirectory:a,open:B,close:M,mknod:P,mkdir:F,rmdir:C,unlink:V,stat:k,fstat:U,link:Y,read:z,readFile:X,write:W,writeFile:q,appendFile:$,exists:J,getxattr:H,fgetxattr:Q,setxattr:G,fsetxattr:K,removexattr:Z,fremovexattr:te,lseek:ee,readdir:ne,utimes:re,futimes:ie,rename:oe,symlink:ae,readlink:se,lstat:ue,truncate:ce,ftruncate:fe}},{"../../lib/nodash.js":4,"../buffer.js":15,"../constants.js":16,"../directory-entry.js":17,"../encoding.js":18,"../errors.js":19,"../node.js":24,"../open-file-description.js":25,"../path.js":26,"../stats.js":34,"../super-node.js":35}],21:[function(t,e){function n(t){return"function"==typeof t?t:function(t){if(t)throw t}}function r(t){t&&console.error("Filer error: ",t)}function i(t,e){function n(){B.forEach(function(t){t.call(this)}.bind(_)),B=null}function i(t){return function(e){function n(e){var r=R();t.getObject(r,function(t,i){return t?(e(t),void 0):(i?n(e):e(null,r),void 0)})}return o(j).contains(d)?(e(null,R()),void 0):(n(e),void 0)}}function u(t){if(t.length){var e=m.getInstance();t.forEach(function(t){e.emit(t.event,t.path)})}}t=t||{},e=e||r;var j=t.flags,R=t.guid?t.guid:b,S=t.provider||new g.Default(t.name||c),x=t.name||S.name,D=o(j).contains(f),_=this;_.readyState=h,_.name=x,_.error=null,_.stdin=w,_.stdout=O,_.stderr=I,this.Shell=v.bind(void 0,this);var N={},L=A;Object.defineProperty(this,"openFiles",{get:function(){return N}}),this.allocDescriptor=function(t){var e=L++;return N[e]=t,e},this.releaseDescriptor=function(t){delete N[t]};var B=[];this.queueOrRun=function(t){var e;return l==_.readyState?t.call(_):p==_.readyState?e=new y.EFILESYSTEMERROR("unknown error"):B.push(t),e},this.watch=function(t,e,n){if(a(t))throw Error("Path must be a string without null bytes.");"function"==typeof e&&(n=e,e={}),e=e||{},n=n||s;var r=new E;return r.start(t,!1,e.recursive),r.on("change",n),r},S.open(function(t){function r(t){function r(t){var e=S[t]();return e.flags=j,e.changes=[],e.guid=i(e),e.close=function(){var t=e.changes;u(t),t.length=0},e}_.provider={openReadWriteContext:function(){return r("getReadWriteContext")},openReadOnlyContext:function(){return r("getReadOnlyContext")}},_.readyState=t?p:l,n(),e(t,_)}if(t)return r(t);var o=S.getReadWriteContext();o.guid=i(o),D?o.clear(function(t){return t?r(t):(T.ensureRootDirectory(o,r),void 0)}):T.ensureRootDirectory(o,r)})}var o=t("../../lib/nodash.js"),a=t("../path.js").isNull,s=t("../shared.js").nop,u=t("../constants.js"),c=u.FILE_SYSTEM_NAME,f=u.FS_FORMAT,l=u.FS_READY,h=u.FS_PENDING,p=u.FS_ERROR,d=u.FS_NODUPEIDCHECK,g=t("../providers/index.js"),v=t("../shell/shell.js"),m=t("../../lib/intercom.js"),E=t("../fs-watcher.js"),y=t("../errors.js"),b=t("../shared.js").guid,w=u.STDIN,O=u.STDOUT,I=u.STDERR,A=u.FIRST_DESCRIPTOR,T=t("./implementation.js");i.providers=g,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){i.prototype[t]=function(){var e=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=n(r[i]),s=e.queueOrRun(function(){function n(){s.close(),a.apply(e,arguments)}var s=e.provider.openReadWriteContext();if(p===e.readyState){var u=new y.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(e,u)}o?r.push(n):r[i]=n;var c=[e,s].concat(r);T[t].apply(null,c)});s&&a(s)}}),e.exports=i},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":16,"../errors.js":19,"../fs-watcher.js":22,"../path.js":26,"../providers/index.js":27,"../shared.js":31,"../shell/shell.js":33,"./implementation.js":20}],22:[function(t,e){function n(){function t(t){(n===t||s&&0===t.indexOf(e))&&a.trigger("change","change",t)}r.call(this);var e,n,a=this,s=!1;a.start=function(r,a,u){if(!n){if(i.isNull(r))throw Error("Path must be a string without null bytes.");n=i.normalize(r),s=u===!0,s&&(e="/"===n?"/":n+"/");var c=o.getInstance();c.on("change",t)}},a.close=function(){var e=o.getInstance();e.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");n.prototype=new r,n.prototype.constructor=n,e.exports=n},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":26}],23:[function(t,e){e.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js"),Shell:t("./shell/shell.js")}},{"./buffer.js":15,"./errors.js":19,"./filesystem/interface.js":21,"./path.js":26,"./shell/shell.js":33}],24:[function(t,e){function n(t){var e=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,e,n){t[e]?n(null):t.guid(function(r,i){t[e]=i,n(r)})}var i=t("./constants.js").MODE_FILE;n.create=function(t,e){r(t,"id",function(i){return i?(e(i),void 0):(r(t,"data",function(r){return r?(e(r),void 0):(e(null,new n(t)),void 0)}),void 0)})},e.exports=n},{"./constants.js":16}],25:[function(t,e){function n(t,e,n,r){this.path=t,this.id=e,this.flags=n,this.position=r}var r=t("./errors.js");n.prototype.getNode=function(t,e){function n(t,n){return t?e(t):n?(e(null,n),void 0):e(new r.EBADF("file descriptor refers to unknown node",o))}var i=this.id,o=this.path;t.getObject(i,n)},e.exports=n},{"./errors.js":19}],26:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function o(t){var e="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),t||e||(t="."),(e?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function s(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var c=[],u=s;i.length>u;u++)c.push("..");return c=c.concat(o.slice(s)),c.join("/")}function u(t){var e=v(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function c(t,e){var n=v(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),""===n?"/":n}function f(t){return v(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function h(t){return-1!==(""+t).indexOf("\0")?!0:!1}function p(t){return t.replace(/\/*$/,"/")}function d(t){return t=t.replace(/\/*$/,""),""===t?"/":t}var g=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,v=function(t){var e=g.exec(t);return[e[1]||"",e[2]||"",e[3]||"",e[4]||""] -};e.exports={normalize:o,resolve:i,join:a,relative:s,sep:"/",delimiter:":",dirname:u,basename:c,extname:f,isAbsolute:l,isNull:h,addTrailing:p,removeTrailing:d}},{}],27:[function(t,e){var n=t("./indexeddb.js"),r=t("./websql.js"),i=t("./memory.js");e.exports={IndexedDB:n,WebSQL:r,Memory:i,Default:n,Fallback:function(){function t(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}return n.isSupported()?n:r.isSupported()?r:(t.isSupported=function(){return!1},t)}()}},{"./indexeddb.js":28,"./memory.js":29,"./websql.js":30}],28:[function(t,e){(function(n,r){function i(t,e){var n=t.transaction(c,e);this.objectStore=n.objectStore(c)}function o(t,e,n){try{var r=t.get(e);r.onsuccess=function(t){var e=t.target.result;n(null,e)},r.onerror=function(t){n(t)}}catch(i){n(i)}}function a(t,e,n,r){try{var i=t.put(n,e);i.onsuccess=function(t){var e=t.target.result;r(null,e)},i.onerror=function(t){r(t)}}catch(o){r(o)}}function s(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,c=t("../constants.js").FILE_STORE_NAME,f=t("../constants.js").IDB_RW;t("../constants.js").IDB_RO;var l=t("../errors.js"),h=t("../buffer.js"),p=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB;i.prototype.clear=function(t){try{var e=this.objectStore.clear();e.onsuccess=function(){t()},e.onerror=function(e){t(e)}}catch(n){t(n)}},i.prototype.getObject=function(t,e){o(this.objectStore,t,e)},i.prototype.getBuffer=function(t,e){o(this.objectStore,t,function(t,n){return t?e(t):(e(null,new h(n)),void 0)})},i.prototype.putObject=function(t,e,n){a(this.objectStore,t,e,n)},i.prototype.putBuffer=function(t,e,n){var i;i=r._useTypedArrays?e.buffer:e.toArrayBuffer(),a(this.objectStore,t,i,n)},i.prototype.delete=function(t,e){try{var n=this.objectStore.delete(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},s.isSupported=function(){return!!p},s.prototype.open=function(t){var e=this;if(e.db)return t();var n=p.open(e.name);n.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(c)&&e.deleteObjectStore(c),e.createObjectStore(c)},n.onsuccess=function(n){e.db=n.target.result,t()},n.onerror=function(){t(new l.EINVAL("IndexedDB cannot be accessed. If private browsing is enabled, disable it."))}},s.prototype.getReadOnlyContext=function(){return new i(this.db,f)},s.prototype.getReadWriteContext=function(){return new i(this.db,f)},e.exports=s}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"../buffer.js":15,"../constants.js":16,"../errors.js":19,buffer:6}],29:[function(t,e){function n(t,e){this.readOnly=e,this.objectStore=t}function r(t){this.name=t||i}var i=t("../constants.js").FILE_SYSTEM_NAME,o=t("../../lib/async.js").setImmediate,a=function(){var t={};return function(e){return t.hasOwnProperty(e)||(t[e]={}),t[e]}}();n.prototype.clear=function(t){if(this.readOnly)return o(function(){t("[MemoryContext] Error: write operation on read only context")}),void 0;var e=this.objectStore;Object.keys(e).forEach(function(t){delete e[t]}),o(t)},n.prototype.getObject=n.prototype.getBuffer=function(t,e){var n=this;o(function(){e(null,n.objectStore[t])})},n.prototype.putObject=n.prototype.putBuffer=function(t,e,n){return this.readOnly?(o(function(){n("[MemoryContext] Error: write operation on read only context")}),void 0):(this.objectStore[t]=e,o(n),void 0)},n.prototype.delete=function(t,e){return this.readOnly?(o(function(){e("[MemoryContext] Error: write operation on read only context")}),void 0):(delete this.objectStore[t],o(e),void 0)},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=a(this.name),o(t)},r.prototype.getReadOnlyContext=function(){return new n(this.db,!0)},r.prototype.getReadWriteContext=function(){return new n(this.db,!1)},e.exports=r},{"../../lib/async.js":1,"../constants.js":16}],30:[function(t,e){(function(n){function r(t,e){var n=this;this.getTransaction=function(r){return n.transaction?(r(n.transaction),void 0):(t[e?"readTransaction":"transaction"](function(t){n.transaction=t,r(t)}),void 0)}}function i(t,e,n){function r(t,e){var r=0===e.rows.length?null:e.rows.item(0).data;n(null,r)}function i(t,e){n(e)}t(function(t){t.executeSql("SELECT data FROM "+u+" WHERE id = ? LIMIT 1;",[e],r,i)})}function o(t,e,n,r){function i(){r(null)}function o(t,e){r(e)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+u+" (id, data) VALUES (?, ?);",[e,n],i,o)})}function a(t){this.name=t||s,this.db=null}var s=t("../constants.js").FILE_SYSTEM_NAME,u=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").WSQL_VERSION,f=t("../constants.js").WSQL_SIZE,l=t("../constants.js").WSQL_DESC,h=t("../errors.js"),p=t("../buffer.js"),d=t("base64-arraybuffer");r.prototype.clear=function(t){function e(e,n){t(n)}function n(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+u+";",[],n,e)})},r.prototype.getObject=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);try{n&&(n=JSON.parse(n))}catch(r){return e(r)}e(null,n)})},r.prototype.getBuffer=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);if(n||""===n){var r=d.decode(n);n=new p(r)}e(null,n)})},r.prototype.putObject=function(t,e,n){var r=JSON.stringify(e);o(this.getTransaction,t,r,n)},r.prototype.putBuffer=function(t,e,n){var r=d.encode(e.buffer);o(this.getTransaction,t,r,n)},r.prototype.delete=function(t,e){function n(){e(null)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+u+" WHERE id = ?;",[t],n,r)})},a.isSupported=function(){return!!n.openDatabase},a.prototype.open=function(t){function e(e,n){5===n.code&&t(new h.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),t(n)}function r(){i.db=o,t()}var i=this;if(i.db)return t();var o=n.openDatabase(i.name,c,l,f);return o?(o.transaction(function(t){function n(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+u+"_id"+" on "+u+" (id);",[],r,e)}t.executeSql("CREATE TABLE IF NOT EXISTS "+u+" (id unique, data TEXT);",[],n,e)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},a.prototype.getReadOnlyContext=function(){return new r(this.db,!0)},a.prototype.getReadWriteContext=function(){return new r(this.db,!1)},e.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":15,"../constants.js":16,"../errors.js":19,"base64-arraybuffer":5}],31:[function(t,e){function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=0|16*Math.random(),n="x"==t?e:8|3&e;return n.toString(16)}).toUpperCase()}function r(){}function i(t){for(var e=[],n=t.length,r=0;n>r;r++)e[r]=t[r];return e}e.exports={guid:n,u8toArray:i,nop:r}},{}],32:[function(t,e){var n=t("../constants.js").ENVIRONMENT;e.exports=function(t){t=t||{},t.TMP=t.TMP||n.TMP,t.PATH=t.PATH||n.PATH,this.get=function(e){return t[e]},this.set=function(e,n){t[e]=n}}},{"../constants.js":16}],33:[function(t,e){function n(t,e){e=e||{};var n=new o(e.env),a="/";Object.defineProperty(this,"fs",{get:function(){return t},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return n},enumerable:!0}),this.cd=function(e,n){e=r.resolve(a,e),t.stat(e,function(t,r){return t?(n(new i.ENOTDIR(null,e)),void 0):("DIRECTORY"===r.type?(a=e,n()):n(new i.ENOTDIR(null,e)),void 0)})},this.pwd=function(){return a}}var r=t("../path.js"),i=t("../errors.js"),o=t("./environment.js"),a=t("../../lib/async.js");t("../encoding.js");var s=t("minimatch");n.prototype.exec=function(t,e,n){var i=this,o=i.fs;"function"==typeof e&&(n=e,e=[]),e=e||[],n=n||function(){},t=r.resolve(i.pwd(),t),o.readFile(t,"utf8",function(t,r){if(t)return n(t),void 0;try{var i=Function("fs","args","callback",r);i(o,e,n)}catch(a){n(a)}})},n.prototype.touch=function(t,e,n){function i(t){s.writeFile(t,"",n)}function o(t){var r=Date.now(),i=e.date||r,o=e.date||r;s.utimes(t,i,o,n)}var a=this,s=a.fs;"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t=r.resolve(a.pwd(),t),s.stat(t,function(r){r?e.updateOnly===!0?n():i(t):o(t)})},n.prototype.cat=function(t,e){function n(t,e){var n=r.resolve(o.pwd(),t);s.readFile(n,"utf8",function(t,n){return t?(e(t),void 0):(u+=n+"\n",e(),void 0)})}var o=this,s=o.fs,u="";return e=e||function(){},t?(t="string"==typeof t?[t]:t,a.eachSeries(t,n,function(t){t?e(t):e(null,u.replace(/\n$/,""))}),void 0):(e(new i.EINVAL("Missing files argument")),void 0)},n.prototype.ls=function(t,e,n){function o(t,n){var i=r.resolve(s.pwd(),t),c=[];u.readdir(i,function(t,s){function f(t,n){t=r.join(i,t),u.stat(t,function(a,s){if(a)return n(a),void 0;var u={path:r.basename(t),links:s.nlinks,size:s.size,modified:s.mtime,type:s.type};e.recursive&&"DIRECTORY"===s.type?o(r.join(i,u.path),function(t,e){return t?(n(t),void 0):(u.contents=e,c.push(u),n(),void 0)}):(c.push(u),n())})}return t?(n(t),void 0):(a.eachSeries(s,f,function(t){n(t,c)}),void 0)})}var s=this,u=s.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing dir argument")),void 0)},n.prototype.rm=function(t,e,n){function o(t,n){t=r.resolve(s.pwd(),t),u.stat(t,function(s,c){return s?(n(s),void 0):"FILE"===c.type?(u.unlink(t,n),void 0):(u.readdir(t,function(s,c){return s?(n(s),void 0):0===c.length?(u.rmdir(t,n),void 0):e.recursive?(c=c.map(function(e){return r.join(t,e)}),a.eachSeries(c,o,function(e){return e?(n(e),void 0):(u.rmdir(t,n),void 0)}),void 0):(n(new i.ENOTEMPTY(null,t)),void 0)}),void 0)})}var s=this,u=s.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},n.prototype.tempDir=function(t){var e=this,n=e.fs,r=e.env.get("TMP");t=t||function(){},n.mkdir(r,function(){t(null,r)})},n.prototype.mkdirp=function(t,e){function n(t,e){a.stat(t,function(o,s){if(s){if(s.isDirectory())return e(),void 0;if(s.isFile())return e(new i.ENOTDIR(null,t)),void 0}else{if(o&&"ENOENT"!==o.code)return e(o),void 0;var u=r.dirname(t);"/"===u?a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}):n(u,function(n){return n?e(n):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}),void 0)})}})}var o=this,a=o.fs;return e=e||function(){},t?"/"===t?(e(),void 0):(n(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0)},n.prototype.find=function(t,e,n){function o(t,e){h(t,function(n){return n?(e(n),void 0):(p.push(t),e(),void 0)})}function u(t,n){var i=r.removeTrailing(t);return e.regex&&!e.regex.test(i)?(n(),void 0):e.name&&!s(r.basename(i),e.name)?(n(),void 0):e.path&&!s(r.dirname(i),e.path)?(n(),void 0):(o(t,n),void 0)}function c(t,e){t=r.resolve(f.pwd(),t),l.readdir(t,function(n,i){return n?("ENOTDIR"===n.code?u(t,e):e(n),void 0):(u(r.addTrailing(t),function(n){return n?(e(n),void 0):(i=i.map(function(e){return r.join(t,e)}),a.eachSeries(i,c,function(t){e(t,p)}),void 0)}),void 0)})}var f=this,l=f.fs;"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){};var h=e.exec||function(t,e){e()},p=[];return t?(l.stat(t,function(e,r){return e?(n(e),void 0):r.isDirectory()?(c(t,n),void 0):(n(new i.ENOTDIR(null,t)),void 0)}),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},e.exports=n},{"../../lib/async.js":1,"../encoding.js":18,"../errors.js":19,"../path.js":26,"./environment.js":32,minimatch:11}],34:[function(t,e){function n(t,e){this.node=t.id,this.dev=e,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}var r=t("./constants.js");n.prototype.isFile=function(){return this.type===r.MODE_FILE},n.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},n.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},n.prototype.isSocket=n.prototype.isFIFO=n.prototype.isCharacterDevice=n.prototype.isBlockDevice=function(){return!1},e.exports=n},{"./constants.js":16}],35:[function(t,e){function n(t){var e=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.rnode=t.rnode}var r=t("./constants.js");n.create=function(t,e){t.guid(function(r,i){return r?(e(r),void 0):(t.rnode=t.rnode||i,e(null,new n(t)),void 0)})},e.exports=n},{"./constants.js":16}]},{},[23])(23)}); \ No newline at end of file +/*! filer 0.0.41 2015-06-29 */ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Filer=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=a.length?c():e())})};e()},b.forEachSeries=b.eachSeries,"undefined"!=typeof a&&a.amd?a([],function(){return b}):"undefined"!=typeof c&&c.exports?c.exports=b:root.async=b}()},{}],2:[function(a,b,c){function d(a,b){for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1);return b}var e=function(){};e.createInterface=function(a){var b={};return b.on=function(b,c){"undefined"==typeof this[a]&&(this[a]={}),this[a].hasOwnProperty(b)||(this[a][b]=[]),this[a][b].push(c)},b.off=function(b,c){"undefined"!=typeof this[a]&&this[a].hasOwnProperty(b)&&d(c,this[a][b])},b.trigger=function(b){if("undefined"!=typeof this[a]&&this[a].hasOwnProperty(b))for(var c=Array.prototype.slice.call(arguments,1),d=0;da&&(c=d,b.apply(this,arguments))}}function e(a,b){if("undefined"!=typeof a&&a||(a={}),"object"==typeof b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function f(){var a=this,b=Date.now();this.origin=h(),this.lastMessage=b,this.receivedIDs={},this.previousValues={};var d=function(){a._onStorageEvent.apply(a,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",d):c.addEventListener("storage",d,!1))}var g=a("./eventemitter.js"),h=a("../src/shared.js").guid,i=function(a){return"undefined"==typeof a||"undefined"==typeof a.localStorage?{getItem:function(){},setItem:function(){},removeItem:function(){}}:a.localStorage}(c);f.prototype._transaction=function(a){function b(){if(!g){var k=Date.now(),m=0|i.getItem(l);if(m&&d>k-m)return h||(f._on("storage",b),h=!0),void(j=setTimeout(b,e));g=!0,i.setItem(l,k),a(),c()}}function c(){h&&f._off("storage",b),j&&clearTimeout(j),i.removeItem(l)}var d=1e3,e=20,f=this,g=!1,h=!1,j=null;b()},f.prototype._cleanup_emit=d(100,function(){var a=this;a._transaction(function(){var a,b=Date.now(),c=b-m,d=0;try{a=JSON.parse(i.getItem(j)||"[]")}catch(e){a=[]}for(var f=a.length-1;f>=0;f--)a[f].timestamp0&&i.setItem(j,JSON.stringify(a))})}),f.prototype._cleanup_once=d(100,function(){var a=this;a._transaction(function(){var b,c,d=(Date.now(),0);try{c=JSON.parse(i.getItem(k)||"{}")}catch(e){c={}}for(b in c)a._once_expired(b,c)&&(delete c[b],d++);d>0&&i.setItem(k,JSON.stringify(c))})}),f.prototype._once_expired=function(a,b){if(!b)return!0;if(!b.hasOwnProperty(a))return!0;if("object"!=typeof b[a])return!0;var c=b[a].ttl||n,d=Date.now(),e=b[a].timestamp;return d-c>e},f.prototype._localStorageChanged=function(a,b){if(a&&a.key)return a.key===b;var c=i.getItem(b);return c===this.previousValues[b]?!1:(this.previousValues[b]=c,!0)},f.prototype._onStorageEvent=function(a){a=a||c.event;var b=this;this._localStorageChanged(a,j)&&this._transaction(function(){var a,c=Date.now(),d=i.getItem(j);try{a=JSON.parse(d||"[]")}catch(e){a=[]}for(var f=0;fd;d++)if(b.call(c,a[d],d,a)===s)return}else{var f=f(a);for(d=0,e=f.length;e>d;d++)if(b.call(c,a[f[d]],f[d],a)===s)return}}function h(a,b,c){b||(b=f);var d=!1;return null==a?d:o&&a.some===o?a.some(b,c):(g(a,function(a,e,f){return d||(d=b.call(c,a,e,f))?s:void 0}),!!d)}function i(a,b){return null==a?!1:n&&a.indexOf===n?-1!=a.indexOf(b):h(a,function(a){return a===b})}function j(a){this.value=a}function k(a){return a&&"object"==typeof a&&!Array.isArray(a)&&q.call(a,"__wrapped__")?a:new j(a)}var l=Array.prototype,m=l.forEach,n=l.indexOf,o=l.some,p=Object.prototype,q=p.hasOwnProperty,r=Object.keys,s={},t=r||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)d(a,c)&&b.push(c);return b};j.prototype.has=function(a){return d(this.value,a)},j.prototype.contains=function(a){return i(this.value,a)},j.prototype.size=function(){return e(this.value)},b.exports=k},{}],5:[function(a,b,c){!function(a){"use strict";c.encode=function(b){var c,d=new Uint8Array(b),e=d.length,f="";for(c=0;e>c;c+=3)f+=a[d[c]>>2],f+=a[(3&d[c])<<4|d[c+1]>>4],f+=a[(15&d[c+1])<<2|d[c+2]>>6],f+=a[63&d[c+2]];return e%3===2?f=f.substring(0,f.length-1)+"=":e%3===1&&(f=f.substring(0,f.length-2)+"=="),f},c.decode=function(b){var c,d,e,f,g,h=.75*b.length,i=b.length,j=0;"="===b[b.length-1]&&(h--,"="===b[b.length-2]&&h--);var k=new ArrayBuffer(h),l=new Uint8Array(k);for(c=0;i>c;c+=4)d=a.indexOf(b[c]),e=a.indexOf(b[c+1]),f=a.indexOf(b[c+2]),g=a.indexOf(b[c+3]),l[j++]=d<<2|e>>4,l[j++]=(15&e)<<4|f>>2,l[j++]=(3&f)<<6|63&g;return k}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(a,b,c){function d(a){return this instanceof d?(this.length=0,this.parent=void 0,"number"==typeof a?e(this,a):"string"==typeof a?f(this,a,arguments.length>1?arguments[1]:"utf8"):g(this,a)):arguments.length>1?new d(a,arguments[1]):new d(a)}function e(a,b){if(a=m(a,0>b?0:0|n(b)),!d.TYPED_ARRAY_SUPPORT)for(var c=0;b>c;c++)a[c]=0;return a}function f(a,b,c){("string"!=typeof c||""===c)&&(c="utf8");var d=0|p(b,c);return a=m(a,d),a.write(b,c),a}function g(a,b){if(d.isBuffer(b))return h(a,b);if(U(b))return i(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");return"undefined"!=typeof ArrayBuffer&&b.buffer instanceof ArrayBuffer?j(a,b):b.length?k(a,b):l(a,b)}function h(a,b){var c=0|n(b.length);return a=m(a,c),b.copy(a,0,0,c),a}function i(a,b){var c=0|n(b.length);a=m(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function j(a,b){var c=0|n(b.length);a=m(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function k(a,b){var c=0|n(b.length);a=m(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function l(a,b){var c,d=0;"Buffer"===b.type&&U(b.data)&&(c=b.data,d=0|n(c.length)),a=m(a,d);for(var e=0;d>e;e+=1)a[e]=255&c[e];return a}function m(a,b){d.TYPED_ARRAY_SUPPORT?a=d._augment(new Uint8Array(b)):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=d.poolSize>>>1;return c&&(a.parent=W),a}function n(a){if(a>=V)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+V.toString(16)+" bytes");return 0|a}function o(a,b){if(!(this instanceof o))return new o(a,b);var c=new d(a,b);return delete c.parent,c}function p(a,b){if("string"!=typeof a&&(a=String(a)),0===a.length)return 0;switch(b||"utf8"){case"ascii":case"binary":case"raw":return a.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*a.length;case"hex":return a.length>>>1;case"utf8":case"utf-8":return M(a).length;case"base64":return P(a).length;default:return a.length}}function q(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function r(a,b,c,d){return Q(M(b,a.length-c),a,c,d)}function s(a,b,c,d){return Q(N(b),a,c,d)}function t(a,b,c,d){return s(a,b,c,d)}function u(a,b,c,d){return Q(P(b),a,c,d)}function v(a,b,c,d){return Q(O(b,a.length-c),a,c,d)}function w(a,b,c){return 0===b&&c===a.length?S.fromByteArray(a):S.fromByteArray(a.slice(b,c))}function x(a,b,c){var d="",e="";c=Math.min(a.length,c);for(var f=b;c>f;f++)a[f]<=127?(d+=R(e)+String.fromCharCode(a[f]),e=""):e+="%"+a[f].toString(16);return d+R(e)}function y(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(127&a[e]);return d}function z(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function A(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=L(a[f]);return e}function B(a,b,c){for(var d=a.slice(b,c),e="",f=0;fa)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function D(a,b,c,e,f,g){if(!d.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>f||g>b)throw new RangeError("value is out of bounds");if(c+e>a.length)throw new RangeError("index out of range")}function E(a,b,c,d){0>b&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);f>e;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function F(a,b,c,d){0>b&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);f>e;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function G(a,b,c,d,e,f){if(b>e||f>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(0>c)throw new RangeError("index out of range")}function H(a,b,c,d,e){return e||G(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),T.write(a,b,c,d,23,4),c+4}function I(a,b,c,d,e){return e||G(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),T.write(a,b,c,d,52,8),c+8}function J(a){if(a=K(a).replace(Y,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function K(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function L(a){return 16>a?"0"+a.toString(16):a.toString(16)}function M(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;d>g;g++){if(c=a.charCodeAt(g),c>55295&&57344>c){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(56320>c){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=e-55296<<10|c-56320|65536,e=null}else e&&((b-=3)>-1&&f.push(239,191,189),e=null);if(128>c){if((b-=1)<0)break;f.push(c)}else if(2048>c){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(65536>c){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(2097152>c))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function N(a){for(var b=[],c=0;c>8,e=c%256,f.push(e),f.push(d);return f}function P(a){return S.toByteArray(J(a))}function Q(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}function R(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}var S=a("base64-js"),T=a("ieee754"),U=a("is-array");c.Buffer=d,c.SlowBuffer=o,c.INSPECT_MAX_BYTES=50,d.poolSize=8192;var V=1073741823,W={};d.TYPED_ARRAY_SUPPORT=function(){try{var a=new ArrayBuffer(0),b=new Uint8Array(a);return b.foo=function(){return 42},42===b.foo()&&"function"==typeof b.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(c){return!1}}(),d.isBuffer=function(a){return!(null==a||!a._isBuffer)},d.compare=function(a,b){if(!d.isBuffer(a)||!d.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,e=b.length,f=0,g=Math.min(c,e);g>f&&a[f]===b[f];)++f;return f!==g&&(c=a[f],e=b[f]),e>c?-1:c>e?1:0},d.isEncoding=function(a){switch(String(a).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}},d.concat=function(a,b){if(!U(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new d(0);if(1===a.length)return a[0];var c;if(void 0===b)for(b=0,c=0;cb&&(b=0),c>this.length&&(c=this.length),b>=c)return"";for(;;)switch(a){case"hex":return A(this,b,c);case"utf8":case"utf-8":return x(this,b,c);case"ascii":return y(this,b,c);case"binary":return z(this,b,c);case"base64":return w(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}},d.prototype.equals=function(a){if(!d.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:0===d.compare(this,a)},d.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),""},d.prototype.compare=function(a){if(!d.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:d.compare(this,a)},d.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e2147483647?b=2147483647:-2147483648>b&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(0>b&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(d.isBuffer(a))return c(this,a,b);if("number"==typeof a)return d.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},d.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},d.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},d.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(0>c||0>b)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return q(this,a,b,c);case"utf8":case"utf-8":return r(this,a,b,c);case"ascii":return s(this,a,b,c);case"binary":return t(this,a,b,c);case"base64":return u(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a);var e;if(d.TYPED_ARRAY_SUPPORT)e=d._augment(this.subarray(a,b));else{var f=b-a;e=new d(f,void 0);for(var g=0;f>g;g++)e[g]=this[g+a]}return e.length&&(e.parent=this.parent||this),e},d.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||C(a,b,this.length);for(var d=this[a],e=1,f=0;++f0&&(e*=256);)d+=this[a+--b]*e;return d},d.prototype.readUInt8=function(a,b){return b||C(a,1,this.length),this[a]},d.prototype.readUInt16LE=function(a,b){return b||C(a,2,this.length),this[a]|this[a+1]<<8},d.prototype.readUInt16BE=function(a,b){return b||C(a,2,this.length),this[a]<<8|this[a+1]},d.prototype.readUInt32LE=function(a,b){return b||C(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},d.prototype.readUInt32BE=function(a,b){return b||C(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},d.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||C(a,b,this.length);for(var d=this[a],e=1,f=0;++f=e&&(d-=Math.pow(2,8*b)),d},d.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||C(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},d.prototype.readInt8=function(a,b){return b||C(a,1,this.length),128&this[a]?-1*(255-this[a]+1):this[a]},d.prototype.readInt16LE=function(a,b){b||C(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},d.prototype.readInt16BE=function(a,b){b||C(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},d.prototype.readInt32LE=function(a,b){return b||C(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},d.prototype.readInt32BE=function(a,b){return b||C(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},d.prototype.readFloatLE=function(a,b){return b||C(a,4,this.length),T.read(this,a,!0,23,4)},d.prototype.readFloatBE=function(a,b){return b||C(a,4,this.length),T.read(this,a,!1,23,4)},d.prototype.readDoubleLE=function(a,b){return b||C(a,8,this.length),T.read(this,a,!0,52,8)},d.prototype.readDoubleBE=function(a,b){return b||C(a,8,this.length),T.read(this,a,!1,52,8)},d.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||D(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f=0&&(f*=256);)this[b+e]=a/f&255;return b+c},d.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,1,255,0),d.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=a,b+1},d.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8):E(this,a,b,!0),b+2},d.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=a):E(this,a,b,!1),b+2},d.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=a):F(this,a,b,!0),b+4},d.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=a):F(this,a,b,!1),b+4},d.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);D(this,a,b,c,e-1,-e)}var f=0,g=1,h=0>a?1:0;for(this[b]=255&a;++f>0)-h&255;return b+c},d.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);D(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=0>a?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},d.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,1,127,-128),d.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),0>a&&(a=255+a+1),this[b]=a,b+1},d.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8):E(this,a,b,!0),b+2},d.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=a):E(this,a,b,!1),b+2},d.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,2147483647,-2147483648),d.TYPED_ARRAY_SUPPORT?(this[b]=a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):F(this,a,b,!0),b+4},d.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||D(this,a,b,4,2147483647,-2147483648),0>a&&(a=4294967295+a+1),d.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=a):F(this,a,b,!1),b+4},d.prototype.writeFloatLE=function(a,b,c){return H(this,a,b,!0,c)},d.prototype.writeFloatBE=function(a,b,c){return H(this,a,b,!1,c)},d.prototype.writeDoubleLE=function(a,b,c){return I(this,a,b,!0,c)},d.prototype.writeDoubleBE=function(a,b,c){return I(this,a,b,!1,c)},d.prototype.copy=function(a,b,c,e){if(c||(c=0),e||0===e||(e=this.length),b>=a.length&&(b=a.length),b||(b=0),e>0&&c>e&&(e=c),e===c)return 0;if(0===a.length||0===this.length)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>c||c>=this.length)throw new RangeError("sourceStart out of bounds");if(0>e)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),a.length-bf||!d.TYPED_ARRAY_SUPPORT)for(var g=0;f>g;g++)a[g+b]=this[g+c];else a._set(this.subarray(c,c+f),b);return f},d.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),b>c)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(0>b||b>=this.length)throw new RangeError("start out of bounds");if(0>c||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=M(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},d.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(d.TYPED_ARRAY_SUPPORT)return new d(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var X=d.prototype;d._augment=function(a){return a.constructor=d,a._isBuffer=!0,a._set=a.set,a.get=X.get,a.set=X.set,a.write=X.write,a.toString=X.toString,a.toLocaleString=X.toString,a.toJSON=X.toJSON,a.equals=X.equals,a.compare=X.compare,a.indexOf=X.indexOf,a.copy=X.copy,a.slice=X.slice,a.readUIntLE=X.readUIntLE,a.readUIntBE=X.readUIntBE,a.readUInt8=X.readUInt8,a.readUInt16LE=X.readUInt16LE,a.readUInt16BE=X.readUInt16BE,a.readUInt32LE=X.readUInt32LE,a.readUInt32BE=X.readUInt32BE,a.readIntLE=X.readIntLE,a.readIntBE=X.readIntBE,a.readInt8=X.readInt8,a.readInt16LE=X.readInt16LE,a.readInt16BE=X.readInt16BE,a.readInt32LE=X.readInt32LE,a.readInt32BE=X.readInt32BE,a.readFloatLE=X.readFloatLE,a.readFloatBE=X.readFloatBE,a.readDoubleLE=X.readDoubleLE,a.readDoubleBE=X.readDoubleBE,a.writeUInt8=X.writeUInt8,a.writeUIntLE=X.writeUIntLE,a.writeUIntBE=X.writeUIntBE,a.writeUInt16LE=X.writeUInt16LE,a.writeUInt16BE=X.writeUInt16BE,a.writeUInt32LE=X.writeUInt32LE,a.writeUInt32BE=X.writeUInt32BE,a.writeIntLE=X.writeIntLE,a.writeIntBE=X.writeIntBE,a.writeInt8=X.writeInt8,a.writeInt16LE=X.writeInt16LE,a.writeInt16BE=X.writeInt16BE,a.writeInt32LE=X.writeInt32LE,a.writeInt32BE=X.writeInt32BE,a.writeFloatLE=X.writeFloatLE,a.writeFloatBE=X.writeFloatBE,a.writeDoubleLE=X.writeDoubleLE,a.writeDoubleBE=X.writeDoubleBE,a.fill=X.fill,a.inspect=X.inspect,a.toArrayBuffer=X.toArrayBuffer,a};var Y=/[^+\/0-9A-z\-]/g},{"base64-js":7,ieee754:8,"is-array":9}],7:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],8:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],9:[function(a,b,c){var d=Array.isArray,e=Object.prototype.toString;b.exports=d||function(a){return!!a&&"[object Array]"==e.call(a)}},{}],10:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function e(a,b){if(a.filter)return a.filter(b);for(var c=[],d=0;d=-1&&!b;c--){var f=c>=0?arguments[c]:process.cwd();if("string"!=typeof f)throw new TypeError("Arguments to path.resolve must be strings");f&&(a=f+"/"+a,b="/"===f.charAt(0))}return a=d(e(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=c.isAbsolute(a),f="/"===h(a,-1);return a=d(e(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&f&&(a+="/"),(b?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(e(a,function(a,b){if("string"!=typeof a)throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;ib&&(b=a.length+b),a.substr(b,c)}},{}],11:[function(a,b,c){!function(a,b,c,d){function e(a){return a.split("").reduce(function(a,b){return a[b]=!0,a},{})}function f(a,b){return b=b||{},function(c,d,e){return h(c,a,b)}}function g(a,b){a=a||{},b=b||{};var c={};return Object.keys(b).forEach(function(a){c[a]=b[a]}),Object.keys(a).forEach(function(b){c[b]=a[b]}),c}function h(a,b,c){if("string"!=typeof b)throw new TypeError("glob pattern string required");return c||(c={}),c.nocomment||"#"!==b.charAt(0)?""===b.trim()?""===a:new i(b,c).match(a):!1}function i(a,b){if(!(this instanceof i))return new i(a,b,t);if("string"!=typeof a)throw new TypeError("glob pattern string required");b||(b={}),a=a.trim(),"win32"===d&&(a=a.split("\\").join("/"));var c=a+"\n"+v(b),e=h.cache.get(c);return e?e:(h.cache.set(c,this),this.options=b,this.set=[],this.pattern=a,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,void this.make())}function j(){if(!this._made){var a=this.pattern,b=this.options;if(!b.nocomment&&"#"===a.charAt(0))return void(this.comment=!0);if(!a)return void(this.empty=!0);this.parseNegate();var c=this.globSet=this.braceExpand();b.debug&&(this.debug=console.error),this.debug(this.pattern,c),c=this.globParts=c.map(function(a){return a.split(B)}),this.debug(this.pattern,c),c=c.map(function(a,b,c){return a.map(this.parse,this)},this),this.debug(this.pattern,c),c=c.filter(function(a){return-1===a.indexOf(!1)}),this.debug(this.pattern,c),this.set=c}}function k(){var a=this.pattern,b=!1,c=this.options,d=0;if(!c.nonegate){for(var e=0,f=a.length;f>e&&"!"===a.charAt(e);e++)b=!b,d++;d&&(this.pattern=a.substr(d)),this.negate=b}}function l(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a}function m(a,b){function c(){t.push(x),x=""}if(b=b||this.options,a="undefined"==typeof a?this.pattern:a,"undefined"==typeof a)throw new Error("undefined pattern");if(b.nobrace||!a.match(/\{.*\}/))return[a];var d=!1;if("{"!==a.charAt(0)){this.debug(a);for(var e=null,f=0,g=a.length;g>f;f++){ +var h=a.charAt(f);if(this.debug(f,h),"\\"===h)d=!d;else if("{"===h&&!d){e=a.substr(0,f);break}}if(null===e)return this.debug("no sets"),[a];var i=m.call(this,a.substr(f),b);return i.map(function(a){return e+a})}var j=a.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);if(j){this.debug("numset",j[1],j[2]);for(var k,n=m.call(this,a.substr(j[0].length),b),o=+j[1],p="0"===j[1][0],q=j[1].length,r=+j[2],s=o>r?-1:1,t=[],f=o;f!=r+s;f+=s){k=p?l(f,q):f+"";for(var u=0,v=n.length;v>u;u++)t.push(k+n[u])}return t}var f=1,w=1,t=[],x="",d=!1;this.debug("Entering for");a:for(f=1,g=a.length;g>f;f++){var h=a.charAt(f);if(this.debug("",f,h),d)d=!1,x+="\\"+h;else switch(h){case"\\":d=!0;continue;case"{":w++,x+="{";continue;case"}":if(w--,0===w){c(),f++;break a}x+=h;continue;case",":1===w?c():x+=h;continue;default:x+=h;continue}}if(0!==w)return this.debug("didn't close",a),m.call(this,"\\"+a,b);this.debug("set",t),this.debug("suffix",a.substr(f));var n=m.call(this,a.substr(f),b),y=1===t.length;this.debug("set pre-expanded",t),t=t.map(function(a){return m.call(this,a,b)},this),this.debug("set expanded",t),t=t.reduce(function(a,b){return a.concat(b)}),y&&(t=t.map(function(a){return"{"+a+"}"}));for(var z=[],f=0,g=t.length;g>f;f++)for(var u=0,v=n.length;v>u;u++)z.push(t[f]+n[u]);return z}function n(a,b){function c(){if(f){switch(f){case"*":h+=x,i=!0;break;case"?":h+=w,i=!0;break;default:h+="\\"+f}p.debug("clearStateChar %j %j",f,h),f=!1}}var d=this.options;if(!d.noglobstar&&"**"===a)return u;if(""===a)return"";for(var e,f,g,h="",i=!!d.nocase,j=!1,k=[],l=!1,m=-1,n=-1,o="."===a.charAt(0)?"":d.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",p=this,r=0,s=a.length;s>r&&(g=a.charAt(r));r++)if(this.debug("%s %s %s %j",a,r,h,g),j&&A[g])h+="\\"+g,j=!1;else switch(g){case"/":return!1;case"\\":c(),j=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",a,r,h,g),l){this.debug(" in class"),"!"===g&&r===n+1&&(g="^"),h+=g;continue}p.debug("call clearStateChar %j",f),c(),f=g,d.noext&&c();continue;case"(":if(l){h+="(";continue}if(!f){h+="\\(";continue}e=f,k.push({type:e,start:r-1,reStart:h.length}),h+="!"===f?"(?:(?!":"(?:",this.debug("plType %j %j",f,h),f=!1;continue;case")":if(l||!k.length){h+="\\)";continue}switch(c(),i=!0,h+=")",e=k.pop().type){case"!":h+="[^/]*?)";break;case"?":case"+":case"*":h+=e;case"@":}continue;case"|":if(l||!k.length||j){h+="\\|",j=!1;continue}c(),h+="|";continue;case"[":if(c(),l){h+="\\"+g;continue}l=!0,n=r,m=h.length,h+=g;continue;case"]":if(r===n+1||!l){h+="\\"+g,j=!1;continue}i=!0,l=!1,h+=g;continue;default:c(),j?j=!1:!A[g]||"^"===g&&l||(h+="\\"),h+=g}if(l){var t=a.substr(n+1),v=this.parse(t,C);h=h.substr(0,m)+"\\["+v[0],i=i||v[1]}for(var y;y=k.pop();){var z=h.slice(y.reStart+3);z=z.replace(/((?:\\{2})*)(\\?)\|/g,function(a,b,c){return c||(c="\\"),b+b+c+"|"}),this.debug("tail=%j\n %s",z,z);var B="*"===y.type?x:"?"===y.type?w:"\\"+y.type;i=!0,h=h.slice(0,y.reStart)+B+"\\("+z}c(),j&&(h+="\\\\");var D=!1;switch(h.charAt(0)){case".":case"[":case"(":D=!0}if(""!==h&&i&&(h="(?=.)"+h),D&&(h=o+h),b===C)return[h,i];if(!i)return q(a);var E=d.nocase?"i":"",F=new RegExp("^"+h+"$",E);return F._glob=a,F._src=h,F}function o(){if(this.regexp||this.regexp===!1)return this.regexp;var a=this.set;if(!a.length)return this.regexp=!1;var b=this.options,c=b.noglobstar?x:b.dot?y:z,d=b.nocase?"i":"",e=a.map(function(a){return a.map(function(a){return a===u?c:"string"==typeof a?r(a):a._src}).join("\\/")}).join("|");e="^(?:"+e+")$",this.negate&&(e="^(?!"+e+").*$");try{return this.regexp=new RegExp(e,d)}catch(f){return this.regexp=!1}}function p(a,b){if(this.debug("match",a,this.pattern),this.comment)return!1;if(this.empty)return""===a;if("/"===a&&b)return!0;var c=this.options;"win32"===d&&(a=a.split("\\").join("/")),a=a.split(B),this.debug(this.pattern,"split",a);var e=this.set;this.debug(this.pattern,"set",e);for(var f,g=a.length-1;g>=0&&!(f=a[g]);g--);for(var g=0,h=e.length;h>g;g++){var i=e[g],j=a;c.matchBase&&1===i.length&&(j=[f]);var k=this.matchOne(j,i,b);if(k)return c.flipNegate?!0:!this.negate}return c.flipNegate?!1:this.negate}function q(a){return a.replace(/\\(.)/g,"$1")}function r(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}c?c.exports=h:b.minimatch=h,a||(a=function(a){switch(a){case"sigmund":return function(a){return JSON.stringify(a)};case"path":return{basename:function(a){a=a.split(/[\/\\]/);var b=a.pop();return b||(b=a.pop()),b}};case"lru-cache":return function(){var a={},b=0;this.set=function(c,d){b++,b>=100&&(a={}),a[c]=d},this.get=function(b){return a[b]}}}}),h.Minimatch=i;var s=a("lru-cache"),t=h.cache=new s({max:100}),u=h.GLOBSTAR=i.GLOBSTAR={},v=a("sigmund"),w=(a("path"),"[^/]"),x=w+"*?",y="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",z="(?:(?!(?:\\/|^)\\.).)*?",A=e("().*{}+?[]^$\\!"),B=/\/+/;h.filter=f,h.defaults=function(a){if(!a||!Object.keys(a).length)return h;var b=h,c=function(c,d,e){return b.minimatch(c,d,g(a,e))};return c.Minimatch=function(c,d){return new b.Minimatch(c,g(a,d))},c},i.defaults=function(a){return a&&Object.keys(a).length?h.defaults(a).Minimatch:i},i.prototype.debug=function(){},i.prototype.make=j,i.prototype.parseNegate=k,h.braceExpand=function(a,b){return new i(a,b).braceExpand()},i.prototype.braceExpand=m,i.prototype.parse=n;var C={};h.makeRe=function(a,b){return new i(a,b||{}).makeRe()},i.prototype.makeRe=o,h.match=function(a,b,c){c=c||{};var d=new i(b,c);return a=a.filter(function(a){return d.match(a)}),d.options.nonull&&!a.length&&a.push(b),a},i.prototype.match=p,i.prototype.matchOne=function(a,b,c){var d=this.options;this.debug("matchOne",{"this":this,file:a,pattern:b}),this.debug("matchOne",a.length,b.length);for(var e=0,f=0,g=a.length,h=b.length;g>e&&h>f;e++,f++){this.debug("matchOne loop");var i=b[f],j=a[e];if(this.debug(b,i,j),i===!1)return!1;if(i===u){this.debug("GLOBSTAR",[b,i,j]);var k=e,l=f+1;if(l===h){for(this.debug("** at the end");g>e;e++)if("."===a[e]||".."===a[e]||!d.dot&&"."===a[e].charAt(0))return!1;return!0}a:for(;g>k;){var m=a[k];if(this.debug("\nglobstar while",a,k,b,l,m),this.matchOne(a.slice(k),b.slice(l),c))return this.debug("globstar found match!",k,g,m),!0;if("."===m||".."===m||!d.dot&&"."===m.charAt(0)){this.debug("dot detected!",a,k,b,l);break a}this.debug("globstar swallow a segment, and continue"),k++}return c&&(this.debug("\n>>> no match, partial?",a,k,b,l),k===g)?!0:!1}var n;if("string"==typeof i?(n=d.nocase?j.toLowerCase()===i.toLowerCase():j===i,this.debug("string match",i,j,n)):(n=j.match(i),this.debug("pattern match",i,j,n)),!n)return!1}if(e===g&&f===h)return!0;if(e===g)return c;if(f===h){var o=e===g-1&&""===a[e];return o}throw new Error("wtf?")}}("function"==typeof a?a:null,this,"object"==typeof b?b:null,"object"==typeof process?process.platform:"win32")},{"lru-cache":12,path:10,sigmund:13}],12:[function(a,b,c){!function(){function a(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function c(){return 1}function d(a){return this instanceof d?("number"==typeof a&&(a={max:a}),a||(a={}),this._max=a.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=a.length||c,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=c),this._allowStale=a.stale||!1,this._maxAge=a.maxAge||null,this._dispose=a.dispose,void this.reset()):new d(a)}function e(a,b,c){var d=a._cache[b];return d&&(f(a,d)?(j(a,d),a._allowStale||(d=void 0)):c&&g(a,d),d&&(d=d.value)),d}function f(a,b){if(!b||!b.maxAge&&!a._maxAge)return!1;var c=!1,d=Date.now()-b.now;return c=b.maxAge?d>b.maxAge:a._maxAge&&d>a._maxAge}function g(a,b){i(a,b),b.lu=a._mru++,a._lruList[b.lu]=b}function h(a){for(;a._lrua._max;)j(a,a._lruList[a._lru])}function i(a,b){for(delete a._lruList[b.lu];a._lru=a)&&(a=1/0),this._max=a,this._length>this._max&&h(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(d.prototype,"lengthCalculator",{set:function(a){if("function"!=typeof a){this._lengthCalculator=c,this._length=this._itemCount;for(var b in this._cache)this._cache[b].length=1}else{this._lengthCalculator=a,this._length=0;for(var b in this._cache)this._cache[b].length=this._lengthCalculator(this._cache[b].value),this._length+=this._cache[b].length}this._length>this._max&&h(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(d.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(d.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),d.prototype.forEach=function(a,b){b=b||this;for(var c=0,d=this._itemCount,e=this._mru-1;e>=0&&d>c;e--)if(this._lruList[e]){c++;var g=this._lruList[e];f(this,g)&&(j(this,g),this._allowStale||(g=void 0)),g&&a.call(b,g.value,g.key,this)}},d.prototype.keys=function(){for(var a=new Array(this._itemCount),b=0,c=this._mru-1;c>=0&&b=0&&bthis._max?(this._dispose&&this._dispose(b,c),!1):(this._length+=g.length,this._lruList[g.lu]=this._cache[b]=g,this._itemCount++,this._length>this._max&&h(this),!0)},d.prototype.has=function(b){if(!a(this._cache,b))return!1;var c=this._cache[b];return f(this,c)?!1:!0},d.prototype.get=function(a){return e(this,a,!0)},d.prototype.peek=function(a){return e(this,a,!1)},d.prototype.pop=function(){var a=this._lruList[this._lru];return j(this,a),a||null},d.prototype.del=function(a){j(this,this._cache[a])}}()},{}],13:[function(a,b,c){function d(a,b){function c(a,g){return g>b||"function"==typeof a||"undefined"==typeof a?void 0:"object"!=typeof a||!a||a instanceof f?void(e+=a):void(-1===d.indexOf(a)&&g!==b&&(d.push(a),e+="{",Object.keys(a).forEach(function(b,d,f){if("_"!==b.charAt(0)){var h=typeof a[b];"function"!==h&&"undefined"!==h&&(e+=b,c(a[b],g+1))}})))}b=b||10;var d=[],e="",f=RegExp;return c(a,0),e}b.exports=d},{}],14:[function(a,b,c){(function(a){function c(b,c,d){return b instanceof ArrayBuffer&&(b=new Uint8Array(b)),new a(b,c,d)}c.prototype=Object.create(a.prototype),c.prototype.constructor=c,Object.keys(a).forEach(function(b){a.hasOwnProperty(b)&&(c[b]=a[b])}),b.exports=c}).call(this,a("buffer").Buffer)},{buffer:6}],15:[function(a,b,c){var d="READ",e="WRITE",f="CREATE",g="EXCLUSIVE",h="TRUNCATE",i="APPEND",j="CREATE",k="REPLACE";b.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:d,O_WRITE:e,O_CREATE:f,O_EXCLUSIVE:g,O_TRUNCATE:h,O_APPEND:i,O_FLAGS:{r:[d],"r+":[d,e],w:[e,f,h],"w+":[e,d,f,h],wx:[e,f,g,h],"wx+":[e,d,f,g,h],a:[e,f,i],"a+":[e,d,f,i],ax:[e,f,g,i],"ax+":[e,d,f,g,i]},XATTR_CREATE:j,XATTR_REPLACE:k,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],16:[function(a,b,c){var d=a("./constants.js").MODE_FILE;b.exports=function(a,b){this.id=a,this.type=b||d}},{"./constants.js":15}],17:[function(a,b,c){(function(a){function c(a){return a.toString("utf8")}function d(b){return new a(b,"utf8")}b.exports={encode:d,decode:c}}).call(this,a("buffer").Buffer)},{buffer:6}],18:[function(a,b,c){var d={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","50:EPERM:operation not permitted","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(a){function b(a,b){Error.call(this),this.name=e,this.code=e,this.errno=c,this.message=a||f,b&&(this.path=b),this.stack=new Error(this.message).stack}a=a.split(":");var c=+a[0],e=a[1],f=a[2];b.prototype=Object.create(Error.prototype),b.prototype.constructor=b,b.prototype.toString=function(){var a=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+a},d[e]=d[c]=b}),b.exports=d},{}],19:[function(a,b,c){function d(a,b,c,d,e){function f(c){a.changes.push({event:"change",path:b}),e(c)}var g=a.flags;ma(g).contains(Ka)&&delete d.ctime,ma(g).contains(Ja)&&delete d.mtime;var h=!1;d.ctime&&(c.ctime=d.ctime,c.atime=d.ctime,h=!0),d.atime&&(c.atime=d.atime,h=!0),d.mtime&&(c.mtime=d.mtime,h=!0),h?a.putObject(c.id,c,f):f()}function e(a,b,c,e){function g(c,d){c?e(c):d.mode!==va?e(new Ma.ENOTDIR("a component of the path prefix is not a directory",b)):(l=d,f(a,b,h))}function h(c,d){!c&&d?e(new Ma.EEXIST("path name already exists",b)):!c||c instanceof Ma.ENOENT?a.getObject(l.data,i):e(c)}function i(b,d){b?e(b):(m=d,Qa.create({guid:a.guid,mode:c},function(b,c){return b?void e(b):(n=c,n.nlinks+=1,void a.putObject(n.id,n,k))}))}function j(b){if(b)e(b);else{var c=Date.now();d(a,p,n,{mtime:c,ctime:c},e)}}function k(b){b?e(b):(m[o]=new Na(n.id,c),a.putObject(l.data,m,j))}if(c!==va&&c!==ua)return e(new Ma.EINVAL("mode must be a directory or file",b));b=oa(b);var l,m,n,o=qa(b),p=pa(b);f(a,p,g)}function f(a,b,c){function d(b,d){b?c(b):d&&d.mode===xa&&d.rnode?a.getObject(d.rnode,e):c(new Ma.EFILESYSTEMERROR)}function e(a,b){a?c(a):b?c(null,b):c(new Ma.ENOENT)}function g(d,e){d?c(d):e.mode===va&&e.data?a.getObject(e.data,h):c(new Ma.ENOTDIR("a component of the path prefix is not a directory",b))}function h(d,e){if(d)c(d);else if(ma(e).has(k)){var f=e[k].id;a.getObject(f,i)}else c(new Ma.ENOENT(null,b))}function i(a,d){a?c(a):d.mode==wa?(m++,m>Aa?c(new Ma.ELOOP(null,b)):j(d.data)):c(null,d)}function j(b){b=oa(b),l=pa(b),k=qa(b),ya==k?a.getObject(za,d):f(a,l,g)}if(b=oa(b),!b)return c(new Ma.ENOENT("path is an empty string"));var k=qa(b),l=pa(b),m=0;ya==k?a.getObject(za,d):f(a,l,g)}function g(a,b,c,e,f,g,h){function i(e){e?h(e):d(a,b,c,{ctime:Date.now()},h)}var j=c.xattrs;g===Ha&&j.hasOwnProperty(e)?h(new Ma.EEXIST("attribute already exists",b)):g!==Ia||j.hasOwnProperty(e)?(j[e]=f,a.putObject(c.id,c,i)):h(new Ma.ENOATTR(null,b))}function h(a,b){function c(c,e){!c&&e?b():!c||c instanceof Ma.ENOENT?Pa.create({guid:a.guid},function(c,e){return c?void b(c):(f=e,void a.putObject(f.id,f,d))}):b(c)}function d(c){c?b(c):Qa.create({guid:a.guid,id:f.rnode,mode:va},function(c,d){return c?void b(c):(g=d,g.nlinks+=1,void a.putObject(g.id,g,e))})}function e(c){c?b(c):(h={},a.putObject(g.data,h,b))}var f,g,h;a.getObject(za,c)}function i(a,b,c){function e(d,e){!d&&e?c(new Ma.EEXIST(null,b)):!d||d instanceof Ma.ENOENT?f(a,q,g):c(d)}function g(b,d){b?c(b):(n=d,a.getObject(n.data,h))}function h(b,d){b?c(b):(o=d,Qa.create({guid:a.guid,mode:va},function(b,d){return b?void c(b):(l=d,l.nlinks+=1,void a.putObject(l.id,l,i))}))}function i(b){b?c(b):(m={},a.putObject(l.data,m,k))}function j(b){if(b)c(b);else{var e=Date.now();d(a,q,n,{mtime:e,ctime:e},c)}}function k(b){b?c(b):(o[p]=new Na(l.id,va),a.putObject(n.data,o,j))}b=oa(b);var l,m,n,o,p=qa(b),q=pa(b);f(a,b,e)}function j(a,b,c){function e(b,d){b?c(b):(p=d,a.getObject(p.data,g))}function g(d,e){d?c(d):ya==r?c(new Ma.EBUSY(null,b)):ma(e).has(r)?(q=e,n=q[r].id,a.getObject(n,h)):c(new Ma.ENOENT(null,b))}function h(d,e){d?c(d):e.mode!=va?c(new Ma.ENOTDIR(null,b)):(n=e,a.getObject(n.data,i))}function i(a,d){a?c(a):(o=d,ma(o).size()>0?c(new Ma.ENOTEMPTY(null,b)):k())}function j(b){if(b)c(b);else{var e=Date.now();d(a,s,p,{mtime:e,ctime:e},l)}}function k(){delete q[r],a.putObject(p.data,q,j)}function l(b){b?c(b):a["delete"](n.id,m)}function m(b){b?c(b):a["delete"](n.data,c)}b=oa(b);var n,o,p,q,r=qa(b),s=pa(b);f(a,s,e)}function k(a,b,c,e){function g(c,d){c?e(c):d.mode!==va?e(new Ma.ENOENT(null,b)):(q=d,a.getObject(q.data,h))}function h(d,f){d?e(d):(r=f,ma(r).has(v)?ma(c).contains(Ea)?e(new Ma.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",b)):(s=r[v],s.type==va&&ma(c).contains(Ca)?e(new Ma.EISDIR("the named file is a directory and O_WRITE is set",b)):a.getObject(s.id,i)):ma(c).contains(Da)?l():e(new Ma.ENOENT("O_CREATE is not set and the named file does not exist",b)))}function i(a,c){if(a)e(a);else{var d=c;d.mode==wa?(x++,x>Aa?e(new Ma.ELOOP(null,b)):j(d.data)):k(void 0,d)}}function j(d){d=oa(d),w=pa(d),v=qa(d),ya==v&&(ma(c).contains(Ca)?e(new Ma.EISDIR("the named file is a directory and O_WRITE is set",b)):f(a,b,k)),f(a,w,g)}function k(a,b){a?e(a):(t=b,e(null,t))}function l(){Qa.create({guid:a.guid,mode:ua},function(b,c){return b?void e(b):(t=c,t.nlinks+=1,void a.putObject(t.id,t,m))})}function m(b){b?e(b):(u=new Sa(0),u.fill(0),a.putBuffer(t.data,u,o))}function n(b){if(b)e(b);else{var c=Date.now();d(a,w,q,{mtime:c,ctime:c},p)}}function o(b){b?e(b):(r[v]=new Na(t.id,ua),a.putObject(q.data,r,n))}function p(a){a?e(a):e(null,t)}b=oa(b);var q,r,s,t,u,v=qa(b),w=pa(b),x=0;ya==v?ma(c).contains(Ca)?e(new Ma.EISDIR("the named file is a directory and O_WRITE is set",b)):f(a,b,k):f(a,w,g)}function l(a,b,c,e,f,g){function h(a){a?g(a):g(null,f)}function i(c){if(c)g(c);else{var e=Date.now();d(a,b.path,l,{mtime:e,ctime:e},h)}}function j(b){b?g(b):a.putObject(l.id,l,i)}function k(d,h){if(d)g(d);else{l=h;var i=new Sa(f);i.fill(0),c.copy(i,0,e,e+f),b.position=f,l.size=f,l.version+=1,a.putBuffer(l.data,i,j)}}var l;a.getObject(b.id,k)}function m(a,b,c,e,f,g,h){function i(a){a?h(a):h(null,f)}function j(c){if(c)h(c);else{var e=Date.now();d(a,b.path,n,{mtime:e,ctime:e},i)}}function k(b){b?h(b):a.putObject(n.id,n,j)}function l(d,i){if(d)h(d);else{if(o=i,!o)return h(new Ma.EIO("Expected Buffer"));var j=void 0!==g&&null!==g?g:b.position,l=Math.max(o.length,j+f),m=new Sa(l);m.fill(0),o&&o.copy(m),c.copy(m,j,e,e+f),void 0===g&&(b.position+=f),n.size=l,n.version+=1,a.putBuffer(n.data,m,k)}}function m(b,c){b?h(b):(n=c,a.getBuffer(n.data,l))}var n,o;a.getObject(b.id,m)}function n(a,b,c,d,e,f,g){function h(a,h){if(a)g(a);else{if(k=h,!k)return g(new Ma.EIO("Expected Buffer"));var i=void 0!==f&&null!==f?f:b.position;e=i+e>c.length?e-i:e,k.copy(c,d,i,i+e),void 0===f&&(b.position+=e),g(null,e)}}function i(c,d){c?g(c):"DIRECTORY"===d.mode?g(new Ma.EISDIR("the named file is a directory",b.path)):(j=d,a.getBuffer(j.data,h))}var j,k;a.getObject(b.id,i)}function o(a,b,c){b=oa(b);qa(b);f(a,b,c)}function p(a,b,c){b.getNode(a,c)}function q(a,b,c){function d(b,d){b?c(b):(g=d,a.getObject(g.data,e))}function e(d,e){d?c(d):(h=e,ma(h).has(i)?a.getObject(h[i].id,c):c(new Ma.ENOENT("a component of the path does not name an existing file",b)))}b=oa(b);var g,h,i=qa(b),j=pa(b);ya==i?f(a,b,c):f(a,j,d)}function r(a,b,c,e){function g(b){b?e(b):d(a,c,t,{ctime:Date.now()},e)}function h(b,c){b?e(b):(t=c,t.nlinks+=1,a.putObject(t.id,t,g))}function i(b,c){b?e(b):a.getObject(s[u].id,h)}function j(b,c){b?e(b):(s=c,ma(s).has(u)?e(new Ma.EEXIST("newpath resolves to an existing file",u)):(s[u]=q[n],a.putObject(r.data,s,i)))}function k(b,c){b?e(b):(r=c,a.getObject(r.data,j))}function l(b,c){b?e(b):(q=c,ma(q).has(n)?"DIRECTORY"===q[n].type?e(new Ma.EPERM("oldpath refers to a directory")):f(a,v,k):e(new Ma.ENOENT("a component of either path prefix does not exist",n)))}function m(b,c){b?e(b):(p=c,a.getObject(p.data,l))}b=oa(b);var n=qa(b),o=pa(b);c=oa(c);var p,q,r,s,t,u=qa(c),v=pa(c);f(a,o,m)}function s(a,b,c){function e(b){b?c(b):(delete m[o],a.putObject(l.data,m,function(b){var e=Date.now();d(a,p,l,{mtime:e,ctime:e},c)}))}function g(b){b?c(b):a["delete"](n.data,e)}function h(f,h){f?c(f):(n=h,n.nlinks-=1,n.nlinks<1?a["delete"](n.id,g):a.putObject(n.id,n,function(c){d(a,b,n,{ctime:Date.now()},e)}))}function i(a,b){a?c(a):"DIRECTORY"===b.mode?c(new Ma.EPERM("unlink not permitted on directories",o)):h(null,b)}function j(b,d){b?c(b):(m=d,ma(m).has(o)?a.getObject(m[o].id,i):c(new Ma.ENOENT("a component of the path does not name an existing file",o)))}function k(b,d){b?c(b):(l=d,a.getObject(l.data,j))}b=oa(b);var l,m,n,o=qa(b),p=pa(b);f(a,p,k)}function t(a,b,c){function d(a,b){if(a)c(a);else{h=b;var d=Object.keys(h);c(null,d)}}function e(e,f){e?c(e):f.mode!==va?c(new Ma.ENOTDIR(null,b)):(g=f,a.getObject(g.data,d))}b=oa(b);var g,h;qa(b);f(a,b,e)}function u(a,b,c,e){function g(b,c){b?e(b):(l=c,a.getObject(l.data,h))}function h(a,b){a?e(a):(m=b,ma(m).has(o)?e(new Ma.EEXIST(null,o)):i())}function i(){Qa.create({guid:a.guid,mode:wa},function(c,d){return c?void e(c):(n=d,n.nlinks+=1,n.size=b.length,n.data=b,void a.putObject(n.id,n,k))})}function j(b){if(b)e(b);else{var c=Date.now();d(a,p,l,{mtime:c,ctime:c},e)}}function k(b){b?e(b):(m[o]=new Na(n.id,wa),a.putObject(l.data,m,j))}c=oa(c);var l,m,n,o=qa(c),p=pa(c);ya==o?e(new Ma.EEXIST(null,o)):f(a,p,g)}function v(a,b,c){function d(b,d){b?c(b):(h=d,a.getObject(h.data,e))}function e(b,d){b?c(b):(i=d,ma(i).has(j)?a.getObject(i[j].id,g):c(new Ma.ENOENT("a component of the path does not name an existing file",j)))}function g(a,d){a?c(a):d.mode!=wa?c(new Ma.EINVAL("path not a symbolic link",b)):c(null,d.data)}b=oa(b);var h,i,j=qa(b),k=pa(b);f(a,k,d)}function w(a,b,c,e){function g(c,d){c?e(c):d.mode==va?e(new Ma.EISDIR(null,b)):(k=d,a.getBuffer(k.data,h))}function h(b,d){if(b)e(b);else{if(!d)return e(new Ma.EIO("Expected Buffer"));var f=new Sa(c);f.fill(0),d&&d.copy(f),a.putBuffer(k.data,f,j)}}function i(c){if(c)e(c);else{var f=Date.now();d(a,b,k,{mtime:f,ctime:f},e)}}function j(b){b?e(b):(k.size=c,k.version+=1,a.putObject(k.id,k,i))}b=oa(b);var k;0>c?e(new Ma.EINVAL("length cannot be negative")):f(a,b,g)}function x(a,b,c,e){function f(b,c){b?e(b):c.mode==va?e(new Ma.EISDIR):(j=c,a.getBuffer(j.data,g))}function g(b,d){if(b)e(b);else{var f;if(!d)return e(new Ma.EIO("Expected Buffer"));d?f=d.slice(0,c):(f=new Sa(c),f.fill(0)),a.putBuffer(j.data,f,i)}}function h(c){if(c)e(c);else{var f=Date.now();d(a,b.path,j,{mtime:f,ctime:f},e)}}function i(b){b?e(b):(j.size=c,j.version+=1,a.putObject(j.id,j,h))}var j;0>c?e(new Ma.EINVAL("length cannot be negative")):b.getNode(a,f)}function y(a,b,c,e,g){function h(f,h){f?g(f):d(a,b,h,{atime:c,ctime:e,mtime:e},g)}b=oa(b),"number"!=typeof c||"number"!=typeof e?g(new Ma.EINVAL("atime and mtime must be number",b)):0>c||0>e?g(new Ma.EINVAL("atime and mtime must be positive integers",b)):f(a,b,h)}function z(a,b,c,e,f){function g(g,h){g?f(g):d(a,b.path,h,{atime:c,ctime:e,mtime:e},f)}"number"!=typeof c||"number"!=typeof e?f(new Ma.EINVAL("atime and mtime must be a number")):0>c||0>e?f(new Ma.EINVAL("atime and mtime must be positive integers")):b.getNode(a,g)}function A(a,b,c,d,e,h){function i(f,i){return f?h(f):void g(a,b,i,c,d,e,h)}b=oa(b),"string"!=typeof c?h(new Ma.EINVAL("attribute name must be a string",b)):c?null!==e&&e!==Ha&&e!==Ia?h(new Ma.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",b)):f(a,b,i):h(new Ma.EINVAL("attribute name cannot be an empty string",b))}function B(a,b,c,d,e,f){function h(h,i){return h?f(h):void g(a,b.path,i,c,d,e,f)}"string"!=typeof c?f(new Ma.EINVAL("attribute name must be a string")):c?null!==e&&e!==Ha&&e!==Ia?f(new Ma.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):b.getNode(a,h):f(new Ma.EINVAL("attribute name cannot be an empty string"))}function C(a,b,c,d){function e(a,e){if(a)return d(a);var f=e.xattrs;f.hasOwnProperty(c)?d(null,f[c]):d(new Ma.ENOATTR(null,b))}b=oa(b),"string"!=typeof c?d(new Ma.EINVAL("attribute name must be a string",b)):c?f(a,b,e):d(new Ma.EINVAL("attribute name cannot be an empty string",b))}function D(a,b,c,d){function e(a,b){if(a)return d(a);var e=b.xattrs;e.hasOwnProperty(c)?d(null,e[c]):d(new Ma.ENOATTR)}"string"!=typeof c?d(new Ma.EINVAL):c?b.getNode(a,e):d(new Ma.EINVAL("attribute name cannot be an empty string"))}function E(a,b,c,e){function g(f,g){function h(c){c?e(c):d(a,b,g,{ctime:Date.now()},e)}if(f)return e(f);var i=g.xattrs;i.hasOwnProperty(c)?(delete i[c],a.putObject(g.id,g,h)):e(new Ma.ENOATTR(null,b))}b=oa(b),"string"!=typeof c?e(new Ma.EINVAL("attribute name must be a string",b)):c?f(a,b,g):e(new Ma.EINVAL("attribute name cannot be an empty string",b))}function F(a,b,c,e){function f(f,g){function h(c){c?e(c):d(a,b.path,g,{ctime:Date.now()},e)}if(f)return e(f);var i=g.xattrs;i.hasOwnProperty(c)?(delete i[c],a.putObject(g.id,g,h)):e(new Ma.ENOATTR)}"string"!=typeof c?e(new Ma.EINVAL("attribute name must be a string")):c?b.getNode(a,f):e(new Ma.EINVAL("attribute name cannot be an empty string"))}function G(a){return ma(Ga).has(a)?Ga[a]:null}function H(a,b,c){return a?"function"==typeof a?a={encoding:b,flag:c}:"string"==typeof a&&(a={encoding:a,flag:c}):a={encoding:b,flag:c},a}function I(a,b){var c;return a?sa(a)?c=new Ma.EINVAL("Path must be a string without null bytes.",a):ra(a)||(c=new Ma.EINVAL("Path must be absolute.",a)):c=new Ma.EINVAL("Path must be a string",a),c?(b(c),!1):!0}function J(a,b,c,d,e,f){function g(b,e){if(b)f(b);else{var g;g=ma(d).contains(Fa)?e.size:0;var h=new Oa(c,e.id,d,g),i=a.allocDescriptor(h);f(null,i)}}f=arguments[arguments.length-1],I(c,f)&&(d=G(d),d||f(new Ma.EINVAL("flags is not valid"),c),k(b,c,d,g))}function K(a,b,c,d){ma(a.openFiles).has(c)?(a.releaseDescriptor(c),d(null)):d(new Ma.EBADF)}function L(a,b,c,d,f){I(c,f)&&e(b,c,d,f)}function M(a,b,c,d,e){e=arguments[arguments.length-1],I(c,e)&&i(b,c,e)}function N(a,b,c,d){I(c,d)&&j(b,c,d)}function O(a,b,c,d){function e(b,c){if(b)d(b);else{var e=new Ra(c,a.name);d(null,e)}}I(c,d)&&o(b,c,e)}function P(a,b,c,d){function e(b,c){if(b)d(b);else{var e=new Ra(c,a.name);d(null,e)}}var f=a.openFiles[c];f?p(b,f,e):d(new Ma.EBADF)}function Q(a,b,c,d,e){I(c,e)&&I(d,e)&&r(b,c,d,e)}function R(a,b,c,d){I(c,d)&&s(b,c,d)}function S(a,b,c,d,e,f,g,h){function i(a,b){h(a,b||0,d)}e=void 0===e?0:e,f=void 0===f?d.length-e:f,h=arguments[arguments.length-1];var j=a.openFiles[c];j?ma(j.flags).contains(Ba)?n(b,j,d,e,f,g,i):h(new Ma.EBADF("descriptor does not permit reading")):h(new Ma.EBADF)}function T(a,b,c,d,e){if(e=arguments[arguments.length-1],d=H(d,null,"r"),I(c,e)){var f=G(d.flag||"r");return f?void k(b,c,f,function(g,h){function i(){a.releaseDescriptor(k)}if(g)return e(g);var j=new Oa(c,h.id,f,0),k=a.allocDescriptor(j);p(b,j,function(f,g){if(f)return i(),e(f);var h=new Ra(g,a.name);if(h.isDirectory())return i(),e(new Ma.EISDIR("illegal operation on directory",c));var k=h.size,l=new Sa(k);l.fill(0),n(b,j,l,0,k,0,function(a,b){if(i(),a)return e(a);var c;c="utf8"===d.encoding?La.decode(l):l,e(null,c)})})}):e(new Ma.EINVAL("flags is not valid",c))}}function U(a,b,c,d,e,f,g,h){h=arguments[arguments.length-1],e=void 0===e?0:e,f=void 0===f?d.length-e:f;var i=a.openFiles[c];i?ma(i.flags).contains(Ca)?d.length-ed?f(new Ma.EINVAL("resulting file offset would be negative")):(h.position=d,f(null,h.position)):"CUR"===e?h.position+d<0?f(new Ma.EINVAL("resulting file offset would be negative")):(h.position+=d,f(null,h.position)):"END"===e?p(b,h,g):f(new Ma.EINVAL("whence argument is not a proper value"))}function da(a,b,c,d){I(c,d)&&t(b,c,d)}function ea(a,b,c,d,e,f){if(I(c,f)){var g=Date.now();d=d?d:g,e=e?e:g,y(b,c,d,e,f)}}function fa(a,b,c,d,e,f){var g=Date.now();d=d?d:g,e=e?e:g;var h=a.openFiles[c];h?ma(h.flags).contains(Ca)?z(b,h,d,e,f):f(new Ma.EBADF("descriptor does not permit writing")):f(new Ma.EBADF)}function ga(a,b,c,e,g){function h(a,c){a?g(a):d(b,e,c,{ctime:Date.now()},g)}function i(a){a?g(a):b.getObject(x[B].id,h)}function k(a){a?g(a):(u.id===w.id&&(v=x),delete v[A],b.putObject(u.data,v,i))}function l(a){a?g(a):(x[B]=v[A],b.putObject(w.data,x,k))}function m(a,c){a?g(a):(x=c,ma(x).has(B)?j(b,e,l):l())}function n(a,c){a?g(a):(w=c,b.getObject(w.data,m))}function o(a,c){a?g(a):(v=c,f(b,z,n))}function p(a,c){a?g(a):(u=c,b.getObject(c.data,o))}function q(a){a?g(a):s(b,c,g)}function t(a,d){a?g(a):"DIRECTORY"===d.mode?f(b,y,p):r(b,c,e,q)}if(I(c,g)&&I(e,g)){c=oa(c),e=oa(e);var u,v,w,x,y=na.dirname(c),z=na.dirname(c),A=na.basename(c),B=na.basename(e);f(b,c,t)}}function ha(a,b,c,d,e,f){f=arguments[arguments.length-1],I(c,f)&&I(d,f)&&u(b,c,d,f)}function ia(a,b,c,d){I(c,d)&&v(b,c,d)}function ja(a,b,c,d){function e(b,c){if(b)d(b);else{var e=new Ra(c,a.name);d(null,e)}}I(c,d)&&q(b,c,e)}function ka(a,b,c,d,e){e=arguments[arguments.length-1],d=d||0,I(c,e)&&w(b,c,d,e)}function la(a,b,c,d,e){e=arguments[arguments.length-1],d=d||0;var f=a.openFiles[c];f?ma(f.flags).contains(Ca)?x(b,f,d,e):e(new Ma.EBADF("descriptor does not permit writing")):e(new Ma.EBADF)}var ma=a("../../lib/nodash.js"),na=a("../path.js"),oa=na.normalize,pa=na.dirname,qa=na.basename,ra=na.isAbsolute,sa=na.isNull,ta=a("../constants.js"),ua=ta.MODE_FILE,va=ta.MODE_DIRECTORY,wa=ta.MODE_SYMBOLIC_LINK,xa=ta.MODE_META,ya=ta.ROOT_DIRECTORY_NAME,za=ta.SUPER_NODE_ID,Aa=ta.SYMLOOP_MAX,Ba=ta.O_READ,Ca=ta.O_WRITE,Da=ta.O_CREATE,Ea=ta.O_EXCLUSIVE,Fa=(ta.O_TRUNCATE, +ta.O_APPEND),Ga=ta.O_FLAGS,Ha=ta.XATTR_CREATE,Ia=ta.XATTR_REPLACE,Ja=ta.FS_NOMTIME,Ka=ta.FS_NOCTIME,La=a("../encoding.js"),Ma=a("../errors.js"),Na=a("../directory-entry.js"),Oa=a("../open-file-description.js"),Pa=a("../super-node.js"),Qa=a("../node.js"),Ra=a("../stats.js"),Sa=a("../buffer.js");b.exports={ensureRootDirectory:h,open:J,close:K,mknod:L,mkdir:M,rmdir:N,unlink:R,stat:O,fstat:P,link:Q,read:S,readFile:T,write:U,writeFile:V,appendFile:W,exists:X,getxattr:Y,fgetxattr:Z,setxattr:$,fsetxattr:_,removexattr:aa,fremovexattr:ba,lseek:ca,readdir:da,utimes:ea,futimes:fa,rename:ga,symlink:ha,readlink:ia,lstat:ja,truncate:ka,ftruncate:la}},{"../../lib/nodash.js":4,"../buffer.js":14,"../constants.js":15,"../directory-entry.js":16,"../encoding.js":17,"../errors.js":18,"../node.js":23,"../open-file-description.js":24,"../path.js":25,"../stats.js":33,"../super-node.js":34}],20:[function(a,b,c){function d(a){return"function"==typeof a?a:function(a){if(a)throw a}}function e(a){a&&console.error("Filer error: ",a)}function f(a,b){function c(){I.forEach(function(a){a.call(this)}.bind(F)),I=null}function d(a){return function(b){function c(b){var d=B();a.getObject(d,function(a,e){return a?void b(a):void(e?c(b):b(null,d))})}return g(j).contains(p)?void b(null,B()):void c(b)}}function f(a){if(a.length){var b=s.getInstance();a.forEach(function(a){b.emit(a.event,a.path)})}}a=a||{},b=b||e;var j=a.flags,B=a.guid?a.guid:v,C=a.provider||new q.Default(a.name||k),D=a.name||C.name,E=g(j).contains(l),F=this;F.readyState=n,F.name=D,F.error=null,F.stdin=w,F.stdout=x,F.stderr=y,this.Shell=r.bind(void 0,this);var G={},H=z;Object.defineProperty(this,"openFiles",{get:function(){return G}}),this.allocDescriptor=function(a){var b=H++;return G[b]=a,b},this.releaseDescriptor=function(a){delete G[a]};var I=[];this.queueOrRun=function(a){var b;return m==F.readyState?a.call(F):o==F.readyState?b=new u.EFILESYSTEMERROR("unknown error"):I.push(a),b},this.watch=function(a,b,c){if(h(a))throw new Error("Path must be a string without null bytes.");"function"==typeof b&&(c=b,b={}),b=b||{},c=c||i;var d=new t;return d.start(a,!1,b.recursive),d.on("change",c),d},C.open(function(a){function e(a){function e(a){var b=C[a]();return b.flags=j,b.changes=[],b.guid=d(b),b.close=function(){var a=b.changes;f(a),a.length=0},b}F.provider={openReadWriteContext:function(){return e("getReadWriteContext")},openReadOnlyContext:function(){return e("getReadOnlyContext")}},a?F.readyState=o:F.readyState=m,c(),b(a,F)}if(a)return e(a);var g=C.getReadWriteContext();g.guid=d(g),E?g.clear(function(a){return a?e(a):void A.ensureRootDirectory(g,e)}):A.ensureRootDirectory(g,e)})}var g=a("../../lib/nodash.js"),h=a("../path.js").isNull,i=a("../shared.js").nop,j=a("../constants.js"),k=j.FILE_SYSTEM_NAME,l=j.FS_FORMAT,m=j.FS_READY,n=j.FS_PENDING,o=j.FS_ERROR,p=j.FS_NODUPEIDCHECK,q=a("../providers/index.js"),r=a("../shell/shell.js"),s=a("../../lib/intercom.js"),t=a("../fs-watcher.js"),u=a("../errors.js"),v=a("../shared.js").guid,w=j.STDIN,x=j.STDOUT,y=j.STDERR,z=j.FIRST_DESCRIPTOR,A=a("./implementation.js");f.providers=q,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(a){f.prototype[a]=function(){var b=this,c=Array.prototype.slice.call(arguments,0),e=c.length-1,f="function"!=typeof c[e],g=d(c[e]),h=b.queueOrRun(function(){function d(){h.close(),g.apply(b,arguments)}var h=b.provider.openReadWriteContext();if(o===b.readyState){var i=new u.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return g.call(b,i)}f?c.push(d):c[e]=d;var j=[b,h].concat(c);A[a].apply(null,j)});h&&g(h)}}),b.exports=f},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":15,"../errors.js":18,"../fs-watcher.js":21,"../path.js":25,"../providers/index.js":26,"../shared.js":30,"../shell/shell.js":32,"./implementation.js":19}],21:[function(a,b,c){function d(){function a(a){(c===a||h&&0===a.indexOf(b))&&d.trigger("change","change",a)}e.call(this);var b,c,d=this,h=!1;d.start=function(d,e,i){if(!c){if(f.isNull(d))throw new Error("Path must be a string without null bytes.");c=f.normalize(d),h=i===!0,h&&(b="/"===c?"/":c+"/");var j=g.getInstance();j.on("change",a)}},d.close=function(){var b=g.getInstance();b.off("change",a),d.removeAllListeners("change")}}var e=a("../lib/eventemitter.js"),f=a("./path.js"),g=a("../lib/intercom.js");d.prototype=new e,d.prototype.constructor=d,b.exports=d},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":25}],22:[function(a,b,c){b.exports={FileSystem:a("./filesystem/interface.js"),Buffer:a("./buffer.js"),Path:a("./path.js"),Errors:a("./errors.js"),Shell:a("./shell/shell.js")}},{"./buffer.js":14,"./errors.js":18,"./filesystem/interface.js":20,"./path.js":25,"./shell/shell.js":32}],23:[function(a,b,c){function d(a){var b=Date.now();this.id=a.id,this.mode=a.mode||f,this.size=a.size||0,this.atime=a.atime||b,this.ctime=a.ctime||b,this.mtime=a.mtime||b,this.flags=a.flags||[],this.xattrs=a.xattrs||{},this.nlinks=a.nlinks||0,this.version=a.version||0,this.blksize=void 0,this.nblocks=1,this.data=a.data}function e(a,b,c){a[b]?c(null):a.guid(function(d,e){a[b]=e,c(d)})}var f=a("./constants.js").MODE_FILE;d.create=function(a,b){e(a,"id",function(c){return c?void b(c):void e(a,"data",function(c){return c?void b(c):void b(null,new d(a))})})},b.exports=d},{"./constants.js":15}],24:[function(a,b,c){function d(a,b,c,d){this.path=a,this.id=b,this.flags=c,this.position=d}var e=a("./errors.js");d.prototype.getNode=function(a,b){function c(a,c){return a?b(a):c?void b(null,c):b(new e.EBADF("file descriptor refers to unknown node",f))}var d=this.id,f=this.path;a.getObject(d,c)},b.exports=d},{"./errors.js":18}],25:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function e(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var e=c>=0?arguments[c]:"/";"string"==typeof e&&e&&(a=e+"/"+a,b="/"===e.charAt(0))}return a=d(a.split("/").filter(function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."}function f(a){var b="/"===a.charAt(0);"/"===a.substr(-1);return a=d(a.split("/").filter(function(a){return!!a}),!b).join("/"),a||b||(a="."),(b?"/":"")+a}function g(){var a=Array.prototype.slice.call(arguments,0);return f(a.filter(function(a,b){return a&&"string"==typeof a}).join("/"))}function h(a,b){function c(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=e(a).substr(1),b=e(b).substr(1);for(var d=c(a.split("/")),f=c(b.split("/")),g=Math.min(d.length,f.length),h=g,i=0;g>i;i++)if(d[i]!==f[i]){h=i;break}for(var j=[],i=h;id;d++)b[d]=a[d];return b}b.exports={guid:d,u8toArray:f,nop:e}},{}],31:[function(a,b,c){var d=a("../constants.js").ENVIRONMENT;b.exports=function(a){a=a||{},a.TMP=a.TMP||d.TMP,a.PATH=a.PATH||d.PATH,this.get=function(b){return a[b]},this.set=function(b,c){a[b]=c}}},{"../constants.js":15}],32:[function(a,b,c){function d(a,b){b=b||{};var c=new g(b.env),d="/";Object.defineProperty(this,"fs",{get:function(){return a},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return c},enumerable:!0}),this.cd=function(b,c){b=e.resolve(d,b),a.stat(b,function(a,e){return a?void c(new f.ENOTDIR(null,b)):void("DIRECTORY"===e.type?(d=b,c()):c(new f.ENOTDIR(null,b)))})},this.pwd=function(){return d}}var e=a("../path.js"),f=a("../errors.js"),g=a("./environment.js"),h=a("../../lib/async.js"),i=(a("../encoding.js"),a("minimatch"));d.prototype.exec=function(a,b,c){var d=this,f=d.fs;"function"==typeof b&&(c=b,b=[]),b=b||[],c=c||function(){},a=e.resolve(d.pwd(),a),f.readFile(a,"utf8",function(a,d){if(a)return void c(a);try{var e=new Function("fs","args","callback",d);e(f,b,c)}catch(g){c(g)}})},d.prototype.touch=function(a,b,c){function d(a){h.writeFile(a,"",c)}function f(a){var d=Date.now(),e=b.date||d,f=b.date||d;h.utimes(a,e,f,c)}var g=this,h=g.fs;"function"==typeof b&&(c=b,b={}),b=b||{},c=c||function(){},a=e.resolve(g.pwd(),a),h.stat(a,function(e,g){e?b.updateOnly===!0?c():d(a):f(a)})},d.prototype.cat=function(a,b){function c(a,b){var c=e.resolve(d.pwd(),a);g.readFile(c,"utf8",function(a,c){return a?void b(a):(i+=c+"\n",void b())})}var d=this,g=d.fs,i="";return b=b||function(){},a?(a="string"==typeof a?[a]:a,void h.eachSeries(a,c,function(a){a?b(a):b(null,i.replace(/\n$/,""))})):void b(new f.EINVAL("Missing files argument"))},d.prototype.ls=function(a,b,c){function d(a,c){var f=e.resolve(g.pwd(),a),j=[];i.readdir(f,function(a,g){function k(a,c){a=e.join(f,a),i.stat(a,function(g,h){if(g)return void c(g);var i={path:e.basename(a),links:h.nlinks,size:h.size,modified:h.mtime,type:h.type};b.recursive&&"DIRECTORY"===h.type?d(e.join(f,i.path),function(a,b){return a?void c(a):(i.contents=b,j.push(i),void c())}):(j.push(i),c())})}return a?void c(a):void h.eachSeries(g,k,function(a){c(a,j)})})}var g=this,i=g.fs;return"function"==typeof b&&(c=b,b={}),b=b||{},c=c||function(){},a?void d(a,c):void c(new f.EINVAL("Missing dir argument"))},d.prototype.rm=function(a,b,c){function d(a,c){a=e.resolve(g.pwd(),a),i.stat(a,function(g,j){return g?void c(g):"FILE"===j.type?void i.unlink(a,c):void i.readdir(a,function(g,j){return g?void c(g):0===j.length?void i.rmdir(a,c):b.recursive?(j=j.map(function(b){return e.join(a,b)}),void h.eachSeries(j,d,function(b){return b?void c(b):void i.rmdir(a,c)})):void c(new f.ENOTEMPTY(null,a))})})}var g=this,i=g.fs;return"function"==typeof b&&(c=b,b={}),b=b||{},c=c||function(){},a?void d(a,c):void c(new f.EINVAL("Missing path argument"))},d.prototype.tempDir=function(a){var b=this,c=b.fs,d=b.env.get("TMP");a=a||function(){},c.mkdir(d,function(b){a(null,d)})},d.prototype.mkdirp=function(a,b){function c(a,b){g.stat(a,function(d,h){if(h){if(h.isDirectory())return void b();if(h.isFile())return void b(new f.ENOTDIR(null,a))}else{if(d&&"ENOENT"!==d.code)return void b(d);var i=e.dirname(a);"/"===i?g.mkdir(a,function(a){return a&&"EEXIST"!=a.code?void b(a):void b()}):c(i,function(c){return c?b(c):void g.mkdir(a,function(a){return a&&"EEXIST"!=a.code?void b(a):void b()})})}})}var d=this,g=d.fs;return b=b||function(){},a?"/"===a?void b():void c(a,b):void b(new f.EINVAL("Missing path argument"))},d.prototype.find=function(a,b,c){function d(a,b){m(a,function(c){return c?void b(c):(n.push(a),void b())})}function g(a,c){var f=e.removeTrailing(a);return b.regex&&!b.regex.test(f)?void c():b.name&&!i(e.basename(f),b.name)?void c():b.path&&!i(e.dirname(f),b.path)?void c():void d(a,c)}function j(a,b){a=e.resolve(k.pwd(),a),l.readdir(a,function(c,d){return c?void("ENOTDIR"===c.code?g(a,b):b(c)):void g(e.addTrailing(a),function(c){return c?void b(c):(d=d.map(function(b){return e.join(a,b)}),void h.eachSeries(d,j,function(a){b(a,n)}))})})}var k=this,l=k.fs;"function"==typeof b&&(c=b,b={}),b=b||{},c=c||function(){};var m=b.exec||function(a,b){b()},n=[];return a?void l.stat(a,function(b,d){return b?void c(b):d.isDirectory()?void j(a,c):void c(new f.ENOTDIR(null,a))}):void c(new f.EINVAL("Missing path argument"))},b.exports=d},{"../../lib/async.js":1,"../encoding.js":17,"../errors.js":18,"../path.js":25,"./environment.js":31,minimatch:11}],33:[function(a,b,c){function d(a,b){this.node=a.id,this.dev=b,this.size=a.size,this.nlinks=a.nlinks,this.atime=a.atime,this.mtime=a.mtime,this.ctime=a.ctime,this.type=a.mode}var e=a("./constants.js");d.prototype.isFile=function(){return this.type===e.MODE_FILE},d.prototype.isDirectory=function(){return this.type===e.MODE_DIRECTORY},d.prototype.isSymbolicLink=function(){return this.type===e.MODE_SYMBOLIC_LINK},d.prototype.isSocket=d.prototype.isFIFO=d.prototype.isCharacterDevice=d.prototype.isBlockDevice=function(){return!1},b.exports=d},{"./constants.js":15}],34:[function(a,b,c){function d(a){var b=Date.now();this.id=e.SUPER_NODE_ID,this.mode=e.MODE_META,this.atime=a.atime||b,this.ctime=a.ctime||b,this.mtime=a.mtime||b,this.rnode=a.rnode}var e=a("./constants.js");d.create=function(a,b){a.guid(function(c,e){return c?void b(c):(a.rnode=a.rnode||e,void b(null,new d(a)))})},b.exports=d},{"./constants.js":15}]},{},[22])(22)}); \ No newline at end of file diff --git a/dist/path.js b/dist/path.js index c5ad2b8..6b67d32 100644 --- a/dist/path.js +++ b/dist/path.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Path=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oa;a++)i(r[a]);return i}({1:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function o(t){var e="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),t||e||(t="."),(e?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function s(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var c=[],u=s;i.length>u;u++)c.push("..");return c=c.concat(o.slice(s)),c.join("/")}function u(t){var e=v(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function c(t,e){var n=v(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),""===n?"/":n}function f(t){return v(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function h(t){return-1!==(""+t).indexOf("\0")?!0:!1}function p(t){return t.replace(/\/*$/,"/")}function d(t){return t=t.replace(/\/*$/,""),""===t?"/":t}var g=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,v=function(t){var e=g.exec(t);return[e[1]||"",e[2]||"",e[3]||"",e[4]||""]};e.exports={normalize:o,resolve:i,join:a,relative:s,sep:"/",delimiter:":",dirname:u,basename:c,extname:f,isAbsolute:l,isNull:h,addTrailing:p,removeTrailing:d}},{}]},{},[1])(1)}); \ No newline at end of file +/*! filer 0.0.41 2015-06-29 */ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Path=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function e(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var e=c>=0?arguments[c]:"/";"string"==typeof e&&e&&(a=e+"/"+a,b="/"===e.charAt(0))}return a=d(a.split("/").filter(function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."}function f(a){var b="/"===a.charAt(0);"/"===a.substr(-1);return a=d(a.split("/").filter(function(a){return!!a}),!b).join("/"),a||b||(a="."),(b?"/":"")+a}function g(){var a=Array.prototype.slice.call(arguments,0);return f(a.filter(function(a,b){return a&&"string"==typeof a}).join("/"))}function h(a,b){function c(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=e(a).substr(1),b=e(b).substr(1);for(var d=c(a.split("/")),f=c(b.split("/")),g=Math.min(d.length,f.length),h=g,i=0;g>i;i++)if(d[i]!==f[i]){h=i;break}for(var j=[],i=h;i