10108 lines
722 KiB
JavaScript
10108 lines
722 KiB
JavaScript
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||
'use strict'
|
||
|
||
exports.byteLength = byteLength
|
||
exports.toByteArray = toByteArray
|
||
exports.fromByteArray = fromByteArray
|
||
|
||
var lookup = []
|
||
var revLookup = []
|
||
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
||
|
||
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||
for (var i = 0, len = code.length; i < len; ++i) {
|
||
lookup[i] = code[i]
|
||
revLookup[code.charCodeAt(i)] = i
|
||
}
|
||
|
||
// Support decoding URL-safe base64 strings, as Node.js does.
|
||
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
||
revLookup['-'.charCodeAt(0)] = 62
|
||
revLookup['_'.charCodeAt(0)] = 63
|
||
|
||
function getLens (b64) {
|
||
var len = b64.length
|
||
|
||
if (len % 4 > 0) {
|
||
throw new Error('Invalid string. Length must be a multiple of 4')
|
||
}
|
||
|
||
// Trim off extra bytes after placeholder bytes are found
|
||
// See: https://github.com/beatgammit/base64-js/issues/42
|
||
var validLen = b64.indexOf('=')
|
||
if (validLen === -1) validLen = len
|
||
|
||
var placeHoldersLen = validLen === len
|
||
? 0
|
||
: 4 - (validLen % 4)
|
||
|
||
return [validLen, placeHoldersLen]
|
||
}
|
||
|
||
// base64 is 4/3 + up to two characters of the original data
|
||
function byteLength (b64) {
|
||
var lens = getLens(b64)
|
||
var validLen = lens[0]
|
||
var placeHoldersLen = lens[1]
|
||
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
||
}
|
||
|
||
function _byteLength (b64, validLen, placeHoldersLen) {
|
||
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
||
}
|
||
|
||
function toByteArray (b64) {
|
||
var tmp
|
||
var lens = getLens(b64)
|
||
var validLen = lens[0]
|
||
var placeHoldersLen = lens[1]
|
||
|
||
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
||
|
||
var curByte = 0
|
||
|
||
// if there are placeholders, only get up to the last complete 4 chars
|
||
var len = placeHoldersLen > 0
|
||
? validLen - 4
|
||
: validLen
|
||
|
||
var i
|
||
for (i = 0; i < len; i += 4) {
|
||
tmp =
|
||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
||
revLookup[b64.charCodeAt(i + 3)]
|
||
arr[curByte++] = (tmp >> 16) & 0xFF
|
||
arr[curByte++] = (tmp >> 8) & 0xFF
|
||
arr[curByte++] = tmp & 0xFF
|
||
}
|
||
|
||
if (placeHoldersLen === 2) {
|
||
tmp =
|
||
(revLookup[b64.charCodeAt(i)] << 2) |
|
||
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
||
arr[curByte++] = tmp & 0xFF
|
||
}
|
||
|
||
if (placeHoldersLen === 1) {
|
||
tmp =
|
||
(revLookup[b64.charCodeAt(i)] << 10) |
|
||
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
||
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
||
arr[curByte++] = (tmp >> 8) & 0xFF
|
||
arr[curByte++] = tmp & 0xFF
|
||
}
|
||
|
||
return arr
|
||
}
|
||
|
||
function tripletToBase64 (num) {
|
||
return lookup[num >> 18 & 0x3F] +
|
||
lookup[num >> 12 & 0x3F] +
|
||
lookup[num >> 6 & 0x3F] +
|
||
lookup[num & 0x3F]
|
||
}
|
||
|
||
function encodeChunk (uint8, start, end) {
|
||
var tmp
|
||
var output = []
|
||
for (var i = start; i < end; i += 3) {
|
||
tmp =
|
||
((uint8[i] << 16) & 0xFF0000) +
|
||
((uint8[i + 1] << 8) & 0xFF00) +
|
||
(uint8[i + 2] & 0xFF)
|
||
output.push(tripletToBase64(tmp))
|
||
}
|
||
return output.join('')
|
||
}
|
||
|
||
function fromByteArray (uint8) {
|
||
var tmp
|
||
var len = uint8.length
|
||
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
||
var parts = []
|
||
var maxChunkLength = 16383 // must be multiple of 3
|
||
|
||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
||
parts.push(encodeChunk(
|
||
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
|
||
))
|
||
}
|
||
|
||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||
if (extraBytes === 1) {
|
||
tmp = uint8[len - 1]
|
||
parts.push(
|
||
lookup[tmp >> 2] +
|
||
lookup[(tmp << 4) & 0x3F] +
|
||
'=='
|
||
)
|
||
} else if (extraBytes === 2) {
|
||
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
||
parts.push(
|
||
lookup[tmp >> 10] +
|
||
lookup[(tmp >> 4) & 0x3F] +
|
||
lookup[(tmp << 2) & 0x3F] +
|
||
'='
|
||
)
|
||
}
|
||
|
||
return parts.join('')
|
||
}
|
||
|
||
},{}],2:[function(require,module,exports){
|
||
|
||
},{}],3:[function(require,module,exports){
|
||
(function (Buffer){
|
||
/*!
|
||
* The buffer module from node.js, for the browser.
|
||
*
|
||
* @author Feross Aboukhadijeh <https://feross.org>
|
||
* @license MIT
|
||
*/
|
||
/* eslint-disable no-proto */
|
||
|
||
'use strict'
|
||
|
||
var base64 = require('base64-js')
|
||
var ieee754 = require('ieee754')
|
||
var customInspectSymbol =
|
||
(typeof Symbol === 'function' && typeof Symbol.for === 'function')
|
||
? Symbol.for('nodejs.util.inspect.custom')
|
||
: null
|
||
|
||
exports.Buffer = Buffer
|
||
exports.SlowBuffer = SlowBuffer
|
||
exports.INSPECT_MAX_BYTES = 50
|
||
|
||
var K_MAX_LENGTH = 0x7fffffff
|
||
exports.kMaxLength = K_MAX_LENGTH
|
||
|
||
/**
|
||
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
||
* === true Use Uint8Array implementation (fastest)
|
||
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
||
* implementation (most compatible, even IE6)
|
||
*
|
||
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
||
* Opera 11.6+, iOS 4.2+.
|
||
*
|
||
* We report that the browser does not support typed arrays if the are not subclassable
|
||
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
||
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
||
* for __proto__ and has a buggy typed array implementation.
|
||
*/
|
||
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
|
||
|
||
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
||
typeof console.error === 'function') {
|
||
console.error(
|
||
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
||
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
||
)
|
||
}
|
||
|
||
function typedArraySupport () {
|
||
// Can typed array instances can be augmented?
|
||
try {
|
||
var arr = new Uint8Array(1)
|
||
var proto = { foo: function () { return 42 } }
|
||
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
||
Object.setPrototypeOf(arr, proto)
|
||
return arr.foo() === 42
|
||
} catch (e) {
|
||
return false
|
||
}
|
||
}
|
||
|
||
Object.defineProperty(Buffer.prototype, 'parent', {
|
||
enumerable: true,
|
||
get: function () {
|
||
if (!Buffer.isBuffer(this)) return undefined
|
||
return this.buffer
|
||
}
|
||
})
|
||
|
||
Object.defineProperty(Buffer.prototype, 'offset', {
|
||
enumerable: true,
|
||
get: function () {
|
||
if (!Buffer.isBuffer(this)) return undefined
|
||
return this.byteOffset
|
||
}
|
||
})
|
||
|
||
function createBuffer (length) {
|
||
if (length > K_MAX_LENGTH) {
|
||
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
||
}
|
||
// Return an augmented `Uint8Array` instance
|
||
var buf = new Uint8Array(length)
|
||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||
return buf
|
||
}
|
||
|
||
/**
|
||
* The Buffer constructor returns instances of `Uint8Array` that have their
|
||
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
||
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
||
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
||
* returns a single octet.
|
||
*
|
||
* The `Uint8Array` prototype remains unmodified.
|
||
*/
|
||
|
||
function Buffer (arg, encodingOrOffset, length) {
|
||
// Common case.
|
||
if (typeof arg === 'number') {
|
||
if (typeof encodingOrOffset === 'string') {
|
||
throw new TypeError(
|
||
'The "string" argument must be of type string. Received type number'
|
||
)
|
||
}
|
||
return allocUnsafe(arg)
|
||
}
|
||
return from(arg, encodingOrOffset, length)
|
||
}
|
||
|
||
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
||
if (typeof Symbol !== 'undefined' && Symbol.species != null &&
|
||
Buffer[Symbol.species] === Buffer) {
|
||
Object.defineProperty(Buffer, Symbol.species, {
|
||
value: null,
|
||
configurable: true,
|
||
enumerable: false,
|
||
writable: false
|
||
})
|
||
}
|
||
|
||
Buffer.poolSize = 8192 // not used by this implementation
|
||
|
||
function from (value, encodingOrOffset, length) {
|
||
if (typeof value === 'string') {
|
||
return fromString(value, encodingOrOffset)
|
||
}
|
||
|
||
if (ArrayBuffer.isView(value)) {
|
||
return fromArrayLike(value)
|
||
}
|
||
|
||
if (value == null) {
|
||
throw new TypeError(
|
||
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
||
'or Array-like Object. Received type ' + (typeof value)
|
||
)
|
||
}
|
||
|
||
if (isInstance(value, ArrayBuffer) ||
|
||
(value && isInstance(value.buffer, ArrayBuffer))) {
|
||
return fromArrayBuffer(value, encodingOrOffset, length)
|
||
}
|
||
|
||
if (typeof value === 'number') {
|
||
throw new TypeError(
|
||
'The "value" argument must not be of type number. Received type number'
|
||
)
|
||
}
|
||
|
||
var valueOf = value.valueOf && value.valueOf()
|
||
if (valueOf != null && valueOf !== value) {
|
||
return Buffer.from(valueOf, encodingOrOffset, length)
|
||
}
|
||
|
||
var b = fromObject(value)
|
||
if (b) return b
|
||
|
||
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
||
typeof value[Symbol.toPrimitive] === 'function') {
|
||
return Buffer.from(
|
||
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
|
||
)
|
||
}
|
||
|
||
throw new TypeError(
|
||
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
||
'or Array-like Object. Received type ' + (typeof value)
|
||
)
|
||
}
|
||
|
||
/**
|
||
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
||
* if value is a number.
|
||
* Buffer.from(str[, encoding])
|
||
* Buffer.from(array)
|
||
* Buffer.from(buffer)
|
||
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
||
**/
|
||
Buffer.from = function (value, encodingOrOffset, length) {
|
||
return from(value, encodingOrOffset, length)
|
||
}
|
||
|
||
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
||
// https://github.com/feross/buffer/pull/148
|
||
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
|
||
Object.setPrototypeOf(Buffer, Uint8Array)
|
||
|
||
function assertSize (size) {
|
||
if (typeof size !== 'number') {
|
||
throw new TypeError('"size" argument must be of type number')
|
||
} else if (size < 0) {
|
||
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
||
}
|
||
}
|
||
|
||
function alloc (size, fill, encoding) {
|
||
assertSize(size)
|
||
if (size <= 0) {
|
||
return createBuffer(size)
|
||
}
|
||
if (fill !== undefined) {
|
||
// Only pay attention to encoding if it's a string. This
|
||
// prevents accidentally sending in a number that would
|
||
// be interpretted as a start offset.
|
||
return typeof encoding === 'string'
|
||
? createBuffer(size).fill(fill, encoding)
|
||
: createBuffer(size).fill(fill)
|
||
}
|
||
return createBuffer(size)
|
||
}
|
||
|
||
/**
|
||
* Creates a new filled Buffer instance.
|
||
* alloc(size[, fill[, encoding]])
|
||
**/
|
||
Buffer.alloc = function (size, fill, encoding) {
|
||
return alloc(size, fill, encoding)
|
||
}
|
||
|
||
function allocUnsafe (size) {
|
||
assertSize(size)
|
||
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
||
}
|
||
|
||
/**
|
||
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
||
* */
|
||
Buffer.allocUnsafe = function (size) {
|
||
return allocUnsafe(size)
|
||
}
|
||
/**
|
||
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
||
*/
|
||
Buffer.allocUnsafeSlow = function (size) {
|
||
return allocUnsafe(size)
|
||
}
|
||
|
||
function fromString (string, encoding) {
|
||
if (typeof encoding !== 'string' || encoding === '') {
|
||
encoding = 'utf8'
|
||
}
|
||
|
||
if (!Buffer.isEncoding(encoding)) {
|
||
throw new TypeError('Unknown encoding: ' + encoding)
|
||
}
|
||
|
||
var length = byteLength(string, encoding) | 0
|
||
var buf = createBuffer(length)
|
||
|
||
var actual = buf.write(string, encoding)
|
||
|
||
if (actual !== length) {
|
||
// Writing a hex string, for example, that contains invalid characters will
|
||
// cause everything after the first invalid character to be ignored. (e.g.
|
||
// 'abxxcd' will be treated as 'ab')
|
||
buf = buf.slice(0, actual)
|
||
}
|
||
|
||
return buf
|
||
}
|
||
|
||
function fromArrayLike (array) {
|
||
var length = array.length < 0 ? 0 : checked(array.length) | 0
|
||
var buf = createBuffer(length)
|
||
for (var i = 0; i < length; i += 1) {
|
||
buf[i] = array[i] & 255
|
||
}
|
||
return buf
|
||
}
|
||
|
||
function fromArrayBuffer (array, byteOffset, length) {
|
||
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
||
throw new RangeError('"offset" is outside of buffer bounds')
|
||
}
|
||
|
||
if (array.byteLength < byteOffset + (length || 0)) {
|
||
throw new RangeError('"length" is outside of buffer bounds')
|
||
}
|
||
|
||
var buf
|
||
if (byteOffset === undefined && length === undefined) {
|
||
buf = new Uint8Array(array)
|
||
} else if (length === undefined) {
|
||
buf = new Uint8Array(array, byteOffset)
|
||
} else {
|
||
buf = new Uint8Array(array, byteOffset, length)
|
||
}
|
||
|
||
// Return an augmented `Uint8Array` instance
|
||
Object.setPrototypeOf(buf, Buffer.prototype)
|
||
|
||
return buf
|
||
}
|
||
|
||
function fromObject (obj) {
|
||
if (Buffer.isBuffer(obj)) {
|
||
var len = checked(obj.length) | 0
|
||
var buf = createBuffer(len)
|
||
|
||
if (buf.length === 0) {
|
||
return buf
|
||
}
|
||
|
||
obj.copy(buf, 0, 0, len)
|
||
return buf
|
||
}
|
||
|
||
if (obj.length !== undefined) {
|
||
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
||
return createBuffer(0)
|
||
}
|
||
return fromArrayLike(obj)
|
||
}
|
||
|
||
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
||
return fromArrayLike(obj.data)
|
||
}
|
||
}
|
||
|
||
function checked (length) {
|
||
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
||
// length is NaN (which is otherwise coerced to zero.)
|
||
if (length >= K_MAX_LENGTH) {
|
||
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
||
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
||
}
|
||
return length | 0
|
||
}
|
||
|
||
function SlowBuffer (length) {
|
||
if (+length != length) { // eslint-disable-line eqeqeq
|
||
length = 0
|
||
}
|
||
return Buffer.alloc(+length)
|
||
}
|
||
|
||
Buffer.isBuffer = function isBuffer (b) {
|
||
return b != null && b._isBuffer === true &&
|
||
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
||
}
|
||
|
||
Buffer.compare = function compare (a, b) {
|
||
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
|
||
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
|
||
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
||
throw new TypeError(
|
||
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
||
)
|
||
}
|
||
|
||
if (a === b) return 0
|
||
|
||
var x = a.length
|
||
var y = b.length
|
||
|
||
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
||
if (a[i] !== b[i]) {
|
||
x = a[i]
|
||
y = b[i]
|
||
break
|
||
}
|
||
}
|
||
|
||
if (x < y) return -1
|
||
if (y < x) return 1
|
||
return 0
|
||
}
|
||
|
||
Buffer.isEncoding = function isEncoding (encoding) {
|
||
switch (String(encoding).toLowerCase()) {
|
||
case 'hex':
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
case 'ascii':
|
||
case 'latin1':
|
||
case 'binary':
|
||
case 'base64':
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return true
|
||
default:
|
||
return false
|
||
}
|
||
}
|
||
|
||
Buffer.concat = function concat (list, length) {
|
||
if (!Array.isArray(list)) {
|
||
throw new TypeError('"list" argument must be an Array of Buffers')
|
||
}
|
||
|
||
if (list.length === 0) {
|
||
return Buffer.alloc(0)
|
||
}
|
||
|
||
var i
|
||
if (length === undefined) {
|
||
length = 0
|
||
for (i = 0; i < list.length; ++i) {
|
||
length += list[i].length
|
||
}
|
||
}
|
||
|
||
var buffer = Buffer.allocUnsafe(length)
|
||
var pos = 0
|
||
for (i = 0; i < list.length; ++i) {
|
||
var buf = list[i]
|
||
if (isInstance(buf, Uint8Array)) {
|
||
buf = Buffer.from(buf)
|
||
}
|
||
if (!Buffer.isBuffer(buf)) {
|
||
throw new TypeError('"list" argument must be an Array of Buffers')
|
||
}
|
||
buf.copy(buffer, pos)
|
||
pos += buf.length
|
||
}
|
||
return buffer
|
||
}
|
||
|
||
function byteLength (string, encoding) {
|
||
if (Buffer.isBuffer(string)) {
|
||
return string.length
|
||
}
|
||
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
||
return string.byteLength
|
||
}
|
||
if (typeof string !== 'string') {
|
||
throw new TypeError(
|
||
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
||
'Received type ' + typeof string
|
||
)
|
||
}
|
||
|
||
var len = string.length
|
||
var mustMatch = (arguments.length > 2 && arguments[2] === true)
|
||
if (!mustMatch && len === 0) return 0
|
||
|
||
// Use a for loop to avoid recursion
|
||
var loweredCase = false
|
||
for (;;) {
|
||
switch (encoding) {
|
||
case 'ascii':
|
||
case 'latin1':
|
||
case 'binary':
|
||
return len
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
return utf8ToBytes(string).length
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return len * 2
|
||
case 'hex':
|
||
return len >>> 1
|
||
case 'base64':
|
||
return base64ToBytes(string).length
|
||
default:
|
||
if (loweredCase) {
|
||
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
||
}
|
||
encoding = ('' + encoding).toLowerCase()
|
||
loweredCase = true
|
||
}
|
||
}
|
||
}
|
||
Buffer.byteLength = byteLength
|
||
|
||
function slowToString (encoding, start, end) {
|
||
var loweredCase = false
|
||
|
||
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
||
// property of a typed array.
|
||
|
||
// This behaves neither like String nor Uint8Array in that we set start/end
|
||
// to their upper/lower bounds if the value passed is out of range.
|
||
// undefined is handled specially as per ECMA-262 6th Edition,
|
||
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
||
if (start === undefined || start < 0) {
|
||
start = 0
|
||
}
|
||
// Return early if start > this.length. Done here to prevent potential uint32
|
||
// coercion fail below.
|
||
if (start > this.length) {
|
||
return ''
|
||
}
|
||
|
||
if (end === undefined || end > this.length) {
|
||
end = this.length
|
||
}
|
||
|
||
if (end <= 0) {
|
||
return ''
|
||
}
|
||
|
||
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
|
||
end >>>= 0
|
||
start >>>= 0
|
||
|
||
if (end <= start) {
|
||
return ''
|
||
}
|
||
|
||
if (!encoding) encoding = 'utf8'
|
||
|
||
while (true) {
|
||
switch (encoding) {
|
||
case 'hex':
|
||
return hexSlice(this, start, end)
|
||
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
return utf8Slice(this, start, end)
|
||
|
||
case 'ascii':
|
||
return asciiSlice(this, start, end)
|
||
|
||
case 'latin1':
|
||
case 'binary':
|
||
return latin1Slice(this, start, end)
|
||
|
||
case 'base64':
|
||
return base64Slice(this, start, end)
|
||
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return utf16leSlice(this, start, end)
|
||
|
||
default:
|
||
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
||
encoding = (encoding + '').toLowerCase()
|
||
loweredCase = true
|
||
}
|
||
}
|
||
}
|
||
|
||
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
||
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
||
// reliably in a browserify context because there could be multiple different
|
||
// copies of the 'buffer' package in use. This method works even for Buffer
|
||
// instances that were created from another copy of the `buffer` package.
|
||
// See: https://github.com/feross/buffer/issues/154
|
||
Buffer.prototype._isBuffer = true
|
||
|
||
function swap (b, n, m) {
|
||
var i = b[n]
|
||
b[n] = b[m]
|
||
b[m] = i
|
||
}
|
||
|
||
Buffer.prototype.swap16 = function swap16 () {
|
||
var len = this.length
|
||
if (len % 2 !== 0) {
|
||
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
||
}
|
||
for (var i = 0; i < len; i += 2) {
|
||
swap(this, i, i + 1)
|
||
}
|
||
return this
|
||
}
|
||
|
||
Buffer.prototype.swap32 = function swap32 () {
|
||
var len = this.length
|
||
if (len % 4 !== 0) {
|
||
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
||
}
|
||
for (var i = 0; i < len; i += 4) {
|
||
swap(this, i, i + 3)
|
||
swap(this, i + 1, i + 2)
|
||
}
|
||
return this
|
||
}
|
||
|
||
Buffer.prototype.swap64 = function swap64 () {
|
||
var len = this.length
|
||
if (len % 8 !== 0) {
|
||
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
||
}
|
||
for (var i = 0; i < len; i += 8) {
|
||
swap(this, i, i + 7)
|
||
swap(this, i + 1, i + 6)
|
||
swap(this, i + 2, i + 5)
|
||
swap(this, i + 3, i + 4)
|
||
}
|
||
return this
|
||
}
|
||
|
||
Buffer.prototype.toString = function toString () {
|
||
var length = this.length
|
||
if (length === 0) return ''
|
||
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
||
return slowToString.apply(this, arguments)
|
||
}
|
||
|
||
Buffer.prototype.toLocaleString = Buffer.prototype.toString
|
||
|
||
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 inspect () {
|
||
var str = ''
|
||
var max = exports.INSPECT_MAX_BYTES
|
||
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
|
||
if (this.length > max) str += ' ... '
|
||
return '<Buffer ' + str + '>'
|
||
}
|
||
if (customInspectSymbol) {
|
||
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
|
||
}
|
||
|
||
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
||
if (isInstance(target, Uint8Array)) {
|
||
target = Buffer.from(target, target.offset, target.byteLength)
|
||
}
|
||
if (!Buffer.isBuffer(target)) {
|
||
throw new TypeError(
|
||
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
||
'Received type ' + (typeof target)
|
||
)
|
||
}
|
||
|
||
if (start === undefined) {
|
||
start = 0
|
||
}
|
||
if (end === undefined) {
|
||
end = target ? target.length : 0
|
||
}
|
||
if (thisStart === undefined) {
|
||
thisStart = 0
|
||
}
|
||
if (thisEnd === undefined) {
|
||
thisEnd = this.length
|
||
}
|
||
|
||
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
||
throw new RangeError('out of range index')
|
||
}
|
||
|
||
if (thisStart >= thisEnd && start >= end) {
|
||
return 0
|
||
}
|
||
if (thisStart >= thisEnd) {
|
||
return -1
|
||
}
|
||
if (start >= end) {
|
||
return 1
|
||
}
|
||
|
||
start >>>= 0
|
||
end >>>= 0
|
||
thisStart >>>= 0
|
||
thisEnd >>>= 0
|
||
|
||
if (this === target) return 0
|
||
|
||
var x = thisEnd - thisStart
|
||
var y = end - start
|
||
var len = Math.min(x, y)
|
||
|
||
var thisCopy = this.slice(thisStart, thisEnd)
|
||
var targetCopy = target.slice(start, end)
|
||
|
||
for (var i = 0; i < len; ++i) {
|
||
if (thisCopy[i] !== targetCopy[i]) {
|
||
x = thisCopy[i]
|
||
y = targetCopy[i]
|
||
break
|
||
}
|
||
}
|
||
|
||
if (x < y) return -1
|
||
if (y < x) return 1
|
||
return 0
|
||
}
|
||
|
||
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
||
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
||
//
|
||
// Arguments:
|
||
// - buffer - a Buffer to search
|
||
// - val - a string, Buffer, or number
|
||
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
||
// - encoding - an optional encoding, relevant is val is a string
|
||
// - dir - true for indexOf, false for lastIndexOf
|
||
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
||
// Empty buffer means no match
|
||
if (buffer.length === 0) return -1
|
||
|
||
// Normalize byteOffset
|
||
if (typeof byteOffset === 'string') {
|
||
encoding = byteOffset
|
||
byteOffset = 0
|
||
} else if (byteOffset > 0x7fffffff) {
|
||
byteOffset = 0x7fffffff
|
||
} else if (byteOffset < -0x80000000) {
|
||
byteOffset = -0x80000000
|
||
}
|
||
byteOffset = +byteOffset // Coerce to Number.
|
||
if (numberIsNaN(byteOffset)) {
|
||
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
||
byteOffset = dir ? 0 : (buffer.length - 1)
|
||
}
|
||
|
||
// Normalize byteOffset: negative offsets start from the end of the buffer
|
||
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
||
if (byteOffset >= buffer.length) {
|
||
if (dir) return -1
|
||
else byteOffset = buffer.length - 1
|
||
} else if (byteOffset < 0) {
|
||
if (dir) byteOffset = 0
|
||
else return -1
|
||
}
|
||
|
||
// Normalize val
|
||
if (typeof val === 'string') {
|
||
val = Buffer.from(val, encoding)
|
||
}
|
||
|
||
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
||
if (Buffer.isBuffer(val)) {
|
||
// Special case: looking for empty string/buffer always fails
|
||
if (val.length === 0) {
|
||
return -1
|
||
}
|
||
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
||
} else if (typeof val === 'number') {
|
||
val = val & 0xFF // Search for a byte value [0-255]
|
||
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
||
if (dir) {
|
||
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
||
} else {
|
||
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
||
}
|
||
}
|
||
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
||
}
|
||
|
||
throw new TypeError('val must be string, number or Buffer')
|
||
}
|
||
|
||
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
||
var indexSize = 1
|
||
var arrLength = arr.length
|
||
var valLength = val.length
|
||
|
||
if (encoding !== undefined) {
|
||
encoding = String(encoding).toLowerCase()
|
||
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
||
encoding === 'utf16le' || encoding === 'utf-16le') {
|
||
if (arr.length < 2 || val.length < 2) {
|
||
return -1
|
||
}
|
||
indexSize = 2
|
||
arrLength /= 2
|
||
valLength /= 2
|
||
byteOffset /= 2
|
||
}
|
||
}
|
||
|
||
function read (buf, i) {
|
||
if (indexSize === 1) {
|
||
return buf[i]
|
||
} else {
|
||
return buf.readUInt16BE(i * indexSize)
|
||
}
|
||
}
|
||
|
||
var i
|
||
if (dir) {
|
||
var foundIndex = -1
|
||
for (i = byteOffset; i < arrLength; i++) {
|
||
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
||
if (foundIndex === -1) foundIndex = i
|
||
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
||
} else {
|
||
if (foundIndex !== -1) i -= i - foundIndex
|
||
foundIndex = -1
|
||
}
|
||
}
|
||
} else {
|
||
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
||
for (i = byteOffset; i >= 0; i--) {
|
||
var found = true
|
||
for (var j = 0; j < valLength; j++) {
|
||
if (read(arr, i + j) !== read(val, j)) {
|
||
found = false
|
||
break
|
||
}
|
||
}
|
||
if (found) return i
|
||
}
|
||
}
|
||
|
||
return -1
|
||
}
|
||
|
||
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
||
return this.indexOf(val, byteOffset, encoding) !== -1
|
||
}
|
||
|
||
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
||
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
||
}
|
||
|
||
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
||
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
||
}
|
||
|
||
function hexWrite (buf, string, offset, length) {
|
||
offset = Number(offset) || 0
|
||
var remaining = buf.length - offset
|
||
if (!length) {
|
||
length = remaining
|
||
} else {
|
||
length = Number(length)
|
||
if (length > remaining) {
|
||
length = remaining
|
||
}
|
||
}
|
||
|
||
var strLen = string.length
|
||
|
||
if (length > strLen / 2) {
|
||
length = strLen / 2
|
||
}
|
||
for (var i = 0; i < length; ++i) {
|
||
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
||
if (numberIsNaN(parsed)) return i
|
||
buf[offset + i] = parsed
|
||
}
|
||
return i
|
||
}
|
||
|
||
function utf8Write (buf, string, offset, length) {
|
||
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
||
}
|
||
|
||
function asciiWrite (buf, string, offset, length) {
|
||
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
||
}
|
||
|
||
function latin1Write (buf, string, offset, length) {
|
||
return asciiWrite(buf, string, offset, length)
|
||
}
|
||
|
||
function base64Write (buf, string, offset, length) {
|
||
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
||
}
|
||
|
||
function ucs2Write (buf, string, offset, length) {
|
||
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, 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 {
|
||
throw new Error(
|
||
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
||
)
|
||
}
|
||
|
||
var remaining = this.length - offset
|
||
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 'latin1':
|
||
case 'binary':
|
||
return latin1Write(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
|
||
}
|
||
}
|
||
}
|
||
|
||
Buffer.prototype.toJSON = function toJSON () {
|
||
return {
|
||
type: 'Buffer',
|
||
data: Array.prototype.slice.call(this._arr || this, 0)
|
||
}
|
||
}
|
||
|
||
function base64Slice (buf, start, end) {
|
||
if (start === 0 && end === buf.length) {
|
||
return base64.fromByteArray(buf)
|
||
} else {
|
||
return base64.fromByteArray(buf.slice(start, end))
|
||
}
|
||
}
|
||
|
||
function utf8Slice (buf, start, end) {
|
||
end = Math.min(buf.length, end)
|
||
var res = []
|
||
|
||
var i = start
|
||
while (i < end) {
|
||
var firstByte = buf[i]
|
||
var codePoint = null
|
||
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
||
: (firstByte > 0xDF) ? 3
|
||
: (firstByte > 0xBF) ? 2
|
||
: 1
|
||
|
||
if (i + bytesPerSequence <= end) {
|
||
var secondByte, thirdByte, fourthByte, tempCodePoint
|
||
|
||
switch (bytesPerSequence) {
|
||
case 1:
|
||
if (firstByte < 0x80) {
|
||
codePoint = firstByte
|
||
}
|
||
break
|
||
case 2:
|
||
secondByte = buf[i + 1]
|
||
if ((secondByte & 0xC0) === 0x80) {
|
||
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
||
if (tempCodePoint > 0x7F) {
|
||
codePoint = tempCodePoint
|
||
}
|
||
}
|
||
break
|
||
case 3:
|
||
secondByte = buf[i + 1]
|
||
thirdByte = buf[i + 2]
|
||
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
||
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
||
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
||
codePoint = tempCodePoint
|
||
}
|
||
}
|
||
break
|
||
case 4:
|
||
secondByte = buf[i + 1]
|
||
thirdByte = buf[i + 2]
|
||
fourthByte = buf[i + 3]
|
||
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
||
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
||
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
||
codePoint = tempCodePoint
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (codePoint === null) {
|
||
// we did not generate a valid codePoint so insert a
|
||
// replacement char (U+FFFD) and advance only 1 byte
|
||
codePoint = 0xFFFD
|
||
bytesPerSequence = 1
|
||
} else if (codePoint > 0xFFFF) {
|
||
// encode to utf16 (surrogate pair dance)
|
||
codePoint -= 0x10000
|
||
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
||
codePoint = 0xDC00 | codePoint & 0x3FF
|
||
}
|
||
|
||
res.push(codePoint)
|
||
i += bytesPerSequence
|
||
}
|
||
|
||
return decodeCodePointsArray(res)
|
||
}
|
||
|
||
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
||
// the lowest limit is Chrome, with 0x10000 args.
|
||
// We go 1 magnitude less, for safety
|
||
var MAX_ARGUMENTS_LENGTH = 0x1000
|
||
|
||
function decodeCodePointsArray (codePoints) {
|
||
var len = codePoints.length
|
||
if (len <= MAX_ARGUMENTS_LENGTH) {
|
||
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
||
}
|
||
|
||
// Decode in chunks to avoid "call stack size exceeded".
|
||
var res = ''
|
||
var i = 0
|
||
while (i < len) {
|
||
res += String.fromCharCode.apply(
|
||
String,
|
||
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
||
)
|
||
}
|
||
return res
|
||
}
|
||
|
||
function asciiSlice (buf, start, end) {
|
||
var ret = ''
|
||
end = Math.min(buf.length, end)
|
||
|
||
for (var i = start; i < end; ++i) {
|
||
ret += String.fromCharCode(buf[i] & 0x7F)
|
||
}
|
||
return ret
|
||
}
|
||
|
||
function latin1Slice (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) {
|
||
var len = buf.length
|
||
|
||
if (!start || start < 0) start = 0
|
||
if (!end || end < 0 || end > len) end = len
|
||
|
||
var out = ''
|
||
for (var i = start; i < end; ++i) {
|
||
out += hexSliceLookupTable[buf[i]]
|
||
}
|
||
return out
|
||
}
|
||
|
||
function utf16leSlice (buf, start, end) {
|
||
var bytes = buf.slice(start, end)
|
||
var res = ''
|
||
for (var i = 0; i < bytes.length; i += 2) {
|
||
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
|
||
}
|
||
return res
|
||
}
|
||
|
||
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
|
||
} else if (start > len) {
|
||
start = len
|
||
}
|
||
|
||
if (end < 0) {
|
||
end += len
|
||
if (end < 0) end = 0
|
||
} else if (end > len) {
|
||
end = len
|
||
}
|
||
|
||
if (end < start) end = start
|
||
|
||
var newBuf = this.subarray(start, end)
|
||
// Return an augmented `Uint8Array` instance
|
||
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
||
|
||
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')
|
||
}
|
||
|
||
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) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 1, this.length)
|
||
return this[offset]
|
||
}
|
||
|
||
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 2, this.length)
|
||
return this[offset] | (this[offset + 1] << 8)
|
||
}
|
||
|
||
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 2, this.length)
|
||
return (this[offset] << 8) | this[offset + 1]
|
||
}
|
||
|
||
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return ((this[offset]) |
|
||
(this[offset + 1] << 8) |
|
||
(this[offset + 2] << 16)) +
|
||
(this[offset + 3] * 0x1000000)
|
||
}
|
||
|
||
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return (this[offset] * 0x1000000) +
|
||
((this[offset + 1] << 16) |
|
||
(this[offset + 2] << 8) |
|
||
this[offset + 3])
|
||
}
|
||
|
||
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) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 1, this.length)
|
||
if (!(this[offset] & 0x80)) return (this[offset])
|
||
return ((0xff - this[offset] + 1) * -1)
|
||
}
|
||
|
||
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
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 readInt16BE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
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 readInt32LE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return (this[offset]) |
|
||
(this[offset + 1] << 8) |
|
||
(this[offset + 2] << 16) |
|
||
(this[offset + 3] << 24)
|
||
}
|
||
|
||
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
|
||
return (this[offset] << 24) |
|
||
(this[offset + 1] << 16) |
|
||
(this[offset + 2] << 8) |
|
||
(this[offset + 3])
|
||
}
|
||
|
||
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
return ieee754.read(this, offset, true, 23, 4)
|
||
}
|
||
|
||
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 4, this.length)
|
||
return ieee754.read(this, offset, false, 23, 4)
|
||
}
|
||
|
||
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkOffset(offset, 8, this.length)
|
||
return ieee754.read(this, offset, true, 52, 8)
|
||
}
|
||
|
||
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
||
offset = offset >>> 0
|
||
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" argument must be a Buffer instance')
|
||
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
||
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
||
}
|
||
|
||
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
byteLength = byteLength >>> 0
|
||
if (!noAssert) {
|
||
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
||
checkInt(this, value, offset, byteLength, maxBytes, 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) {
|
||
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
||
checkInt(this, value, offset, byteLength, maxBytes, 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)
|
||
this[offset] = (value & 0xff)
|
||
return offset + 1
|
||
}
|
||
|
||
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
||
this[offset] = (value & 0xff)
|
||
this[offset + 1] = (value >>> 8)
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
||
this[offset] = (value >>> 8)
|
||
this[offset + 1] = (value & 0xff)
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
||
this[offset + 3] = (value >>> 24)
|
||
this[offset + 2] = (value >>> 16)
|
||
this[offset + 1] = (value >>> 8)
|
||
this[offset] = (value & 0xff)
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
||
this[offset] = (value >>> 24)
|
||
this[offset + 1] = (value >>> 16)
|
||
this[offset + 2] = (value >>> 8)
|
||
this[offset + 3] = (value & 0xff)
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeIntLE = function writeIntLE (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 = 0
|
||
var mul = 1
|
||
var sub = 0
|
||
this[offset] = value & 0xFF
|
||
while (++i < byteLength && (mul *= 0x100)) {
|
||
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
||
sub = 1
|
||
}
|
||
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 = 0
|
||
this[offset + i] = value & 0xFF
|
||
while (--i >= 0 && (mul *= 0x100)) {
|
||
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
||
sub = 1
|
||
}
|
||
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 (value < 0) value = 0xff + value + 1
|
||
this[offset] = (value & 0xff)
|
||
return offset + 1
|
||
}
|
||
|
||
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
||
this[offset] = (value & 0xff)
|
||
this[offset + 1] = (value >>> 8)
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
||
this[offset] = (value >>> 8)
|
||
this[offset + 1] = (value & 0xff)
|
||
return offset + 2
|
||
}
|
||
|
||
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
||
this[offset] = (value & 0xff)
|
||
this[offset + 1] = (value >>> 8)
|
||
this[offset + 2] = (value >>> 16)
|
||
this[offset + 3] = (value >>> 24)
|
||
return offset + 4
|
||
}
|
||
|
||
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
||
if (value < 0) value = 0xffffffff + value + 1
|
||
this[offset] = (value >>> 24)
|
||
this[offset + 1] = (value >>> 16)
|
||
this[offset + 2] = (value >>> 8)
|
||
this[offset + 3] = (value & 0xff)
|
||
return offset + 4
|
||
}
|
||
|
||
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
||
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) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
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 writeFloatLE (value, offset, noAssert) {
|
||
return writeFloat(this, value, offset, true, noAssert)
|
||
}
|
||
|
||
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
||
return writeFloat(this, value, offset, false, noAssert)
|
||
}
|
||
|
||
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
||
value = +value
|
||
offset = offset >>> 0
|
||
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 writeDoubleLE (value, offset, noAssert) {
|
||
return writeDouble(this, value, offset, true, 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 copy (target, targetStart, start, end) {
|
||
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
||
if (!start) start = 0
|
||
if (!end && end !== 0) end = this.length
|
||
if (targetStart >= target.length) targetStart = target.length
|
||
if (!targetStart) targetStart = 0
|
||
if (end > 0 && end < start) end = start
|
||
|
||
// Copy 0 bytes; we're done
|
||
if (end === start) return 0
|
||
if (target.length === 0 || this.length === 0) return 0
|
||
|
||
// Fatal error conditions
|
||
if (targetStart < 0) {
|
||
throw new RangeError('targetStart out of bounds')
|
||
}
|
||
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
||
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
||
|
||
// Are we oob?
|
||
if (end > this.length) end = this.length
|
||
if (target.length - targetStart < end - start) {
|
||
end = target.length - targetStart + start
|
||
}
|
||
|
||
var len = end - start
|
||
|
||
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
||
// Use built-in when available, missing from IE11
|
||
this.copyWithin(targetStart, start, end)
|
||
} else if (this === target && start < targetStart && targetStart < end) {
|
||
// descending copy from end
|
||
for (var i = len - 1; i >= 0; --i) {
|
||
target[i + targetStart] = this[i + start]
|
||
}
|
||
} else {
|
||
Uint8Array.prototype.set.call(
|
||
target,
|
||
this.subarray(start, end),
|
||
targetStart
|
||
)
|
||
}
|
||
|
||
return len
|
||
}
|
||
|
||
// Usage:
|
||
// buffer.fill(number[, offset[, end]])
|
||
// buffer.fill(buffer[, offset[, end]])
|
||
// buffer.fill(string[, offset[, end]][, encoding])
|
||
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
||
// Handle string cases:
|
||
if (typeof val === 'string') {
|
||
if (typeof start === 'string') {
|
||
encoding = start
|
||
start = 0
|
||
end = this.length
|
||
} else if (typeof end === 'string') {
|
||
encoding = end
|
||
end = this.length
|
||
}
|
||
if (encoding !== undefined && typeof encoding !== 'string') {
|
||
throw new TypeError('encoding must be a string')
|
||
}
|
||
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
||
throw new TypeError('Unknown encoding: ' + encoding)
|
||
}
|
||
if (val.length === 1) {
|
||
var code = val.charCodeAt(0)
|
||
if ((encoding === 'utf8' && code < 128) ||
|
||
encoding === 'latin1') {
|
||
// Fast path: If `val` fits into a single byte, use that numeric value.
|
||
val = code
|
||
}
|
||
}
|
||
} else if (typeof val === 'number') {
|
||
val = val & 255
|
||
} else if (typeof val === 'boolean') {
|
||
val = Number(val)
|
||
}
|
||
|
||
// Invalid ranges are not set to a default, so can range check early.
|
||
if (start < 0 || this.length < start || this.length < end) {
|
||
throw new RangeError('Out of range index')
|
||
}
|
||
|
||
if (end <= start) {
|
||
return this
|
||
}
|
||
|
||
start = start >>> 0
|
||
end = end === undefined ? this.length : end >>> 0
|
||
|
||
if (!val) val = 0
|
||
|
||
var i
|
||
if (typeof val === 'number') {
|
||
for (i = start; i < end; ++i) {
|
||
this[i] = val
|
||
}
|
||
} else {
|
||
var bytes = Buffer.isBuffer(val)
|
||
? val
|
||
: Buffer.from(val, encoding)
|
||
var len = bytes.length
|
||
if (len === 0) {
|
||
throw new TypeError('The value "' + val +
|
||
'" is invalid for argument "value"')
|
||
}
|
||
for (i = 0; i < end - start; ++i) {
|
||
this[i + start] = bytes[i % len]
|
||
}
|
||
}
|
||
|
||
return this
|
||
}
|
||
|
||
// HELPER FUNCTIONS
|
||
// ================
|
||
|
||
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
|
||
|
||
function base64clean (str) {
|
||
// Node takes equal signs as end of the Base64 encoding
|
||
str = str.split('=')[0]
|
||
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
||
str = str.trim().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 + '='
|
||
}
|
||
return str
|
||
}
|
||
|
||
function utf8ToBytes (string, units) {
|
||
units = units || Infinity
|
||
var codePoint
|
||
var length = string.length
|
||
var leadSurrogate = null
|
||
var bytes = []
|
||
|
||
for (var i = 0; i < length; ++i) {
|
||
codePoint = string.charCodeAt(i)
|
||
|
||
// is surrogate component
|
||
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
||
// last char was a lead
|
||
if (!leadSurrogate) {
|
||
// 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
|
||
}
|
||
|
||
// valid lead
|
||
leadSurrogate = codePoint
|
||
|
||
continue
|
||
}
|
||
|
||
// 2 leads in a row
|
||
if (codePoint < 0xDC00) {
|
||
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
||
leadSurrogate = codePoint
|
||
continue
|
||
}
|
||
|
||
// valid surrogate pair
|
||
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
||
} 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 < 0x110000) {
|
||
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 bytes
|
||
}
|
||
|
||
function asciiToBytes (str) {
|
||
var byteArray = []
|
||
for (var i = 0; i < str.length; ++i) {
|
||
// Node's code seems to be doing this and not & 0x7F..
|
||
byteArray.push(str.charCodeAt(i) & 0xFF)
|
||
}
|
||
return byteArray
|
||
}
|
||
|
||
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
|
||
byteArray.push(lo)
|
||
byteArray.push(hi)
|
||
}
|
||
|
||
return byteArray
|
||
}
|
||
|
||
function base64ToBytes (str) {
|
||
return base64.toByteArray(base64clean(str))
|
||
}
|
||
|
||
function blitBuffer (src, dst, offset, length) {
|
||
for (var i = 0; i < length; ++i) {
|
||
if ((i + offset >= dst.length) || (i >= src.length)) break
|
||
dst[i + offset] = src[i]
|
||
}
|
||
return i
|
||
}
|
||
|
||
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
||
// the `instanceof` check but they should be treated as of that type.
|
||
// See: https://github.com/feross/buffer/issues/166
|
||
function isInstance (obj, type) {
|
||
return obj instanceof type ||
|
||
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
||
obj.constructor.name === type.name)
|
||
}
|
||
function numberIsNaN (obj) {
|
||
// For IE11 support
|
||
return obj !== obj // eslint-disable-line no-self-compare
|
||
}
|
||
|
||
// Create lookup table for `toString('hex')`
|
||
// See: https://github.com/feross/buffer/issues/219
|
||
var hexSliceLookupTable = (function () {
|
||
var alphabet = '0123456789abcdef'
|
||
var table = new Array(256)
|
||
for (var i = 0; i < 16; ++i) {
|
||
var i16 = i * 16
|
||
for (var j = 0; j < 16; ++j) {
|
||
table[i16 + j] = alphabet[i] + alphabet[j]
|
||
}
|
||
}
|
||
return table
|
||
})()
|
||
|
||
}).call(this,require("buffer").Buffer)
|
||
},{"base64-js":1,"buffer":3,"ieee754":6}],4:[function(require,module,exports){
|
||
(function (Buffer){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
// NOTE: These type checking functions intentionally don't use `instanceof`
|
||
// because it is fragile and can be easily faked with `Object.create()`.
|
||
|
||
function isArray(arg) {
|
||
if (Array.isArray) {
|
||
return Array.isArray(arg);
|
||
}
|
||
return objectToString(arg) === '[object Array]';
|
||
}
|
||
exports.isArray = isArray;
|
||
|
||
function isBoolean(arg) {
|
||
return typeof arg === 'boolean';
|
||
}
|
||
exports.isBoolean = isBoolean;
|
||
|
||
function isNull(arg) {
|
||
return arg === null;
|
||
}
|
||
exports.isNull = isNull;
|
||
|
||
function isNullOrUndefined(arg) {
|
||
return arg == null;
|
||
}
|
||
exports.isNullOrUndefined = isNullOrUndefined;
|
||
|
||
function isNumber(arg) {
|
||
return typeof arg === 'number';
|
||
}
|
||
exports.isNumber = isNumber;
|
||
|
||
function isString(arg) {
|
||
return typeof arg === 'string';
|
||
}
|
||
exports.isString = isString;
|
||
|
||
function isSymbol(arg) {
|
||
return typeof arg === 'symbol';
|
||
}
|
||
exports.isSymbol = isSymbol;
|
||
|
||
function isUndefined(arg) {
|
||
return arg === void 0;
|
||
}
|
||
exports.isUndefined = isUndefined;
|
||
|
||
function isRegExp(re) {
|
||
return objectToString(re) === '[object RegExp]';
|
||
}
|
||
exports.isRegExp = isRegExp;
|
||
|
||
function isObject(arg) {
|
||
return typeof arg === 'object' && arg !== null;
|
||
}
|
||
exports.isObject = isObject;
|
||
|
||
function isDate(d) {
|
||
return objectToString(d) === '[object Date]';
|
||
}
|
||
exports.isDate = isDate;
|
||
|
||
function isError(e) {
|
||
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
||
}
|
||
exports.isError = isError;
|
||
|
||
function isFunction(arg) {
|
||
return typeof arg === 'function';
|
||
}
|
||
exports.isFunction = isFunction;
|
||
|
||
function isPrimitive(arg) {
|
||
return arg === null ||
|
||
typeof arg === 'boolean' ||
|
||
typeof arg === 'number' ||
|
||
typeof arg === 'string' ||
|
||
typeof arg === 'symbol' || // ES6 symbol
|
||
typeof arg === 'undefined';
|
||
}
|
||
exports.isPrimitive = isPrimitive;
|
||
|
||
exports.isBuffer = Buffer.isBuffer;
|
||
|
||
function objectToString(o) {
|
||
return Object.prototype.toString.call(o);
|
||
}
|
||
|
||
}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
|
||
},{"../../is-buffer/index.js":8}],5:[function(require,module,exports){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
var objectCreate = Object.create || objectCreatePolyfill
|
||
var objectKeys = Object.keys || objectKeysPolyfill
|
||
var bind = Function.prototype.bind || functionBindPolyfill
|
||
|
||
function EventEmitter() {
|
||
if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
|
||
this._events = objectCreate(null);
|
||
this._eventsCount = 0;
|
||
}
|
||
|
||
this._maxListeners = this._maxListeners || undefined;
|
||
}
|
||
module.exports = EventEmitter;
|
||
|
||
// Backwards-compat with node 0.10.x
|
||
EventEmitter.EventEmitter = EventEmitter;
|
||
|
||
EventEmitter.prototype._events = undefined;
|
||
EventEmitter.prototype._maxListeners = undefined;
|
||
|
||
// By default EventEmitters will print a warning if more than 10 listeners are
|
||
// added to it. This is a useful default which helps finding memory leaks.
|
||
var defaultMaxListeners = 10;
|
||
|
||
var hasDefineProperty;
|
||
try {
|
||
var o = {};
|
||
if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
|
||
hasDefineProperty = o.x === 0;
|
||
} catch (err) { hasDefineProperty = false }
|
||
if (hasDefineProperty) {
|
||
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
||
enumerable: true,
|
||
get: function() {
|
||
return defaultMaxListeners;
|
||
},
|
||
set: function(arg) {
|
||
// check whether the input is a positive number (whose value is zero or
|
||
// greater and not a NaN).
|
||
if (typeof arg !== 'number' || arg < 0 || arg !== arg)
|
||
throw new TypeError('"defaultMaxListeners" must be a positive number');
|
||
defaultMaxListeners = arg;
|
||
}
|
||
});
|
||
} else {
|
||
EventEmitter.defaultMaxListeners = defaultMaxListeners;
|
||
}
|
||
|
||
// Obviously not all Emitters should be limited to 10. This function allows
|
||
// that to be increased. Set to zero for unlimited.
|
||
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
||
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
||
throw new TypeError('"n" argument must be a positive number');
|
||
this._maxListeners = n;
|
||
return this;
|
||
};
|
||
|
||
function $getMaxListeners(that) {
|
||
if (that._maxListeners === undefined)
|
||
return EventEmitter.defaultMaxListeners;
|
||
return that._maxListeners;
|
||
}
|
||
|
||
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
||
return $getMaxListeners(this);
|
||
};
|
||
|
||
// These standalone emit* functions are used to optimize calling of event
|
||
// handlers for fast cases because emit() itself often has a variable number of
|
||
// arguments and can be deoptimized because of that. These functions always have
|
||
// the same number of arguments and thus do not get deoptimized, so the code
|
||
// inside them can execute faster.
|
||
function emitNone(handler, isFn, self) {
|
||
if (isFn)
|
||
handler.call(self);
|
||
else {
|
||
var len = handler.length;
|
||
var listeners = arrayClone(handler, len);
|
||
for (var i = 0; i < len; ++i)
|
||
listeners[i].call(self);
|
||
}
|
||
}
|
||
function emitOne(handler, isFn, self, arg1) {
|
||
if (isFn)
|
||
handler.call(self, arg1);
|
||
else {
|
||
var len = handler.length;
|
||
var listeners = arrayClone(handler, len);
|
||
for (var i = 0; i < len; ++i)
|
||
listeners[i].call(self, arg1);
|
||
}
|
||
}
|
||
function emitTwo(handler, isFn, self, arg1, arg2) {
|
||
if (isFn)
|
||
handler.call(self, arg1, arg2);
|
||
else {
|
||
var len = handler.length;
|
||
var listeners = arrayClone(handler, len);
|
||
for (var i = 0; i < len; ++i)
|
||
listeners[i].call(self, arg1, arg2);
|
||
}
|
||
}
|
||
function emitThree(handler, isFn, self, arg1, arg2, arg3) {
|
||
if (isFn)
|
||
handler.call(self, arg1, arg2, arg3);
|
||
else {
|
||
var len = handler.length;
|
||
var listeners = arrayClone(handler, len);
|
||
for (var i = 0; i < len; ++i)
|
||
listeners[i].call(self, arg1, arg2, arg3);
|
||
}
|
||
}
|
||
|
||
function emitMany(handler, isFn, self, args) {
|
||
if (isFn)
|
||
handler.apply(self, args);
|
||
else {
|
||
var len = handler.length;
|
||
var listeners = arrayClone(handler, len);
|
||
for (var i = 0; i < len; ++i)
|
||
listeners[i].apply(self, args);
|
||
}
|
||
}
|
||
|
||
EventEmitter.prototype.emit = function emit(type) {
|
||
var er, handler, len, args, i, events;
|
||
var doError = (type === 'error');
|
||
|
||
events = this._events;
|
||
if (events)
|
||
doError = (doError && events.error == null);
|
||
else if (!doError)
|
||
return false;
|
||
|
||
// If there is no 'error' event listener then throw.
|
||
if (doError) {
|
||
if (arguments.length > 1)
|
||
er = arguments[1];
|
||
if (er instanceof Error) {
|
||
throw er; // Unhandled 'error' event
|
||
} else {
|
||
// At least give some kind of context to the user
|
||
var err = new Error('Unhandled "error" event. (' + er + ')');
|
||
err.context = er;
|
||
throw err;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
handler = events[type];
|
||
|
||
if (!handler)
|
||
return false;
|
||
|
||
var isFn = typeof handler === 'function';
|
||
len = arguments.length;
|
||
switch (len) {
|
||
// fast cases
|
||
case 1:
|
||
emitNone(handler, isFn, this);
|
||
break;
|
||
case 2:
|
||
emitOne(handler, isFn, this, arguments[1]);
|
||
break;
|
||
case 3:
|
||
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
|
||
break;
|
||
case 4:
|
||
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
|
||
break;
|
||
// slower
|
||
default:
|
||
args = new Array(len - 1);
|
||
for (i = 1; i < len; i++)
|
||
args[i - 1] = arguments[i];
|
||
emitMany(handler, isFn, this, args);
|
||
}
|
||
|
||
return true;
|
||
};
|
||
|
||
function _addListener(target, type, listener, prepend) {
|
||
var m;
|
||
var events;
|
||
var existing;
|
||
|
||
if (typeof listener !== 'function')
|
||
throw new TypeError('"listener" argument must be a function');
|
||
|
||
events = target._events;
|
||
if (!events) {
|
||
events = target._events = objectCreate(null);
|
||
target._eventsCount = 0;
|
||
} else {
|
||
// To avoid recursion in the case that type === "newListener"! Before
|
||
// adding it to the listeners, first emit "newListener".
|
||
if (events.newListener) {
|
||
target.emit('newListener', type,
|
||
listener.listener ? listener.listener : listener);
|
||
|
||
// Re-assign `events` because a newListener handler could have caused the
|
||
// this._events to be assigned to a new object
|
||
events = target._events;
|
||
}
|
||
existing = events[type];
|
||
}
|
||
|
||
if (!existing) {
|
||
// Optimize the case of one listener. Don't need the extra array object.
|
||
existing = events[type] = listener;
|
||
++target._eventsCount;
|
||
} else {
|
||
if (typeof existing === 'function') {
|
||
// Adding the second element, need to change to array.
|
||
existing = events[type] =
|
||
prepend ? [listener, existing] : [existing, listener];
|
||
} else {
|
||
// If we've already got an array, just append.
|
||
if (prepend) {
|
||
existing.unshift(listener);
|
||
} else {
|
||
existing.push(listener);
|
||
}
|
||
}
|
||
|
||
// Check for listener leak
|
||
if (!existing.warned) {
|
||
m = $getMaxListeners(target);
|
||
if (m && m > 0 && existing.length > m) {
|
||
existing.warned = true;
|
||
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
||
existing.length + ' "' + String(type) + '" listeners ' +
|
||
'added. Use emitter.setMaxListeners() to ' +
|
||
'increase limit.');
|
||
w.name = 'MaxListenersExceededWarning';
|
||
w.emitter = target;
|
||
w.type = type;
|
||
w.count = existing.length;
|
||
if (typeof console === 'object' && console.warn) {
|
||
console.warn('%s: %s', w.name, w.message);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return target;
|
||
}
|
||
|
||
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
||
return _addListener(this, type, listener, false);
|
||
};
|
||
|
||
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
||
|
||
EventEmitter.prototype.prependListener =
|
||
function prependListener(type, listener) {
|
||
return _addListener(this, type, listener, true);
|
||
};
|
||
|
||
function onceWrapper() {
|
||
if (!this.fired) {
|
||
this.target.removeListener(this.type, this.wrapFn);
|
||
this.fired = true;
|
||
switch (arguments.length) {
|
||
case 0:
|
||
return this.listener.call(this.target);
|
||
case 1:
|
||
return this.listener.call(this.target, arguments[0]);
|
||
case 2:
|
||
return this.listener.call(this.target, arguments[0], arguments[1]);
|
||
case 3:
|
||
return this.listener.call(this.target, arguments[0], arguments[1],
|
||
arguments[2]);
|
||
default:
|
||
var args = new Array(arguments.length);
|
||
for (var i = 0; i < args.length; ++i)
|
||
args[i] = arguments[i];
|
||
this.listener.apply(this.target, args);
|
||
}
|
||
}
|
||
}
|
||
|
||
function _onceWrap(target, type, listener) {
|
||
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
|
||
var wrapped = bind.call(onceWrapper, state);
|
||
wrapped.listener = listener;
|
||
state.wrapFn = wrapped;
|
||
return wrapped;
|
||
}
|
||
|
||
EventEmitter.prototype.once = function once(type, listener) {
|
||
if (typeof listener !== 'function')
|
||
throw new TypeError('"listener" argument must be a function');
|
||
this.on(type, _onceWrap(this, type, listener));
|
||
return this;
|
||
};
|
||
|
||
EventEmitter.prototype.prependOnceListener =
|
||
function prependOnceListener(type, listener) {
|
||
if (typeof listener !== 'function')
|
||
throw new TypeError('"listener" argument must be a function');
|
||
this.prependListener(type, _onceWrap(this, type, listener));
|
||
return this;
|
||
};
|
||
|
||
// Emits a 'removeListener' event if and only if the listener was removed.
|
||
EventEmitter.prototype.removeListener =
|
||
function removeListener(type, listener) {
|
||
var list, events, position, i, originalListener;
|
||
|
||
if (typeof listener !== 'function')
|
||
throw new TypeError('"listener" argument must be a function');
|
||
|
||
events = this._events;
|
||
if (!events)
|
||
return this;
|
||
|
||
list = events[type];
|
||
if (!list)
|
||
return this;
|
||
|
||
if (list === listener || list.listener === listener) {
|
||
if (--this._eventsCount === 0)
|
||
this._events = objectCreate(null);
|
||
else {
|
||
delete events[type];
|
||
if (events.removeListener)
|
||
this.emit('removeListener', type, list.listener || listener);
|
||
}
|
||
} else if (typeof list !== 'function') {
|
||
position = -1;
|
||
|
||
for (i = list.length - 1; i >= 0; i--) {
|
||
if (list[i] === listener || list[i].listener === listener) {
|
||
originalListener = list[i].listener;
|
||
position = i;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (position < 0)
|
||
return this;
|
||
|
||
if (position === 0)
|
||
list.shift();
|
||
else
|
||
spliceOne(list, position);
|
||
|
||
if (list.length === 1)
|
||
events[type] = list[0];
|
||
|
||
if (events.removeListener)
|
||
this.emit('removeListener', type, originalListener || listener);
|
||
}
|
||
|
||
return this;
|
||
};
|
||
|
||
EventEmitter.prototype.removeAllListeners =
|
||
function removeAllListeners(type) {
|
||
var listeners, events, i;
|
||
|
||
events = this._events;
|
||
if (!events)
|
||
return this;
|
||
|
||
// not listening for removeListener, no need to emit
|
||
if (!events.removeListener) {
|
||
if (arguments.length === 0) {
|
||
this._events = objectCreate(null);
|
||
this._eventsCount = 0;
|
||
} else if (events[type]) {
|
||
if (--this._eventsCount === 0)
|
||
this._events = objectCreate(null);
|
||
else
|
||
delete events[type];
|
||
}
|
||
return this;
|
||
}
|
||
|
||
// emit removeListener for all listeners on all events
|
||
if (arguments.length === 0) {
|
||
var keys = objectKeys(events);
|
||
var key;
|
||
for (i = 0; i < keys.length; ++i) {
|
||
key = keys[i];
|
||
if (key === 'removeListener') continue;
|
||
this.removeAllListeners(key);
|
||
}
|
||
this.removeAllListeners('removeListener');
|
||
this._events = objectCreate(null);
|
||
this._eventsCount = 0;
|
||
return this;
|
||
}
|
||
|
||
listeners = events[type];
|
||
|
||
if (typeof listeners === 'function') {
|
||
this.removeListener(type, listeners);
|
||
} else if (listeners) {
|
||
// LIFO order
|
||
for (i = listeners.length - 1; i >= 0; i--) {
|
||
this.removeListener(type, listeners[i]);
|
||
}
|
||
}
|
||
|
||
return this;
|
||
};
|
||
|
||
function _listeners(target, type, unwrap) {
|
||
var events = target._events;
|
||
|
||
if (!events)
|
||
return [];
|
||
|
||
var evlistener = events[type];
|
||
if (!evlistener)
|
||
return [];
|
||
|
||
if (typeof evlistener === 'function')
|
||
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
||
|
||
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
||
}
|
||
|
||
EventEmitter.prototype.listeners = function listeners(type) {
|
||
return _listeners(this, type, true);
|
||
};
|
||
|
||
EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
||
return _listeners(this, type, false);
|
||
};
|
||
|
||
EventEmitter.listenerCount = function(emitter, type) {
|
||
if (typeof emitter.listenerCount === 'function') {
|
||
return emitter.listenerCount(type);
|
||
} else {
|
||
return listenerCount.call(emitter, type);
|
||
}
|
||
};
|
||
|
||
EventEmitter.prototype.listenerCount = listenerCount;
|
||
function listenerCount(type) {
|
||
var events = this._events;
|
||
|
||
if (events) {
|
||
var evlistener = events[type];
|
||
|
||
if (typeof evlistener === 'function') {
|
||
return 1;
|
||
} else if (evlistener) {
|
||
return evlistener.length;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
EventEmitter.prototype.eventNames = function eventNames() {
|
||
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
||
};
|
||
|
||
// About 1.5x faster than the two-arg version of Array#splice().
|
||
function spliceOne(list, index) {
|
||
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
|
||
list[i] = list[k];
|
||
list.pop();
|
||
}
|
||
|
||
function arrayClone(arr, n) {
|
||
var copy = new Array(n);
|
||
for (var i = 0; i < n; ++i)
|
||
copy[i] = arr[i];
|
||
return copy;
|
||
}
|
||
|
||
function unwrapListeners(arr) {
|
||
var ret = new Array(arr.length);
|
||
for (var i = 0; i < ret.length; ++i) {
|
||
ret[i] = arr[i].listener || arr[i];
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
function objectCreatePolyfill(proto) {
|
||
var F = function() {};
|
||
F.prototype = proto;
|
||
return new F;
|
||
}
|
||
function objectKeysPolyfill(obj) {
|
||
var keys = [];
|
||
for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
|
||
keys.push(k);
|
||
}
|
||
return k;
|
||
}
|
||
function functionBindPolyfill(context) {
|
||
var fn = this;
|
||
return function () {
|
||
return fn.apply(context, arguments);
|
||
};
|
||
}
|
||
|
||
},{}],6:[function(require,module,exports){
|
||
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
||
var e, m
|
||
var eLen = (nBytes * 8) - mLen - 1
|
||
var eMax = (1 << eLen) - 1
|
||
var eBias = eMax >> 1
|
||
var nBits = -7
|
||
var i = isLE ? (nBytes - 1) : 0
|
||
var d = isLE ? -1 : 1
|
||
var s = buffer[offset + i]
|
||
|
||
i += d
|
||
|
||
e = s & ((1 << (-nBits)) - 1)
|
||
s >>= (-nBits)
|
||
nBits += eLen
|
||
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
||
|
||
m = e & ((1 << (-nBits)) - 1)
|
||
e >>= (-nBits)
|
||
nBits += mLen
|
||
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
||
|
||
if (e === 0) {
|
||
e = 1 - eBias
|
||
} else if (e === eMax) {
|
||
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
||
} else {
|
||
m = m + Math.pow(2, mLen)
|
||
e = e - eBias
|
||
}
|
||
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
||
}
|
||
|
||
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)
|
||
|
||
if (isNaN(value) || value === Infinity) {
|
||
m = isNaN(value) ? 1 : 0
|
||
e = eMax
|
||
} else {
|
||
e = Math.floor(Math.log(value) / Math.LN2)
|
||
if (value * (c = Math.pow(2, -e)) < 1) {
|
||
e--
|
||
c *= 2
|
||
}
|
||
if (e + eBias >= 1) {
|
||
value += rt / c
|
||
} else {
|
||
value += rt * Math.pow(2, 1 - eBias)
|
||
}
|
||
if (value * c >= 2) {
|
||
e++
|
||
c /= 2
|
||
}
|
||
|
||
if (e + eBias >= eMax) {
|
||
m = 0
|
||
e = eMax
|
||
} else if (e + eBias >= 1) {
|
||
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
|
||
}
|
||
}
|
||
|
||
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) {}
|
||
|
||
buffer[offset + i - d] |= s * 128
|
||
}
|
||
|
||
},{}],7:[function(require,module,exports){
|
||
if (typeof Object.create === 'function') {
|
||
// implementation from standard node.js 'util' module
|
||
module.exports = function inherits(ctor, superCtor) {
|
||
if (superCtor) {
|
||
ctor.super_ = superCtor
|
||
ctor.prototype = Object.create(superCtor.prototype, {
|
||
constructor: {
|
||
value: ctor,
|
||
enumerable: false,
|
||
writable: true,
|
||
configurable: true
|
||
}
|
||
})
|
||
}
|
||
};
|
||
} else {
|
||
// old school shim for old browsers
|
||
module.exports = function inherits(ctor, superCtor) {
|
||
if (superCtor) {
|
||
ctor.super_ = superCtor
|
||
var TempCtor = function () {}
|
||
TempCtor.prototype = superCtor.prototype
|
||
ctor.prototype = new TempCtor()
|
||
ctor.prototype.constructor = ctor
|
||
}
|
||
}
|
||
}
|
||
|
||
},{}],8:[function(require,module,exports){
|
||
/*!
|
||
* Determine if an object is a Buffer
|
||
*
|
||
* @author Feross Aboukhadijeh <https://feross.org>
|
||
* @license MIT
|
||
*/
|
||
|
||
// The _isBuffer check is for Safari 5-7 support, because it's missing
|
||
// Object.prototype.constructor. Remove this eventually
|
||
module.exports = function (obj) {
|
||
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
|
||
}
|
||
|
||
function isBuffer (obj) {
|
||
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
|
||
}
|
||
|
||
// For Node v0.10 support. Remove this eventually.
|
||
function isSlowBuffer (obj) {
|
||
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
|
||
}
|
||
|
||
},{}],9:[function(require,module,exports){
|
||
var toString = {}.toString;
|
||
|
||
module.exports = Array.isArray || function (arr) {
|
||
return toString.call(arr) == '[object Array]';
|
||
};
|
||
|
||
},{}],10:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
if (typeof process === 'undefined' ||
|
||
!process.version ||
|
||
process.version.indexOf('v0.') === 0 ||
|
||
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
|
||
module.exports = { nextTick: nextTick };
|
||
} else {
|
||
module.exports = process
|
||
}
|
||
|
||
function nextTick(fn, arg1, arg2, arg3) {
|
||
if (typeof fn !== 'function') {
|
||
throw new TypeError('"callback" argument must be a function');
|
||
}
|
||
var len = arguments.length;
|
||
var args, i;
|
||
switch (len) {
|
||
case 0:
|
||
case 1:
|
||
return process.nextTick(fn);
|
||
case 2:
|
||
return process.nextTick(function afterTickOne() {
|
||
fn.call(null, arg1);
|
||
});
|
||
case 3:
|
||
return process.nextTick(function afterTickTwo() {
|
||
fn.call(null, arg1, arg2);
|
||
});
|
||
case 4:
|
||
return process.nextTick(function afterTickThree() {
|
||
fn.call(null, arg1, arg2, arg3);
|
||
});
|
||
default:
|
||
args = new Array(len - 1);
|
||
i = 0;
|
||
while (i < args.length) {
|
||
args[i++] = arguments[i];
|
||
}
|
||
return process.nextTick(function afterTick() {
|
||
fn.apply(null, args);
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
}).call(this,require('_process'))
|
||
},{"_process":11}],11:[function(require,module,exports){
|
||
// shim for using process in browser
|
||
var process = module.exports = {};
|
||
|
||
// cached from whatever global is present so that test runners that stub it
|
||
// don't break things. But we need to wrap it in a try catch in case it is
|
||
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
||
// function because try/catches deoptimize in certain engines.
|
||
|
||
var cachedSetTimeout;
|
||
var cachedClearTimeout;
|
||
|
||
function defaultSetTimout() {
|
||
throw new Error('setTimeout has not been defined');
|
||
}
|
||
function defaultClearTimeout () {
|
||
throw new Error('clearTimeout has not been defined');
|
||
}
|
||
(function () {
|
||
try {
|
||
if (typeof setTimeout === 'function') {
|
||
cachedSetTimeout = setTimeout;
|
||
} else {
|
||
cachedSetTimeout = defaultSetTimout;
|
||
}
|
||
} catch (e) {
|
||
cachedSetTimeout = defaultSetTimout;
|
||
}
|
||
try {
|
||
if (typeof clearTimeout === 'function') {
|
||
cachedClearTimeout = clearTimeout;
|
||
} else {
|
||
cachedClearTimeout = defaultClearTimeout;
|
||
}
|
||
} catch (e) {
|
||
cachedClearTimeout = defaultClearTimeout;
|
||
}
|
||
} ())
|
||
function runTimeout(fun) {
|
||
if (cachedSetTimeout === setTimeout) {
|
||
//normal enviroments in sane situations
|
||
return setTimeout(fun, 0);
|
||
}
|
||
// if setTimeout wasn't available but was latter defined
|
||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
||
cachedSetTimeout = setTimeout;
|
||
return setTimeout(fun, 0);
|
||
}
|
||
try {
|
||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||
return cachedSetTimeout(fun, 0);
|
||
} catch(e){
|
||
try {
|
||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||
return cachedSetTimeout.call(null, fun, 0);
|
||
} catch(e){
|
||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||
return cachedSetTimeout.call(this, fun, 0);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
function runClearTimeout(marker) {
|
||
if (cachedClearTimeout === clearTimeout) {
|
||
//normal enviroments in sane situations
|
||
return clearTimeout(marker);
|
||
}
|
||
// if clearTimeout wasn't available but was latter defined
|
||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
||
cachedClearTimeout = clearTimeout;
|
||
return clearTimeout(marker);
|
||
}
|
||
try {
|
||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||
return cachedClearTimeout(marker);
|
||
} catch (e){
|
||
try {
|
||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||
return cachedClearTimeout.call(null, marker);
|
||
} catch (e){
|
||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||
return cachedClearTimeout.call(this, marker);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
var queue = [];
|
||
var draining = false;
|
||
var currentQueue;
|
||
var queueIndex = -1;
|
||
|
||
function cleanUpNextTick() {
|
||
if (!draining || !currentQueue) {
|
||
return;
|
||
}
|
||
draining = false;
|
||
if (currentQueue.length) {
|
||
queue = currentQueue.concat(queue);
|
||
} else {
|
||
queueIndex = -1;
|
||
}
|
||
if (queue.length) {
|
||
drainQueue();
|
||
}
|
||
}
|
||
|
||
function drainQueue() {
|
||
if (draining) {
|
||
return;
|
||
}
|
||
var timeout = runTimeout(cleanUpNextTick);
|
||
draining = true;
|
||
|
||
var len = queue.length;
|
||
while(len) {
|
||
currentQueue = queue;
|
||
queue = [];
|
||
while (++queueIndex < len) {
|
||
if (currentQueue) {
|
||
currentQueue[queueIndex].run();
|
||
}
|
||
}
|
||
queueIndex = -1;
|
||
len = queue.length;
|
||
}
|
||
currentQueue = null;
|
||
draining = false;
|
||
runClearTimeout(timeout);
|
||
}
|
||
|
||
process.nextTick = function (fun) {
|
||
var args = new Array(arguments.length - 1);
|
||
if (arguments.length > 1) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
args[i - 1] = arguments[i];
|
||
}
|
||
}
|
||
queue.push(new Item(fun, args));
|
||
if (queue.length === 1 && !draining) {
|
||
runTimeout(drainQueue);
|
||
}
|
||
};
|
||
|
||
// v8 likes predictible objects
|
||
function Item(fun, array) {
|
||
this.fun = fun;
|
||
this.array = array;
|
||
}
|
||
Item.prototype.run = function () {
|
||
this.fun.apply(null, this.array);
|
||
};
|
||
process.title = 'browser';
|
||
process.browser = true;
|
||
process.env = {};
|
||
process.argv = [];
|
||
process.version = ''; // empty string to avoid regexp issues
|
||
process.versions = {};
|
||
|
||
function noop() {}
|
||
|
||
process.on = noop;
|
||
process.addListener = noop;
|
||
process.once = noop;
|
||
process.off = noop;
|
||
process.removeListener = noop;
|
||
process.removeAllListeners = noop;
|
||
process.emit = noop;
|
||
process.prependListener = noop;
|
||
process.prependOnceListener = noop;
|
||
|
||
process.listeners = function (name) { return [] }
|
||
|
||
process.binding = function (name) {
|
||
throw new Error('process.binding is not supported');
|
||
};
|
||
|
||
process.cwd = function () { return '/' };
|
||
process.chdir = function (dir) {
|
||
throw new Error('process.chdir is not supported');
|
||
};
|
||
process.umask = function() { return 0; };
|
||
|
||
},{}],12:[function(require,module,exports){
|
||
module.exports = require('./lib/_stream_duplex.js');
|
||
|
||
},{"./lib/_stream_duplex.js":13}],13:[function(require,module,exports){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
// a duplex stream is just a stream that is both readable and writable.
|
||
// Since JS doesn't have multiple prototypal inheritance, this class
|
||
// prototypally inherits from Readable, and then parasitically from
|
||
// Writable.
|
||
|
||
'use strict';
|
||
|
||
/*<replacement>*/
|
||
|
||
var pna = require('process-nextick-args');
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var objectKeys = Object.keys || function (obj) {
|
||
var keys = [];
|
||
for (var key in obj) {
|
||
keys.push(key);
|
||
}return keys;
|
||
};
|
||
/*</replacement>*/
|
||
|
||
module.exports = Duplex;
|
||
|
||
/*<replacement>*/
|
||
var util = require('core-util-is');
|
||
util.inherits = require('inherits');
|
||
/*</replacement>*/
|
||
|
||
var Readable = require('./_stream_readable');
|
||
var Writable = require('./_stream_writable');
|
||
|
||
util.inherits(Duplex, Readable);
|
||
|
||
{
|
||
// avoid scope creep, the keys array can then be collected
|
||
var keys = objectKeys(Writable.prototype);
|
||
for (var v = 0; v < keys.length; v++) {
|
||
var method = keys[v];
|
||
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
||
}
|
||
}
|
||
|
||
function Duplex(options) {
|
||
if (!(this instanceof Duplex)) return new Duplex(options);
|
||
|
||
Readable.call(this, options);
|
||
Writable.call(this, options);
|
||
|
||
if (options && options.readable === false) this.readable = false;
|
||
|
||
if (options && options.writable === false) this.writable = false;
|
||
|
||
this.allowHalfOpen = true;
|
||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
||
|
||
this.once('end', onend);
|
||
}
|
||
|
||
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
||
// making it explicit this property is not enumerable
|
||
// because otherwise some prototype manipulation in
|
||
// userland will fail
|
||
enumerable: false,
|
||
get: function () {
|
||
return this._writableState.highWaterMark;
|
||
}
|
||
});
|
||
|
||
// the no-half-open enforcer
|
||
function onend() {
|
||
// if we allow half-open state, or if the writable side ended,
|
||
// then we're ok.
|
||
if (this.allowHalfOpen || this._writableState.ended) return;
|
||
|
||
// no more data can be written.
|
||
// But allow more writes to happen in this tick.
|
||
pna.nextTick(onEndNT, this);
|
||
}
|
||
|
||
function onEndNT(self) {
|
||
self.end();
|
||
}
|
||
|
||
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
||
get: function () {
|
||
if (this._readableState === undefined || this._writableState === undefined) {
|
||
return false;
|
||
}
|
||
return this._readableState.destroyed && this._writableState.destroyed;
|
||
},
|
||
set: function (value) {
|
||
// we ignore the value if the stream
|
||
// has not been initialized yet
|
||
if (this._readableState === undefined || this._writableState === undefined) {
|
||
return;
|
||
}
|
||
|
||
// backward compatibility, the user is explicitly
|
||
// managing destroyed
|
||
this._readableState.destroyed = value;
|
||
this._writableState.destroyed = value;
|
||
}
|
||
});
|
||
|
||
Duplex.prototype._destroy = function (err, cb) {
|
||
this.push(null);
|
||
this.end();
|
||
|
||
pna.nextTick(cb, err);
|
||
};
|
||
},{"./_stream_readable":15,"./_stream_writable":17,"core-util-is":4,"inherits":7,"process-nextick-args":10}],14:[function(require,module,exports){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
// a passthrough stream.
|
||
// basically just the most minimal sort of Transform stream.
|
||
// Every written chunk gets output as-is.
|
||
|
||
'use strict';
|
||
|
||
module.exports = PassThrough;
|
||
|
||
var Transform = require('./_stream_transform');
|
||
|
||
/*<replacement>*/
|
||
var util = require('core-util-is');
|
||
util.inherits = require('inherits');
|
||
/*</replacement>*/
|
||
|
||
util.inherits(PassThrough, Transform);
|
||
|
||
function PassThrough(options) {
|
||
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
||
|
||
Transform.call(this, options);
|
||
}
|
||
|
||
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
||
cb(null, chunk);
|
||
};
|
||
},{"./_stream_transform":16,"core-util-is":4,"inherits":7}],15:[function(require,module,exports){
|
||
(function (process,global){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
'use strict';
|
||
|
||
/*<replacement>*/
|
||
|
||
var pna = require('process-nextick-args');
|
||
/*</replacement>*/
|
||
|
||
module.exports = Readable;
|
||
|
||
/*<replacement>*/
|
||
var isArray = require('isarray');
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var Duplex;
|
||
/*</replacement>*/
|
||
|
||
Readable.ReadableState = ReadableState;
|
||
|
||
/*<replacement>*/
|
||
var EE = require('events').EventEmitter;
|
||
|
||
var EElistenerCount = function (emitter, type) {
|
||
return emitter.listeners(type).length;
|
||
};
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var Stream = require('./internal/streams/stream');
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
|
||
var Buffer = require('safe-buffer').Buffer;
|
||
var OurUint8Array = global.Uint8Array || function () {};
|
||
function _uint8ArrayToBuffer(chunk) {
|
||
return Buffer.from(chunk);
|
||
}
|
||
function _isUint8Array(obj) {
|
||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||
}
|
||
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var util = require('core-util-is');
|
||
util.inherits = require('inherits');
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var debugUtil = require('util');
|
||
var debug = void 0;
|
||
if (debugUtil && debugUtil.debuglog) {
|
||
debug = debugUtil.debuglog('stream');
|
||
} else {
|
||
debug = function () {};
|
||
}
|
||
/*</replacement>*/
|
||
|
||
var BufferList = require('./internal/streams/BufferList');
|
||
var destroyImpl = require('./internal/streams/destroy');
|
||
var StringDecoder;
|
||
|
||
util.inherits(Readable, Stream);
|
||
|
||
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
||
|
||
function prependListener(emitter, event, fn) {
|
||
// Sadly this is not cacheable as some libraries bundle their own
|
||
// event emitter implementation with them.
|
||
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
||
|
||
// This is a hack to make sure that our error handler is attached before any
|
||
// userland ones. NEVER DO THIS. This is here only because this code needs
|
||
// to continue to work with older versions of Node.js that do not include
|
||
// the prependListener() method. The goal is to eventually remove this hack.
|
||
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
||
}
|
||
|
||
function ReadableState(options, stream) {
|
||
Duplex = Duplex || require('./_stream_duplex');
|
||
|
||
options = options || {};
|
||
|
||
// Duplex streams are both readable and writable, but share
|
||
// the same options object.
|
||
// However, some cases require setting options to different
|
||
// values for the readable and the writable sides of the duplex stream.
|
||
// These options can be provided separately as readableXXX and writableXXX.
|
||
var isDuplex = stream instanceof Duplex;
|
||
|
||
// object stream flag. Used to make read(n) ignore n and to
|
||
// make all the buffer merging and length checks go away
|
||
this.objectMode = !!options.objectMode;
|
||
|
||
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
||
|
||
// the point at which it stops calling _read() to fill the buffer
|
||
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
||
var hwm = options.highWaterMark;
|
||
var readableHwm = options.readableHighWaterMark;
|
||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||
|
||
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
|
||
|
||
// cast to ints.
|
||
this.highWaterMark = Math.floor(this.highWaterMark);
|
||
|
||
// A linked list is used to store data chunks instead of an array because the
|
||
// linked list can remove elements from the beginning faster than
|
||
// array.shift()
|
||
this.buffer = new BufferList();
|
||
this.length = 0;
|
||
this.pipes = null;
|
||
this.pipesCount = 0;
|
||
this.flowing = null;
|
||
this.ended = false;
|
||
this.endEmitted = false;
|
||
this.reading = false;
|
||
|
||
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
||
// immediately, or on a later tick. We set this to true at first, because
|
||
// any actions that shouldn't happen until "later" should generally also
|
||
// not happen before the first read call.
|
||
this.sync = true;
|
||
|
||
// whenever we return null, then we set a flag to say
|
||
// that we're awaiting a 'readable' event emission.
|
||
this.needReadable = false;
|
||
this.emittedReadable = false;
|
||
this.readableListening = false;
|
||
this.resumeScheduled = false;
|
||
|
||
// has it been destroyed
|
||
this.destroyed = false;
|
||
|
||
// Crypto is kind of old and crusty. Historically, its default string
|
||
// encoding is 'binary' so we have to make this configurable.
|
||
// Everything else in the universe uses 'utf8', though.
|
||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||
|
||
// the number of writers that are awaiting a drain event in .pipe()s
|
||
this.awaitDrain = 0;
|
||
|
||
// if true, a maybeReadMore has been scheduled
|
||
this.readingMore = false;
|
||
|
||
this.decoder = null;
|
||
this.encoding = null;
|
||
if (options.encoding) {
|
||
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
|
||
this.decoder = new StringDecoder(options.encoding);
|
||
this.encoding = options.encoding;
|
||
}
|
||
}
|
||
|
||
function Readable(options) {
|
||
Duplex = Duplex || require('./_stream_duplex');
|
||
|
||
if (!(this instanceof Readable)) return new Readable(options);
|
||
|
||
this._readableState = new ReadableState(options, this);
|
||
|
||
// legacy
|
||
this.readable = true;
|
||
|
||
if (options) {
|
||
if (typeof options.read === 'function') this._read = options.read;
|
||
|
||
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
||
}
|
||
|
||
Stream.call(this);
|
||
}
|
||
|
||
Object.defineProperty(Readable.prototype, 'destroyed', {
|
||
get: function () {
|
||
if (this._readableState === undefined) {
|
||
return false;
|
||
}
|
||
return this._readableState.destroyed;
|
||
},
|
||
set: function (value) {
|
||
// we ignore the value if the stream
|
||
// has not been initialized yet
|
||
if (!this._readableState) {
|
||
return;
|
||
}
|
||
|
||
// backward compatibility, the user is explicitly
|
||
// managing destroyed
|
||
this._readableState.destroyed = value;
|
||
}
|
||
});
|
||
|
||
Readable.prototype.destroy = destroyImpl.destroy;
|
||
Readable.prototype._undestroy = destroyImpl.undestroy;
|
||
Readable.prototype._destroy = function (err, cb) {
|
||
this.push(null);
|
||
cb(err);
|
||
};
|
||
|
||
// Manually shove something into the read() buffer.
|
||
// This returns true if the highWaterMark has not been hit yet,
|
||
// similar to how Writable.write() returns true if you should
|
||
// write() some more.
|
||
Readable.prototype.push = function (chunk, encoding) {
|
||
var state = this._readableState;
|
||
var skipChunkCheck;
|
||
|
||
if (!state.objectMode) {
|
||
if (typeof chunk === 'string') {
|
||
encoding = encoding || state.defaultEncoding;
|
||
if (encoding !== state.encoding) {
|
||
chunk = Buffer.from(chunk, encoding);
|
||
encoding = '';
|
||
}
|
||
skipChunkCheck = true;
|
||
}
|
||
} else {
|
||
skipChunkCheck = true;
|
||
}
|
||
|
||
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
||
};
|
||
|
||
// Unshift should *always* be something directly out of read()
|
||
Readable.prototype.unshift = function (chunk) {
|
||
return readableAddChunk(this, chunk, null, true, false);
|
||
};
|
||
|
||
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
||
var state = stream._readableState;
|
||
if (chunk === null) {
|
||
state.reading = false;
|
||
onEofChunk(stream, state);
|
||
} else {
|
||
var er;
|
||
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
||
if (er) {
|
||
stream.emit('error', er);
|
||
} else if (state.objectMode || chunk && chunk.length > 0) {
|
||
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
||
chunk = _uint8ArrayToBuffer(chunk);
|
||
}
|
||
|
||
if (addToFront) {
|
||
if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
|
||
} else if (state.ended) {
|
||
stream.emit('error', new Error('stream.push() after EOF'));
|
||
} else {
|
||
state.reading = false;
|
||
if (state.decoder && !encoding) {
|
||
chunk = state.decoder.write(chunk);
|
||
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
||
} else {
|
||
addChunk(stream, state, chunk, false);
|
||
}
|
||
}
|
||
} else if (!addToFront) {
|
||
state.reading = false;
|
||
}
|
||
}
|
||
|
||
return needMoreData(state);
|
||
}
|
||
|
||
function addChunk(stream, state, chunk, addToFront) {
|
||
if (state.flowing && state.length === 0 && !state.sync) {
|
||
stream.emit('data', chunk);
|
||
stream.read(0);
|
||
} else {
|
||
// update the buffer info.
|
||
state.length += state.objectMode ? 1 : chunk.length;
|
||
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
||
|
||
if (state.needReadable) emitReadable(stream);
|
||
}
|
||
maybeReadMore(stream, state);
|
||
}
|
||
|
||
function chunkInvalid(state, chunk) {
|
||
var er;
|
||
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
||
er = new TypeError('Invalid non-string/buffer chunk');
|
||
}
|
||
return er;
|
||
}
|
||
|
||
// if it's past the high water mark, we can push in some more.
|
||
// Also, if we have no data yet, we can stand some
|
||
// more bytes. This is to work around cases where hwm=0,
|
||
// such as the repl. Also, if the push() triggered a
|
||
// readable event, and the user called read(largeNumber) such that
|
||
// needReadable was set, then we ought to push more, so that another
|
||
// 'readable' event will be triggered.
|
||
function needMoreData(state) {
|
||
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
||
}
|
||
|
||
Readable.prototype.isPaused = function () {
|
||
return this._readableState.flowing === false;
|
||
};
|
||
|
||
// backwards compatibility.
|
||
Readable.prototype.setEncoding = function (enc) {
|
||
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
|
||
this._readableState.decoder = new StringDecoder(enc);
|
||
this._readableState.encoding = enc;
|
||
return this;
|
||
};
|
||
|
||
// Don't raise the hwm > 8MB
|
||
var MAX_HWM = 0x800000;
|
||
function computeNewHighWaterMark(n) {
|
||
if (n >= MAX_HWM) {
|
||
n = MAX_HWM;
|
||
} else {
|
||
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
||
// tiny amounts
|
||
n--;
|
||
n |= n >>> 1;
|
||
n |= n >>> 2;
|
||
n |= n >>> 4;
|
||
n |= n >>> 8;
|
||
n |= n >>> 16;
|
||
n++;
|
||
}
|
||
return n;
|
||
}
|
||
|
||
// This function is designed to be inlinable, so please take care when making
|
||
// changes to the function body.
|
||
function howMuchToRead(n, state) {
|
||
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
||
if (state.objectMode) return 1;
|
||
if (n !== n) {
|
||
// Only flow one buffer at a time
|
||
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
||
}
|
||
// If we're asking for more than the current hwm, then raise the hwm.
|
||
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
||
if (n <= state.length) return n;
|
||
// Don't have enough
|
||
if (!state.ended) {
|
||
state.needReadable = true;
|
||
return 0;
|
||
}
|
||
return state.length;
|
||
}
|
||
|
||
// you can override either this method, or the async _read(n) below.
|
||
Readable.prototype.read = function (n) {
|
||
debug('read', n);
|
||
n = parseInt(n, 10);
|
||
var state = this._readableState;
|
||
var nOrig = n;
|
||
|
||
if (n !== 0) state.emittedReadable = false;
|
||
|
||
// if we're doing read(0) to trigger a readable event, but we
|
||
// already have a bunch of data in the buffer, then just trigger
|
||
// the 'readable' event and move on.
|
||
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
||
debug('read: emitReadable', state.length, state.ended);
|
||
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
||
return null;
|
||
}
|
||
|
||
n = howMuchToRead(n, state);
|
||
|
||
// if we've ended, and we're now clear, then finish it up.
|
||
if (n === 0 && state.ended) {
|
||
if (state.length === 0) endReadable(this);
|
||
return null;
|
||
}
|
||
|
||
// All the actual chunk generation logic needs to be
|
||
// *below* the call to _read. The reason is that in certain
|
||
// synthetic stream cases, such as passthrough streams, _read
|
||
// may be a completely synchronous operation which may change
|
||
// the state of the read buffer, providing enough data when
|
||
// before there was *not* enough.
|
||
//
|
||
// So, the steps are:
|
||
// 1. Figure out what the state of things will be after we do
|
||
// a read from the buffer.
|
||
//
|
||
// 2. If that resulting state will trigger a _read, then call _read.
|
||
// Note that this may be asynchronous, or synchronous. Yes, it is
|
||
// deeply ugly to write APIs this way, but that still doesn't mean
|
||
// that the Readable class should behave improperly, as streams are
|
||
// designed to be sync/async agnostic.
|
||
// Take note if the _read call is sync or async (ie, if the read call
|
||
// has returned yet), so that we know whether or not it's safe to emit
|
||
// 'readable' etc.
|
||
//
|
||
// 3. Actually pull the requested chunks out of the buffer and return.
|
||
|
||
// if we need a readable event, then we need to do some reading.
|
||
var doRead = state.needReadable;
|
||
debug('need readable', doRead);
|
||
|
||
// if we currently have less than the highWaterMark, then also read some
|
||
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
||
doRead = true;
|
||
debug('length less than watermark', doRead);
|
||
}
|
||
|
||
// however, if we've ended, then there's no point, and if we're already
|
||
// reading, then it's unnecessary.
|
||
if (state.ended || state.reading) {
|
||
doRead = false;
|
||
debug('reading or ended', doRead);
|
||
} else if (doRead) {
|
||
debug('do read');
|
||
state.reading = true;
|
||
state.sync = true;
|
||
// if the length is currently zero, then we *need* a readable event.
|
||
if (state.length === 0) state.needReadable = true;
|
||
// call internal read method
|
||
this._read(state.highWaterMark);
|
||
state.sync = false;
|
||
// If _read pushed data synchronously, then `reading` will be false,
|
||
// and we need to re-evaluate how much data we can return to the user.
|
||
if (!state.reading) n = howMuchToRead(nOrig, state);
|
||
}
|
||
|
||
var ret;
|
||
if (n > 0) ret = fromList(n, state);else ret = null;
|
||
|
||
if (ret === null) {
|
||
state.needReadable = true;
|
||
n = 0;
|
||
} else {
|
||
state.length -= n;
|
||
}
|
||
|
||
if (state.length === 0) {
|
||
// If we have nothing in the buffer, then we want to know
|
||
// as soon as we *do* get something into the buffer.
|
||
if (!state.ended) state.needReadable = true;
|
||
|
||
// If we tried to read() past the EOF, then emit end on the next tick.
|
||
if (nOrig !== n && state.ended) endReadable(this);
|
||
}
|
||
|
||
if (ret !== null) this.emit('data', ret);
|
||
|
||
return ret;
|
||
};
|
||
|
||
function onEofChunk(stream, state) {
|
||
if (state.ended) return;
|
||
if (state.decoder) {
|
||
var chunk = state.decoder.end();
|
||
if (chunk && chunk.length) {
|
||
state.buffer.push(chunk);
|
||
state.length += state.objectMode ? 1 : chunk.length;
|
||
}
|
||
}
|
||
state.ended = true;
|
||
|
||
// emit 'readable' now to make sure it gets picked up.
|
||
emitReadable(stream);
|
||
}
|
||
|
||
// Don't emit readable right away in sync mode, because this can trigger
|
||
// another read() call => stack overflow. This way, it might trigger
|
||
// a nextTick recursion warning, but that's not so bad.
|
||
function emitReadable(stream) {
|
||
var state = stream._readableState;
|
||
state.needReadable = false;
|
||
if (!state.emittedReadable) {
|
||
debug('emitReadable', state.flowing);
|
||
state.emittedReadable = true;
|
||
if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
|
||
}
|
||
}
|
||
|
||
function emitReadable_(stream) {
|
||
debug('emit readable');
|
||
stream.emit('readable');
|
||
flow(stream);
|
||
}
|
||
|
||
// at this point, the user has presumably seen the 'readable' event,
|
||
// and called read() to consume some data. that may have triggered
|
||
// in turn another _read(n) call, in which case reading = true if
|
||
// it's in progress.
|
||
// However, if we're not ended, or reading, and the length < hwm,
|
||
// then go ahead and try to read some more preemptively.
|
||
function maybeReadMore(stream, state) {
|
||
if (!state.readingMore) {
|
||
state.readingMore = true;
|
||
pna.nextTick(maybeReadMore_, stream, state);
|
||
}
|
||
}
|
||
|
||
function maybeReadMore_(stream, state) {
|
||
var len = state.length;
|
||
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
||
debug('maybeReadMore read 0');
|
||
stream.read(0);
|
||
if (len === state.length)
|
||
// didn't get any data, stop spinning.
|
||
break;else len = state.length;
|
||
}
|
||
state.readingMore = false;
|
||
}
|
||
|
||
// abstract method. to be overridden in specific implementation classes.
|
||
// call cb(er, data) where data is <= n in length.
|
||
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
||
// arbitrary, and perhaps not very meaningful.
|
||
Readable.prototype._read = function (n) {
|
||
this.emit('error', new Error('_read() is not implemented'));
|
||
};
|
||
|
||
Readable.prototype.pipe = function (dest, pipeOpts) {
|
||
var src = this;
|
||
var state = this._readableState;
|
||
|
||
switch (state.pipesCount) {
|
||
case 0:
|
||
state.pipes = dest;
|
||
break;
|
||
case 1:
|
||
state.pipes = [state.pipes, dest];
|
||
break;
|
||
default:
|
||
state.pipes.push(dest);
|
||
break;
|
||
}
|
||
state.pipesCount += 1;
|
||
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
||
|
||
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
||
|
||
var endFn = doEnd ? onend : unpipe;
|
||
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
|
||
|
||
dest.on('unpipe', onunpipe);
|
||
function onunpipe(readable, unpipeInfo) {
|
||
debug('onunpipe');
|
||
if (readable === src) {
|
||
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
||
unpipeInfo.hasUnpiped = true;
|
||
cleanup();
|
||
}
|
||
}
|
||
}
|
||
|
||
function onend() {
|
||
debug('onend');
|
||
dest.end();
|
||
}
|
||
|
||
// when the dest drains, it reduces the awaitDrain counter
|
||
// on the source. This would be more elegant with a .once()
|
||
// handler in flow(), but adding and removing repeatedly is
|
||
// too slow.
|
||
var ondrain = pipeOnDrain(src);
|
||
dest.on('drain', ondrain);
|
||
|
||
var cleanedUp = false;
|
||
function cleanup() {
|
||
debug('cleanup');
|
||
// cleanup event handlers once the pipe is broken
|
||
dest.removeListener('close', onclose);
|
||
dest.removeListener('finish', onfinish);
|
||
dest.removeListener('drain', ondrain);
|
||
dest.removeListener('error', onerror);
|
||
dest.removeListener('unpipe', onunpipe);
|
||
src.removeListener('end', onend);
|
||
src.removeListener('end', unpipe);
|
||
src.removeListener('data', ondata);
|
||
|
||
cleanedUp = true;
|
||
|
||
// if the reader is waiting for a drain event from this
|
||
// specific writer, then it would cause it to never start
|
||
// flowing again.
|
||
// So, if this is awaiting a drain, then we just call it now.
|
||
// If we don't know, then assume that we are waiting for one.
|
||
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
||
}
|
||
|
||
// If the user pushes more data while we're writing to dest then we'll end up
|
||
// in ondata again. However, we only want to increase awaitDrain once because
|
||
// dest will only emit one 'drain' event for the multiple writes.
|
||
// => Introduce a guard on increasing awaitDrain.
|
||
var increasedAwaitDrain = false;
|
||
src.on('data', ondata);
|
||
function ondata(chunk) {
|
||
debug('ondata');
|
||
increasedAwaitDrain = false;
|
||
var ret = dest.write(chunk);
|
||
if (false === ret && !increasedAwaitDrain) {
|
||
// If the user unpiped during `dest.write()`, it is possible
|
||
// to get stuck in a permanently paused state if that write
|
||
// also returned false.
|
||
// => Check whether `dest` is still a piping destination.
|
||
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
||
debug('false write response, pause', src._readableState.awaitDrain);
|
||
src._readableState.awaitDrain++;
|
||
increasedAwaitDrain = true;
|
||
}
|
||
src.pause();
|
||
}
|
||
}
|
||
|
||
// if the dest has an error, then stop piping into it.
|
||
// however, don't suppress the throwing behavior for this.
|
||
function onerror(er) {
|
||
debug('onerror', er);
|
||
unpipe();
|
||
dest.removeListener('error', onerror);
|
||
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
|
||
}
|
||
|
||
// Make sure our error handler is attached before userland ones.
|
||
prependListener(dest, 'error', onerror);
|
||
|
||
// Both close and finish should trigger unpipe, but only once.
|
||
function onclose() {
|
||
dest.removeListener('finish', onfinish);
|
||
unpipe();
|
||
}
|
||
dest.once('close', onclose);
|
||
function onfinish() {
|
||
debug('onfinish');
|
||
dest.removeListener('close', onclose);
|
||
unpipe();
|
||
}
|
||
dest.once('finish', onfinish);
|
||
|
||
function unpipe() {
|
||
debug('unpipe');
|
||
src.unpipe(dest);
|
||
}
|
||
|
||
// tell the dest that it's being piped to
|
||
dest.emit('pipe', src);
|
||
|
||
// start the flow if it hasn't been started already.
|
||
if (!state.flowing) {
|
||
debug('pipe resume');
|
||
src.resume();
|
||
}
|
||
|
||
return dest;
|
||
};
|
||
|
||
function pipeOnDrain(src) {
|
||
return function () {
|
||
var state = src._readableState;
|
||
debug('pipeOnDrain', state.awaitDrain);
|
||
if (state.awaitDrain) state.awaitDrain--;
|
||
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
||
state.flowing = true;
|
||
flow(src);
|
||
}
|
||
};
|
||
}
|
||
|
||
Readable.prototype.unpipe = function (dest) {
|
||
var state = this._readableState;
|
||
var unpipeInfo = { hasUnpiped: false };
|
||
|
||
// if we're not piping anywhere, then do nothing.
|
||
if (state.pipesCount === 0) return this;
|
||
|
||
// just one destination. most common case.
|
||
if (state.pipesCount === 1) {
|
||
// passed in one, but it's not the right one.
|
||
if (dest && dest !== state.pipes) return this;
|
||
|
||
if (!dest) dest = state.pipes;
|
||
|
||
// got a match.
|
||
state.pipes = null;
|
||
state.pipesCount = 0;
|
||
state.flowing = false;
|
||
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
||
return this;
|
||
}
|
||
|
||
// slow case. multiple pipe destinations.
|
||
|
||
if (!dest) {
|
||
// remove all.
|
||
var dests = state.pipes;
|
||
var len = state.pipesCount;
|
||
state.pipes = null;
|
||
state.pipesCount = 0;
|
||
state.flowing = false;
|
||
|
||
for (var i = 0; i < len; i++) {
|
||
dests[i].emit('unpipe', this, unpipeInfo);
|
||
}return this;
|
||
}
|
||
|
||
// try to find the right one.
|
||
var index = indexOf(state.pipes, dest);
|
||
if (index === -1) return this;
|
||
|
||
state.pipes.splice(index, 1);
|
||
state.pipesCount -= 1;
|
||
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
||
|
||
dest.emit('unpipe', this, unpipeInfo);
|
||
|
||
return this;
|
||
};
|
||
|
||
// set up data events if they are asked for
|
||
// Ensure readable listeners eventually get something
|
||
Readable.prototype.on = function (ev, fn) {
|
||
var res = Stream.prototype.on.call(this, ev, fn);
|
||
|
||
if (ev === 'data') {
|
||
// Start flowing on next tick if stream isn't explicitly paused
|
||
if (this._readableState.flowing !== false) this.resume();
|
||
} else if (ev === 'readable') {
|
||
var state = this._readableState;
|
||
if (!state.endEmitted && !state.readableListening) {
|
||
state.readableListening = state.needReadable = true;
|
||
state.emittedReadable = false;
|
||
if (!state.reading) {
|
||
pna.nextTick(nReadingNextTick, this);
|
||
} else if (state.length) {
|
||
emitReadable(this);
|
||
}
|
||
}
|
||
}
|
||
|
||
return res;
|
||
};
|
||
Readable.prototype.addListener = Readable.prototype.on;
|
||
|
||
function nReadingNextTick(self) {
|
||
debug('readable nexttick read 0');
|
||
self.read(0);
|
||
}
|
||
|
||
// pause() and resume() are remnants of the legacy readable stream API
|
||
// If the user uses them, then switch into old mode.
|
||
Readable.prototype.resume = function () {
|
||
var state = this._readableState;
|
||
if (!state.flowing) {
|
||
debug('resume');
|
||
state.flowing = true;
|
||
resume(this, state);
|
||
}
|
||
return this;
|
||
};
|
||
|
||
function resume(stream, state) {
|
||
if (!state.resumeScheduled) {
|
||
state.resumeScheduled = true;
|
||
pna.nextTick(resume_, stream, state);
|
||
}
|
||
}
|
||
|
||
function resume_(stream, state) {
|
||
if (!state.reading) {
|
||
debug('resume read 0');
|
||
stream.read(0);
|
||
}
|
||
|
||
state.resumeScheduled = false;
|
||
state.awaitDrain = 0;
|
||
stream.emit('resume');
|
||
flow(stream);
|
||
if (state.flowing && !state.reading) stream.read(0);
|
||
}
|
||
|
||
Readable.prototype.pause = function () {
|
||
debug('call pause flowing=%j', this._readableState.flowing);
|
||
if (false !== this._readableState.flowing) {
|
||
debug('pause');
|
||
this._readableState.flowing = false;
|
||
this.emit('pause');
|
||
}
|
||
return this;
|
||
};
|
||
|
||
function flow(stream) {
|
||
var state = stream._readableState;
|
||
debug('flow', state.flowing);
|
||
while (state.flowing && stream.read() !== null) {}
|
||
}
|
||
|
||
// wrap an old-style stream as the async data source.
|
||
// This is *not* part of the readable stream interface.
|
||
// It is an ugly unfortunate mess of history.
|
||
Readable.prototype.wrap = function (stream) {
|
||
var _this = this;
|
||
|
||
var state = this._readableState;
|
||
var paused = false;
|
||
|
||
stream.on('end', function () {
|
||
debug('wrapped end');
|
||
if (state.decoder && !state.ended) {
|
||
var chunk = state.decoder.end();
|
||
if (chunk && chunk.length) _this.push(chunk);
|
||
}
|
||
|
||
_this.push(null);
|
||
});
|
||
|
||
stream.on('data', function (chunk) {
|
||
debug('wrapped data');
|
||
if (state.decoder) chunk = state.decoder.write(chunk);
|
||
|
||
// don't skip over falsy values in objectMode
|
||
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
||
|
||
var ret = _this.push(chunk);
|
||
if (!ret) {
|
||
paused = true;
|
||
stream.pause();
|
||
}
|
||
});
|
||
|
||
// proxy all the other methods.
|
||
// important when wrapping filters and duplexes.
|
||
for (var i in stream) {
|
||
if (this[i] === undefined && typeof stream[i] === 'function') {
|
||
this[i] = function (method) {
|
||
return function () {
|
||
return stream[method].apply(stream, arguments);
|
||
};
|
||
}(i);
|
||
}
|
||
}
|
||
|
||
// proxy certain important events.
|
||
for (var n = 0; n < kProxyEvents.length; n++) {
|
||
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
||
}
|
||
|
||
// when we try to consume some more bytes, simply unpause the
|
||
// underlying stream.
|
||
this._read = function (n) {
|
||
debug('wrapped _read', n);
|
||
if (paused) {
|
||
paused = false;
|
||
stream.resume();
|
||
}
|
||
};
|
||
|
||
return this;
|
||
};
|
||
|
||
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
||
// making it explicit this property is not enumerable
|
||
// because otherwise some prototype manipulation in
|
||
// userland will fail
|
||
enumerable: false,
|
||
get: function () {
|
||
return this._readableState.highWaterMark;
|
||
}
|
||
});
|
||
|
||
// exposed for testing purposes only.
|
||
Readable._fromList = fromList;
|
||
|
||
// Pluck off n bytes from an array of buffers.
|
||
// Length is the combined lengths of all the buffers in the list.
|
||
// This function is designed to be inlinable, so please take care when making
|
||
// changes to the function body.
|
||
function fromList(n, state) {
|
||
// nothing buffered
|
||
if (state.length === 0) return null;
|
||
|
||
var ret;
|
||
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
||
// read it all, truncate the list
|
||
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
|
||
state.buffer.clear();
|
||
} else {
|
||
// read part of list
|
||
ret = fromListPartial(n, state.buffer, state.decoder);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
// Extracts only enough buffered data to satisfy the amount requested.
|
||
// This function is designed to be inlinable, so please take care when making
|
||
// changes to the function body.
|
||
function fromListPartial(n, list, hasStrings) {
|
||
var ret;
|
||
if (n < list.head.data.length) {
|
||
// slice is the same for buffers and strings
|
||
ret = list.head.data.slice(0, n);
|
||
list.head.data = list.head.data.slice(n);
|
||
} else if (n === list.head.data.length) {
|
||
// first chunk is a perfect match
|
||
ret = list.shift();
|
||
} else {
|
||
// result spans more than one buffer
|
||
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
// Copies a specified amount of characters from the list of buffered data
|
||
// chunks.
|
||
// This function is designed to be inlinable, so please take care when making
|
||
// changes to the function body.
|
||
function copyFromBufferString(n, list) {
|
||
var p = list.head;
|
||
var c = 1;
|
||
var ret = p.data;
|
||
n -= ret.length;
|
||
while (p = p.next) {
|
||
var str = p.data;
|
||
var nb = n > str.length ? str.length : n;
|
||
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
||
n -= nb;
|
||
if (n === 0) {
|
||
if (nb === str.length) {
|
||
++c;
|
||
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
||
} else {
|
||
list.head = p;
|
||
p.data = str.slice(nb);
|
||
}
|
||
break;
|
||
}
|
||
++c;
|
||
}
|
||
list.length -= c;
|
||
return ret;
|
||
}
|
||
|
||
// Copies a specified amount of bytes from the list of buffered data chunks.
|
||
// This function is designed to be inlinable, so please take care when making
|
||
// changes to the function body.
|
||
function copyFromBuffer(n, list) {
|
||
var ret = Buffer.allocUnsafe(n);
|
||
var p = list.head;
|
||
var c = 1;
|
||
p.data.copy(ret);
|
||
n -= p.data.length;
|
||
while (p = p.next) {
|
||
var buf = p.data;
|
||
var nb = n > buf.length ? buf.length : n;
|
||
buf.copy(ret, ret.length - n, 0, nb);
|
||
n -= nb;
|
||
if (n === 0) {
|
||
if (nb === buf.length) {
|
||
++c;
|
||
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
||
} else {
|
||
list.head = p;
|
||
p.data = buf.slice(nb);
|
||
}
|
||
break;
|
||
}
|
||
++c;
|
||
}
|
||
list.length -= c;
|
||
return ret;
|
||
}
|
||
|
||
function endReadable(stream) {
|
||
var state = stream._readableState;
|
||
|
||
// If we get here before consuming all the bytes, then that is a
|
||
// bug in node. Should never happen.
|
||
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
|
||
|
||
if (!state.endEmitted) {
|
||
state.ended = true;
|
||
pna.nextTick(endReadableNT, state, stream);
|
||
}
|
||
}
|
||
|
||
function endReadableNT(state, stream) {
|
||
// Check that we didn't get one last unshift.
|
||
if (!state.endEmitted && state.length === 0) {
|
||
state.endEmitted = true;
|
||
stream.readable = false;
|
||
stream.emit('end');
|
||
}
|
||
}
|
||
|
||
function indexOf(xs, x) {
|
||
for (var i = 0, l = xs.length; i < l; i++) {
|
||
if (xs[i] === x) return i;
|
||
}
|
||
return -1;
|
||
}
|
||
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
},{"./_stream_duplex":13,"./internal/streams/BufferList":18,"./internal/streams/destroy":19,"./internal/streams/stream":20,"_process":11,"core-util-is":4,"events":5,"inherits":7,"isarray":9,"process-nextick-args":10,"safe-buffer":21,"string_decoder/":22,"util":2}],16:[function(require,module,exports){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
// a transform stream is a readable/writable stream where you do
|
||
// something with the data. Sometimes it's called a "filter",
|
||
// but that's not a great name for it, since that implies a thing where
|
||
// some bits pass through, and others are simply ignored. (That would
|
||
// be a valid example of a transform, of course.)
|
||
//
|
||
// While the output is causally related to the input, it's not a
|
||
// necessarily symmetric or synchronous transformation. For example,
|
||
// a zlib stream might take multiple plain-text writes(), and then
|
||
// emit a single compressed chunk some time in the future.
|
||
//
|
||
// Here's how this works:
|
||
//
|
||
// The Transform stream has all the aspects of the readable and writable
|
||
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
||
// internally, and returns false if there's a lot of pending writes
|
||
// buffered up. When you call read(), that calls _read(n) until
|
||
// there's enough pending readable data buffered up.
|
||
//
|
||
// In a transform stream, the written data is placed in a buffer. When
|
||
// _read(n) is called, it transforms the queued up data, calling the
|
||
// buffered _write cb's as it consumes chunks. If consuming a single
|
||
// written chunk would result in multiple output chunks, then the first
|
||
// outputted bit calls the readcb, and subsequent chunks just go into
|
||
// the read buffer, and will cause it to emit 'readable' if necessary.
|
||
//
|
||
// This way, back-pressure is actually determined by the reading side,
|
||
// since _read has to be called to start processing a new chunk. However,
|
||
// a pathological inflate type of transform can cause excessive buffering
|
||
// here. For example, imagine a stream where every byte of input is
|
||
// interpreted as an integer from 0-255, and then results in that many
|
||
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
||
// 1kb of data being output. In this case, you could write a very small
|
||
// amount of input, and end up with a very large amount of output. In
|
||
// such a pathological inflating mechanism, there'd be no way to tell
|
||
// the system to stop doing the transform. A single 4MB write could
|
||
// cause the system to run out of memory.
|
||
//
|
||
// However, even in such a pathological case, only a single written chunk
|
||
// would be consumed, and then the rest would wait (un-transformed) until
|
||
// the results of the previous transformed chunk were consumed.
|
||
|
||
'use strict';
|
||
|
||
module.exports = Transform;
|
||
|
||
var Duplex = require('./_stream_duplex');
|
||
|
||
/*<replacement>*/
|
||
var util = require('core-util-is');
|
||
util.inherits = require('inherits');
|
||
/*</replacement>*/
|
||
|
||
util.inherits(Transform, Duplex);
|
||
|
||
function afterTransform(er, data) {
|
||
var ts = this._transformState;
|
||
ts.transforming = false;
|
||
|
||
var cb = ts.writecb;
|
||
|
||
if (!cb) {
|
||
return this.emit('error', new Error('write callback called multiple times'));
|
||
}
|
||
|
||
ts.writechunk = null;
|
||
ts.writecb = null;
|
||
|
||
if (data != null) // single equals check for both `null` and `undefined`
|
||
this.push(data);
|
||
|
||
cb(er);
|
||
|
||
var rs = this._readableState;
|
||
rs.reading = false;
|
||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||
this._read(rs.highWaterMark);
|
||
}
|
||
}
|
||
|
||
function Transform(options) {
|
||
if (!(this instanceof Transform)) return new Transform(options);
|
||
|
||
Duplex.call(this, options);
|
||
|
||
this._transformState = {
|
||
afterTransform: afterTransform.bind(this),
|
||
needTransform: false,
|
||
transforming: false,
|
||
writecb: null,
|
||
writechunk: null,
|
||
writeencoding: null
|
||
};
|
||
|
||
// start out asking for a readable event once data is transformed.
|
||
this._readableState.needReadable = true;
|
||
|
||
// we have implemented the _read method, and done the other things
|
||
// that Readable wants before the first _read call, so unset the
|
||
// sync guard flag.
|
||
this._readableState.sync = false;
|
||
|
||
if (options) {
|
||
if (typeof options.transform === 'function') this._transform = options.transform;
|
||
|
||
if (typeof options.flush === 'function') this._flush = options.flush;
|
||
}
|
||
|
||
// When the writable side finishes, then flush out anything remaining.
|
||
this.on('prefinish', prefinish);
|
||
}
|
||
|
||
function prefinish() {
|
||
var _this = this;
|
||
|
||
if (typeof this._flush === 'function') {
|
||
this._flush(function (er, data) {
|
||
done(_this, er, data);
|
||
});
|
||
} else {
|
||
done(this, null, null);
|
||
}
|
||
}
|
||
|
||
Transform.prototype.push = function (chunk, encoding) {
|
||
this._transformState.needTransform = false;
|
||
return Duplex.prototype.push.call(this, chunk, encoding);
|
||
};
|
||
|
||
// This is the part where you do stuff!
|
||
// override this function in implementation classes.
|
||
// 'chunk' is an input chunk.
|
||
//
|
||
// Call `push(newChunk)` to pass along transformed output
|
||
// to the readable side. You may call 'push' zero or more times.
|
||
//
|
||
// Call `cb(err)` when you are done with this chunk. If you pass
|
||
// an error, then that'll put the hurt on the whole operation. If you
|
||
// never call cb(), then you'll never get another chunk.
|
||
Transform.prototype._transform = function (chunk, encoding, cb) {
|
||
throw new Error('_transform() is not implemented');
|
||
};
|
||
|
||
Transform.prototype._write = function (chunk, encoding, cb) {
|
||
var ts = this._transformState;
|
||
ts.writecb = cb;
|
||
ts.writechunk = chunk;
|
||
ts.writeencoding = encoding;
|
||
if (!ts.transforming) {
|
||
var rs = this._readableState;
|
||
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
||
}
|
||
};
|
||
|
||
// Doesn't matter what the args are here.
|
||
// _transform does all the work.
|
||
// That we got here means that the readable side wants more data.
|
||
Transform.prototype._read = function (n) {
|
||
var ts = this._transformState;
|
||
|
||
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
||
ts.transforming = true;
|
||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||
} else {
|
||
// mark that we need a transform, so that any data that comes in
|
||
// will get processed, now that we've asked for it.
|
||
ts.needTransform = true;
|
||
}
|
||
};
|
||
|
||
Transform.prototype._destroy = function (err, cb) {
|
||
var _this2 = this;
|
||
|
||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||
cb(err2);
|
||
_this2.emit('close');
|
||
});
|
||
};
|
||
|
||
function done(stream, er, data) {
|
||
if (er) return stream.emit('error', er);
|
||
|
||
if (data != null) // single equals check for both `null` and `undefined`
|
||
stream.push(data);
|
||
|
||
// if there's nothing in the write buffer, then that means
|
||
// that nothing more will ever be provided
|
||
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
||
|
||
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
||
|
||
return stream.push(null);
|
||
}
|
||
},{"./_stream_duplex":13,"core-util-is":4,"inherits":7}],17:[function(require,module,exports){
|
||
(function (process,global,setImmediate){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
// A bit simpler than readable streams.
|
||
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
||
// the drain event emission and buffering.
|
||
|
||
'use strict';
|
||
|
||
/*<replacement>*/
|
||
|
||
var pna = require('process-nextick-args');
|
||
/*</replacement>*/
|
||
|
||
module.exports = Writable;
|
||
|
||
/* <replacement> */
|
||
function WriteReq(chunk, encoding, cb) {
|
||
this.chunk = chunk;
|
||
this.encoding = encoding;
|
||
this.callback = cb;
|
||
this.next = null;
|
||
}
|
||
|
||
// It seems a linked list but it is not
|
||
// there will be only 2 of these for each stream
|
||
function CorkedRequest(state) {
|
||
var _this = this;
|
||
|
||
this.next = null;
|
||
this.entry = null;
|
||
this.finish = function () {
|
||
onCorkedFinish(_this, state);
|
||
};
|
||
}
|
||
/* </replacement> */
|
||
|
||
/*<replacement>*/
|
||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var Duplex;
|
||
/*</replacement>*/
|
||
|
||
Writable.WritableState = WritableState;
|
||
|
||
/*<replacement>*/
|
||
var util = require('core-util-is');
|
||
util.inherits = require('inherits');
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var internalUtil = {
|
||
deprecate: require('util-deprecate')
|
||
};
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
var Stream = require('./internal/streams/stream');
|
||
/*</replacement>*/
|
||
|
||
/*<replacement>*/
|
||
|
||
var Buffer = require('safe-buffer').Buffer;
|
||
var OurUint8Array = global.Uint8Array || function () {};
|
||
function _uint8ArrayToBuffer(chunk) {
|
||
return Buffer.from(chunk);
|
||
}
|
||
function _isUint8Array(obj) {
|
||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||
}
|
||
|
||
/*</replacement>*/
|
||
|
||
var destroyImpl = require('./internal/streams/destroy');
|
||
|
||
util.inherits(Writable, Stream);
|
||
|
||
function nop() {}
|
||
|
||
function WritableState(options, stream) {
|
||
Duplex = Duplex || require('./_stream_duplex');
|
||
|
||
options = options || {};
|
||
|
||
// Duplex streams are both readable and writable, but share
|
||
// the same options object.
|
||
// However, some cases require setting options to different
|
||
// values for the readable and the writable sides of the duplex stream.
|
||
// These options can be provided separately as readableXXX and writableXXX.
|
||
var isDuplex = stream instanceof Duplex;
|
||
|
||
// object stream flag to indicate whether or not this stream
|
||
// contains buffers or objects.
|
||
this.objectMode = !!options.objectMode;
|
||
|
||
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
||
|
||
// the point at which write() starts returning false
|
||
// Note: 0 is a valid value, means that we always return false if
|
||
// the entire buffer is not flushed immediately on write()
|
||
var hwm = options.highWaterMark;
|
||
var writableHwm = options.writableHighWaterMark;
|
||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||
|
||
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
||
|
||
// cast to ints.
|
||
this.highWaterMark = Math.floor(this.highWaterMark);
|
||
|
||
// if _final has been called
|
||
this.finalCalled = false;
|
||
|
||
// drain event flag.
|
||
this.needDrain = false;
|
||
// at the start of calling end()
|
||
this.ending = false;
|
||
// when end() has been called, and returned
|
||
this.ended = false;
|
||
// when 'finish' is emitted
|
||
this.finished = false;
|
||
|
||
// has it been destroyed
|
||
this.destroyed = false;
|
||
|
||
// should we decode strings into buffers before passing to _write?
|
||
// this is here so that some node-core streams can optimize string
|
||
// handling at a lower level.
|
||
var noDecode = options.decodeStrings === false;
|
||
this.decodeStrings = !noDecode;
|
||
|
||
// Crypto is kind of old and crusty. Historically, its default string
|
||
// encoding is 'binary' so we have to make this configurable.
|
||
// Everything else in the universe uses 'utf8', though.
|
||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||
|
||
// not an actual buffer we keep track of, but a measurement
|
||
// of how much we're waiting to get pushed to some underlying
|
||
// socket or file.
|
||
this.length = 0;
|
||
|
||
// a flag to see when we're in the middle of a write.
|
||
this.writing = false;
|
||
|
||
// when true all writes will be buffered until .uncork() call
|
||
this.corked = 0;
|
||
|
||
// a flag to be able to tell if the onwrite cb is called immediately,
|
||
// or on a later tick. We set this to true at first, because any
|
||
// actions that shouldn't happen until "later" should generally also
|
||
// not happen before the first write call.
|
||
this.sync = true;
|
||
|
||
// a flag to know if we're processing previously buffered items, which
|
||
// may call the _write() callback in the same tick, so that we don't
|
||
// end up in an overlapped onwrite situation.
|
||
this.bufferProcessing = false;
|
||
|
||
// the callback that's passed to _write(chunk,cb)
|
||
this.onwrite = function (er) {
|
||
onwrite(stream, er);
|
||
};
|
||
|
||
// the callback that the user supplies to write(chunk,encoding,cb)
|
||
this.writecb = null;
|
||
|
||
// the amount that is being written when _write is called.
|
||
this.writelen = 0;
|
||
|
||
this.bufferedRequest = null;
|
||
this.lastBufferedRequest = null;
|
||
|
||
// number of pending user-supplied write callbacks
|
||
// this must be 0 before 'finish' can be emitted
|
||
this.pendingcb = 0;
|
||
|
||
// emit prefinish if the only thing we're waiting for is _write cbs
|
||
// This is relevant for synchronous Transform streams
|
||
this.prefinished = false;
|
||
|
||
// True if the error was already emitted and should not be thrown again
|
||
this.errorEmitted = false;
|
||
|
||
// count buffered requests
|
||
this.bufferedRequestCount = 0;
|
||
|
||
// allocate the first CorkedRequest, there is always
|
||
// one allocated and free to use, and we maintain at most two
|
||
this.corkedRequestsFree = new CorkedRequest(this);
|
||
}
|
||
|
||
WritableState.prototype.getBuffer = function getBuffer() {
|
||
var current = this.bufferedRequest;
|
||
var out = [];
|
||
while (current) {
|
||
out.push(current);
|
||
current = current.next;
|
||
}
|
||
return out;
|
||
};
|
||
|
||
(function () {
|
||
try {
|
||
Object.defineProperty(WritableState.prototype, 'buffer', {
|
||
get: internalUtil.deprecate(function () {
|
||
return this.getBuffer();
|
||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
||
});
|
||
} catch (_) {}
|
||
})();
|
||
|
||
// Test _writableState for inheritance to account for Duplex streams,
|
||
// whose prototype chain only points to Readable.
|
||
var realHasInstance;
|
||
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
||
realHasInstance = Function.prototype[Symbol.hasInstance];
|
||
Object.defineProperty(Writable, Symbol.hasInstance, {
|
||
value: function (object) {
|
||
if (realHasInstance.call(this, object)) return true;
|
||
if (this !== Writable) return false;
|
||
|
||
return object && object._writableState instanceof WritableState;
|
||
}
|
||
});
|
||
} else {
|
||
realHasInstance = function (object) {
|
||
return object instanceof this;
|
||
};
|
||
}
|
||
|
||
function Writable(options) {
|
||
Duplex = Duplex || require('./_stream_duplex');
|
||
|
||
// Writable ctor is applied to Duplexes, too.
|
||
// `realHasInstance` is necessary because using plain `instanceof`
|
||
// would return false, as no `_writableState` property is attached.
|
||
|
||
// Trying to use the custom `instanceof` for Writable here will also break the
|
||
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
||
// `_writableState` that would lead to infinite recursion.
|
||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
||
return new Writable(options);
|
||
}
|
||
|
||
this._writableState = new WritableState(options, this);
|
||
|
||
// legacy.
|
||
this.writable = true;
|
||
|
||
if (options) {
|
||
if (typeof options.write === 'function') this._write = options.write;
|
||
|
||
if (typeof options.writev === 'function') this._writev = options.writev;
|
||
|
||
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
||
|
||
if (typeof options.final === 'function') this._final = options.final;
|
||
}
|
||
|
||
Stream.call(this);
|
||
}
|
||
|
||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||
Writable.prototype.pipe = function () {
|
||
this.emit('error', new Error('Cannot pipe, not readable'));
|
||
};
|
||
|
||
function writeAfterEnd(stream, cb) {
|
||
var er = new Error('write after end');
|
||
// TODO: defer error events consistently everywhere, not just the cb
|
||
stream.emit('error', er);
|
||
pna.nextTick(cb, er);
|
||
}
|
||
|
||
// Checks that a user-supplied chunk is valid, especially for the particular
|
||
// mode the stream is in. Currently this means that `null` is never accepted
|
||
// and undefined/non-string values are only allowed in object mode.
|
||
function validChunk(stream, state, chunk, cb) {
|
||
var valid = true;
|
||
var er = false;
|
||
|
||
if (chunk === null) {
|
||
er = new TypeError('May not write null values to stream');
|
||
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
||
er = new TypeError('Invalid non-string/buffer chunk');
|
||
}
|
||
if (er) {
|
||
stream.emit('error', er);
|
||
pna.nextTick(cb, er);
|
||
valid = false;
|
||
}
|
||
return valid;
|
||
}
|
||
|
||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||
var state = this._writableState;
|
||
var ret = false;
|
||
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
||
|
||
if (isBuf && !Buffer.isBuffer(chunk)) {
|
||
chunk = _uint8ArrayToBuffer(chunk);
|
||
}
|
||
|
||
if (typeof encoding === 'function') {
|
||
cb = encoding;
|
||
encoding = null;
|
||
}
|
||
|
||
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
||
|
||
if (typeof cb !== 'function') cb = nop;
|
||
|
||
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
||
state.pendingcb++;
|
||
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
||
}
|
||
|
||
return ret;
|
||
};
|
||
|
||
Writable.prototype.cork = function () {
|
||
var state = this._writableState;
|
||
|
||
state.corked++;
|
||
};
|
||
|
||
Writable.prototype.uncork = function () {
|
||
var state = this._writableState;
|
||
|
||
if (state.corked) {
|
||
state.corked--;
|
||
|
||
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
||
}
|
||
};
|
||
|
||
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
||
// node::ParseEncoding() requires lower case.
|
||
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
||
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
||
this._writableState.defaultEncoding = encoding;
|
||
return this;
|
||
};
|
||
|
||
function decodeChunk(state, chunk, encoding) {
|
||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||
chunk = Buffer.from(chunk, encoding);
|
||
}
|
||
return chunk;
|
||
}
|
||
|
||
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
||
// making it explicit this property is not enumerable
|
||
// because otherwise some prototype manipulation in
|
||
// userland will fail
|
||
enumerable: false,
|
||
get: function () {
|
||
return this._writableState.highWaterMark;
|
||
}
|
||
});
|
||
|
||
// if we're already writing something, then just put this
|
||
// in the queue, and wait our turn. Otherwise, call _write
|
||
// If we return false, then we need a drain event, so set that flag.
|
||
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
||
if (!isBuf) {
|
||
var newChunk = decodeChunk(state, chunk, encoding);
|
||
if (chunk !== newChunk) {
|
||
isBuf = true;
|
||
encoding = 'buffer';
|
||
chunk = newChunk;
|
||
}
|
||
}
|
||
var len = state.objectMode ? 1 : chunk.length;
|
||
|
||
state.length += len;
|
||
|
||
var ret = state.length < state.highWaterMark;
|
||
// we must ensure that previous needDrain will not be reset to false.
|
||
if (!ret) state.needDrain = true;
|
||
|
||
if (state.writing || state.corked) {
|
||
var last = state.lastBufferedRequest;
|
||
state.lastBufferedRequest = {
|
||
chunk: chunk,
|
||
encoding: encoding,
|
||
isBuf: isBuf,
|
||
callback: cb,
|
||
next: null
|
||
};
|
||
if (last) {
|
||
last.next = state.lastBufferedRequest;
|
||
} else {
|
||
state.bufferedRequest = state.lastBufferedRequest;
|
||
}
|
||
state.bufferedRequestCount += 1;
|
||
} else {
|
||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
||
state.writelen = len;
|
||
state.writecb = cb;
|
||
state.writing = true;
|
||
state.sync = true;
|
||
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
||
state.sync = false;
|
||
}
|
||
|
||
function onwriteError(stream, state, sync, er, cb) {
|
||
--state.pendingcb;
|
||
|
||
if (sync) {
|
||
// defer the callback if we are being called synchronously
|
||
// to avoid piling up things on the stack
|
||
pna.nextTick(cb, er);
|
||
// this can emit finish, and it will always happen
|
||
// after error
|
||
pna.nextTick(finishMaybe, stream, state);
|
||
stream._writableState.errorEmitted = true;
|
||
stream.emit('error', er);
|
||
} else {
|
||
// the caller expect this to happen before if
|
||
// it is async
|
||
cb(er);
|
||
stream._writableState.errorEmitted = true;
|
||
stream.emit('error', er);
|
||
// this can emit finish, but finish must
|
||
// always follow error
|
||
finishMaybe(stream, state);
|
||
}
|
||
}
|
||
|
||
function onwriteStateUpdate(state) {
|
||
state.writing = false;
|
||
state.writecb = null;
|
||
state.length -= state.writelen;
|
||
state.writelen = 0;
|
||
}
|
||
|
||
function onwrite(stream, er) {
|
||
var state = stream._writableState;
|
||
var sync = state.sync;
|
||
var cb = state.writecb;
|
||
|
||
onwriteStateUpdate(state);
|
||
|
||
if (er) onwriteError(stream, state, sync, er, cb);else {
|
||
// Check if we're actually ready to finish, but don't emit yet
|
||
var finished = needFinish(state);
|
||
|
||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||
clearBuffer(stream, state);
|
||
}
|
||
|
||
if (sync) {
|
||
/*<replacement>*/
|
||
asyncWrite(afterWrite, stream, state, finished, cb);
|
||
/*</replacement>*/
|
||
} else {
|
||
afterWrite(stream, state, finished, cb);
|
||
}
|
||
}
|
||
}
|
||
|
||
function afterWrite(stream, state, finished, cb) {
|
||
if (!finished) onwriteDrain(stream, state);
|
||
state.pendingcb--;
|
||
cb();
|
||
finishMaybe(stream, state);
|
||
}
|
||
|
||
// Must force callback to be called on nextTick, so that we don't
|
||
// emit 'drain' before the write() consumer gets the 'false' return
|
||
// value, and has a chance to attach a 'drain' listener.
|
||
function onwriteDrain(stream, state) {
|
||
if (state.length === 0 && state.needDrain) {
|
||
state.needDrain = false;
|
||
stream.emit('drain');
|
||
}
|
||
}
|
||
|
||
// if there's something in the buffer waiting, then process it
|
||
function clearBuffer(stream, state) {
|
||
state.bufferProcessing = true;
|
||
var entry = state.bufferedRequest;
|
||
|
||
if (stream._writev && entry && entry.next) {
|
||
// Fast case, write everything using _writev()
|
||
var l = state.bufferedRequestCount;
|
||
var buffer = new Array(l);
|
||
var holder = state.corkedRequestsFree;
|
||
holder.entry = entry;
|
||
|
||
var count = 0;
|
||
var allBuffers = true;
|
||
while (entry) {
|
||
buffer[count] = entry;
|
||
if (!entry.isBuf) allBuffers = false;
|
||
entry = entry.next;
|
||
count += 1;
|
||
}
|
||
buffer.allBuffers = allBuffers;
|
||
|
||
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
||
|
||
// doWrite is almost always async, defer these to save a bit of time
|
||
// as the hot path ends with doWrite
|
||
state.pendingcb++;
|
||
state.lastBufferedRequest = null;
|
||
if (holder.next) {
|
||
state.corkedRequestsFree = holder.next;
|
||
holder.next = null;
|
||
} else {
|
||
state.corkedRequestsFree = new CorkedRequest(state);
|
||
}
|
||
state.bufferedRequestCount = 0;
|
||
} else {
|
||
// Slow case, write chunks one-by-one
|
||
while (entry) {
|
||
var chunk = entry.chunk;
|
||
var encoding = entry.encoding;
|
||
var cb = entry.callback;
|
||
var len = state.objectMode ? 1 : chunk.length;
|
||
|
||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||
entry = entry.next;
|
||
state.bufferedRequestCount--;
|
||
// if we didn't call the onwrite immediately, then
|
||
// it means that we need to wait until it does.
|
||
// also, that means that the chunk and cb are currently
|
||
// being processed, so move the buffer counter past them.
|
||
if (state.writing) {
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (entry === null) state.lastBufferedRequest = null;
|
||
}
|
||
|
||
state.bufferedRequest = entry;
|
||
state.bufferProcessing = false;
|
||
}
|
||
|
||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||
cb(new Error('_write() is not implemented'));
|
||
};
|
||
|
||
Writable.prototype._writev = null;
|
||
|
||
Writable.prototype.end = function (chunk, encoding, cb) {
|
||
var state = this._writableState;
|
||
|
||
if (typeof chunk === 'function') {
|
||
cb = chunk;
|
||
chunk = null;
|
||
encoding = null;
|
||
} else if (typeof encoding === 'function') {
|
||
cb = encoding;
|
||
encoding = null;
|
||
}
|
||
|
||
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
||
|
||
// .end() fully uncorks
|
||
if (state.corked) {
|
||
state.corked = 1;
|
||
this.uncork();
|
||
}
|
||
|
||
// ignore unnecessary end() calls.
|
||
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
||
};
|
||
|
||
function needFinish(state) {
|
||
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
||
}
|
||
function callFinal(stream, state) {
|
||
stream._final(function (err) {
|
||
state.pendingcb--;
|
||
if (err) {
|
||
stream.emit('error', err);
|
||
}
|
||
state.prefinished = true;
|
||
stream.emit('prefinish');
|
||
finishMaybe(stream, state);
|
||
});
|
||
}
|
||
function prefinish(stream, state) {
|
||
if (!state.prefinished && !state.finalCalled) {
|
||
if (typeof stream._final === 'function') {
|
||
state.pendingcb++;
|
||
state.finalCalled = true;
|
||
pna.nextTick(callFinal, stream, state);
|
||
} else {
|
||
state.prefinished = true;
|
||
stream.emit('prefinish');
|
||
}
|
||
}
|
||
}
|
||
|
||
function finishMaybe(stream, state) {
|
||
var need = needFinish(state);
|
||
if (need) {
|
||
prefinish(stream, state);
|
||
if (state.pendingcb === 0) {
|
||
state.finished = true;
|
||
stream.emit('finish');
|
||
}
|
||
}
|
||
return need;
|
||
}
|
||
|
||
function endWritable(stream, state, cb) {
|
||
state.ending = true;
|
||
finishMaybe(stream, state);
|
||
if (cb) {
|
||
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
||
}
|
||
state.ended = true;
|
||
stream.writable = false;
|
||
}
|
||
|
||
function onCorkedFinish(corkReq, state, err) {
|
||
var entry = corkReq.entry;
|
||
corkReq.entry = null;
|
||
while (entry) {
|
||
var cb = entry.callback;
|
||
state.pendingcb--;
|
||
cb(err);
|
||
entry = entry.next;
|
||
}
|
||
if (state.corkedRequestsFree) {
|
||
state.corkedRequestsFree.next = corkReq;
|
||
} else {
|
||
state.corkedRequestsFree = corkReq;
|
||
}
|
||
}
|
||
|
||
Object.defineProperty(Writable.prototype, 'destroyed', {
|
||
get: function () {
|
||
if (this._writableState === undefined) {
|
||
return false;
|
||
}
|
||
return this._writableState.destroyed;
|
||
},
|
||
set: function (value) {
|
||
// we ignore the value if the stream
|
||
// has not been initialized yet
|
||
if (!this._writableState) {
|
||
return;
|
||
}
|
||
|
||
// backward compatibility, the user is explicitly
|
||
// managing destroyed
|
||
this._writableState.destroyed = value;
|
||
}
|
||
});
|
||
|
||
Writable.prototype.destroy = destroyImpl.destroy;
|
||
Writable.prototype._undestroy = destroyImpl.undestroy;
|
||
Writable.prototype._destroy = function (err, cb) {
|
||
this.end();
|
||
cb(err);
|
||
};
|
||
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
|
||
},{"./_stream_duplex":13,"./internal/streams/destroy":19,"./internal/streams/stream":20,"_process":11,"core-util-is":4,"inherits":7,"process-nextick-args":10,"safe-buffer":21,"timers":28,"util-deprecate":29}],18:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
var Buffer = require('safe-buffer').Buffer;
|
||
var util = require('util');
|
||
|
||
function copyBuffer(src, target, offset) {
|
||
src.copy(target, offset);
|
||
}
|
||
|
||
module.exports = function () {
|
||
function BufferList() {
|
||
_classCallCheck(this, BufferList);
|
||
|
||
this.head = null;
|
||
this.tail = null;
|
||
this.length = 0;
|
||
}
|
||
|
||
BufferList.prototype.push = function push(v) {
|
||
var entry = { data: v, next: null };
|
||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
||
this.tail = entry;
|
||
++this.length;
|
||
};
|
||
|
||
BufferList.prototype.unshift = function unshift(v) {
|
||
var entry = { data: v, next: this.head };
|
||
if (this.length === 0) this.tail = entry;
|
||
this.head = entry;
|
||
++this.length;
|
||
};
|
||
|
||
BufferList.prototype.shift = function shift() {
|
||
if (this.length === 0) return;
|
||
var ret = this.head.data;
|
||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
||
--this.length;
|
||
return ret;
|
||
};
|
||
|
||
BufferList.prototype.clear = function clear() {
|
||
this.head = this.tail = null;
|
||
this.length = 0;
|
||
};
|
||
|
||
BufferList.prototype.join = function join(s) {
|
||
if (this.length === 0) return '';
|
||
var p = this.head;
|
||
var ret = '' + p.data;
|
||
while (p = p.next) {
|
||
ret += s + p.data;
|
||
}return ret;
|
||
};
|
||
|
||
BufferList.prototype.concat = function concat(n) {
|
||
if (this.length === 0) return Buffer.alloc(0);
|
||
if (this.length === 1) return this.head.data;
|
||
var ret = Buffer.allocUnsafe(n >>> 0);
|
||
var p = this.head;
|
||
var i = 0;
|
||
while (p) {
|
||
copyBuffer(p.data, ret, i);
|
||
i += p.data.length;
|
||
p = p.next;
|
||
}
|
||
return ret;
|
||
};
|
||
|
||
return BufferList;
|
||
}();
|
||
|
||
if (util && util.inspect && util.inspect.custom) {
|
||
module.exports.prototype[util.inspect.custom] = function () {
|
||
var obj = util.inspect({ length: this.length });
|
||
return this.constructor.name + ' ' + obj;
|
||
};
|
||
}
|
||
},{"safe-buffer":21,"util":2}],19:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
/*<replacement>*/
|
||
|
||
var pna = require('process-nextick-args');
|
||
/*</replacement>*/
|
||
|
||
// undocumented cb() API, needed for core, not for public API
|
||
function destroy(err, cb) {
|
||
var _this = this;
|
||
|
||
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
||
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
||
|
||
if (readableDestroyed || writableDestroyed) {
|
||
if (cb) {
|
||
cb(err);
|
||
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
|
||
pna.nextTick(emitErrorNT, this, err);
|
||
}
|
||
return this;
|
||
}
|
||
|
||
// we set destroyed to true before firing error callbacks in order
|
||
// to make it re-entrance safe in case destroy() is called within callbacks
|
||
|
||
if (this._readableState) {
|
||
this._readableState.destroyed = true;
|
||
}
|
||
|
||
// if this is a duplex stream mark the writable part as destroyed as well
|
||
if (this._writableState) {
|
||
this._writableState.destroyed = true;
|
||
}
|
||
|
||
this._destroy(err || null, function (err) {
|
||
if (!cb && err) {
|
||
pna.nextTick(emitErrorNT, _this, err);
|
||
if (_this._writableState) {
|
||
_this._writableState.errorEmitted = true;
|
||
}
|
||
} else if (cb) {
|
||
cb(err);
|
||
}
|
||
});
|
||
|
||
return this;
|
||
}
|
||
|
||
function undestroy() {
|
||
if (this._readableState) {
|
||
this._readableState.destroyed = false;
|
||
this._readableState.reading = false;
|
||
this._readableState.ended = false;
|
||
this._readableState.endEmitted = false;
|
||
}
|
||
|
||
if (this._writableState) {
|
||
this._writableState.destroyed = false;
|
||
this._writableState.ended = false;
|
||
this._writableState.ending = false;
|
||
this._writableState.finished = false;
|
||
this._writableState.errorEmitted = false;
|
||
}
|
||
}
|
||
|
||
function emitErrorNT(self, err) {
|
||
self.emit('error', err);
|
||
}
|
||
|
||
module.exports = {
|
||
destroy: destroy,
|
||
undestroy: undestroy
|
||
};
|
||
},{"process-nextick-args":10}],20:[function(require,module,exports){
|
||
module.exports = require('events').EventEmitter;
|
||
|
||
},{"events":5}],21:[function(require,module,exports){
|
||
/* eslint-disable node/no-deprecated-api */
|
||
var buffer = require('buffer')
|
||
var Buffer = buffer.Buffer
|
||
|
||
// alternative to using Object.keys for old browsers
|
||
function copyProps (src, dst) {
|
||
for (var key in src) {
|
||
dst[key] = src[key]
|
||
}
|
||
}
|
||
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
||
module.exports = buffer
|
||
} else {
|
||
// Copy properties from require('buffer')
|
||
copyProps(buffer, exports)
|
||
exports.Buffer = SafeBuffer
|
||
}
|
||
|
||
function SafeBuffer (arg, encodingOrOffset, length) {
|
||
return Buffer(arg, encodingOrOffset, length)
|
||
}
|
||
|
||
// Copy static methods from Buffer
|
||
copyProps(Buffer, SafeBuffer)
|
||
|
||
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
||
if (typeof arg === 'number') {
|
||
throw new TypeError('Argument must not be a number')
|
||
}
|
||
return Buffer(arg, encodingOrOffset, length)
|
||
}
|
||
|
||
SafeBuffer.alloc = function (size, fill, encoding) {
|
||
if (typeof size !== 'number') {
|
||
throw new TypeError('Argument must be a number')
|
||
}
|
||
var buf = Buffer(size)
|
||
if (fill !== undefined) {
|
||
if (typeof encoding === 'string') {
|
||
buf.fill(fill, encoding)
|
||
} else {
|
||
buf.fill(fill)
|
||
}
|
||
} else {
|
||
buf.fill(0)
|
||
}
|
||
return buf
|
||
}
|
||
|
||
SafeBuffer.allocUnsafe = function (size) {
|
||
if (typeof size !== 'number') {
|
||
throw new TypeError('Argument must be a number')
|
||
}
|
||
return Buffer(size)
|
||
}
|
||
|
||
SafeBuffer.allocUnsafeSlow = function (size) {
|
||
if (typeof size !== 'number') {
|
||
throw new TypeError('Argument must be a number')
|
||
}
|
||
return buffer.SlowBuffer(size)
|
||
}
|
||
|
||
},{"buffer":3}],22:[function(require,module,exports){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
'use strict';
|
||
|
||
/*<replacement>*/
|
||
|
||
var Buffer = require('safe-buffer').Buffer;
|
||
/*</replacement>*/
|
||
|
||
var isEncoding = Buffer.isEncoding || function (encoding) {
|
||
encoding = '' + encoding;
|
||
switch (encoding && encoding.toLowerCase()) {
|
||
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
|
||
return true;
|
||
default:
|
||
return false;
|
||
}
|
||
};
|
||
|
||
function _normalizeEncoding(enc) {
|
||
if (!enc) return 'utf8';
|
||
var retried;
|
||
while (true) {
|
||
switch (enc) {
|
||
case 'utf8':
|
||
case 'utf-8':
|
||
return 'utf8';
|
||
case 'ucs2':
|
||
case 'ucs-2':
|
||
case 'utf16le':
|
||
case 'utf-16le':
|
||
return 'utf16le';
|
||
case 'latin1':
|
||
case 'binary':
|
||
return 'latin1';
|
||
case 'base64':
|
||
case 'ascii':
|
||
case 'hex':
|
||
return enc;
|
||
default:
|
||
if (retried) return; // undefined
|
||
enc = ('' + enc).toLowerCase();
|
||
retried = true;
|
||
}
|
||
}
|
||
};
|
||
|
||
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
||
// modules monkey-patch it to support additional encodings
|
||
function normalizeEncoding(enc) {
|
||
var nenc = _normalizeEncoding(enc);
|
||
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
||
return nenc || enc;
|
||
}
|
||
|
||
// StringDecoder provides an interface for efficiently splitting a series of
|
||
// buffers into a series of JS strings without breaking apart multi-byte
|
||
// characters.
|
||
exports.StringDecoder = StringDecoder;
|
||
function StringDecoder(encoding) {
|
||
this.encoding = normalizeEncoding(encoding);
|
||
var nb;
|
||
switch (this.encoding) {
|
||
case 'utf16le':
|
||
this.text = utf16Text;
|
||
this.end = utf16End;
|
||
nb = 4;
|
||
break;
|
||
case 'utf8':
|
||
this.fillLast = utf8FillLast;
|
||
nb = 4;
|
||
break;
|
||
case 'base64':
|
||
this.text = base64Text;
|
||
this.end = base64End;
|
||
nb = 3;
|
||
break;
|
||
default:
|
||
this.write = simpleWrite;
|
||
this.end = simpleEnd;
|
||
return;
|
||
}
|
||
this.lastNeed = 0;
|
||
this.lastTotal = 0;
|
||
this.lastChar = Buffer.allocUnsafe(nb);
|
||
}
|
||
|
||
StringDecoder.prototype.write = function (buf) {
|
||
if (buf.length === 0) return '';
|
||
var r;
|
||
var i;
|
||
if (this.lastNeed) {
|
||
r = this.fillLast(buf);
|
||
if (r === undefined) return '';
|
||
i = this.lastNeed;
|
||
this.lastNeed = 0;
|
||
} else {
|
||
i = 0;
|
||
}
|
||
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
||
return r || '';
|
||
};
|
||
|
||
StringDecoder.prototype.end = utf8End;
|
||
|
||
// Returns only complete characters in a Buffer
|
||
StringDecoder.prototype.text = utf8Text;
|
||
|
||
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
||
StringDecoder.prototype.fillLast = function (buf) {
|
||
if (this.lastNeed <= buf.length) {
|
||
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
||
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
||
}
|
||
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
||
this.lastNeed -= buf.length;
|
||
};
|
||
|
||
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
||
// continuation byte. If an invalid byte is detected, -2 is returned.
|
||
function utf8CheckByte(byte) {
|
||
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
|
||
return byte >> 6 === 0x02 ? -1 : -2;
|
||
}
|
||
|
||
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
||
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
||
// needed to complete the UTF-8 character (if applicable) are returned.
|
||
function utf8CheckIncomplete(self, buf, i) {
|
||
var j = buf.length - 1;
|
||
if (j < i) return 0;
|
||
var nb = utf8CheckByte(buf[j]);
|
||
if (nb >= 0) {
|
||
if (nb > 0) self.lastNeed = nb - 1;
|
||
return nb;
|
||
}
|
||
if (--j < i || nb === -2) return 0;
|
||
nb = utf8CheckByte(buf[j]);
|
||
if (nb >= 0) {
|
||
if (nb > 0) self.lastNeed = nb - 2;
|
||
return nb;
|
||
}
|
||
if (--j < i || nb === -2) return 0;
|
||
nb = utf8CheckByte(buf[j]);
|
||
if (nb >= 0) {
|
||
if (nb > 0) {
|
||
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
||
}
|
||
return nb;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
||
// needed or are available. If we see a non-continuation byte where we expect
|
||
// one, we "replace" the validated continuation bytes we've seen so far with
|
||
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
||
// behavior. The continuation byte check is included three times in the case
|
||
// where all of the continuation bytes for a character exist in the same buffer.
|
||
// It is also done this way as a slight performance increase instead of using a
|
||
// loop.
|
||
function utf8CheckExtraBytes(self, buf, p) {
|
||
if ((buf[0] & 0xC0) !== 0x80) {
|
||
self.lastNeed = 0;
|
||
return '\ufffd';
|
||
}
|
||
if (self.lastNeed > 1 && buf.length > 1) {
|
||
if ((buf[1] & 0xC0) !== 0x80) {
|
||
self.lastNeed = 1;
|
||
return '\ufffd';
|
||
}
|
||
if (self.lastNeed > 2 && buf.length > 2) {
|
||
if ((buf[2] & 0xC0) !== 0x80) {
|
||
self.lastNeed = 2;
|
||
return '\ufffd';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
||
function utf8FillLast(buf) {
|
||
var p = this.lastTotal - this.lastNeed;
|
||
var r = utf8CheckExtraBytes(this, buf, p);
|
||
if (r !== undefined) return r;
|
||
if (this.lastNeed <= buf.length) {
|
||
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
||
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
||
}
|
||
buf.copy(this.lastChar, p, 0, buf.length);
|
||
this.lastNeed -= buf.length;
|
||
}
|
||
|
||
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
||
// partial character, the character's bytes are buffered until the required
|
||
// number of bytes are available.
|
||
function utf8Text(buf, i) {
|
||
var total = utf8CheckIncomplete(this, buf, i);
|
||
if (!this.lastNeed) return buf.toString('utf8', i);
|
||
this.lastTotal = total;
|
||
var end = buf.length - (total - this.lastNeed);
|
||
buf.copy(this.lastChar, 0, end);
|
||
return buf.toString('utf8', i, end);
|
||
}
|
||
|
||
// For UTF-8, a replacement character is added when ending on a partial
|
||
// character.
|
||
function utf8End(buf) {
|
||
var r = buf && buf.length ? this.write(buf) : '';
|
||
if (this.lastNeed) return r + '\ufffd';
|
||
return r;
|
||
}
|
||
|
||
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
||
// number of bytes available, we need to check if we end on a leading/high
|
||
// surrogate. In that case, we need to wait for the next two bytes in order to
|
||
// decode the last character properly.
|
||
function utf16Text(buf, i) {
|
||
if ((buf.length - i) % 2 === 0) {
|
||
var r = buf.toString('utf16le', i);
|
||
if (r) {
|
||
var c = r.charCodeAt(r.length - 1);
|
||
if (c >= 0xD800 && c <= 0xDBFF) {
|
||
this.lastNeed = 2;
|
||
this.lastTotal = 4;
|
||
this.lastChar[0] = buf[buf.length - 2];
|
||
this.lastChar[1] = buf[buf.length - 1];
|
||
return r.slice(0, -1);
|
||
}
|
||
}
|
||
return r;
|
||
}
|
||
this.lastNeed = 1;
|
||
this.lastTotal = 2;
|
||
this.lastChar[0] = buf[buf.length - 1];
|
||
return buf.toString('utf16le', i, buf.length - 1);
|
||
}
|
||
|
||
// For UTF-16LE we do not explicitly append special replacement characters if we
|
||
// end on a partial character, we simply let v8 handle that.
|
||
function utf16End(buf) {
|
||
var r = buf && buf.length ? this.write(buf) : '';
|
||
if (this.lastNeed) {
|
||
var end = this.lastTotal - this.lastNeed;
|
||
return r + this.lastChar.toString('utf16le', 0, end);
|
||
}
|
||
return r;
|
||
}
|
||
|
||
function base64Text(buf, i) {
|
||
var n = (buf.length - i) % 3;
|
||
if (n === 0) return buf.toString('base64', i);
|
||
this.lastNeed = 3 - n;
|
||
this.lastTotal = 3;
|
||
if (n === 1) {
|
||
this.lastChar[0] = buf[buf.length - 1];
|
||
} else {
|
||
this.lastChar[0] = buf[buf.length - 2];
|
||
this.lastChar[1] = buf[buf.length - 1];
|
||
}
|
||
return buf.toString('base64', i, buf.length - n);
|
||
}
|
||
|
||
function base64End(buf) {
|
||
var r = buf && buf.length ? this.write(buf) : '';
|
||
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
||
return r;
|
||
}
|
||
|
||
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
||
function simpleWrite(buf) {
|
||
return buf.toString(this.encoding);
|
||
}
|
||
|
||
function simpleEnd(buf) {
|
||
return buf && buf.length ? this.write(buf) : '';
|
||
}
|
||
},{"safe-buffer":21}],23:[function(require,module,exports){
|
||
module.exports = require('./readable').PassThrough
|
||
|
||
},{"./readable":24}],24:[function(require,module,exports){
|
||
exports = module.exports = require('./lib/_stream_readable.js');
|
||
exports.Stream = exports;
|
||
exports.Readable = exports;
|
||
exports.Writable = require('./lib/_stream_writable.js');
|
||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||
exports.Transform = require('./lib/_stream_transform.js');
|
||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||
|
||
},{"./lib/_stream_duplex.js":13,"./lib/_stream_passthrough.js":14,"./lib/_stream_readable.js":15,"./lib/_stream_transform.js":16,"./lib/_stream_writable.js":17}],25:[function(require,module,exports){
|
||
module.exports = require('./readable').Transform
|
||
|
||
},{"./readable":24}],26:[function(require,module,exports){
|
||
module.exports = require('./lib/_stream_writable.js');
|
||
|
||
},{"./lib/_stream_writable.js":17}],27:[function(require,module,exports){
|
||
// Copyright Joyent, Inc. and other Node contributors.
|
||
//
|
||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||
// copy of this software and associated documentation files (the
|
||
// "Software"), to deal in the Software without restriction, including
|
||
// without limitation the rights to use, copy, modify, merge, publish,
|
||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||
// persons to whom the Software is furnished to do so, subject to the
|
||
// following conditions:
|
||
//
|
||
// The above copyright notice and this permission notice shall be included
|
||
// in all copies or substantial portions of the Software.
|
||
//
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
module.exports = Stream;
|
||
|
||
var EE = require('events').EventEmitter;
|
||
var inherits = require('inherits');
|
||
|
||
inherits(Stream, EE);
|
||
Stream.Readable = require('readable-stream/readable.js');
|
||
Stream.Writable = require('readable-stream/writable.js');
|
||
Stream.Duplex = require('readable-stream/duplex.js');
|
||
Stream.Transform = require('readable-stream/transform.js');
|
||
Stream.PassThrough = require('readable-stream/passthrough.js');
|
||
|
||
// Backwards-compat with node 0.4.x
|
||
Stream.Stream = Stream;
|
||
|
||
|
||
|
||
// old-style streams. Note that the pipe method (the only relevant
|
||
// part of this class) is overridden in the Readable class.
|
||
|
||
function Stream() {
|
||
EE.call(this);
|
||
}
|
||
|
||
Stream.prototype.pipe = function(dest, options) {
|
||
var source = this;
|
||
|
||
function ondata(chunk) {
|
||
if (dest.writable) {
|
||
if (false === dest.write(chunk) && source.pause) {
|
||
source.pause();
|
||
}
|
||
}
|
||
}
|
||
|
||
source.on('data', ondata);
|
||
|
||
function ondrain() {
|
||
if (source.readable && source.resume) {
|
||
source.resume();
|
||
}
|
||
}
|
||
|
||
dest.on('drain', ondrain);
|
||
|
||
// If the 'end' option is not supplied, dest.end() will be called when
|
||
// source gets the 'end' or 'close' events. Only dest.end() once.
|
||
if (!dest._isStdio && (!options || options.end !== false)) {
|
||
source.on('end', onend);
|
||
source.on('close', onclose);
|
||
}
|
||
|
||
var didOnEnd = false;
|
||
function onend() {
|
||
if (didOnEnd) return;
|
||
didOnEnd = true;
|
||
|
||
dest.end();
|
||
}
|
||
|
||
|
||
function onclose() {
|
||
if (didOnEnd) return;
|
||
didOnEnd = true;
|
||
|
||
if (typeof dest.destroy === 'function') dest.destroy();
|
||
}
|
||
|
||
// don't leave dangling pipes when there are errors.
|
||
function onerror(er) {
|
||
cleanup();
|
||
if (EE.listenerCount(this, 'error') === 0) {
|
||
throw er; // Unhandled stream error in pipe.
|
||
}
|
||
}
|
||
|
||
source.on('error', onerror);
|
||
dest.on('error', onerror);
|
||
|
||
// remove all the event listeners that were added.
|
||
function cleanup() {
|
||
source.removeListener('data', ondata);
|
||
dest.removeListener('drain', ondrain);
|
||
|
||
source.removeListener('end', onend);
|
||
source.removeListener('close', onclose);
|
||
|
||
source.removeListener('error', onerror);
|
||
dest.removeListener('error', onerror);
|
||
|
||
source.removeListener('end', cleanup);
|
||
source.removeListener('close', cleanup);
|
||
|
||
dest.removeListener('close', cleanup);
|
||
}
|
||
|
||
source.on('end', cleanup);
|
||
source.on('close', cleanup);
|
||
|
||
dest.on('close', cleanup);
|
||
|
||
dest.emit('pipe', source);
|
||
|
||
// Allow for unix-like usage: A.pipe(B).pipe(C)
|
||
return dest;
|
||
};
|
||
|
||
},{"events":5,"inherits":7,"readable-stream/duplex.js":12,"readable-stream/passthrough.js":23,"readable-stream/readable.js":24,"readable-stream/transform.js":25,"readable-stream/writable.js":26}],28:[function(require,module,exports){
|
||
(function (setImmediate,clearImmediate){
|
||
var nextTick = require('process/browser.js').nextTick;
|
||
var apply = Function.prototype.apply;
|
||
var slice = Array.prototype.slice;
|
||
var immediateIds = {};
|
||
var nextImmediateId = 0;
|
||
|
||
// DOM APIs, for completeness
|
||
|
||
exports.setTimeout = function() {
|
||
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
|
||
};
|
||
exports.setInterval = function() {
|
||
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
|
||
};
|
||
exports.clearTimeout =
|
||
exports.clearInterval = function(timeout) { timeout.close(); };
|
||
|
||
function Timeout(id, clearFn) {
|
||
this._id = id;
|
||
this._clearFn = clearFn;
|
||
}
|
||
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
|
||
Timeout.prototype.close = function() {
|
||
this._clearFn.call(window, this._id);
|
||
};
|
||
|
||
// Does not start the time, just sets up the members needed.
|
||
exports.enroll = function(item, msecs) {
|
||
clearTimeout(item._idleTimeoutId);
|
||
item._idleTimeout = msecs;
|
||
};
|
||
|
||
exports.unenroll = function(item) {
|
||
clearTimeout(item._idleTimeoutId);
|
||
item._idleTimeout = -1;
|
||
};
|
||
|
||
exports._unrefActive = exports.active = function(item) {
|
||
clearTimeout(item._idleTimeoutId);
|
||
|
||
var msecs = item._idleTimeout;
|
||
if (msecs >= 0) {
|
||
item._idleTimeoutId = setTimeout(function onTimeout() {
|
||
if (item._onTimeout)
|
||
item._onTimeout();
|
||
}, msecs);
|
||
}
|
||
};
|
||
|
||
// That's not how node.js implements it but the exposed api is the same.
|
||
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
|
||
var id = nextImmediateId++;
|
||
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
|
||
|
||
immediateIds[id] = true;
|
||
|
||
nextTick(function onNextTick() {
|
||
if (immediateIds[id]) {
|
||
// fn.call() is faster so we optimize for the common use-case
|
||
// @see http://jsperf.com/call-apply-segu
|
||
if (args) {
|
||
fn.apply(null, args);
|
||
} else {
|
||
fn.call(null);
|
||
}
|
||
// Prevent ids from leaking
|
||
exports.clearImmediate(id);
|
||
}
|
||
});
|
||
|
||
return id;
|
||
};
|
||
|
||
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
|
||
delete immediateIds[id];
|
||
};
|
||
}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
|
||
},{"process/browser.js":11,"timers":28}],29:[function(require,module,exports){
|
||
(function (global){
|
||
|
||
/**
|
||
* Module exports.
|
||
*/
|
||
|
||
module.exports = deprecate;
|
||
|
||
/**
|
||
* Mark that a method should not be used.
|
||
* Returns a modified function which warns once by default.
|
||
*
|
||
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
||
*
|
||
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
||
* will throw an Error when invoked.
|
||
*
|
||
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
||
* will invoke `console.trace()` instead of `console.error()`.
|
||
*
|
||
* @param {Function} fn - the function to deprecate
|
||
* @param {String} msg - the string to print to the console when `fn` is invoked
|
||
* @returns {Function} a new "deprecated" version of `fn`
|
||
* @api public
|
||
*/
|
||
|
||
function deprecate (fn, msg) {
|
||
if (config('noDeprecation')) {
|
||
return fn;
|
||
}
|
||
|
||
var warned = false;
|
||
function deprecated() {
|
||
if (!warned) {
|
||
if (config('throwDeprecation')) {
|
||
throw new Error(msg);
|
||
} else if (config('traceDeprecation')) {
|
||
console.trace(msg);
|
||
} else {
|
||
console.warn(msg);
|
||
}
|
||
warned = true;
|
||
}
|
||
return fn.apply(this, arguments);
|
||
}
|
||
|
||
return deprecated;
|
||
}
|
||
|
||
/**
|
||
* Checks `localStorage` for boolean values for the given `name`.
|
||
*
|
||
* @param {String} name
|
||
* @returns {Boolean}
|
||
* @api private
|
||
*/
|
||
|
||
function config (name) {
|
||
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
||
try {
|
||
if (!global.localStorage) return false;
|
||
} catch (_) {
|
||
return false;
|
||
}
|
||
var val = global.localStorage[name];
|
||
if (null == val) return false;
|
||
return String(val).toLowerCase() === 'true';
|
||
}
|
||
|
||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||
},{}],30:[function(require,module,exports){
|
||
var app = require('./src/app');
|
||
var stream = require('./src/stream');
|
||
app.stream = stream;
|
||
module.exports = app;
|
||
},{"./src/app":31,"./src/stream":33}],31:[function(require,module,exports){
|
||
var helper = require('./helper.js');
|
||
module.exports = {
|
||
toObject : toObject,
|
||
toArray : toArray,
|
||
toColumnArray : toColumnArray,
|
||
toSchemaObject : toSchemaObject,
|
||
toCSV : toCSV
|
||
}
|
||
|
||
|
||
function toColumnArray(data, opts){
|
||
|
||
opts = opts || { };
|
||
|
||
var delimiter = (opts.delimiter || ',');
|
||
var quote = helper.getQuoteChar(opts.quote);
|
||
var content = data;
|
||
var headers = null;
|
||
|
||
if(typeof(content) !== "string"){
|
||
throw new Error("Invalid input, input data should be a string");
|
||
}
|
||
|
||
content = content.split(/[\n\r]+/ig);
|
||
|
||
if(typeof(opts.headers) === "string"){
|
||
headers = opts.headers.split(/[\n\r]+/ig);
|
||
headers = quote ?
|
||
helper.convertArray(headers.shift(), delimiter, quote) :
|
||
headers.shift().split(delimiter);
|
||
}else{
|
||
headers = quote ?
|
||
helper.convertArray(content.shift(), delimiter, quote) :
|
||
content.shift().split(delimiter);
|
||
}
|
||
|
||
|
||
var hashData = { };
|
||
|
||
headers.forEach(function(item){
|
||
hashData[item] = [];
|
||
});
|
||
|
||
content.forEach(function(item){
|
||
if(item){
|
||
item = quote ?
|
||
helper.convertArray(item, delimiter, quote) :
|
||
item.split(delimiter);
|
||
item.forEach(function(val, index){
|
||
hashData[headers[index]].push(helper.removeQuote(val));
|
||
});
|
||
}
|
||
});
|
||
|
||
return hashData;
|
||
}
|
||
|
||
function toObject(data, opts){
|
||
|
||
opts = opts || { };
|
||
|
||
var delimiter = (opts.delimiter || ',');
|
||
var quote = helper.getQuoteChar(opts.quote);
|
||
var content = data;
|
||
var headers = null;
|
||
|
||
if(typeof(content) !== "string"){
|
||
throw new Error("Invalid input, input data should be a string");
|
||
}
|
||
|
||
content = content.split(/[\n\r]+/ig);
|
||
|
||
if(typeof(opts.headers) === "string"){
|
||
headers = opts.headers.split(/[\n\r]+/ig);
|
||
headers = quote ?
|
||
helper.convertArray(headers.shift(), delimiter, quote) :
|
||
headers.shift().split(delimiter);
|
||
}else{
|
||
headers = quote ?
|
||
helper.convertArray(content.shift(), delimiter, quote) :
|
||
content.shift().split(delimiter);
|
||
}
|
||
|
||
var hashData = [ ];
|
||
content.forEach(function(item){
|
||
if(item){
|
||
item = quote ?
|
||
helper.convertArray(item, delimiter, quote) :
|
||
item.split(delimiter);
|
||
var hashItem = { };
|
||
headers.forEach(function(headerItem, index){
|
||
hashItem[headerItem] = helper.removeQuote(item[index]);
|
||
});
|
||
hashData.push(hashItem);
|
||
}
|
||
});
|
||
return hashData;
|
||
}
|
||
|
||
function toSchemaObject(data, opts){
|
||
|
||
opts = opts || { };
|
||
|
||
var delimiter = (opts.delimiter || ',');
|
||
var quote = helper.getQuoteChar(opts.quote);
|
||
var content = data;
|
||
var headers = null;
|
||
if(typeof(content) !== "string"){
|
||
throw new Error("Invalid input, input should be a string");
|
||
}
|
||
|
||
content = content.split(/[\n\r]+/ig);
|
||
|
||
|
||
if(typeof(opts.headers) === "string"){
|
||
headers = opts.headers.split(/[\n\r]+/ig);
|
||
headers = quote ?
|
||
helper.convertArray(headers.shift(), delimiter, quote) :
|
||
headers.shift().split(delimiter);
|
||
}else{
|
||
headers = quote ?
|
||
helper.convertArray(content.shift(), delimiter, quote) :
|
||
content.shift().split(delimiter);
|
||
}
|
||
|
||
|
||
var hashData = [ ];
|
||
|
||
content.forEach(function(item){
|
||
if(item){
|
||
item = quote ?
|
||
helper.convertArray(item, delimiter, quote) :
|
||
item.split(delimiter);
|
||
var schemaObject = {};
|
||
item.forEach(function(val, index){
|
||
helper.addDataInSchema(headers[index], val, schemaObject , delimiter, quote);
|
||
});
|
||
hashData.push(schemaObject);
|
||
}
|
||
});
|
||
|
||
return hashData;
|
||
}
|
||
|
||
function toArray(data, opts){
|
||
|
||
opts = opts || { };
|
||
|
||
var delimiter = (opts.delimiter || ',');
|
||
var quote = helper.getQuoteChar(opts.quote);
|
||
var content = data;
|
||
|
||
if(typeof(content) !== "string"){
|
||
throw new Error("Invalid input, input data should be a string");
|
||
}
|
||
|
||
content = content.split(/[\n\r]+/ig);
|
||
var arrayData = [ ];
|
||
content.forEach(function(item){
|
||
if(item){
|
||
item = quote ?
|
||
helper.convertArray(item, delimiter, quote) :
|
||
item.split(delimiter);
|
||
|
||
item = item.map(function(cItem){
|
||
return helper.removeQuote(cItem);
|
||
});
|
||
arrayData.push(item);
|
||
}
|
||
});
|
||
return arrayData;
|
||
}
|
||
|
||
function toCSV(data, opts){
|
||
|
||
opts = (opts || { });
|
||
opts.delimiter = (opts.delimiter || ',');
|
||
opts.wrap = (opts.wrap || '');
|
||
opts.arrayDenote = (opts.arrayDenote && String(opts.arrayDenote).trim() ? opts.arrayDenote : '[]');
|
||
opts.objectDenote = (opts.objectDenote && String(opts.objectDenote).trim() ? opts.objectDenote : '.');
|
||
opts.detailedOutput = (typeof(opts.detailedOutput) !== "boolean" ? true : opts.detailedOutput);
|
||
opts.headers = String(opts.headers).toLowerCase();
|
||
var csvJSON = { };
|
||
var csvData = "";
|
||
|
||
if(!opts.headers.match(/none|full|relative|key/)){
|
||
opts.headers = 'full';
|
||
}else{
|
||
opts.headers = opts.headers.match(/none|full|relative|key/)[0];
|
||
}
|
||
|
||
if(opts.wrap === true){
|
||
opts.wrap = '"';
|
||
}
|
||
|
||
if(typeof(data) === "string"){
|
||
data = JSON.parse(data);
|
||
}
|
||
|
||
helper.toCsv(data, csvJSON, "", 0, opts);
|
||
|
||
var headers = helper.getHeaders(opts.headers, csvJSON, opts);
|
||
|
||
if(headers){
|
||
if(opts.wrap){
|
||
headers = headers.map(function(item){
|
||
return opts.wrap + item + opts.wrap;
|
||
});
|
||
}
|
||
csvData = headers.join(opts.delimiter);
|
||
}
|
||
|
||
var bigArrayLen = helper.getLengthyItem(csvJSON);
|
||
var keys = Object.keys(csvJSON);
|
||
var row = [ ];
|
||
|
||
var replaceNewLinePattern = /\n|\r/g;
|
||
if(!opts.wrap){
|
||
replaceNewLinePattern = new RegExp('\n|\r|' + opts.delimiter, 'g');
|
||
}
|
||
|
||
|
||
for(var i = 0; i < bigArrayLen; i++){
|
||
row = [ ];
|
||
for(var j = 0; j < keys.length; j++){
|
||
if(csvJSON[keys[j]][i]){
|
||
csvJSON[keys[j]][i] = csvJSON[keys[j]][i].replace(replaceNewLinePattern, '\t');
|
||
if(opts.wrap){
|
||
csvJSON[keys[j]][i] = opts.wrap + csvJSON[keys[j]][i] + opts.wrap;
|
||
}
|
||
row[row.length] = csvJSON[keys[j]][i];
|
||
}else{
|
||
row[row.length] = "";
|
||
}
|
||
}
|
||
csvData += '\n' + row.join(opts.delimiter);
|
||
}
|
||
return csvData;
|
||
}
|
||
|
||
},{"./helper.js":32}],32:[function(require,module,exports){
|
||
module.exports = {
|
||
getQuoteChar : getQuoteChar,
|
||
dataType : dataType,
|
||
toCsv : toCsv,
|
||
putData : putData,
|
||
allObjsOrArray : allObjsOrArray,
|
||
getHeaders : getHeaders,
|
||
getLengthyItem : getLengthyItem,
|
||
addDataInSchema : addDataInSchema,
|
||
removeQuote : removeQuote,
|
||
arrayToCsv : arrayToCsv,
|
||
objectToCsv : objectToCsv,
|
||
convertArray : convertArray,
|
||
csvToArray : csvToArray
|
||
}
|
||
|
||
function getQuoteChar(q){
|
||
if(typeof(q) === "string"){
|
||
return q;
|
||
}else if(q === true){
|
||
return '"';
|
||
}
|
||
return null;
|
||
}
|
||
|
||
function dataType(arg) {
|
||
if (arg === null) {
|
||
return 'null';
|
||
}
|
||
else if (arg && (arg.nodeType === 1 || arg.nodeType === 9)) {
|
||
return 'element';
|
||
}
|
||
var type = (Object.prototype.toString.call(arg)).match(/\[object (.*?)\]/)[1].toLowerCase();
|
||
if (type === 'number') {
|
||
if (isNaN(arg)) {
|
||
return 'nan';
|
||
}
|
||
if (!isFinite(arg)) {
|
||
return 'infinity';
|
||
}
|
||
}
|
||
return type;
|
||
}
|
||
|
||
|
||
function toCsv(data, table, parent, row, opt){
|
||
if(dataType(data) === 'undefined'){
|
||
return putData('', table, parent, row, opt);
|
||
}else if(dataType(data) === 'null'){
|
||
return putData('null', table, parent, row, opt);
|
||
}else if(Array.isArray(data)){
|
||
return arrayToCsv(data, table, parent, row, opt);
|
||
}else if(typeof(data) === "object"){
|
||
return objectToCsv(data, table, parent, row, opt);
|
||
}else{
|
||
return putData(String(data), table, parent, row, opt);
|
||
}
|
||
}
|
||
|
||
function putData(data, table, parent, row, opt){
|
||
if(!table || !table[parent]){
|
||
table[parent] = [ ];
|
||
}
|
||
if(row < table[parent].length){
|
||
row = table[parent].length;
|
||
}
|
||
table[parent][row] = data;
|
||
return table;
|
||
}
|
||
|
||
|
||
function allObjsOrArray(array){
|
||
return array.every(function(item){
|
||
var datatype = dataType(item);
|
||
if(!datatype.match(/array|object/)){
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
}
|
||
|
||
|
||
function getHeaders(headerType, table, opt){
|
||
var keyMatchPattern = /([^\[\]\.]+)$/;
|
||
var relativeMatchPattern = /\[\]\.?([^\[\]]+)$/;
|
||
switch(headerType){
|
||
case "none":
|
||
return null;
|
||
case "full":
|
||
return Object.keys(table);
|
||
case "key":
|
||
return Object.keys(table).map(function(header){
|
||
var head = header.match(keyMatchPattern);
|
||
if(head && head.length === 2){
|
||
return head[1];
|
||
}
|
||
return header;
|
||
});
|
||
case "relative":
|
||
return Object.keys(table).map(function(header){
|
||
var head = header.match(relativeMatchPattern);
|
||
if(head && head.length === 2){
|
||
return head[1];
|
||
}
|
||
return header;
|
||
});
|
||
}
|
||
}
|
||
|
||
function getLengthyItem(table){
|
||
var len = 0;
|
||
Object.keys(table).forEach(function(item){
|
||
if(Array.isArray(table[item]) && table[item].length > len){
|
||
len = table[item].length;
|
||
}
|
||
});
|
||
return len;
|
||
}
|
||
|
||
function addDataInSchema(header, item, schema, delimiter, quote){
|
||
var match = header.match(/\[*[\d]\]\.(\w+)|\.|\[\]|\[(.)\]|-|\+/ig);
|
||
var headerName, currentPoint;
|
||
if(match){
|
||
var testMatch = match[0];
|
||
if(match.indexOf('-') !== -1){
|
||
return true;
|
||
}else if(match.indexOf('.') !== -1){
|
||
var headParts = header.split('.');
|
||
currentPoint = headParts.shift();
|
||
schema[currentPoint] = schema[currentPoint] || {};
|
||
addDataInSchema(headParts.join('.'), item, schema[currentPoint], delimiter, quote);
|
||
}else if(match.indexOf('[]') !== -1){
|
||
headerName = header.replace(/\[\]/ig,'');
|
||
if(!schema[headerName]){
|
||
schema[headerName] = [];
|
||
}
|
||
schema[headerName].push(item);
|
||
}else if(/\[*[\d]\]\.(\w+)/.test(testMatch)){
|
||
headerName = header.split('[').shift();
|
||
var index = parseInt(testMatch.match(/\[(.)\]/).pop(),10);
|
||
currentPoint = header.split('.').pop();
|
||
schema[headerName] = schema[headerName] || [];
|
||
schema[headerName][index] = schema[headerName][index] || {};
|
||
schema[headerName][index][currentPoint] = item;
|
||
}else if(/\[(.)\]/.test(testMatch)){
|
||
var delimiter = testMatch.match(/\[(.)\]/).pop();
|
||
headerName = header.replace(/\[(.)\]/ig,'');
|
||
schema[headerName] = convertArray(item, delimiter, quote);
|
||
}else if(match.indexOf('+') !== -1){
|
||
headerName = header.replace(/\+/ig,"");
|
||
schema[headerName] = Number(item);
|
||
}
|
||
}else{
|
||
schema[header] = removeQuote(item);
|
||
}
|
||
return schema ;
|
||
}
|
||
|
||
function removeQuote(str){
|
||
if(str){
|
||
return String(str).trim().replace(/^["|'](.*)["|']$/, '$1');
|
||
}
|
||
return "";
|
||
}
|
||
|
||
function arrayToCsv(data, table, parent, row, opt){
|
||
if(allObjsOrArray(data)){
|
||
return putData(data.join(';'), table, parent + opt.arrayDenote, row, opt);
|
||
}
|
||
data.forEach(function(item, index){
|
||
return toCsv(item, table, parent + opt.arrayDenote, index, opt);
|
||
});
|
||
}
|
||
|
||
function objectToCsv(data, table, parent, row, opt){
|
||
Object.keys(data).forEach(function(item){
|
||
return toCsv(data[item], table, parent + opt.objectDenote + item, row, opt);
|
||
});
|
||
}
|
||
|
||
function convertArray(str, delimiter, quote) {
|
||
if(quote && str.indexOf(quote) !== -1){
|
||
return csvToArray(str, delimiter, quote);
|
||
}
|
||
var output = [];
|
||
var arr = str.split(delimiter);
|
||
arr.forEach(function(val) {
|
||
var trimmed = val.trim();
|
||
output.push(trimmed);
|
||
});
|
||
return output;
|
||
}
|
||
|
||
function csvToArray(text, delimit, quote) {
|
||
|
||
delimit = delimit || ",";
|
||
quote = quote || '"';
|
||
|
||
var value = new RegExp("(?!\\s*$)\\s*(?:" + quote + "([^" + quote + "\\\\]*(?:\\\\[\\S\\s][^" + quote + "\\\\]*)*)" + quote + "|([^" + delimit + quote + "\\s\\\\]*(?:\\s+[^" + delimit + quote + "\\s\\\\]+)*))\\s*(?:" + delimit + "|$)", "g");
|
||
|
||
var a = [ ];
|
||
|
||
text.replace(value,
|
||
function(m0, m1, m2) {
|
||
if(m1 !== undefined){
|
||
a.push(m1.replace(/\\'/g, "'"));
|
||
}else if(m2 !== undefined){
|
||
a.push(m2);
|
||
}
|
||
return '';
|
||
}
|
||
);
|
||
|
||
if (/,\s*$/.test(text)){
|
||
a.push('');
|
||
}
|
||
return a;
|
||
}
|
||
|
||
},{}],33:[function(require,module,exports){
|
||
var app = require('./app.js');
|
||
|
||
module.exports = {
|
||
toColumnArray: toColumnArray,
|
||
toObject: toObject,
|
||
toSchemaObject: toSchemaObject,
|
||
toArray: toArray,
|
||
transform: transform,
|
||
stringify: stringify
|
||
}
|
||
|
||
function chopLines(str) {
|
||
return str.split(/[\n\r]/ig);
|
||
}
|
||
|
||
function transform(func) {
|
||
var stream = require('stream');
|
||
return new stream.Transform({
|
||
readableObjectMode: true,
|
||
writableObjectMode: true,
|
||
transform: func
|
||
});
|
||
}
|
||
|
||
function stringify(space) {
|
||
return transform(function (data, encoding, callback) {
|
||
this.push(JSON.stringify(data, null, space))
|
||
callback()
|
||
});
|
||
}
|
||
|
||
function _toColumnArray(data, encoding, callback, trans) {
|
||
var lines = chopLines(data.toString());
|
||
if (!trans._head) {
|
||
var head = lines.shift();
|
||
trans._head = head;
|
||
trans._opts.headers = head;
|
||
}
|
||
this.push(app.toColumnArray(lines.join('\n'), trans._opts))
|
||
callback()
|
||
}
|
||
|
||
function toColumnArray(opts) {
|
||
opts = opts || {};
|
||
var trans = transform(function (data, encoding, callback) {
|
||
_toColumnArray.call(this, data, encoding, callback, trans);
|
||
});
|
||
trans._head = opts.headers ? opts.headers : null;
|
||
trans._opts = opts;
|
||
return trans;
|
||
}
|
||
|
||
function _toObject(data, encoding, callback, trans) {
|
||
var lines = chopLines(data.toString());
|
||
if (!trans._head) {
|
||
var head = lines.shift();
|
||
trans._head = head;
|
||
trans._opts.headers = head;
|
||
}
|
||
this.push(app.toObject(lines.join('\n'), trans._opts))
|
||
callback()
|
||
}
|
||
|
||
function toObject(opts) {
|
||
opts = opts || {};
|
||
var trans = transform(function (data, encoding, callback) {
|
||
_toObject.call(this, data, encoding, callback, trans);
|
||
});
|
||
trans._head = opts.headers ? opts.headers : null;
|
||
trans._opts = opts;
|
||
return trans;
|
||
}
|
||
|
||
function _toSchemaObject(data, encoding, callback, trans) {
|
||
var lines = chopLines(data.toString());
|
||
if (!trans._head) {
|
||
var head = lines.shift();
|
||
trans._head = head;
|
||
trans._opts.headers = head;
|
||
}
|
||
this.push(app.toSchemaObject(lines.join('\n'), trans._opts))
|
||
callback()
|
||
}
|
||
|
||
function toSchemaObject(opts) {
|
||
opts = opts || {};
|
||
var trans = transform(function (data, encoding, callback) {
|
||
_toSchemaObject.call(this, data, encoding, callback, trans);
|
||
});
|
||
trans._head = opts.headers ? opts.headers : null;
|
||
trans._opts = opts;
|
||
return trans;
|
||
}
|
||
|
||
function _toArray(data, encoding, callback, trans) {
|
||
var lines = chopLines(data.toString());
|
||
this.push(app.toArray(lines.join('\n'), trans._opts))
|
||
callback()
|
||
}
|
||
|
||
function toArray(opts) {
|
||
opts = opts || {};
|
||
var trans = transform(function (data, encoding, callback) {
|
||
_toArray.call(this, data, encoding, callback, trans);
|
||
});
|
||
trans._opts = opts;
|
||
return trans;
|
||
}
|
||
},{"./app.js":31,"stream":27}],34:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
var isArray = Array.isArray;
|
||
var keyList = Object.keys;
|
||
var hasProp = Object.prototype.hasOwnProperty;
|
||
|
||
module.exports = function equal(a, b) {
|
||
if (a === b) return true;
|
||
|
||
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
||
var arrA = isArray(a)
|
||
, arrB = isArray(b)
|
||
, i
|
||
, length
|
||
, key;
|
||
|
||
if (arrA && arrB) {
|
||
length = a.length;
|
||
if (length != b.length) return false;
|
||
for (i = length; i-- !== 0;)
|
||
if (!equal(a[i], b[i])) return false;
|
||
return true;
|
||
}
|
||
|
||
if (arrA != arrB) return false;
|
||
|
||
var dateA = a instanceof Date
|
||
, dateB = b instanceof Date;
|
||
if (dateA != dateB) return false;
|
||
if (dateA && dateB) return a.getTime() == b.getTime();
|
||
|
||
var regexpA = a instanceof RegExp
|
||
, regexpB = b instanceof RegExp;
|
||
if (regexpA != regexpB) return false;
|
||
if (regexpA && regexpB) return a.toString() == b.toString();
|
||
|
||
var keys = keyList(a);
|
||
length = keys.length;
|
||
|
||
if (length !== keyList(b).length)
|
||
return false;
|
||
|
||
for (i = length; i-- !== 0;)
|
||
if (!hasProp.call(b, keys[i])) return false;
|
||
|
||
for (i = length; i-- !== 0;) {
|
||
key = keys[i];
|
||
if (!equal(a[key], b[key])) return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
return a!==a && b!==b;
|
||
};
|
||
|
||
},{}],35:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, '__esModule', { value: true });
|
||
|
||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||
|
||
var resolvePathname = _interopDefault(require('resolve-pathname'));
|
||
var valueEqual = _interopDefault(require('value-equal'));
|
||
var warning = _interopDefault(require('tiny-warning'));
|
||
var invariant = _interopDefault(require('tiny-invariant'));
|
||
|
||
function _extends() {
|
||
_extends = Object.assign || function (target) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var source = arguments[i];
|
||
|
||
for (var key in source) {
|
||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||
target[key] = source[key];
|
||
}
|
||
}
|
||
}
|
||
|
||
return target;
|
||
};
|
||
|
||
return _extends.apply(this, arguments);
|
||
}
|
||
|
||
function addLeadingSlash(path) {
|
||
return path.charAt(0) === '/' ? path : '/' + path;
|
||
}
|
||
function stripLeadingSlash(path) {
|
||
return path.charAt(0) === '/' ? path.substr(1) : path;
|
||
}
|
||
function hasBasename(path, prefix) {
|
||
return path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && '/?#'.indexOf(path.charAt(prefix.length)) !== -1;
|
||
}
|
||
function stripBasename(path, prefix) {
|
||
return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
||
}
|
||
function stripTrailingSlash(path) {
|
||
return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
|
||
}
|
||
function parsePath(path) {
|
||
var pathname = path || '/';
|
||
var search = '';
|
||
var hash = '';
|
||
var hashIndex = pathname.indexOf('#');
|
||
|
||
if (hashIndex !== -1) {
|
||
hash = pathname.substr(hashIndex);
|
||
pathname = pathname.substr(0, hashIndex);
|
||
}
|
||
|
||
var searchIndex = pathname.indexOf('?');
|
||
|
||
if (searchIndex !== -1) {
|
||
search = pathname.substr(searchIndex);
|
||
pathname = pathname.substr(0, searchIndex);
|
||
}
|
||
|
||
return {
|
||
pathname: pathname,
|
||
search: search === '?' ? '' : search,
|
||
hash: hash === '#' ? '' : hash
|
||
};
|
||
}
|
||
function createPath(location) {
|
||
var pathname = location.pathname,
|
||
search = location.search,
|
||
hash = location.hash;
|
||
var path = pathname || '/';
|
||
if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
|
||
if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
|
||
return path;
|
||
}
|
||
|
||
function createLocation(path, state, key, currentLocation) {
|
||
var location;
|
||
|
||
if (typeof path === 'string') {
|
||
// Two-arg form: push(path, state)
|
||
location = parsePath(path);
|
||
location.state = state;
|
||
} else {
|
||
// One-arg form: push(location)
|
||
location = _extends({}, path);
|
||
if (location.pathname === undefined) location.pathname = '';
|
||
|
||
if (location.search) {
|
||
if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
|
||
} else {
|
||
location.search = '';
|
||
}
|
||
|
||
if (location.hash) {
|
||
if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
|
||
} else {
|
||
location.hash = '';
|
||
}
|
||
|
||
if (state !== undefined && location.state === undefined) location.state = state;
|
||
}
|
||
|
||
try {
|
||
location.pathname = decodeURI(location.pathname);
|
||
} catch (e) {
|
||
if (e instanceof URIError) {
|
||
throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
|
||
} else {
|
||
throw e;
|
||
}
|
||
}
|
||
|
||
if (key) location.key = key;
|
||
|
||
if (currentLocation) {
|
||
// Resolve incomplete/relative pathname relative to current location.
|
||
if (!location.pathname) {
|
||
location.pathname = currentLocation.pathname;
|
||
} else if (location.pathname.charAt(0) !== '/') {
|
||
location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
|
||
}
|
||
} else {
|
||
// When there is no prior location and pathname is empty, set it to /
|
||
if (!location.pathname) {
|
||
location.pathname = '/';
|
||
}
|
||
}
|
||
|
||
return location;
|
||
}
|
||
function locationsAreEqual(a, b) {
|
||
return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
|
||
}
|
||
|
||
function createTransitionManager() {
|
||
var prompt = null;
|
||
|
||
function setPrompt(nextPrompt) {
|
||
warning(prompt == null, 'A history supports only one prompt at a time');
|
||
prompt = nextPrompt;
|
||
return function () {
|
||
if (prompt === nextPrompt) prompt = null;
|
||
};
|
||
}
|
||
|
||
function confirmTransitionTo(location, action, getUserConfirmation, callback) {
|
||
// TODO: If another transition starts while we're still confirming
|
||
// the previous one, we may end up in a weird state. Figure out the
|
||
// best way to handle this.
|
||
if (prompt != null) {
|
||
var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
|
||
|
||
if (typeof result === 'string') {
|
||
if (typeof getUserConfirmation === 'function') {
|
||
getUserConfirmation(result, callback);
|
||
} else {
|
||
warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message');
|
||
callback(true);
|
||
}
|
||
} else {
|
||
// Return false from a transition hook to cancel the transition.
|
||
callback(result !== false);
|
||
}
|
||
} else {
|
||
callback(true);
|
||
}
|
||
}
|
||
|
||
var listeners = [];
|
||
|
||
function appendListener(fn) {
|
||
var isActive = true;
|
||
|
||
function listener() {
|
||
if (isActive) fn.apply(void 0, arguments);
|
||
}
|
||
|
||
listeners.push(listener);
|
||
return function () {
|
||
isActive = false;
|
||
listeners = listeners.filter(function (item) {
|
||
return item !== listener;
|
||
});
|
||
};
|
||
}
|
||
|
||
function notifyListeners() {
|
||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||
args[_key] = arguments[_key];
|
||
}
|
||
|
||
listeners.forEach(function (listener) {
|
||
return listener.apply(void 0, args);
|
||
});
|
||
}
|
||
|
||
return {
|
||
setPrompt: setPrompt,
|
||
confirmTransitionTo: confirmTransitionTo,
|
||
appendListener: appendListener,
|
||
notifyListeners: notifyListeners
|
||
};
|
||
}
|
||
|
||
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||
function getConfirmation(message, callback) {
|
||
callback(window.confirm(message)); // eslint-disable-line no-alert
|
||
}
|
||
/**
|
||
* Returns true if the HTML5 history API is supported. Taken from Modernizr.
|
||
*
|
||
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
||
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
||
* changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
|
||
*/
|
||
|
||
function supportsHistory() {
|
||
var ua = window.navigator.userAgent;
|
||
if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
|
||
return window.history && 'pushState' in window.history;
|
||
}
|
||
/**
|
||
* Returns true if browser fires popstate on hash change.
|
||
* IE10 and IE11 do not.
|
||
*/
|
||
|
||
function supportsPopStateOnHashChange() {
|
||
return window.navigator.userAgent.indexOf('Trident') === -1;
|
||
}
|
||
/**
|
||
* Returns false if using go(n) with hash history causes a full page reload.
|
||
*/
|
||
|
||
function supportsGoWithoutReloadUsingHash() {
|
||
return window.navigator.userAgent.indexOf('Firefox') === -1;
|
||
}
|
||
/**
|
||
* Returns true if a given popstate event is an extraneous WebKit event.
|
||
* Accounts for the fact that Chrome on iOS fires real popstate events
|
||
* containing undefined state when pressing the back button.
|
||
*/
|
||
|
||
function isExtraneousPopstateEvent(event) {
|
||
return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
|
||
}
|
||
|
||
var PopStateEvent = 'popstate';
|
||
var HashChangeEvent = 'hashchange';
|
||
|
||
function getHistoryState() {
|
||
try {
|
||
return window.history.state || {};
|
||
} catch (e) {
|
||
// IE 11 sometimes throws when accessing window.history.state
|
||
// See https://github.com/ReactTraining/history/pull/289
|
||
return {};
|
||
}
|
||
}
|
||
/**
|
||
* Creates a history object that uses the HTML5 history API including
|
||
* pushState, replaceState, and the popstate event.
|
||
*/
|
||
|
||
|
||
function createBrowserHistory(props) {
|
||
if (props === void 0) {
|
||
props = {};
|
||
}
|
||
|
||
!canUseDOM ? invariant(false, 'Browser history needs a DOM') : void 0;
|
||
var globalHistory = window.history;
|
||
var canUseHistory = supportsHistory();
|
||
var needsHashChangeListener = !supportsPopStateOnHashChange();
|
||
var _props = props,
|
||
_props$forceRefresh = _props.forceRefresh,
|
||
forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
|
||
_props$getUserConfirm = _props.getUserConfirmation,
|
||
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
|
||
_props$keyLength = _props.keyLength,
|
||
keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
|
||
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
|
||
|
||
function getDOMLocation(historyState) {
|
||
var _ref = historyState || {},
|
||
key = _ref.key,
|
||
state = _ref.state;
|
||
|
||
var _window$location = window.location,
|
||
pathname = _window$location.pathname,
|
||
search = _window$location.search,
|
||
hash = _window$location.hash;
|
||
var path = pathname + search + hash;
|
||
warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');
|
||
if (basename) path = stripBasename(path, basename);
|
||
return createLocation(path, state, key);
|
||
}
|
||
|
||
function createKey() {
|
||
return Math.random().toString(36).substr(2, keyLength);
|
||
}
|
||
|
||
var transitionManager = createTransitionManager();
|
||
|
||
function setState(nextState) {
|
||
_extends(history, nextState);
|
||
|
||
history.length = globalHistory.length;
|
||
transitionManager.notifyListeners(history.location, history.action);
|
||
}
|
||
|
||
function handlePopState(event) {
|
||
// Ignore extraneous popstate events in WebKit.
|
||
if (isExtraneousPopstateEvent(event)) return;
|
||
handlePop(getDOMLocation(event.state));
|
||
}
|
||
|
||
function handleHashChange() {
|
||
handlePop(getDOMLocation(getHistoryState()));
|
||
}
|
||
|
||
var forceNextPop = false;
|
||
|
||
function handlePop(location) {
|
||
if (forceNextPop) {
|
||
forceNextPop = false;
|
||
setState();
|
||
} else {
|
||
var action = 'POP';
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (ok) {
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
} else {
|
||
revertPop(location);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function revertPop(fromLocation) {
|
||
var toLocation = history.location; // TODO: We could probably make this more reliable by
|
||
// keeping a list of keys we've seen in sessionStorage.
|
||
// Instead, we just default to 0 for keys we don't know.
|
||
|
||
var toIndex = allKeys.indexOf(toLocation.key);
|
||
if (toIndex === -1) toIndex = 0;
|
||
var fromIndex = allKeys.indexOf(fromLocation.key);
|
||
if (fromIndex === -1) fromIndex = 0;
|
||
var delta = toIndex - fromIndex;
|
||
|
||
if (delta) {
|
||
forceNextPop = true;
|
||
go(delta);
|
||
}
|
||
}
|
||
|
||
var initialLocation = getDOMLocation(getHistoryState());
|
||
var allKeys = [initialLocation.key]; // Public interface
|
||
|
||
function createHref(location) {
|
||
return basename + createPath(location);
|
||
}
|
||
|
||
function push(path, state) {
|
||
warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
|
||
var action = 'PUSH';
|
||
var location = createLocation(path, state, createKey(), history.location);
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (!ok) return;
|
||
var href = createHref(location);
|
||
var key = location.key,
|
||
state = location.state;
|
||
|
||
if (canUseHistory) {
|
||
globalHistory.pushState({
|
||
key: key,
|
||
state: state
|
||
}, null, href);
|
||
|
||
if (forceRefresh) {
|
||
window.location.href = href;
|
||
} else {
|
||
var prevIndex = allKeys.indexOf(history.location.key);
|
||
var nextKeys = allKeys.slice(0, prevIndex + 1);
|
||
nextKeys.push(location.key);
|
||
allKeys = nextKeys;
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
}
|
||
} else {
|
||
warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history');
|
||
window.location.href = href;
|
||
}
|
||
});
|
||
}
|
||
|
||
function replace(path, state) {
|
||
warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
|
||
var action = 'REPLACE';
|
||
var location = createLocation(path, state, createKey(), history.location);
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (!ok) return;
|
||
var href = createHref(location);
|
||
var key = location.key,
|
||
state = location.state;
|
||
|
||
if (canUseHistory) {
|
||
globalHistory.replaceState({
|
||
key: key,
|
||
state: state
|
||
}, null, href);
|
||
|
||
if (forceRefresh) {
|
||
window.location.replace(href);
|
||
} else {
|
||
var prevIndex = allKeys.indexOf(history.location.key);
|
||
if (prevIndex !== -1) allKeys[prevIndex] = location.key;
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
}
|
||
} else {
|
||
warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history');
|
||
window.location.replace(href);
|
||
}
|
||
});
|
||
}
|
||
|
||
function go(n) {
|
||
globalHistory.go(n);
|
||
}
|
||
|
||
function goBack() {
|
||
go(-1);
|
||
}
|
||
|
||
function goForward() {
|
||
go(1);
|
||
}
|
||
|
||
var listenerCount = 0;
|
||
|
||
function checkDOMListeners(delta) {
|
||
listenerCount += delta;
|
||
|
||
if (listenerCount === 1 && delta === 1) {
|
||
window.addEventListener(PopStateEvent, handlePopState);
|
||
if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
|
||
} else if (listenerCount === 0) {
|
||
window.removeEventListener(PopStateEvent, handlePopState);
|
||
if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
|
||
}
|
||
}
|
||
|
||
var isBlocked = false;
|
||
|
||
function block(prompt) {
|
||
if (prompt === void 0) {
|
||
prompt = false;
|
||
}
|
||
|
||
var unblock = transitionManager.setPrompt(prompt);
|
||
|
||
if (!isBlocked) {
|
||
checkDOMListeners(1);
|
||
isBlocked = true;
|
||
}
|
||
|
||
return function () {
|
||
if (isBlocked) {
|
||
isBlocked = false;
|
||
checkDOMListeners(-1);
|
||
}
|
||
|
||
return unblock();
|
||
};
|
||
}
|
||
|
||
function listen(listener) {
|
||
var unlisten = transitionManager.appendListener(listener);
|
||
checkDOMListeners(1);
|
||
return function () {
|
||
checkDOMListeners(-1);
|
||
unlisten();
|
||
};
|
||
}
|
||
|
||
var history = {
|
||
length: globalHistory.length,
|
||
action: 'POP',
|
||
location: initialLocation,
|
||
createHref: createHref,
|
||
push: push,
|
||
replace: replace,
|
||
go: go,
|
||
goBack: goBack,
|
||
goForward: goForward,
|
||
block: block,
|
||
listen: listen
|
||
};
|
||
return history;
|
||
}
|
||
|
||
var HashChangeEvent$1 = 'hashchange';
|
||
var HashPathCoders = {
|
||
hashbang: {
|
||
encodePath: function encodePath(path) {
|
||
return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);
|
||
},
|
||
decodePath: function decodePath(path) {
|
||
return path.charAt(0) === '!' ? path.substr(1) : path;
|
||
}
|
||
},
|
||
noslash: {
|
||
encodePath: stripLeadingSlash,
|
||
decodePath: addLeadingSlash
|
||
},
|
||
slash: {
|
||
encodePath: addLeadingSlash,
|
||
decodePath: addLeadingSlash
|
||
}
|
||
};
|
||
|
||
function stripHash(url) {
|
||
var hashIndex = url.indexOf('#');
|
||
return hashIndex === -1 ? url : url.slice(0, hashIndex);
|
||
}
|
||
|
||
function getHashPath() {
|
||
// We can't use window.location.hash here because it's not
|
||
// consistent across browsers - Firefox will pre-decode it!
|
||
var href = window.location.href;
|
||
var hashIndex = href.indexOf('#');
|
||
return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
|
||
}
|
||
|
||
function pushHashPath(path) {
|
||
window.location.hash = path;
|
||
}
|
||
|
||
function replaceHashPath(path) {
|
||
window.location.replace(stripHash(window.location.href) + '#' + path);
|
||
}
|
||
|
||
function createHashHistory(props) {
|
||
if (props === void 0) {
|
||
props = {};
|
||
}
|
||
|
||
!canUseDOM ? invariant(false, 'Hash history needs a DOM') : void 0;
|
||
var globalHistory = window.history;
|
||
var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
|
||
var _props = props,
|
||
_props$getUserConfirm = _props.getUserConfirmation,
|
||
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
|
||
_props$hashType = _props.hashType,
|
||
hashType = _props$hashType === void 0 ? 'slash' : _props$hashType;
|
||
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
|
||
var _HashPathCoders$hashT = HashPathCoders[hashType],
|
||
encodePath = _HashPathCoders$hashT.encodePath,
|
||
decodePath = _HashPathCoders$hashT.decodePath;
|
||
|
||
function getDOMLocation() {
|
||
var path = decodePath(getHashPath());
|
||
warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');
|
||
if (basename) path = stripBasename(path, basename);
|
||
return createLocation(path);
|
||
}
|
||
|
||
var transitionManager = createTransitionManager();
|
||
|
||
function setState(nextState) {
|
||
_extends(history, nextState);
|
||
|
||
history.length = globalHistory.length;
|
||
transitionManager.notifyListeners(history.location, history.action);
|
||
}
|
||
|
||
var forceNextPop = false;
|
||
var ignorePath = null;
|
||
|
||
function locationsAreEqual$$1(a, b) {
|
||
return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash;
|
||
}
|
||
|
||
function handleHashChange() {
|
||
var path = getHashPath();
|
||
var encodedPath = encodePath(path);
|
||
|
||
if (path !== encodedPath) {
|
||
// Ensure we always have a properly-encoded hash.
|
||
replaceHashPath(encodedPath);
|
||
} else {
|
||
var location = getDOMLocation();
|
||
var prevLocation = history.location;
|
||
if (!forceNextPop && locationsAreEqual$$1(prevLocation, location)) return; // A hashchange doesn't always == location change.
|
||
|
||
if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.
|
||
|
||
ignorePath = null;
|
||
handlePop(location);
|
||
}
|
||
}
|
||
|
||
function handlePop(location) {
|
||
if (forceNextPop) {
|
||
forceNextPop = false;
|
||
setState();
|
||
} else {
|
||
var action = 'POP';
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (ok) {
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
} else {
|
||
revertPop(location);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function revertPop(fromLocation) {
|
||
var toLocation = history.location; // TODO: We could probably make this more reliable by
|
||
// keeping a list of paths we've seen in sessionStorage.
|
||
// Instead, we just default to 0 for paths we don't know.
|
||
|
||
var toIndex = allPaths.lastIndexOf(createPath(toLocation));
|
||
if (toIndex === -1) toIndex = 0;
|
||
var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));
|
||
if (fromIndex === -1) fromIndex = 0;
|
||
var delta = toIndex - fromIndex;
|
||
|
||
if (delta) {
|
||
forceNextPop = true;
|
||
go(delta);
|
||
}
|
||
} // Ensure the hash is encoded properly before doing anything else.
|
||
|
||
|
||
var path = getHashPath();
|
||
var encodedPath = encodePath(path);
|
||
if (path !== encodedPath) replaceHashPath(encodedPath);
|
||
var initialLocation = getDOMLocation();
|
||
var allPaths = [createPath(initialLocation)]; // Public interface
|
||
|
||
function createHref(location) {
|
||
var baseTag = document.querySelector('base');
|
||
var href = '';
|
||
|
||
if (baseTag && baseTag.getAttribute('href')) {
|
||
href = stripHash(window.location.href);
|
||
}
|
||
|
||
return href + '#' + encodePath(basename + createPath(location));
|
||
}
|
||
|
||
function push(path, state) {
|
||
warning(state === undefined, 'Hash history cannot push state; it is ignored');
|
||
var action = 'PUSH';
|
||
var location = createLocation(path, undefined, undefined, history.location);
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (!ok) return;
|
||
var path = createPath(location);
|
||
var encodedPath = encodePath(basename + path);
|
||
var hashChanged = getHashPath() !== encodedPath;
|
||
|
||
if (hashChanged) {
|
||
// We cannot tell if a hashchange was caused by a PUSH, so we'd
|
||
// rather setState here and ignore the hashchange. The caveat here
|
||
// is that other hash histories in the page will consider it a POP.
|
||
ignorePath = path;
|
||
pushHashPath(encodedPath);
|
||
var prevIndex = allPaths.lastIndexOf(createPath(history.location));
|
||
var nextPaths = allPaths.slice(0, prevIndex + 1);
|
||
nextPaths.push(path);
|
||
allPaths = nextPaths;
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
} else {
|
||
warning(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');
|
||
setState();
|
||
}
|
||
});
|
||
}
|
||
|
||
function replace(path, state) {
|
||
warning(state === undefined, 'Hash history cannot replace state; it is ignored');
|
||
var action = 'REPLACE';
|
||
var location = createLocation(path, undefined, undefined, history.location);
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (!ok) return;
|
||
var path = createPath(location);
|
||
var encodedPath = encodePath(basename + path);
|
||
var hashChanged = getHashPath() !== encodedPath;
|
||
|
||
if (hashChanged) {
|
||
// We cannot tell if a hashchange was caused by a REPLACE, so we'd
|
||
// rather setState here and ignore the hashchange. The caveat here
|
||
// is that other hash histories in the page will consider it a POP.
|
||
ignorePath = path;
|
||
replaceHashPath(encodedPath);
|
||
}
|
||
|
||
var prevIndex = allPaths.indexOf(createPath(history.location));
|
||
if (prevIndex !== -1) allPaths[prevIndex] = path;
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
});
|
||
}
|
||
|
||
function go(n) {
|
||
warning(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');
|
||
globalHistory.go(n);
|
||
}
|
||
|
||
function goBack() {
|
||
go(-1);
|
||
}
|
||
|
||
function goForward() {
|
||
go(1);
|
||
}
|
||
|
||
var listenerCount = 0;
|
||
|
||
function checkDOMListeners(delta) {
|
||
listenerCount += delta;
|
||
|
||
if (listenerCount === 1 && delta === 1) {
|
||
window.addEventListener(HashChangeEvent$1, handleHashChange);
|
||
} else if (listenerCount === 0) {
|
||
window.removeEventListener(HashChangeEvent$1, handleHashChange);
|
||
}
|
||
}
|
||
|
||
var isBlocked = false;
|
||
|
||
function block(prompt) {
|
||
if (prompt === void 0) {
|
||
prompt = false;
|
||
}
|
||
|
||
var unblock = transitionManager.setPrompt(prompt);
|
||
|
||
if (!isBlocked) {
|
||
checkDOMListeners(1);
|
||
isBlocked = true;
|
||
}
|
||
|
||
return function () {
|
||
if (isBlocked) {
|
||
isBlocked = false;
|
||
checkDOMListeners(-1);
|
||
}
|
||
|
||
return unblock();
|
||
};
|
||
}
|
||
|
||
function listen(listener) {
|
||
var unlisten = transitionManager.appendListener(listener);
|
||
checkDOMListeners(1);
|
||
return function () {
|
||
checkDOMListeners(-1);
|
||
unlisten();
|
||
};
|
||
}
|
||
|
||
var history = {
|
||
length: globalHistory.length,
|
||
action: 'POP',
|
||
location: initialLocation,
|
||
createHref: createHref,
|
||
push: push,
|
||
replace: replace,
|
||
go: go,
|
||
goBack: goBack,
|
||
goForward: goForward,
|
||
block: block,
|
||
listen: listen
|
||
};
|
||
return history;
|
||
}
|
||
|
||
function clamp(n, lowerBound, upperBound) {
|
||
return Math.min(Math.max(n, lowerBound), upperBound);
|
||
}
|
||
/**
|
||
* Creates a history object that stores locations in memory.
|
||
*/
|
||
|
||
|
||
function createMemoryHistory(props) {
|
||
if (props === void 0) {
|
||
props = {};
|
||
}
|
||
|
||
var _props = props,
|
||
getUserConfirmation = _props.getUserConfirmation,
|
||
_props$initialEntries = _props.initialEntries,
|
||
initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
|
||
_props$initialIndex = _props.initialIndex,
|
||
initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
|
||
_props$keyLength = _props.keyLength,
|
||
keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
|
||
var transitionManager = createTransitionManager();
|
||
|
||
function setState(nextState) {
|
||
_extends(history, nextState);
|
||
|
||
history.length = history.entries.length;
|
||
transitionManager.notifyListeners(history.location, history.action);
|
||
}
|
||
|
||
function createKey() {
|
||
return Math.random().toString(36).substr(2, keyLength);
|
||
}
|
||
|
||
var index = clamp(initialIndex, 0, initialEntries.length - 1);
|
||
var entries = initialEntries.map(function (entry) {
|
||
return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
|
||
}); // Public interface
|
||
|
||
var createHref = createPath;
|
||
|
||
function push(path, state) {
|
||
warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
|
||
var action = 'PUSH';
|
||
var location = createLocation(path, state, createKey(), history.location);
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (!ok) return;
|
||
var prevIndex = history.index;
|
||
var nextIndex = prevIndex + 1;
|
||
var nextEntries = history.entries.slice(0);
|
||
|
||
if (nextEntries.length > nextIndex) {
|
||
nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
|
||
} else {
|
||
nextEntries.push(location);
|
||
}
|
||
|
||
setState({
|
||
action: action,
|
||
location: location,
|
||
index: nextIndex,
|
||
entries: nextEntries
|
||
});
|
||
});
|
||
}
|
||
|
||
function replace(path, state) {
|
||
warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');
|
||
var action = 'REPLACE';
|
||
var location = createLocation(path, state, createKey(), history.location);
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (!ok) return;
|
||
history.entries[history.index] = location;
|
||
setState({
|
||
action: action,
|
||
location: location
|
||
});
|
||
});
|
||
}
|
||
|
||
function go(n) {
|
||
var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
|
||
var action = 'POP';
|
||
var location = history.entries[nextIndex];
|
||
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
|
||
if (ok) {
|
||
setState({
|
||
action: action,
|
||
location: location,
|
||
index: nextIndex
|
||
});
|
||
} else {
|
||
// Mimic the behavior of DOM histories by
|
||
// causing a render after a cancelled POP.
|
||
setState();
|
||
}
|
||
});
|
||
}
|
||
|
||
function goBack() {
|
||
go(-1);
|
||
}
|
||
|
||
function goForward() {
|
||
go(1);
|
||
}
|
||
|
||
function canGo(n) {
|
||
var nextIndex = history.index + n;
|
||
return nextIndex >= 0 && nextIndex < history.entries.length;
|
||
}
|
||
|
||
function block(prompt) {
|
||
if (prompt === void 0) {
|
||
prompt = false;
|
||
}
|
||
|
||
return transitionManager.setPrompt(prompt);
|
||
}
|
||
|
||
function listen(listener) {
|
||
return transitionManager.appendListener(listener);
|
||
}
|
||
|
||
var history = {
|
||
length: entries.length,
|
||
action: 'POP',
|
||
location: entries[index],
|
||
index: index,
|
||
entries: entries,
|
||
createHref: createHref,
|
||
push: push,
|
||
replace: replace,
|
||
go: go,
|
||
goBack: goBack,
|
||
goForward: goForward,
|
||
canGo: canGo,
|
||
block: block,
|
||
listen: listen
|
||
};
|
||
return history;
|
||
}
|
||
|
||
exports.createBrowserHistory = createBrowserHistory;
|
||
exports.createHashHistory = createHashHistory;
|
||
exports.createMemoryHistory = createMemoryHistory;
|
||
exports.createLocation = createLocation;
|
||
exports.locationsAreEqual = locationsAreEqual;
|
||
exports.parsePath = parsePath;
|
||
exports.createPath = createPath;
|
||
|
||
},{"resolve-pathname":49,"tiny-invariant":50,"tiny-warning":51,"value-equal":54}],36:[function(require,module,exports){
|
||
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var resolvePathname=_interopDefault(require("resolve-pathname")),valueEqual=_interopDefault(require("value-equal"));require("tiny-warning");var invariant=_interopDefault(require("tiny-invariant"));function _extends(){return(_extends=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t}).apply(this,arguments)}function addLeadingSlash(t){return"/"===t.charAt(0)?t:"/"+t}function stripLeadingSlash(t){return"/"===t.charAt(0)?t.substr(1):t}function hasBasename(t,n){return 0===t.toLowerCase().indexOf(n.toLowerCase())&&-1!=="/?#".indexOf(t.charAt(n.length))}function stripBasename(t,n){return hasBasename(t,n)?t.substr(n.length):t}function stripTrailingSlash(t){return"/"===t.charAt(t.length-1)?t.slice(0,-1):t}function parsePath(t){var n=t||"/",e="",a="",r=n.indexOf("#");-1!==r&&(a=n.substr(r),n=n.substr(0,r));var o=n.indexOf("?");return-1!==o&&(e=n.substr(o),n=n.substr(0,o)),{pathname:n,search:"?"===e?"":e,hash:"#"===a?"":a}}function createPath(t){var n=t.pathname,e=t.search,a=t.hash,r=n||"/";return e&&"?"!==e&&(r+="?"===e.charAt(0)?e:"?"+e),a&&"#"!==a&&(r+="#"===a.charAt(0)?a:"#"+a),r}function createLocation(t,n,e,a){var r;"string"==typeof t?(r=parsePath(t)).state=n:(void 0===(r=_extends({},t)).pathname&&(r.pathname=""),r.search?"?"!==r.search.charAt(0)&&(r.search="?"+r.search):r.search="",r.hash?"#"!==r.hash.charAt(0)&&(r.hash="#"+r.hash):r.hash="",void 0!==n&&void 0===r.state&&(r.state=n));try{r.pathname=decodeURI(r.pathname)}catch(t){throw t instanceof URIError?new URIError('Pathname "'+r.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):t}return e&&(r.key=e),a?r.pathname?"/"!==r.pathname.charAt(0)&&(r.pathname=resolvePathname(r.pathname,a.pathname)):r.pathname=a.pathname:r.pathname||(r.pathname="/"),r}function locationsAreEqual(t,n){return t.pathname===n.pathname&&t.search===n.search&&t.hash===n.hash&&t.key===n.key&&valueEqual(t.state,n.state)}function createTransitionManager(){var o=null;var a=[];return{setPrompt:function(t){return o=t,function(){o===t&&(o=null)}},confirmTransitionTo:function(t,n,e,a){if(null!=o){var r="function"==typeof o?o(t,n):o;"string"==typeof r?"function"==typeof e?e(r,a):a(!0):a(!1!==r)}else a(!0)},appendListener:function(t){var n=!0;function e(){n&&t.apply(void 0,arguments)}return a.push(e),function(){n=!1,a=a.filter(function(t){return t!==e})}},notifyListeners:function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];a.forEach(function(t){return t.apply(void 0,n)})}}}var canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement);function getConfirmation(t,n){n(window.confirm(t))}function supportsHistory(){var t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}function supportsPopStateOnHashChange(){return-1===window.navigator.userAgent.indexOf("Trident")}function supportsGoWithoutReloadUsingHash(){return-1===window.navigator.userAgent.indexOf("Firefox")}function isExtraneousPopstateEvent(t){return void 0===t.state&&-1===navigator.userAgent.indexOf("CriOS")}var PopStateEvent="popstate",HashChangeEvent="hashchange";function getHistoryState(){try{return window.history.state||{}}catch(t){return{}}}function createBrowserHistory(t){void 0===t&&(t={}),canUseDOM||invariant(!1);var s=window.history,c=supportsHistory(),n=!supportsPopStateOnHashChange(),e=t,a=e.forceRefresh,h=void 0!==a&&a,r=e.getUserConfirmation,u=void 0===r?getConfirmation:r,o=e.keyLength,i=void 0===o?6:o,f=t.basename?stripTrailingSlash(addLeadingSlash(t.basename)):"";function l(t){var n=t||{},e=n.key,a=n.state,r=window.location,o=r.pathname+r.search+r.hash;return f&&(o=stripBasename(o,f)),createLocation(o,a,e)}function d(){return Math.random().toString(36).substr(2,i)}var v=createTransitionManager();function p(t){_extends(T,t),T.length=s.length,v.notifyListeners(T.location,T.action)}function g(t){isExtraneousPopstateEvent(t)||w(l(t.state))}function P(){w(l(getHistoryState()))}var m=!1;function w(n){if(m)m=!1,p();else{v.confirmTransitionTo(n,"POP",u,function(t){t?p({action:"POP",location:n}):function(t){var n=T.location,e=H.indexOf(n.key);-1===e&&(e=0);var a=H.indexOf(t.key);-1===a&&(a=0);var r=e-a;r&&(m=!0,L(r))}(n)})}}var y=l(getHistoryState()),H=[y.key];function x(t){return f+createPath(t)}function L(t){s.go(t)}var O=0;function E(t){1===(O+=t)&&1===t?(window.addEventListener(PopStateEvent,g),n&&window.addEventListener(HashChangeEvent,P)):0===O&&(window.removeEventListener(PopStateEvent,g),n&&window.removeEventListener(HashChangeEvent,P))}var S=!1;var T={length:s.length,action:"POP",location:y,createHref:x,push:function(t,n){var i=createLocation(t,n,d(),T.location);v.confirmTransitionTo(i,"PUSH",u,function(t){if(t){var n=x(i),e=i.key,a=i.state;if(c)if(s.pushState({key:e,state:a},null,n),h)window.location.href=n;else{var r=H.indexOf(T.location.key),o=H.slice(0,r+1);o.push(i.key),H=o,p({action:"PUSH",location:i})}else window.location.href=n}})},replace:function(t,n){var o="REPLACE",i=createLocation(t,n,d(),T.location);v.confirmTransitionTo(i,o,u,function(t){if(t){var n=x(i),e=i.key,a=i.state;if(c)if(s.replaceState({key:e,state:a},null,n),h)window.location.replace(n);else{var r=H.indexOf(T.location.key);-1!==r&&(H[r]=i.key),p({action:o,location:i})}else window.location.replace(n)}})},go:L,goBack:function(){L(-1)},goForward:function(){L(1)},block:function(t){void 0===t&&(t=!1);var n=v.setPrompt(t);return S||(E(1),S=!0),function(){return S&&(S=!1,E(-1)),n()}},listen:function(t){var n=v.appendListener(t);return E(1),function(){E(-1),n()}}};return T}var HashChangeEvent$1="hashchange",HashPathCoders={hashbang:{encodePath:function(t){return"!"===t.charAt(0)?t:"!/"+stripLeadingSlash(t)},decodePath:function(t){return"!"===t.charAt(0)?t.substr(1):t}},noslash:{encodePath:stripLeadingSlash,decodePath:addLeadingSlash},slash:{encodePath:addLeadingSlash,decodePath:addLeadingSlash}};function stripHash(t){var n=t.indexOf("#");return-1===n?t:t.slice(0,n)}function getHashPath(){var t=window.location.href,n=t.indexOf("#");return-1===n?"":t.substring(n+1)}function pushHashPath(t){window.location.hash=t}function replaceHashPath(t){window.location.replace(stripHash(window.location.href)+"#"+t)}function createHashHistory(t){void 0===t&&(t={}),canUseDOM||invariant(!1);var n=window.history,e=(supportsGoWithoutReloadUsingHash(),t),a=e.getUserConfirmation,i=void 0===a?getConfirmation:a,r=e.hashType,o=void 0===r?"slash":r,s=t.basename?stripTrailingSlash(addLeadingSlash(t.basename)):"",c=HashPathCoders[o],h=c.encodePath,u=c.decodePath;function f(){var t=u(getHashPath());return s&&(t=stripBasename(t,s)),createLocation(t)}var l=createTransitionManager();function d(t){_extends(E,t),E.length=n.length,l.notifyListeners(E.location,E.action)}var v=!1,p=null;function g(){var t=getHashPath(),n=h(t);if(t!==n)replaceHashPath(n);else{var e=f(),a=E.location;if(!v&&function(t,n){return t.pathname===n.pathname&&t.search===n.search&&t.hash===n.hash}(a,e))return;if(p===createPath(e))return;p=null,function(n){if(v)v=!1,d();else{l.confirmTransitionTo(n,"POP",i,function(t){t?d({action:"POP",location:n}):function(t){var n=E.location,e=y.lastIndexOf(createPath(n));-1===e&&(e=0);var a=y.lastIndexOf(createPath(t));-1===a&&(a=0);var r=e-a;r&&(v=!0,H(r))}(n)})}}(e)}}var P=getHashPath(),m=h(P);P!==m&&replaceHashPath(m);var w=f(),y=[createPath(w)];function H(t){n.go(t)}var x=0;function L(t){1===(x+=t)&&1===t?window.addEventListener(HashChangeEvent$1,g):0===x&&window.removeEventListener(HashChangeEvent$1,g)}var O=!1;var E={length:n.length,action:"POP",location:w,createHref:function(t){var n=document.querySelector("base"),e="";return n&&n.getAttribute("href")&&(e=stripHash(window.location.href)),e+"#"+h(s+createPath(t))},push:function(t,n){var o=createLocation(t,void 0,void 0,E.location);l.confirmTransitionTo(o,"PUSH",i,function(t){if(t){var n=createPath(o),e=h(s+n);if(getHashPath()!==e){p=n,pushHashPath(e);var a=y.lastIndexOf(createPath(E.location)),r=y.slice(0,a+1);r.push(n),y=r,d({action:"PUSH",location:o})}else d()}})},replace:function(t,n){var r="REPLACE",o=createLocation(t,void 0,void 0,E.location);l.confirmTransitionTo(o,r,i,function(t){if(t){var n=createPath(o),e=h(s+n);getHashPath()!==e&&(p=n,replaceHashPath(e));var a=y.indexOf(createPath(E.location));-1!==a&&(y[a]=n),d({action:r,location:o})}})},go:H,goBack:function(){H(-1)},goForward:function(){H(1)},block:function(t){void 0===t&&(t=!1);var n=l.setPrompt(t);return O||(L(1),O=!0),function(){return O&&(O=!1,L(-1)),n()}},listen:function(t){var n=l.appendListener(t);return L(1),function(){L(-1),n()}}};return E}function clamp(t,n,e){return Math.min(Math.max(t,n),e)}function createMemoryHistory(t){void 0===t&&(t={});var n=t,r=n.getUserConfirmation,e=n.initialEntries,a=void 0===e?["/"]:e,o=n.initialIndex,i=void 0===o?0:o,s=n.keyLength,c=void 0===s?6:s,h=createTransitionManager();function u(t){_extends(g,t),g.length=g.entries.length,h.notifyListeners(g.location,g.action)}function f(){return Math.random().toString(36).substr(2,c)}var l=clamp(i,0,a.length-1),d=a.map(function(t){return createLocation(t,void 0,"string"==typeof t?f():t.key||f())}),v=createPath;function p(t){var n=clamp(g.index+t,0,g.entries.length-1),e=g.entries[n];h.confirmTransitionTo(e,"POP",r,function(t){t?u({action:"POP",location:e,index:n}):u()})}var g={length:d.length,action:"POP",location:d[l],index:l,entries:d,createHref:v,push:function(t,n){var a=createLocation(t,n,f(),g.location);h.confirmTransitionTo(a,"PUSH",r,function(t){if(t){var n=g.index+1,e=g.entries.slice(0);e.length>n?e.splice(n,e.length-n,a):e.push(a),u({action:"PUSH",location:a,index:n,entries:e})}})},replace:function(t,n){var e="REPLACE",a=createLocation(t,n,f(),g.location);h.confirmTransitionTo(a,e,r,function(t){t&&(g.entries[g.index]=a,u({action:e,location:a}))})},go:p,goBack:function(){p(-1)},goForward:function(){p(1)},canGo:function(t){var n=g.index+t;return 0<=n&&n<g.entries.length},block:function(t){return void 0===t&&(t=!1),h.setPrompt(t)},listen:function(t){return h.appendListener(t)}};return g}exports.createBrowserHistory=createBrowserHistory,exports.createHashHistory=createHashHistory,exports.createMemoryHistory=createMemoryHistory,exports.createLocation=createLocation,exports.locationsAreEqual=locationsAreEqual,exports.parsePath=parsePath,exports.createPath=createPath;
|
||
|
||
},{"resolve-pathname":49,"tiny-invariant":50,"tiny-warning":51,"value-equal":54}],37:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
if (process.env.NODE_ENV === 'production') {
|
||
module.exports = require('./cjs/history.min.js');
|
||
} else {
|
||
module.exports = require('./cjs/history.js');
|
||
}
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./cjs/history.js":35,"./cjs/history.min.js":36,"_process":11}],38:[function(require,module,exports){
|
||
/*
|
||
object-assign
|
||
(c) Sindre Sorhus
|
||
@license MIT
|
||
*/
|
||
|
||
'use strict';
|
||
/* eslint-disable no-unused-vars */
|
||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||
|
||
function toObject(val) {
|
||
if (val === null || val === undefined) {
|
||
throw new TypeError('Object.assign cannot be called with null or undefined');
|
||
}
|
||
|
||
return Object(val);
|
||
}
|
||
|
||
function shouldUseNative() {
|
||
try {
|
||
if (!Object.assign) {
|
||
return false;
|
||
}
|
||
|
||
// Detect buggy property enumeration order in older V8 versions.
|
||
|
||
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
||
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
||
test1[5] = 'de';
|
||
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
||
return false;
|
||
}
|
||
|
||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
||
var test2 = {};
|
||
for (var i = 0; i < 10; i++) {
|
||
test2['_' + String.fromCharCode(i)] = i;
|
||
}
|
||
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
||
return test2[n];
|
||
});
|
||
if (order2.join('') !== '0123456789') {
|
||
return false;
|
||
}
|
||
|
||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
||
var test3 = {};
|
||
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
||
test3[letter] = letter;
|
||
});
|
||
if (Object.keys(Object.assign({}, test3)).join('') !==
|
||
'abcdefghijklmnopqrst') {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
} catch (err) {
|
||
// We don't expect any of the above to throw, but better to be safe.
|
||
return false;
|
||
}
|
||
}
|
||
|
||
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
||
var from;
|
||
var to = toObject(target);
|
||
var symbols;
|
||
|
||
for (var s = 1; s < arguments.length; s++) {
|
||
from = Object(arguments[s]);
|
||
|
||
for (var key in from) {
|
||
if (hasOwnProperty.call(from, key)) {
|
||
to[key] = from[key];
|
||
}
|
||
}
|
||
|
||
if (getOwnPropertySymbols) {
|
||
symbols = getOwnPropertySymbols(from);
|
||
for (var i = 0; i < symbols.length; i++) {
|
||
if (propIsEnumerable.call(from, symbols[i])) {
|
||
to[symbols[i]] = from[symbols[i]];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return to;
|
||
};
|
||
|
||
},{}],39:[function(require,module,exports){
|
||
(function (process){
|
||
/**
|
||
* Copyright (c) 2013-present, Facebook, Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
var printWarning = function() {};
|
||
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
|
||
var loggedTypeFailures = {};
|
||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||
|
||
printWarning = function(text) {
|
||
var message = 'Warning: ' + text;
|
||
if (typeof console !== 'undefined') {
|
||
console.error(message);
|
||
}
|
||
try {
|
||
// --- Welcome to debugging React ---
|
||
// This error was thrown as a convenience so that you can use this stack
|
||
// to find the callsite that caused this warning to fire.
|
||
throw new Error(message);
|
||
} catch (x) {}
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Assert that the values match with the type specs.
|
||
* Error messages are memorized and will only be shown once.
|
||
*
|
||
* @param {object} typeSpecs Map of name to a ReactPropType
|
||
* @param {object} values Runtime values that need to be type-checked
|
||
* @param {string} location e.g. "prop", "context", "child context"
|
||
* @param {string} componentName Name of the component for error messages.
|
||
* @param {?Function} getStack Returns the component stack.
|
||
* @private
|
||
*/
|
||
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
for (var typeSpecName in typeSpecs) {
|
||
if (has(typeSpecs, typeSpecName)) {
|
||
var error;
|
||
// Prop type validation may throw. In case they do, we don't want to
|
||
// fail the render phase where it didn't fail before. So we log it.
|
||
// After these have been cleaned up, we'll let them throw.
|
||
try {
|
||
// This is intentionally an invariant that gets caught. It's the same
|
||
// behavior as without this statement except with a better message.
|
||
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
||
var err = Error(
|
||
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
||
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
||
);
|
||
err.name = 'Invariant Violation';
|
||
throw err;
|
||
}
|
||
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
||
} catch (ex) {
|
||
error = ex;
|
||
}
|
||
if (error && !(error instanceof Error)) {
|
||
printWarning(
|
||
(componentName || 'React class') + ': type specification of ' +
|
||
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
||
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
||
'You may have forgotten to pass an argument to the type checker ' +
|
||
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
||
'shape all require an argument).'
|
||
);
|
||
}
|
||
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
||
// Only monitor this failure once because there tends to be a lot of the
|
||
// same error.
|
||
loggedTypeFailures[error.message] = true;
|
||
|
||
var stack = getStack ? getStack() : '';
|
||
|
||
printWarning(
|
||
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
||
);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Resets warning cache when testing.
|
||
*
|
||
* @private
|
||
*/
|
||
checkPropTypes.resetWarningCache = function() {
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
loggedTypeFailures = {};
|
||
}
|
||
}
|
||
|
||
module.exports = checkPropTypes;
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./lib/ReactPropTypesSecret":43,"_process":11}],40:[function(require,module,exports){
|
||
/**
|
||
* Copyright (c) 2013-present, Facebook, Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
|
||
|
||
function emptyFunction() {}
|
||
function emptyFunctionWithReset() {}
|
||
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
||
|
||
module.exports = function() {
|
||
function shim(props, propName, componentName, location, propFullName, secret) {
|
||
if (secret === ReactPropTypesSecret) {
|
||
// It is still safe when called from React.
|
||
return;
|
||
}
|
||
var err = new Error(
|
||
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
||
'Use PropTypes.checkPropTypes() to call them. ' +
|
||
'Read more at http://fb.me/use-check-prop-types'
|
||
);
|
||
err.name = 'Invariant Violation';
|
||
throw err;
|
||
};
|
||
shim.isRequired = shim;
|
||
function getShim() {
|
||
return shim;
|
||
};
|
||
// Important!
|
||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
||
var ReactPropTypes = {
|
||
array: shim,
|
||
bool: shim,
|
||
func: shim,
|
||
number: shim,
|
||
object: shim,
|
||
string: shim,
|
||
symbol: shim,
|
||
|
||
any: shim,
|
||
arrayOf: getShim,
|
||
element: shim,
|
||
elementType: shim,
|
||
instanceOf: getShim,
|
||
node: shim,
|
||
objectOf: getShim,
|
||
oneOf: getShim,
|
||
oneOfType: getShim,
|
||
shape: getShim,
|
||
exact: getShim,
|
||
|
||
checkPropTypes: emptyFunctionWithReset,
|
||
resetWarningCache: emptyFunction
|
||
};
|
||
|
||
ReactPropTypes.PropTypes = ReactPropTypes;
|
||
|
||
return ReactPropTypes;
|
||
};
|
||
|
||
},{"./lib/ReactPropTypesSecret":43}],41:[function(require,module,exports){
|
||
(function (process){
|
||
/**
|
||
* Copyright (c) 2013-present, Facebook, Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
var ReactIs = require('react-is');
|
||
var assign = require('object-assign');
|
||
|
||
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
|
||
var checkPropTypes = require('./checkPropTypes');
|
||
|
||
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
||
var printWarning = function() {};
|
||
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
printWarning = function(text) {
|
||
var message = 'Warning: ' + text;
|
||
if (typeof console !== 'undefined') {
|
||
console.error(message);
|
||
}
|
||
try {
|
||
// --- Welcome to debugging React ---
|
||
// This error was thrown as a convenience so that you can use this stack
|
||
// to find the callsite that caused this warning to fire.
|
||
throw new Error(message);
|
||
} catch (x) {}
|
||
};
|
||
}
|
||
|
||
function emptyFunctionThatReturnsNull() {
|
||
return null;
|
||
}
|
||
|
||
module.exports = function(isValidElement, throwOnDirectAccess) {
|
||
/* global Symbol */
|
||
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
||
|
||
/**
|
||
* Returns the iterator method function contained on the iterable object.
|
||
*
|
||
* Be sure to invoke the function with the iterable as context:
|
||
*
|
||
* var iteratorFn = getIteratorFn(myIterable);
|
||
* if (iteratorFn) {
|
||
* var iterator = iteratorFn.call(myIterable);
|
||
* ...
|
||
* }
|
||
*
|
||
* @param {?object} maybeIterable
|
||
* @return {?function}
|
||
*/
|
||
function getIteratorFn(maybeIterable) {
|
||
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
||
if (typeof iteratorFn === 'function') {
|
||
return iteratorFn;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Collection of methods that allow declaration and validation of props that are
|
||
* supplied to React components. Example usage:
|
||
*
|
||
* var Props = require('ReactPropTypes');
|
||
* var MyArticle = React.createClass({
|
||
* propTypes: {
|
||
* // An optional string prop named "description".
|
||
* description: Props.string,
|
||
*
|
||
* // A required enum prop named "category".
|
||
* category: Props.oneOf(['News','Photos']).isRequired,
|
||
*
|
||
* // A prop named "dialog" that requires an instance of Dialog.
|
||
* dialog: Props.instanceOf(Dialog).isRequired
|
||
* },
|
||
* render: function() { ... }
|
||
* });
|
||
*
|
||
* A more formal specification of how these methods are used:
|
||
*
|
||
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
||
* decl := ReactPropTypes.{type}(.isRequired)?
|
||
*
|
||
* Each and every declaration produces a function with the same signature. This
|
||
* allows the creation of custom validation functions. For example:
|
||
*
|
||
* var MyLink = React.createClass({
|
||
* propTypes: {
|
||
* // An optional string or URI prop named "href".
|
||
* href: function(props, propName, componentName) {
|
||
* var propValue = props[propName];
|
||
* if (propValue != null && typeof propValue !== 'string' &&
|
||
* !(propValue instanceof URI)) {
|
||
* return new Error(
|
||
* 'Expected a string or an URI for ' + propName + ' in ' +
|
||
* componentName
|
||
* );
|
||
* }
|
||
* }
|
||
* },
|
||
* render: function() {...}
|
||
* });
|
||
*
|
||
* @internal
|
||
*/
|
||
|
||
var ANONYMOUS = '<<anonymous>>';
|
||
|
||
// Important!
|
||
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
||
var ReactPropTypes = {
|
||
array: createPrimitiveTypeChecker('array'),
|
||
bool: createPrimitiveTypeChecker('boolean'),
|
||
func: createPrimitiveTypeChecker('function'),
|
||
number: createPrimitiveTypeChecker('number'),
|
||
object: createPrimitiveTypeChecker('object'),
|
||
string: createPrimitiveTypeChecker('string'),
|
||
symbol: createPrimitiveTypeChecker('symbol'),
|
||
|
||
any: createAnyTypeChecker(),
|
||
arrayOf: createArrayOfTypeChecker,
|
||
element: createElementTypeChecker(),
|
||
elementType: createElementTypeTypeChecker(),
|
||
instanceOf: createInstanceTypeChecker,
|
||
node: createNodeChecker(),
|
||
objectOf: createObjectOfTypeChecker,
|
||
oneOf: createEnumTypeChecker,
|
||
oneOfType: createUnionTypeChecker,
|
||
shape: createShapeTypeChecker,
|
||
exact: createStrictShapeTypeChecker,
|
||
};
|
||
|
||
/**
|
||
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
||
*/
|
||
/*eslint-disable no-self-compare*/
|
||
function is(x, y) {
|
||
// SameValue algorithm
|
||
if (x === y) {
|
||
// Steps 1-5, 7-10
|
||
// Steps 6.b-6.e: +0 != -0
|
||
return x !== 0 || 1 / x === 1 / y;
|
||
} else {
|
||
// Step 6.a: NaN == NaN
|
||
return x !== x && y !== y;
|
||
}
|
||
}
|
||
/*eslint-enable no-self-compare*/
|
||
|
||
/**
|
||
* We use an Error-like object for backward compatibility as people may call
|
||
* PropTypes directly and inspect their output. However, we don't use real
|
||
* Errors anymore. We don't inspect their stack anyway, and creating them
|
||
* is prohibitively expensive if they are created too often, such as what
|
||
* happens in oneOfType() for any type before the one that matched.
|
||
*/
|
||
function PropTypeError(message) {
|
||
this.message = message;
|
||
this.stack = '';
|
||
}
|
||
// Make `instanceof Error` still work for returned errors.
|
||
PropTypeError.prototype = Error.prototype;
|
||
|
||
function createChainableTypeChecker(validate) {
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
var manualPropTypeCallCache = {};
|
||
var manualPropTypeWarningCount = 0;
|
||
}
|
||
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
||
componentName = componentName || ANONYMOUS;
|
||
propFullName = propFullName || propName;
|
||
|
||
if (secret !== ReactPropTypesSecret) {
|
||
if (throwOnDirectAccess) {
|
||
// New behavior only for users of `prop-types` package
|
||
var err = new Error(
|
||
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
||
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
||
'Read more at http://fb.me/use-check-prop-types'
|
||
);
|
||
err.name = 'Invariant Violation';
|
||
throw err;
|
||
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
||
// Old behavior for people using React.PropTypes
|
||
var cacheKey = componentName + ':' + propName;
|
||
if (
|
||
!manualPropTypeCallCache[cacheKey] &&
|
||
// Avoid spamming the console because they are often not actionable except for lib authors
|
||
manualPropTypeWarningCount < 3
|
||
) {
|
||
printWarning(
|
||
'You are manually calling a React.PropTypes validation ' +
|
||
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
||
'and will throw in the standalone `prop-types` package. ' +
|
||
'You may be seeing this warning due to a third-party PropTypes ' +
|
||
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
||
);
|
||
manualPropTypeCallCache[cacheKey] = true;
|
||
manualPropTypeWarningCount++;
|
||
}
|
||
}
|
||
}
|
||
if (props[propName] == null) {
|
||
if (isRequired) {
|
||
if (props[propName] === null) {
|
||
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
||
}
|
||
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
||
}
|
||
return null;
|
||
} else {
|
||
return validate(props, propName, componentName, location, propFullName);
|
||
}
|
||
}
|
||
|
||
var chainedCheckType = checkType.bind(null, false);
|
||
chainedCheckType.isRequired = checkType.bind(null, true);
|
||
|
||
return chainedCheckType;
|
||
}
|
||
|
||
function createPrimitiveTypeChecker(expectedType) {
|
||
function validate(props, propName, componentName, location, propFullName, secret) {
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== expectedType) {
|
||
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
||
// check, but we can offer a more precise error message here rather than
|
||
// 'of type `object`'.
|
||
var preciseType = getPreciseType(propValue);
|
||
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createAnyTypeChecker() {
|
||
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
||
}
|
||
|
||
function createArrayOfTypeChecker(typeChecker) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (typeof typeChecker !== 'function') {
|
||
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
||
}
|
||
var propValue = props[propName];
|
||
if (!Array.isArray(propValue)) {
|
||
var propType = getPropType(propValue);
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
||
}
|
||
for (var i = 0; i < propValue.length; i++) {
|
||
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
||
if (error instanceof Error) {
|
||
return error;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createElementTypeChecker() {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
if (!isValidElement(propValue)) {
|
||
var propType = getPropType(propValue);
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createElementTypeTypeChecker() {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
if (!ReactIs.isValidElementType(propValue)) {
|
||
var propType = getPropType(propValue);
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createInstanceTypeChecker(expectedClass) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (!(props[propName] instanceof expectedClass)) {
|
||
var expectedClassName = expectedClass.name || ANONYMOUS;
|
||
var actualClassName = getClassName(props[propName]);
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createEnumTypeChecker(expectedValues) {
|
||
if (!Array.isArray(expectedValues)) {
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
if (arguments.length > 1) {
|
||
printWarning(
|
||
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
||
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
||
);
|
||
} else {
|
||
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
||
}
|
||
}
|
||
return emptyFunctionThatReturnsNull;
|
||
}
|
||
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
for (var i = 0; i < expectedValues.length; i++) {
|
||
if (is(propValue, expectedValues[i])) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
||
var type = getPreciseType(value);
|
||
if (type === 'symbol') {
|
||
return String(value);
|
||
}
|
||
return value;
|
||
});
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createObjectOfTypeChecker(typeChecker) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (typeof typeChecker !== 'function') {
|
||
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
||
}
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== 'object') {
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
||
}
|
||
for (var key in propValue) {
|
||
if (has(propValue, key)) {
|
||
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
||
if (error instanceof Error) {
|
||
return error;
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
||
if (!Array.isArray(arrayOfTypeCheckers)) {
|
||
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
||
return emptyFunctionThatReturnsNull;
|
||
}
|
||
|
||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
||
var checker = arrayOfTypeCheckers[i];
|
||
if (typeof checker !== 'function') {
|
||
printWarning(
|
||
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
||
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
||
);
|
||
return emptyFunctionThatReturnsNull;
|
||
}
|
||
}
|
||
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
||
var checker = arrayOfTypeCheckers[i];
|
||
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createNodeChecker() {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
if (!isNode(props[propName])) {
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createShapeTypeChecker(shapeTypes) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== 'object') {
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
||
}
|
||
for (var key in shapeTypes) {
|
||
var checker = shapeTypes[key];
|
||
if (!checker) {
|
||
continue;
|
||
}
|
||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
||
if (error) {
|
||
return error;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function createStrictShapeTypeChecker(shapeTypes) {
|
||
function validate(props, propName, componentName, location, propFullName) {
|
||
var propValue = props[propName];
|
||
var propType = getPropType(propValue);
|
||
if (propType !== 'object') {
|
||
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
||
}
|
||
// We need to check all keys in case some are required but missing from
|
||
// props.
|
||
var allKeys = assign({}, props[propName], shapeTypes);
|
||
for (var key in allKeys) {
|
||
var checker = shapeTypes[key];
|
||
if (!checker) {
|
||
return new PropTypeError(
|
||
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
||
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
||
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
||
);
|
||
}
|
||
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
||
if (error) {
|
||
return error;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
return createChainableTypeChecker(validate);
|
||
}
|
||
|
||
function isNode(propValue) {
|
||
switch (typeof propValue) {
|
||
case 'number':
|
||
case 'string':
|
||
case 'undefined':
|
||
return true;
|
||
case 'boolean':
|
||
return !propValue;
|
||
case 'object':
|
||
if (Array.isArray(propValue)) {
|
||
return propValue.every(isNode);
|
||
}
|
||
if (propValue === null || isValidElement(propValue)) {
|
||
return true;
|
||
}
|
||
|
||
var iteratorFn = getIteratorFn(propValue);
|
||
if (iteratorFn) {
|
||
var iterator = iteratorFn.call(propValue);
|
||
var step;
|
||
if (iteratorFn !== propValue.entries) {
|
||
while (!(step = iterator.next()).done) {
|
||
if (!isNode(step.value)) {
|
||
return false;
|
||
}
|
||
}
|
||
} else {
|
||
// Iterator will provide entry [k,v] tuples rather than values.
|
||
while (!(step = iterator.next()).done) {
|
||
var entry = step.value;
|
||
if (entry) {
|
||
if (!isNode(entry[1])) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
default:
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function isSymbol(propType, propValue) {
|
||
// Native Symbol.
|
||
if (propType === 'symbol') {
|
||
return true;
|
||
}
|
||
|
||
// falsy value can't be a Symbol
|
||
if (!propValue) {
|
||
return false;
|
||
}
|
||
|
||
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
||
if (propValue['@@toStringTag'] === 'Symbol') {
|
||
return true;
|
||
}
|
||
|
||
// Fallback for non-spec compliant Symbols which are polyfilled.
|
||
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
// Equivalent of `typeof` but with special handling for array and regexp.
|
||
function getPropType(propValue) {
|
||
var propType = typeof propValue;
|
||
if (Array.isArray(propValue)) {
|
||
return 'array';
|
||
}
|
||
if (propValue instanceof RegExp) {
|
||
// Old webkits (at least until Android 4.0) return 'function' rather than
|
||
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
||
// passes PropTypes.object.
|
||
return 'object';
|
||
}
|
||
if (isSymbol(propType, propValue)) {
|
||
return 'symbol';
|
||
}
|
||
return propType;
|
||
}
|
||
|
||
// This handles more types than `getPropType`. Only used for error messages.
|
||
// See `createPrimitiveTypeChecker`.
|
||
function getPreciseType(propValue) {
|
||
if (typeof propValue === 'undefined' || propValue === null) {
|
||
return '' + propValue;
|
||
}
|
||
var propType = getPropType(propValue);
|
||
if (propType === 'object') {
|
||
if (propValue instanceof Date) {
|
||
return 'date';
|
||
} else if (propValue instanceof RegExp) {
|
||
return 'regexp';
|
||
}
|
||
}
|
||
return propType;
|
||
}
|
||
|
||
// Returns a string that is postfixed to a warning about an invalid type.
|
||
// For example, "undefined" or "of type array"
|
||
function getPostfixForTypeWarning(value) {
|
||
var type = getPreciseType(value);
|
||
switch (type) {
|
||
case 'array':
|
||
case 'object':
|
||
return 'an ' + type;
|
||
case 'boolean':
|
||
case 'date':
|
||
case 'regexp':
|
||
return 'a ' + type;
|
||
default:
|
||
return type;
|
||
}
|
||
}
|
||
|
||
// Returns class name of the object, if any.
|
||
function getClassName(propValue) {
|
||
if (!propValue.constructor || !propValue.constructor.name) {
|
||
return ANONYMOUS;
|
||
}
|
||
return propValue.constructor.name;
|
||
}
|
||
|
||
ReactPropTypes.checkPropTypes = checkPropTypes;
|
||
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
||
ReactPropTypes.PropTypes = ReactPropTypes;
|
||
|
||
return ReactPropTypes;
|
||
};
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./checkPropTypes":39,"./lib/ReactPropTypesSecret":43,"_process":11,"object-assign":38,"react-is":46}],42:[function(require,module,exports){
|
||
(function (process){
|
||
/**
|
||
* Copyright (c) 2013-present, Facebook, Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
if (process.env.NODE_ENV !== 'production') {
|
||
var ReactIs = require('react-is');
|
||
|
||
// By explicitly using `prop-types` you are opting into new development behavior.
|
||
// http://fb.me/prop-types-in-prod
|
||
var throwOnDirectAccess = true;
|
||
module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);
|
||
} else {
|
||
// By explicitly using `prop-types` you are opting into new production behavior.
|
||
// http://fb.me/prop-types-in-prod
|
||
module.exports = require('./factoryWithThrowingShims')();
|
||
}
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./factoryWithThrowingShims":40,"./factoryWithTypeCheckers":41,"_process":11,"react-is":46}],43:[function(require,module,exports){
|
||
/**
|
||
* Copyright (c) 2013-present, Facebook, Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
||
|
||
module.exports = ReactPropTypesSecret;
|
||
|
||
},{}],44:[function(require,module,exports){
|
||
(function (process){
|
||
/** @license React v16.10.2
|
||
* react-is.development.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
|
||
|
||
if (process.env.NODE_ENV !== "production") {
|
||
(function() {
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, '__esModule', { value: true });
|
||
|
||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||
// nor polyfill, then a plain number is used for performance.
|
||
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
||
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
||
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
||
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
||
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
||
// (unstable) APIs that have been removed. Can we remove the symbols?
|
||
|
||
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
||
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
||
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
||
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
||
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
||
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
||
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
||
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
||
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
||
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
||
|
||
function isValidElementType(type) {
|
||
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
||
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
|
||
}
|
||
|
||
/**
|
||
* Forked from fbjs/warning:
|
||
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
||
*
|
||
* Only change is we use console.warn instead of console.error,
|
||
* and do nothing when 'console' is not supported.
|
||
* This really simplifies the code.
|
||
* ---
|
||
* Similar to invariant but only logs a warning if the condition is not met.
|
||
* This can be used to log issues in development environments in critical
|
||
* paths. Removing the logging code for production environments will keep the
|
||
* same logic and follow the same code paths.
|
||
*/
|
||
var lowPriorityWarningWithoutStack = function () {};
|
||
|
||
{
|
||
var printWarning = function (format) {
|
||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||
args[_key - 1] = arguments[_key];
|
||
}
|
||
|
||
var argIndex = 0;
|
||
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
||
return args[argIndex++];
|
||
});
|
||
|
||
if (typeof console !== 'undefined') {
|
||
console.warn(message);
|
||
}
|
||
|
||
try {
|
||
// --- Welcome to debugging React ---
|
||
// This error was thrown as a convenience so that you can use this stack
|
||
// to find the callsite that caused this warning to fire.
|
||
throw new Error(message);
|
||
} catch (x) {}
|
||
};
|
||
|
||
lowPriorityWarningWithoutStack = function (condition, format) {
|
||
if (format === undefined) {
|
||
throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
||
}
|
||
|
||
if (!condition) {
|
||
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
||
args[_key2 - 2] = arguments[_key2];
|
||
}
|
||
|
||
printWarning.apply(void 0, [format].concat(args));
|
||
}
|
||
};
|
||
}
|
||
|
||
var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
|
||
|
||
function typeOf(object) {
|
||
if (typeof object === 'object' && object !== null) {
|
||
var $$typeof = object.$$typeof;
|
||
|
||
switch ($$typeof) {
|
||
case REACT_ELEMENT_TYPE:
|
||
var type = object.type;
|
||
|
||
switch (type) {
|
||
case REACT_ASYNC_MODE_TYPE:
|
||
case REACT_CONCURRENT_MODE_TYPE:
|
||
case REACT_FRAGMENT_TYPE:
|
||
case REACT_PROFILER_TYPE:
|
||
case REACT_STRICT_MODE_TYPE:
|
||
case REACT_SUSPENSE_TYPE:
|
||
return type;
|
||
|
||
default:
|
||
var $$typeofType = type && type.$$typeof;
|
||
|
||
switch ($$typeofType) {
|
||
case REACT_CONTEXT_TYPE:
|
||
case REACT_FORWARD_REF_TYPE:
|
||
case REACT_PROVIDER_TYPE:
|
||
return $$typeofType;
|
||
|
||
default:
|
||
return $$typeof;
|
||
}
|
||
|
||
}
|
||
|
||
case REACT_LAZY_TYPE:
|
||
case REACT_MEMO_TYPE:
|
||
case REACT_PORTAL_TYPE:
|
||
return $$typeof;
|
||
}
|
||
}
|
||
|
||
return undefined;
|
||
} // AsyncMode is deprecated along with isAsyncMode
|
||
|
||
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
||
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
||
var ContextConsumer = REACT_CONTEXT_TYPE;
|
||
var ContextProvider = REACT_PROVIDER_TYPE;
|
||
var Element = REACT_ELEMENT_TYPE;
|
||
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
||
var Fragment = REACT_FRAGMENT_TYPE;
|
||
var Lazy = REACT_LAZY_TYPE;
|
||
var Memo = REACT_MEMO_TYPE;
|
||
var Portal = REACT_PORTAL_TYPE;
|
||
var Profiler = REACT_PROFILER_TYPE;
|
||
var StrictMode = REACT_STRICT_MODE_TYPE;
|
||
var Suspense = REACT_SUSPENSE_TYPE;
|
||
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
||
|
||
function isAsyncMode(object) {
|
||
{
|
||
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
||
hasWarnedAboutDeprecatedIsAsyncMode = true;
|
||
lowPriorityWarningWithoutStack$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
||
}
|
||
}
|
||
|
||
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
||
}
|
||
function isConcurrentMode(object) {
|
||
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
||
}
|
||
function isContextConsumer(object) {
|
||
return typeOf(object) === REACT_CONTEXT_TYPE;
|
||
}
|
||
function isContextProvider(object) {
|
||
return typeOf(object) === REACT_PROVIDER_TYPE;
|
||
}
|
||
function isElement(object) {
|
||
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
||
}
|
||
function isForwardRef(object) {
|
||
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
||
}
|
||
function isFragment(object) {
|
||
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
||
}
|
||
function isLazy(object) {
|
||
return typeOf(object) === REACT_LAZY_TYPE;
|
||
}
|
||
function isMemo(object) {
|
||
return typeOf(object) === REACT_MEMO_TYPE;
|
||
}
|
||
function isPortal(object) {
|
||
return typeOf(object) === REACT_PORTAL_TYPE;
|
||
}
|
||
function isProfiler(object) {
|
||
return typeOf(object) === REACT_PROFILER_TYPE;
|
||
}
|
||
function isStrictMode(object) {
|
||
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
||
}
|
||
function isSuspense(object) {
|
||
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
||
}
|
||
|
||
exports.typeOf = typeOf;
|
||
exports.AsyncMode = AsyncMode;
|
||
exports.ConcurrentMode = ConcurrentMode;
|
||
exports.ContextConsumer = ContextConsumer;
|
||
exports.ContextProvider = ContextProvider;
|
||
exports.Element = Element;
|
||
exports.ForwardRef = ForwardRef;
|
||
exports.Fragment = Fragment;
|
||
exports.Lazy = Lazy;
|
||
exports.Memo = Memo;
|
||
exports.Portal = Portal;
|
||
exports.Profiler = Profiler;
|
||
exports.StrictMode = StrictMode;
|
||
exports.Suspense = Suspense;
|
||
exports.isValidElementType = isValidElementType;
|
||
exports.isAsyncMode = isAsyncMode;
|
||
exports.isConcurrentMode = isConcurrentMode;
|
||
exports.isContextConsumer = isContextConsumer;
|
||
exports.isContextProvider = isContextProvider;
|
||
exports.isElement = isElement;
|
||
exports.isForwardRef = isForwardRef;
|
||
exports.isFragment = isFragment;
|
||
exports.isLazy = isLazy;
|
||
exports.isMemo = isMemo;
|
||
exports.isPortal = isPortal;
|
||
exports.isProfiler = isProfiler;
|
||
exports.isStrictMode = isStrictMode;
|
||
exports.isSuspense = isSuspense;
|
||
})();
|
||
}
|
||
|
||
}).call(this,require('_process'))
|
||
},{"_process":11}],45:[function(require,module,exports){
|
||
/** @license React v16.10.2
|
||
* react-is.production.min.js
|
||
*
|
||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});
|
||
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
|
||
60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118,x=b?Symbol.for("react.scope"):60119;function y(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function z(a){return y(a)===m}
|
||
exports.typeOf=y;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
|
||
exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w||a.$$typeof===x)};exports.isAsyncMode=function(a){return z(a)||y(a)===l};exports.isConcurrentMode=z;exports.isContextConsumer=function(a){return y(a)===k};exports.isContextProvider=function(a){return y(a)===h};
|
||
exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return y(a)===n};exports.isFragment=function(a){return y(a)===e};exports.isLazy=function(a){return y(a)===t};exports.isMemo=function(a){return y(a)===r};exports.isPortal=function(a){return y(a)===d};exports.isProfiler=function(a){return y(a)===g};exports.isStrictMode=function(a){return y(a)===f};exports.isSuspense=function(a){return y(a)===p};
|
||
|
||
},{}],46:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
if (process.env.NODE_ENV === 'production') {
|
||
module.exports = require('./cjs/react-is.production.min.js');
|
||
} else {
|
||
module.exports = require('./cjs/react-is.development.js');
|
||
}
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./cjs/react-is.development.js":44,"./cjs/react-is.production.min.js":45,"_process":11}],47:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
function isAbsolute(pathname) {
|
||
return pathname.charAt(0) === '/';
|
||
}
|
||
|
||
// About 1.5x faster than the two-arg version of Array#splice()
|
||
function spliceOne(list, index) {
|
||
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
|
||
list[i] = list[k];
|
||
}
|
||
|
||
list.pop();
|
||
}
|
||
|
||
// This implementation is based heavily on node's url.parse
|
||
function resolvePathname(to, from) {
|
||
if (from === undefined) from = '';
|
||
|
||
var toParts = (to && to.split('/')) || [];
|
||
var fromParts = (from && from.split('/')) || [];
|
||
|
||
var isToAbs = to && isAbsolute(to);
|
||
var isFromAbs = from && isAbsolute(from);
|
||
var mustEndAbs = isToAbs || isFromAbs;
|
||
|
||
if (to && isAbsolute(to)) {
|
||
// to is absolute
|
||
fromParts = toParts;
|
||
} else if (toParts.length) {
|
||
// to is relative, drop the filename
|
||
fromParts.pop();
|
||
fromParts = fromParts.concat(toParts);
|
||
}
|
||
|
||
if (!fromParts.length) return '/';
|
||
|
||
var hasTrailingSlash;
|
||
if (fromParts.length) {
|
||
var last = fromParts[fromParts.length - 1];
|
||
hasTrailingSlash = last === '.' || last === '..' || last === '';
|
||
} else {
|
||
hasTrailingSlash = false;
|
||
}
|
||
|
||
var up = 0;
|
||
for (var i = fromParts.length; i >= 0; i--) {
|
||
var part = fromParts[i];
|
||
|
||
if (part === '.') {
|
||
spliceOne(fromParts, i);
|
||
} else if (part === '..') {
|
||
spliceOne(fromParts, i);
|
||
up++;
|
||
} else if (up) {
|
||
spliceOne(fromParts, i);
|
||
up--;
|
||
}
|
||
}
|
||
|
||
if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');
|
||
|
||
if (
|
||
mustEndAbs &&
|
||
fromParts[0] !== '' &&
|
||
(!fromParts[0] || !isAbsolute(fromParts[0]))
|
||
)
|
||
fromParts.unshift('');
|
||
|
||
var result = fromParts.join('/');
|
||
|
||
if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
||
|
||
return result;
|
||
}
|
||
|
||
module.exports = resolvePathname;
|
||
|
||
},{}],48:[function(require,module,exports){
|
||
"use strict";function isAbsolute(e){return"/"===e.charAt(0)}function spliceOne(e,t){for(var s=t,n=s+1,i=e.length;n<i;s+=1,n+=1)e[s]=e[n];e.pop()}function resolvePathname(e,t){void 0===t&&(t="");var s,n=e&&e.split("/")||[],i=t&&t.split("/")||[],l=e&&isAbsolute(e),r=t&&isAbsolute(t),o=l||r;if(e&&isAbsolute(e)?i=n:n.length&&(i.pop(),i=i.concat(n)),!i.length)return"/";if(i.length){var u=i[i.length-1];s="."===u||".."===u||""===u}else s=!1;for(var a=0,c=i.length;0<=c;c--){var f=i[c];"."===f?spliceOne(i,c):".."===f?(spliceOne(i,c),a++):a&&(spliceOne(i,c),a--)}if(!o)for(;a--;a)i.unshift("..");!o||""===i[0]||i[0]&&isAbsolute(i[0])||i.unshift("");var h=i.join("/");return s&&"/"!==h.substr(-1)&&(h+="/"),h}module.exports=resolvePathname;
|
||
|
||
},{}],49:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
if (process.env.NODE_ENV === 'production') {
|
||
module.exports = require('./cjs/resolve-pathname.min.js');
|
||
} else {
|
||
module.exports = require('./cjs/resolve-pathname.js');
|
||
}
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./cjs/resolve-pathname.js":47,"./cjs/resolve-pathname.min.js":48,"_process":11}],50:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
var isProduction = process.env.NODE_ENV === 'production';
|
||
var prefix = 'Invariant failed';
|
||
function invariant(condition, message) {
|
||
if (condition) {
|
||
return;
|
||
}
|
||
|
||
if (isProduction) {
|
||
throw new Error(prefix);
|
||
} else {
|
||
throw new Error(prefix + ": " + (message || ''));
|
||
}
|
||
}
|
||
|
||
module.exports = invariant;
|
||
|
||
}).call(this,require('_process'))
|
||
},{"_process":11}],51:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
var isProduction = process.env.NODE_ENV === 'production';
|
||
function warning(condition, message) {
|
||
if (!isProduction) {
|
||
if (condition) {
|
||
return;
|
||
}
|
||
|
||
var text = "Warning: " + message;
|
||
|
||
if (typeof console !== 'undefined') {
|
||
console.warn(text);
|
||
}
|
||
|
||
try {
|
||
throw Error(text);
|
||
} catch (x) {}
|
||
}
|
||
}
|
||
|
||
module.exports = warning;
|
||
|
||
}).call(this,require('_process'))
|
||
},{"_process":11}],52:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
function valueOf(obj) {
|
||
return obj.valueOf ? obj.valueOf() : Object.prototype.valueOf.call(obj);
|
||
}
|
||
|
||
function valueEqual(a, b) {
|
||
// Test for strict equality first.
|
||
if (a === b) return true;
|
||
|
||
// Otherwise, if either of them == null they are not equal.
|
||
if (a == null || b == null) return false;
|
||
|
||
if (Array.isArray(a)) {
|
||
return (
|
||
Array.isArray(b) &&
|
||
a.length === b.length &&
|
||
a.every(function(item, index) {
|
||
return valueEqual(item, b[index]);
|
||
})
|
||
);
|
||
}
|
||
|
||
if (typeof a === 'object' || typeof b === 'object') {
|
||
var aValue = valueOf(a);
|
||
var bValue = valueOf(b);
|
||
|
||
if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
|
||
|
||
return Object.keys(Object.assign({}, a, b)).every(function(key) {
|
||
return valueEqual(a[key], b[key]);
|
||
});
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
module.exports = valueEqual;
|
||
|
||
},{}],53:[function(require,module,exports){
|
||
"use strict";function valueOf(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}function valueEqual(u,r){if(u===r)return!0;if(null==u||null==r)return!1;if(Array.isArray(u))return Array.isArray(r)&&u.length===r.length&&u.every(function(e,u){return valueEqual(e,r[u])});if("object"!=typeof u&&"object"!=typeof r)return!1;var e=valueOf(u),t=valueOf(r);return e!==u||t!==r?valueEqual(e,t):Object.keys(Object.assign({},u,r)).every(function(e){return valueEqual(u[e],r[e])})}module.exports=valueEqual;
|
||
|
||
},{}],54:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
if (process.env.NODE_ENV === 'production') {
|
||
module.exports = require('./cjs/value-equal.min.js');
|
||
} else {
|
||
module.exports = require('./cjs/value-equal.js');
|
||
}
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./cjs/value-equal.js":52,"./cjs/value-equal.min.js":53,"_process":11}],55:[function(require,module,exports){
|
||
(function (process){
|
||
'use strict';
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
var _history = require('./history');
|
||
|
||
var _history2 = _interopRequireDefault(_history);
|
||
|
||
var _typeMenu = require('./typeMenu.js');
|
||
|
||
var _typeMenu2 = _interopRequireDefault(_typeMenu);
|
||
|
||
var _tagMenu = require('./tagMenu.js');
|
||
|
||
var _tagMenu2 = _interopRequireDefault(_tagMenu);
|
||
|
||
var _search = require('./search.js');
|
||
|
||
var _search2 = _interopRequireDefault(_search);
|
||
|
||
var _shirtList = require('./shirtList.js');
|
||
|
||
var _shirtList2 = _interopRequireDefault(_shirtList);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
// npx babel --watch src --out-dir . --presets react-app/prod
|
||
// browserify -t brfs src/app.js > bundle.js
|
||
// browserify -t [ babelify --presets [ react-app/prod ] ] -t brfs src/app.js > bundle.js
|
||
|
||
// React and ReactRouterDOM are available on the page, via a CDN reference
|
||
|
||
// from brfs
|
||
var csvjson = require('csvjson');
|
||
|
||
var App = function (_React$Component) {
|
||
_inherits(App, _React$Component);
|
||
|
||
function App(props) {
|
||
_classCallCheck(this, App);
|
||
|
||
var _this = _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).call(this, props));
|
||
|
||
_this._onAppFilterChange = _this._onAppFilterChange.bind(_this);
|
||
_this._onAppFilterClear = _this._onAppFilterClear.bind(_this);
|
||
_this._onAppFocusChange = _this._onAppFocusChange.bind(_this);
|
||
_this._handleKeyPress = _this._handleKeyPress.bind(_this);
|
||
_this.state = { query: '', origItems: [], items: [], frameCssClasses: 'frame', isFocused: false };
|
||
return _this;
|
||
}
|
||
|
||
_createClass(App, [{
|
||
key: '_onAppFilterChange',
|
||
value: function _onAppFilterChange(query) {
|
||
|
||
console.log('##QUERY: ' + query);
|
||
|
||
var updatedList = this.state.origItems;
|
||
updatedList = updatedList.filter(function (shirt) {
|
||
return typeof query === 'undefined' || shirt.title.toLowerCase().includes(query) || shirt.description.trim().split('ΓÇó').pop().toLowerCase().includes(query) || shirt.description.trim().toLowerCase().split("#").join("style:").includes(query);
|
||
});
|
||
|
||
this.setState({
|
||
items: updatedList,
|
||
query: query
|
||
});
|
||
|
||
this._onAppFocusChange(query);
|
||
}
|
||
}, {
|
||
key: '_onAppFilterClear',
|
||
value: function _onAppFilterClear() {
|
||
this.setState({
|
||
items: this.state.origItems,
|
||
query: ''
|
||
});
|
||
this._onAppFocusChange(true);
|
||
}
|
||
}, {
|
||
key: '_onAppFocusChange',
|
||
value: function _onAppFocusChange(isFocused) {
|
||
this.setState({
|
||
frameCssClasses: isFocused ? 'frame focused' : 'frame'
|
||
});
|
||
}
|
||
}, {
|
||
key: '_handleKeyPress',
|
||
value: function _handleKeyPress(event) {
|
||
if (this.state.query == '') {
|
||
var validateKeypress = function validateKeypress(validChars) {
|
||
var keyChar = String.fromCharCode(event.which || event.keyCode);
|
||
return validChars.test(keyChar) ? keyChar : false;
|
||
};
|
||
|
||
var alphanumeric = /[!@#$%^&*(),.?":{}|<>A-Za-z0-9]/;
|
||
|
||
var char = validateKeypress(alphanumeric);
|
||
|
||
console.log('#filter from keypress: ' + char);
|
||
this._onAppFilterChange(char);
|
||
}
|
||
}
|
||
}, {
|
||
key: 'componentDidMount',
|
||
value: function componentDidMount() {
|
||
var _this2 = this;
|
||
|
||
window.addEventListener('keypress', this._handleKeyPress);
|
||
|
||
//console.log('blog will mount');
|
||
|
||
|
||
// filling shirt list with initial csv data
|
||
var self = this;
|
||
process.nextTick(function(){(function (err, fileContent) {
|
||
if (err) {
|
||
console.log(err); // Do something to handle the error or just throw it
|
||
throw new Error(err);
|
||
}
|
||
|
||
var options = {
|
||
delimiter: ',', // optional
|
||
quote: '"' // optional
|
||
};
|
||
|
||
//var parser = new DOMParser;
|
||
//var dom = parser.parseFromString(fileContent, 'text/html');
|
||
//var decodedString = dom.body.textContent;
|
||
//console.log("1: "+fileContent);
|
||
fileContent = fileContent.replace(/"[^"]*(?:""[^"]*)*"/g, function (m) {
|
||
return m.replace(/[\r\n]+/g, '');
|
||
});
|
||
//console.log("2: "+fileContent);
|
||
var fileContentAsJson = csvjson.toObject(fileContent, options).reverse(); // reverse, so that it's in newest to oldest
|
||
|
||
_this2.setState({ origItems: fileContentAsJson, items: fileContentAsJson });
|
||
|
||
console.log(fileContentAsJson);
|
||
|
||
if (_this2.state.query !== _this2.props.match.params.query) {
|
||
console.log('#filter from route (didmount, after csv): ' + _this2.props.match.params.query);
|
||
_this2._onAppFilterChange(_this2.props.match.params.query || '');
|
||
}
|
||
})(null,"id,availability,condition,description,image_link,link,title,price,brand,additional_image_link,google_product_category,product_type,custom_label_0,custom_label_1,custom_label_2\nlarry-sharpe-for-ny,in stock,new,\"\r\nShow your support for the hardest working gubernatorial candidate in the country!  http://twitter.com/LarrySharpe    http://larrysharpe.com\r\nThis design, based on Milton Glaser's iconic campaign, is bold, elegant and just about screams New York.(not affiliated with the Larry Sharpe campaign. just a fan with a computer)#men #women #tees #swag\r\n\r\n•Politics, Libertarian, New York City, Libertarian Party, Larry Sharpe\r\n\",https://vangogh.teespring.com/og_pic/68480445/68725303/front.jpg?v=2018-10-10-22-46&background-image=wood&effects=inner-glow,https://teespring.com/larry-sharpe-for-ny,Larry Sharpe for NY,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/hc36lsMtmhwDndokJy6esGGRV5U/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,for-a-cause,\"vol-attire,vol-attire-swag,vol-attire-women,vol-attire-men,vol-attire-classic,vol-attire-tees\",\"Politics,Libertarian,New York City,Libertarian Party,Larry Sharpe\"\nchange-my-mind-march-2019,in stock,new,\"The best way to start a debate.#men #women #tees #vees #tanks #streetwear\r\n\r\n•Conservative, Libertarian, Debate\r\n\",https://vangogh.teespring.com/v3/image/KOkDvRRlcYEcLhVK60Wnf6bZFv8/560/560.jpg,https://teespring.com/change-my-mind-march-2019,Change My Mind,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/KOkDvRRlcYEcLhVK60Wnf6bZFv8/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees\",\"Conservative,Libertarian,Debate\"\ni-d-rather-be-seasteading-dk,in stock,new,\"If you'd rather be growing a petri dish of competitive governance out on the open ocean than shopping for T-Shirts online, then you've come to the right shirt. https://www.seasteading.org/https://ocean.builders/#men #women #tees #vees #funny\r\n\r\n\r\n•Anarchy, Thailand, Seasteading, Decentralization\r\n\",https://vangogh.teespring.com/v3/image/GXAdecfZO_tcZiGBEKy3FyXndoI/560/560.jpg,https://teespring.com/i-d-rather-be-seasteading-dk,I'd Rather Be Seasteading (DARK),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/GXAdecfZO_tcZiGBEKy3FyXndoI/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-seasteading,vol-attire-men,vol-attire-classic,vol-attire-tees,vol-attire-women\",\"Anarchy,Libertarian,Seasteading\"\nsea-stead-ing-light,in stock,new,\"Are you a pioneer?https://www.seasteading.org/https://ocean.builders/#men #women #tees #vees #streetwear\r\n\r\n•Seasteading\r\n\",https://vangogh.teespring.com/v3/image/-fMtvJg0Mjes5TNq2K6anKYQneg/560/560.jpg,https://teespring.com/sea-stead-ing-light,SEA-STEAD-ING (LIGHT),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/-fMtvJg0Mjes5TNq2K6anKYQneg/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-seasteading,vol-attire-men\",\"Anarchy,Libertarian,Seasteading\"\nsea-stead-ing-dark,in stock,new,\"Are you a pioneer?https://www.seasteading.org/https://ocean.builders/\r\n#men #women #tees #vees #streetwear\r\n\r\n•Seasteading, Decentralization\",https://vangogh.teespring.com/v3/image/ojqaRyZ5IriyaNd-EN7oyKzjkx4/560/560.jpg,https://teespring.com/sea-stead-ing-dark,SEA-STEAD-ING (DARK),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/ojqaRyZ5IriyaNd-EN7oyKzjkx4/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-seasteading,vol-attire-streetwear,vol-attire-women,vol-attire-men\",\"Anarchy,Libertarian,Seasteading\"\nlibrotarian,in stock,new,\"Did you start a beer pong tourney at Mises University?Did you crush Anatomy of the State whilst blasting your quads?Is your Enjoy Capitalism shirt several sizes too small?\r\n#men #women #tanks #funny\r\n\r\n•Bro, Beach, Libertarian, Muscle Shirt, Summer\r\n\",https://vangogh.teespring.com/v3/image/J3gCH3AGvOsKcTPPShiIJoJe9bA/560/560.jpg,https://teespring.com/librotarian,LiBROtarian,21.99 USD,Teespring,http://vangogh.teespring.com/v3/image/J3gCH3AGvOsKcTPPShiIJoJe9bA/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,tank_top,\"\",\"vol-attire,vol-attire-men,vol-attire-tanks,vol-attire-classic\",\"Tank,Volleyball,Bro,Beach,Libertarian,Muscles\"\nfree-ross-1,in stock,new,\"#FREEROSS\r\nRoss Ulbricht is serving a double life sentence + 40 years without parole for all non-violent charges. \r\nI promise to donate all profits from these items (~10USD per shirt) to the Ross Ulbricht Legal Defense Fund. (I'll post screenshots of the sales for accountability.)Please donate here: freeross.org/donate and sign the petition here: freeross.org/petition#men #women #tees #vees #tanks #hoodies #streetwear\r\n\r\n\r\n•Bitcoin, Activism, Libertarian, Silk Road, Ross Ulbricht, Free Ross, Dark Web\",https://vangogh.teespring.com/v3/image/R3-XZ_KGpP_s7JHjlsupn4JKuKs/560/560.jpg,https://teespring.com/free-ross-1,Free Ross (#1),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/R3-XZ_KGpP_s7JHjlsupn4JKuKs/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire-free-ross,vol-attire,vol-attire-streetwear,vol-attire-children,vol-attire-women\",\"Bitcoin,Activism,Libertarian,Silk Road,Ross Ulbricht,Free Ross\"\nfree-ross-2,in stock,new,\"#FREEROSS\r\nRoss Ulbricht is serving a double life sentence + 40 years without parole for all non-violent charges. \r\nI promise to donate all profits from these items (~10USD per shirt) to the Ross Ulbricht Legal Defense Fund. (I'll post screenshots of the sales for accountability.)Please donate here: freeross.org/donate and sign the petition here: freeross.org/petition#men #women #tees #vees #tanks #hoodies #streetwear\r\n\r\n\r\n•Bitcoin, Activism, Libertarian, Silk Road, Ross Ulbricht, Free Ross, Dark Web\",https://vangogh.teespring.com/v3/image/FR69E7Ai011km__cvkLA1krKJgM/560/560.jpg,https://teespring.com/free-ross-2,Free Ross (#2),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/FR69E7Ai011km__cvkLA1krKJgM/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire-free-ross,vol-attire,vol-attire-women,vol-attire-men,vol-attire-tees\",\"Bitcoin,Activism,Libertarian,Silk Road,Ross Ulbricht,Free Ross,Free Ross\"\nfree-ross-3,in stock,new,\"#FREEROSS\r\nRoss Ulbricht is serving a double life sentence + 40 years without parole for all non-violent charges. \r\nI promise to donate all profits from these items (~10USD per shirt) to the Ross Ulbricht Legal Defense Fund. (I'll post screenshots of the sales for accountability.)Please donate here: freeross.org/donate and sign the petition here: freeross.org/petition#men #women #tees #vees #tanks #hoodies #streetwear\r\n\r\n\r\n•Bitcoin, Activism, Libertarian, Silk Road, Ross Ulbricht, Free Ross, Dark Web\r\n\r\n\",https://vangogh.teespring.com/v3/image/JqFfGxV64gx-EyWyDoAJvepzo0k/560/560.jpg,https://teespring.com/free-ross-3,Free Ross (#3),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/JqFfGxV64gx-EyWyDoAJvepzo0k/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire-free-ross,vol-attire,vol-attire-women,vol-attire-men,vol-attire-hoodies,vol-attire-tanks\",\"Activism,Silk Road,Ross Ulbricht\"\nadam-smith-profile,in stock,new,\"Knock knock.Who's there?An Inquiry into the Nature and Causes of the Wealth of Nations and The Theory of Moral SentimentsNot interested. Next time, please come back with a nice concise T-Shirt.#men #women #tees #vees #tanks #hoodies #streetwear #swag\r\n\r\n•Author, Libertarian, Celebrities, Economics, Adam Smith\r\n\",https://vangogh.teespring.com/v3/image/vbuC_9UWSaT577kWAbc8_Vn0GlQ/560/560.jpg,https://teespring.com/adam-smith-profile,Adam Smith Profile,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/vbuC_9UWSaT577kWAbc8_Vn0GlQ/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-swag,vol-attire-women,vol-attire-men,vol-attire-tanks\",\"Streetwear,Author,Libertarian,Celebrities,Economics,Adam Smith\"\nmade-in-liberland,in stock,new,\"Comfortable and stylish apparel specifically designed for the temperate climate of the western bank of the Danube, somewhere between Serbia and Croatia.#men #women #tees #vees #tanks #hoodies #funny #swag\r\n\r\n\r\n•Serbia, Libertarian, Croatia, Liberland, Europe, Politics, Decentralization\r\n\",https://vangogh.teespring.com/v3/image/VGQToo7Fh5Dqn7uLjMTPEjNWkJY/560/560.jpg,https://teespring.com/made-in-liberland,Made In Liberland,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/VGQToo7Fh5Dqn7uLjMTPEjNWkJY/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-women,vol-attire-men,vol-attire-hoodies,vol-attire-tanks,vol-attire-classic\",\"Serbia,Libertarian,Croatia,Liberland,Danube\"\nmenos-marx-mais-mises-3,in stock,new,\"The finest in Brazilian Political Streetwear.#men #women #tees #vees #tanks #streetwear\r\n\r\n\r\n•Abstract, Politics, Libertarian, Marxism, Geometric, Brazil, Mises, Libertarianismo\r\n\",https://vangogh.teespring.com/v3/image/E8PBmm5O7lqFuYtjy2zMBmRqt9s/560/560.jpg,https://teespring.com/menos-marx-mais-mises-3,Menos Marx; Mais Mises (#3),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/E8PBmm5O7lqFuYtjy2zMBmRqt9s/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees\",\"Abstract,Politics,Libertarian,Celebrities,Marx,Geometric,Brazil,Mises,Marxism,Libertarianismo\"\nwho-is-going-to-stop-me-1,in stock,new,\"Howard Roark didn't say this, but your shirt will.\r\n\r\n#men #women #tees #vees #tanks #streetwear\r\n\r\n•Self Help, Ayn Rand, Objectivism, Geometric, Abstract, Quotes\",https://vangogh.teespring.com/v3/image/_hO6VKPzvPf0SEebCSDiRt3ycaQ/560/560.jpg,https://teespring.com/who-is-going-to-stop-me-1,Who Is Going To Stop Me (#1),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/_hO6VKPzvPf0SEebCSDiRt3ycaQ/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees\",\"Liberty,Libertarian,Libertarianism,Self Help,Ayn Rand,Objectivism,Geometric Abstract\"\nmenos-marx-mais-mises-1,in stock,new,\"The finest in Brazilian Political Streetwear.#men #women #tees #vees #tanks #streetwear\r\n\r\n\r\n•Abstract, Politics, Libertarian, Marxism, Geometric, Brazil, Mises, Libertarianismo\r\n\",https://vangogh.teespring.com/v3/image/AF_wvgDquQd7m9n0L-vVL1_k3Ww/560/560.jpg,https://teespring.com/menos-marx-mais-mises-1,Menos Marx; Mais Mises (#1),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/AF_wvgDquQd7m9n0L-vVL1_k3Ww/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees\",\"Abstract,Politics,Libertarian,Celebrities,Marx,Geometric,Brazil,Mises,Marxism,Libertarianismo\"\ngold-black-1,in stock,new,\"As if your torso was a stately smoking room in the mansion of a Liberlandian aristocrat.#men #women #tees #vees #tanks #streetwear\r\n\r\n•Anarchy, Libertarian, Ancap, Anarcho Capitalism, Abstract\r\n\",https://vangogh.teespring.com/v3/image/S3d7n7dEt_0oiGIBm4FpWyUZl_k/560/560.jpg,https://teespring.com/gold-black-1,Gold & Black (#1),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/S3d7n7dEt_0oiGIBm4FpWyUZl_k/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees,vol-attire\",\"Streetwear,Anarchy,Libertarian,Ancap,Anarcho Capitalism\"\nyimby-1,in stock,new,\"Try playing Sim City without one.\r\n\r\n#men #tees #streetwear\r\n\r\n•Nimby, Climate, Climate Change, Power Plant, Nuclear Power, Regulation\",https://vangogh.teespring.com/v3/image/2SPlWIV8OudTssQNzPEF7-IGAUY/560/560.jpg,https://teespring.com/yimby-1,YIMBY #1,25.99 USD,Teespring,http://vangogh.teespring.com/v3/image/2SPlWIV8OudTssQNzPEF7-IGAUY/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire-tees,vol-attire,vol-attire-men,vol-attire-streetwear\",\"Libertarian,Nimby,Climate,Power Plant,Nuclear Power\"\njudge-nap-onesie,in stock,new,\"A perfect accessory for the little constitutionalist juggernaut in your life.http://www.judgenap.com/#kids #funny\r\n\r\n•Libertarian, Babies, Celebrities, Onsies\r\n\",https://vangogh.teespring.com/v3/image/UIV-6rFUCUcXfDPhlFPtlNUtvZQ/560/560.jpg,https://teespring.com/judge-nap-onesie,Judge Nap Onesie,18.99 USD,Teespring,http://vangogh.teespring.com/v3/image/UIV-6rFUCUcXfDPhlFPtlNUtvZQ/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,onesie,\"\",\"vol-attire,vol-attire-children,vol-attire-classic\",\"Libertarian,Babies,Celebrities,Onsies\"\nadam-smith-pocket-hoodie,in stock,new,\"When you wear this hoodie, you're telling the world I have Wealth of Nations in my Amazon Wish-List, and your 5-year-old will think I'm hilarious.#men #hoodies #funny\r\n\r\n\r\n•Author, Libertarian, Pocket, Celebrities, Economics, Adam Smith\r\n\",https://vangogh.teespring.com/v3/image/P57G4xpewfP7h8D9ADTyQwF0CuY/560/560.jpg,https://teespring.com/adam-smith-pocket-hoodie,Adam Smith Pocket Hoodie,44.99 USD,Teespring,http://vangogh.teespring.com/v3/image/P57G4xpewfP7h8D9ADTyQwF0CuY/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,hoodie,\"\",\"vol-attire,vol-attire-hoodies,vol-attire-classic,vol-attire-men\",\"Author,Libertarian,Pocket,Celebrities,Economics,Adam Smith\"\nan-ar-ch-y,in stock,new,\"Because your letters can be inside the box as long as you ideas aren't\r\n\r\n#men #women #tees #hoodies #streetwear\r\n\r\n•Anarchy, Ancap, Geometric, Anarcho Capitalism, Minimalist\",https://vangogh.teespring.com/v3/image/q7DSo8lH_QfhrsJOFl-2jTl82Cs/560/560.jpg,https://teespring.com/an-ar-ch-y,AN-AR-CH-Y,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/q7DSo8lH_QfhrsJOFl-2jTl82Cs/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-streetwear,vol-attire-men\",\"Streetwear,Anarchy,Ancap,Geometric,Anarcho Capitalism\"\npeace-love-anarchy-light,in stock,new,\"Because your letters can be inside the box as long as you ideas aren't.#men #women #tees #vees #streetwear\r\n\r\n\r\n•Love, Peace, Anarchy, Libertarian, Ancap, Antiwar, Anarcho Capitalist, Geometric, Minimalist\r\n\",https://vangogh.teespring.com/v3/image/rUvM5Dl7tXGkjeSq88AW_xU_ryw/560/560.jpg,https://teespring.com/peace-love-anarchy-light,PEACE LOVE ANARCHY (LIGHT),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/rUvM5Dl7tXGkjeSq88AW_xU_ryw/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-women,vol-attire-streetwear,vol-attire-men\",\"Love,Peace,Anarchy,Libertarian,Ancap,Antiwar,Anarcho Capitalist\"\npeace-love-anarchy-dark,in stock,new,\"Because your letters can be inside the box as long as you ideas aren't.#men #women #tees #vees #streetwear\r\n\r\n\r\n•Love, Peace, Anarchy, Libertarian, Ancap, Antiwar, Anarcho Capitalist, Geometric, Minimalist\r\n\",https://vangogh.teespring.com/v3/image/eUYUmrWARyBtZsdSvEsWTjimkS0/560/560.jpg,https://teespring.com/peace-love-anarchy-dark,PEACE LOVE ANARCHY (DARK),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/eUYUmrWARyBtZsdSvEsWTjimkS0/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-women,vol-attire-streetwear,vol-attire-men\",\"Love,Peace,Anarchy,Libertarian,Ancap,Anarcho Capitalism\"\na-few-more-issues,in stock,new,\"For starting that Thanksgiving Dinner conversation that no one asked for.#men #women #tees #vees #funny\r\n\r\n\r\n•Anarchy, Liberty, Ancap, Anarcho Capitalist, Pro Choice\r\n\",https://vangogh.teespring.com/v3/image/pbyMHJeSHYX3Hqr0ASovTYogA7Q/560/560.jpg,https://teespring.com/a-few-more-issues,A Few More Issues,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/pbyMHJeSHYX3Hqr0ASovTYogA7Q/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-classic,vol-attire-tees,vol-attire-women,vol-attire-men\",\"Anarchy,Liberty,Libertarian,Ancap,Anarchist,Pro Choice\"\nmnr-1,in stock,new,\"The inexorable merger of humanity's two greatest triumphs: regular polygons and Austrian Economics.#men #tees #vees #streetwear\r\n\r\n\r\n•Author, Libertarian, Economics, Rothbard, Ancap, Geometric\r\n\",https://vangogh.teespring.com/v3/image/sZ1ajPKnzDH78dGbtEg6EO2mc64/560/560.jpg,https://teespring.com/mnr-1,MNR #1,22.99 USD,Teespring,http://vangogh.teespring.com/v3/image/sZ1ajPKnzDH78dGbtEg6EO2mc64/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-streetwear,vol-attire-men\",\"Author,Liberty,Libertarian,Celebrities,Economics,Rand,Rothbard\"\nmenos-marx-mais-mises-2,in stock,new,\"The finest in Brazilian Political Streetwear.#men #women #tees #vees #tanks #streetwear\r\n\r\n\r\n•Abstract, Politics, Libertarian, Marxism, Geometric, Brazil, Mises, Libertarianismo\r\n\",https://vangogh.teespring.com/v3/image/PwzMEHtQMCa1nb90886X3b2sfj4/560/560.jpg,https://teespring.com/menos-marx-mais-mises-2,Menos Marx; Mais Mises (#2),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/PwzMEHtQMCa1nb90886X3b2sfj4/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-men,vol-attire-tees,vol-attire-women\",\"Abstract,Politics,Libertarian,Celebrities,Marx,Geometric,Brazil,Mises,Anarcho Capitalista\"\ncircle-a-technicolor,in stock,new,\"For colorful dissenters.#men #women #tees #tanks #hoodies #vees #streetwear\r\n\r\n\r\n•Colorful, Anarchy, Gradient, Ancap, Anarcho Capitalist, Circle A\r\n\",https://vangogh.teespring.com/v3/image/3gxD3yml-MAaxuLqxuEE8J14YAk/560/560.jpg,https://teespring.com/circle-a-technicolor,Circle A (TECHNICOLOR),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/3gxD3yml-MAaxuLqxuEE8J14YAk/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees\",\"Colorful,Anarchy,Libertarian,Gradient,Ancap,Anarchist,Anarcho Capitalist,Circle A\"\nas-long-as-its-peaceful,in stock,new,\"I'd vote for this t-shirt.#men #women #tees #hoodies #vees #streetwear\r\n\r\n\r\n•Peace, Anarchy, Libertarian, Ancap, Antiwar, Anarcho Capitalism\r\n\",https://vangogh.teespring.com/v3/image/5NJeYc6kAi4h1fGVleZL0bZZSoI/560/560.jpg,https://teespring.com/as-long-as-its-peaceful,As Long As It's Peaceful,25.99 USD,Teespring,http://vangogh.teespring.com/v3/image/5NJeYc6kAi4h1fGVleZL0bZZSoI/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-men\",\"Peace,Anarchy,Libertarian,Ancap,Antiwar,Anarcho Capitalism\"\npay-taxes,in stock,new,\"Oceania needs your contribution.#men #women #tees #tanks #vees #streetwear\r\n\r\n\r\n•1984, Big Brother, Taxes, IRS, Orwell, Libertarian\r\n\",https://vangogh.teespring.com/v3/image/FA4LfwHf_ntW-WOlDfBmGJCgPm8/560/560.jpg,https://teespring.com/pay-taxes,Pay Taxes,23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/FA4LfwHf_ntW-WOlDfBmGJCgPm8/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-classic\",\"Streetwear,1984,Libertarian,Big Brother,Taxes,Irs,Orwell\"\nnost-epon-snek-dark,in stock,new,\"Christopher Gadsden, meets meme, meets lazy Scandinavian layout design.#men #women #tees #vees #streetwear\r\n\r\n\r\n•Flag, Libertarian, Don't Tread On Me, Gadsden, No Step On Snek\r\n\",https://vangogh.teespring.com/v3/image/s9U8cpL7pRL-SMfUzYwVQCnNBpY/560/560.jpg,https://teespring.com/nost-epon-snek-dark,NOST-EPON-SNEK (DARK),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/s9U8cpL7pRL-SMfUzYwVQCnNBpY/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-women,vol-attire-streetwear,vol-attire-men\",\"America,Flag,Streetwear,Anarchy,Libertarian,Ancap,Gadsden,Snek,New Listing\"\nsmart-elephant-1,in stock,new,\"Apparently this elephant can stand for something while simultaneously sitting.\r\n\r\n#men #tees #vees #streetwear\r\n\r\n•Flag, Anarchy, Libertarian, Elephant, Ancap, Anarcho Capitalism, Abstract\r\n\",https://vangogh.teespring.com/v3/image/czV6ZJKgTP2Za3RNOJvxZ0XwGZY/560/560.jpg,https://teespring.com/smart-elephant-1,Smart Elephant (#1),33.99 USD,Teespring,http://vangogh.teespring.com/v3/image/czV6ZJKgTP2Za3RNOJvxZ0XwGZY/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,other,\"\",\"vol-attire,vol-attire-streetwear\",\"Flag,Streetwear,Anarchy,Libertarian,Elephant,Ancap,Anarcho Capitalism\"\nnew-anarch-1,in stock,new,\"With this shirt, play an invisible game with your thrones in your ethereal house made of cards.#men #tees #streetwear\r\n\r\n\r\n•Anarchy, Ancap, Anarcho Capitalist, ANARCH, Flag\r\n\",https://vangogh.teespring.com/v3/image/QgInv63NXLF0QxjCUe0SebO0qpw/560/560.jpg,https://teespring.com/new-anarch-1,anarch (#1),33.99 USD,Teespring,http://vangogh.teespring.com/v3/image/QgInv63NXLF0QxjCUe0SebO0qpw/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,other,\"\",\"vol-attire,vol-attire-streetwear\",\"Flag,Streetwear,Anarchy,Libertarian,Ancap,Anarcho Capitalism\"\ni-d-rather-be-seasteading-lt,in stock,new,\"If you'd rather be growing a petri dish of competitive governance out on the open ocean than shopping for T-Shirts online, then you've come to the right shirt. https://www.seasteading.org/https://ocean.builders/#men #women #tees #vees #funny\r\n\r\n\r\n•Anarchy, Thailand, Seasteading, Decentralization\r\n\",https://vangogh.teespring.com/v3/image/tJGT5I_ATvGW-Sj43N8AkjpVTYc/560/560.jpg,https://teespring.com/i-d-rather-be-seasteading-lt,I'd Rather Be Seasteading (LIGHT),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/tJGT5I_ATvGW-Sj43N8AkjpVTYc/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-seasteading,vol-attire-men,vol-attire-classic,vol-attire-tees,vol-attire-women\",\"Anarchy,Thailand,Libertarian,Seasteading\"\nhey-gloojes,in stock,new,\"From the time that guy came up with that thing to say.asdf\r\nhttps://twitter.com/Timcast/status/1171398383317200896\r\n#men #tees #funny\r\n\r\n\r\n•Twitter, SJW, Tim Pool\",https://vangogh.teespring.com/v3/image/oublMy0K5xb4eDrpIEAktSpQleo/560/560.jpg,https://teespring.com/hey-gloojes,Hey Gloojes!,25.99 USD,Teespring,http://vangogh.teespring.com/v3/image/oublMy0K5xb4eDrpIEAktSpQleo/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",vol-attire,\"Twitter,Sjw,Tim Pool\"\nnost-epon-snek-light,in stock,new,\"Christopher Gadsden, meets meme, meets lazy Scandinavian layout design.#men #women #tees #vees #streetwear\r\n\r\n\r\n•Flag, Libertarian, Don't Tread On Me, Gadsden, No Step On Snek\r\n\",https://vangogh.teespring.com/v3/image/tZTGnyIRF_4U3R4ySzKLOqrZWFg/560/560.jpg,https://teespring.com/nost-epon-snek-light,NOST-EPON-SNEK (LIGHT),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/tZTGnyIRF_4U3R4ySzKLOqrZWFg/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-women,vol-attire-streetwear,vol-attire-men\",\"Flag,Anarchy,Libertarian,Donttreadonme,Gadsden,No Step On Snek,New Listing,Dont Tread On Me\"\n2a-1-dark,in stock,new,\"If your F150 features a Molon Labe bumper sticker right next to a Thin Blue Line bumper sticker, you might want to buy a #CognitiveDissonance t-shirt instead.#men #women #tees #tanks #hoodies #vees #streetwear\r\n\r\n•Libertarian, 2nd Amendment, Gun Control, Molon Labe, Don't Tread On Me, Cops\r\n\",https://vangogh.teespring.com/v3/image/LLbOhU6wHJ6D1GNlbmePG2h_8yI/560/560.jpg,https://teespring.com/2a-1-dark,2A (#1 DARK),25.99 USD,Teespring,http://vangogh.teespring.com/v3/image/LLbOhU6wHJ6D1GNlbmePG2h_8yI/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-men,vol-attire-streetwear\",\"Streetwear,Libertarian,2a,2nd Amendment,Thin Blue Line,Gun Control,Molon Labe,Dont Tread On Me\"\ncircle-a-hawaiian-navy,in stock,new,\"If King Kamehameha read Rothbard.#men #women #tees #tanks #streetwear\r\n\r\n•Colorful, Anarchy, Hawaiian, Ancap, Anarcho Capitalist, Circle A, Summer\",https://vangogh.teespring.com/v3/image/gWSbMom2HHTzlPgcmnjV0kmw9rY/560/560.jpg,https://teespring.com/circle-a-hawaiian-navy,Circle A (HAWAIIAN #1),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/gWSbMom2HHTzlPgcmnjV0kmw9rY/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-streetwear,vol-attire-women,vol-attire-men,vol-attire-tanks,vol-attire-tees\",\"Streetwear,Anarchy,Flowers,Hawaii,Libertarian,Symbol,Ancap,Anarcho Capitalism,Circle A\"\njumpman-in-ancapistan,in stock,new,\"He can't run around crushing those turtle things without violating the NAP, so instead he's moonlighting as a flag-unhoister.\r\n\r\n#men #tees #streetwear\r\n\r\n•Ancap, Anarcho Capitalism, Mario, 8-Bit\",https://vangogh.teespring.com/v3/image/2p6yCy6u13qYIFQ5_K6Tac_WJVM/560/560.jpg,https://teespring.com/jumpman-in-ancapistan,Jumpman in Ancapistan,25.99 USD,Teespring,http://vangogh.teespring.com/v3/image/2p6yCy6u13qYIFQ5_K6Tac_WJVM/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-men,vol-attire-streetwear\",New Listing\nno-step-1-light,in stock,new,\"8-bit snake agrees with Christopher Gadsden.#men #tees #vees\r\n\r\n•Libertarian, Don't Tread On Me, Gadsden, No Step On Snek, 8-Bit, BogArt\r\n\",https://vangogh.teespring.com/v3/image/JPrPu3ARzZi5z1l8N1-mSCTpe9k/560/560.jpg,https://teespring.com/no-step-1-light,No Step (#1 LIGHT),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/JPrPu3ARzZi5z1l8N1-mSCTpe9k/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-men,vol-attire-tees,vol-attire-classic,vol-attire-streetwear\",New Listing\nan-ar-ch-y-dark,in stock,new,\"Because your letters can be inside the box as long as you ideas aren't\r\n\r\n#men #women #tees #hoodies #streetwear\r\n\r\n•Anarchy, Ancap, Geometric, Anarcho Capitalism, Minimalist\",https://vangogh.teespring.com/v3/image/G8NiZmsKWjKwcyDzkXQQzbCZPDA/560/560.jpg,https://teespring.com/an-ar-ch-y-dark,AN-AR-CH-Y (DARK),23.99 USD,Teespring,http://vangogh.teespring.com/v3/image/G8NiZmsKWjKwcyDzkXQQzbCZPDA/560/560.jpg,Apparel & Accessories > Clothing > Shirts & Tops,t_shirt,\"\",\"vol-attire,vol-attire-tees,vol-attire-women,vol-attire-streetwear,vol-attire-men\",\"Streetwear,Anarchy,Ancap,Anarcho Capitalist\"\n")});
|
||
}
|
||
}, {
|
||
key: 'UNSAFE_componentWillMount',
|
||
value: function UNSAFE_componentWillMount() {
|
||
var _this3 = this;
|
||
|
||
this.unlisten = this.props.history.listen(function (location, action) {
|
||
//var route = location.hash.replace('#/','');
|
||
var route = location.pathname.replace('/', '');
|
||
|
||
console.log("route changed to: " + route);
|
||
|
||
if (_this3.state.query !== route) {
|
||
console.log('#filter from route: ' + route);
|
||
_this3._onAppFilterChange(route);
|
||
}
|
||
});
|
||
}
|
||
}, {
|
||
key: 'componentWillUnmount',
|
||
value: function componentWillUnmount() {
|
||
this.unlisten();
|
||
window.removeEventListener('keypress', this._handleKeyPress);
|
||
}
|
||
|
||
// componentDidUpdate(){
|
||
// if(this.state.query !== this.props.match.params.query){
|
||
// this._onAppFilterChange(this.props.match.params.query);
|
||
// }
|
||
// }
|
||
|
||
}, {
|
||
key: 'render',
|
||
value: function render() {
|
||
|
||
return React.createElement(
|
||
'div',
|
||
{ className: this.state.frameCssClasses },
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'tag-bar' },
|
||
React.createElement(_typeMenu2.default, { onComponentFilterChange: this._onAppFilterChange }),
|
||
React.createElement(_tagMenu2.default, { items: this.state.origItems, onComponentFilterChange: this._onAppFilterChange })
|
||
),
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'social-bar' },
|
||
React.createElement(
|
||
'ul',
|
||
null,
|
||
React.createElement(
|
||
'li',
|
||
null,
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'mailto:team@wearvol.com' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/2709.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'email'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
null,
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://twitter.com/wearvol' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F426.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'twitter'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
{ className: 'hidden' },
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://www.instagram.com/wearvol/' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F4F7.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'instagram'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
null,
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://gab.com/wearvol' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F438.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'gab'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
null,
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://www.minds.com/wearvol/' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F4A1.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'minds'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
{ className: 'hidden' },
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://steemit.com/@wearvol' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F682.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'steemit'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
{ className: 'hidden' },
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://peepeth.com/wearvol' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F427.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'peepeth'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
{ className: 'hidden' },
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://liberdon.com/@wearvol' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/1F5FD.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'liberdon'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
{ className: 'hidden' },
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://twetch.app/u/4869' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/E245.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'twetch'
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'li',
|
||
{ className: 'hidden' },
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://flote.app/WearVol' },
|
||
React.createElement('img', { src: 'https://openmoji.org/data/black/svg/26F5.svg' }),
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'flote'
|
||
)
|
||
)
|
||
)
|
||
)
|
||
),
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'logolist-container' },
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'container logo-container' },
|
||
React.createElement('img', { className: 'logo',
|
||
src: 'https://d1muf25xaso8hp.cloudfront.net/https%3A%2F%2Fs3.amazonaws.com%2Fappforest_uf%2Ff1554687707730x758341742193788800%2Fsite_logo.png' })
|
||
),
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'list-container' },
|
||
React.createElement(_search2.default, {
|
||
query: this.state.query,
|
||
onComponentFilterChange: this._onAppFilterChange,
|
||
onComponentFilterClear: this._onAppFilterClear,
|
||
onFocusBlur: this._onAppFocusChange,
|
||
isFocused: this.state.isFocused,
|
||
items: this.state.items
|
||
}),
|
||
React.createElement(_shirtList2.default, {
|
||
items: this.state.items
|
||
})
|
||
)
|
||
)
|
||
);
|
||
}
|
||
}]);
|
||
|
||
return App;
|
||
}(React.Component);
|
||
|
||
ReactDOM.render(React.createElement(
|
||
ReactRouterDOM.HashRouter,
|
||
{ history: _history2.default },
|
||
React.createElement(ReactRouterDOM.Route, { exact: true, path: '/', component: App }),
|
||
React.createElement(ReactRouterDOM.Route, { exact: true, path: '/:query', component: App })
|
||
), document.querySelector('#root'));
|
||
|
||
//<Route exact path="/test/:userId" component={App} />
|
||
|
||
}).call(this,require('_process'))
|
||
},{"./history":59,"./search.js":60,"./shirtList.js":61,"./tagMenu.js":62,"./typeMenu.js":63,"_process":11,"csvjson":30}],56:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
var ContentEditable = function (_React$Component) {
|
||
_inherits(ContentEditable, _React$Component);
|
||
|
||
function ContentEditable(props) {
|
||
_classCallCheck(this, ContentEditable);
|
||
|
||
var _this = _possibleConstructorReturn(this, (ContentEditable.__proto__ || Object.getPrototypeOf(ContentEditable)).call(this, props));
|
||
|
||
_this._onChange = _this._onChange.bind(_this);
|
||
_this._onPaste = _this._onPaste.bind(_this);
|
||
_this._onKeyPress = _this._onKeyPress.bind(_this);
|
||
return _this;
|
||
}
|
||
|
||
_createClass(ContentEditable, [{
|
||
key: '_onChange',
|
||
value: function _onChange(ev) {
|
||
var method = this.getInnerMethod();
|
||
var value = this.elem[method];
|
||
|
||
this.props.onChange(ev, value);
|
||
}
|
||
}, {
|
||
key: '_onPaste',
|
||
value: function _onPaste(ev) {
|
||
var _props = this.props,
|
||
onPaste = _props.onPaste,
|
||
contentEditable = _props.contentEditable;
|
||
|
||
|
||
if (contentEditable === 'plaintext-only') {
|
||
ev.preventDefault();
|
||
var text = ev.clipboardData.getData("text");
|
||
document.execCommand('insertText', false, text);
|
||
}
|
||
|
||
if (onPaste) {
|
||
onPaste(ev);
|
||
}
|
||
}
|
||
}, {
|
||
key: '_onKeyPress',
|
||
value: function _onKeyPress(ev) {
|
||
var method = this.getInnerMethod();
|
||
var value = this.elem[method];
|
||
|
||
this.props.onKeyPress(ev, value);
|
||
}
|
||
}, {
|
||
key: 'getInnerMethod',
|
||
value: function getInnerMethod() {
|
||
return this.props.contentEditable === 'plaintext-only' ? 'innerText' : 'innerHTML';
|
||
}
|
||
|
||
// shouldComponentUpdate(nextProps, nextState) {
|
||
// const method = this.getInnerMethod();
|
||
// return nextProps.html !== this.elem[method];
|
||
// }
|
||
|
||
}, {
|
||
key: 'componentDidUpdate',
|
||
value: function componentDidUpdate(prevProp, prevState) {
|
||
this.refs.test.innerHTML = this.props.html;
|
||
}
|
||
}, {
|
||
key: 'render',
|
||
value: function render() {
|
||
var _props2 = this.props,
|
||
tagName = _props2.tagName,
|
||
html = _props2.html,
|
||
contentEditable = _props2.contentEditable,
|
||
props = _objectWithoutProperties(_props2, ['tagName', 'html', 'contentEditable']);
|
||
|
||
var Element = tagName || "div";
|
||
|
||
return React.createElement(Element, Object.assign({}, props, {
|
||
ref: 'test',
|
||
contentEditable: contentEditable === 'false' ? false : true,
|
||
onInput: this._onChange,
|
||
onPaste: this._onPaste
|
||
|
||
}));
|
||
}
|
||
}]);
|
||
|
||
return ContentEditable;
|
||
}(React.Component);
|
||
|
||
//dangerouslySetInnerHTML={{ __html: html }}
|
||
//ref={(elem) => { this.elem = elem }}
|
||
//onKeyPress={this._onKeyPress}
|
||
|
||
|
||
exports.default = ContentEditable;
|
||
|
||
},{}],57:[function(require,module,exports){
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
/*************************************************
|
||
* PlainTextContentEditable
|
||
* -----------------------------------------------
|
||
* Acts like a textarea but can be used with a
|
||
* column-width/count CSS styling
|
||
* -----------------------------------------------
|
||
* Props:
|
||
* - onChange : function(event)
|
||
* to get ev.target.value
|
||
* - placeholder: placeholder text
|
||
* - className : className to pass the div
|
||
*************************************************/
|
||
var PlainTextContentEditable = function (_React$Component) {
|
||
_inherits(PlainTextContentEditable, _React$Component);
|
||
|
||
function PlainTextContentEditable(props) {
|
||
_classCallCheck(this, PlainTextContentEditable);
|
||
|
||
var _this = _possibleConstructorReturn(this, (PlainTextContentEditable.__proto__ || Object.getPrototypeOf(PlainTextContentEditable)).call(this, props));
|
||
|
||
_this.state = { text: "" };
|
||
_this.getText = _this.getText.bind(_this);
|
||
_this.getTextForFirefox = _this.getTextForFirefox.bind(_this);
|
||
_this.onTextChange = _this.onTextChange.bind(_this);
|
||
_this.onPaste = _this.onPaste.bind(_this);
|
||
return _this;
|
||
}
|
||
|
||
// getDefaultProps() {
|
||
// return {
|
||
// onChange: function() {},
|
||
// placeholder: "",
|
||
// className: ""
|
||
// };
|
||
// }
|
||
|
||
_createClass(PlainTextContentEditable, [{
|
||
key: "getText",
|
||
value: function getText(el) {
|
||
return el.innerText || this.getTextForFirefox(el);
|
||
}
|
||
}, {
|
||
key: "getTextForFirefox",
|
||
value: function getTextForFirefox(el) {
|
||
// Taken from http://stackoverflow.com/a/3908094
|
||
var text = "";
|
||
if (typeof window.getSelection != "undefined") {
|
||
var sel = window.getSelection();
|
||
var tempRange = sel.getRangeAt(0);
|
||
sel.removeAllRanges();
|
||
var range = document.createRange();
|
||
range.selectNodeContents(el);
|
||
sel.addRange(range);
|
||
text = sel.toString();
|
||
sel.removeAllRanges();
|
||
sel.addRange(tempRange);
|
||
}
|
||
|
||
return text;
|
||
}
|
||
}, {
|
||
key: "onTextChange",
|
||
value: function onTextChange(ev) {
|
||
var text = this.getText(ev.target);
|
||
this.setState({ text: text });
|
||
this.props.onChange({
|
||
target: {
|
||
value: text
|
||
}
|
||
});
|
||
}
|
||
}, {
|
||
key: "onPaste",
|
||
value: function onPaste(ev) {
|
||
ev.preventDefault();
|
||
var text = ev.clipboardData.getData("text");
|
||
document.execCommand('insertText', false, text);
|
||
}
|
||
}, {
|
||
key: "getClassName",
|
||
value: function getClassName() {
|
||
var placeholder = this.state.text === "" ? "comPlainTextContentEditable--has-placeholder" : "";
|
||
return "comPlainTextContentEditable " + placeholder + " " + this.props.className;
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render() {
|
||
return React.createElement("div", {
|
||
ref: "content",
|
||
contentEditable: "true",
|
||
className: "search-div",
|
||
onPaste: this.onPaste,
|
||
onInput: this.onTextChange,
|
||
placeholder: this.props.placeholder
|
||
});
|
||
}
|
||
}]);
|
||
|
||
return PlainTextContentEditable;
|
||
}(React.Component);
|
||
|
||
exports.default = PlainTextContentEditable;
|
||
|
||
},{}],58:[function(require,module,exports){
|
||
"use strict";
|
||
|
||
var __extends = undefined && undefined.__extends || function () {
|
||
var _extendStatics = function extendStatics(d, b) {
|
||
_extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
|
||
d.__proto__ = b;
|
||
} || function (d, b) {
|
||
for (var p in b) {
|
||
if (b.hasOwnProperty(p)) d[p] = b[p];
|
||
}
|
||
};
|
||
return _extendStatics(d, b);
|
||
};
|
||
return function (d, b) {
|
||
_extendStatics(d, b);
|
||
function __() {
|
||
this.constructor = d;
|
||
}
|
||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||
};
|
||
}();
|
||
var __assign = undefined && undefined.__assign || function () {
|
||
__assign = Object.assign || function (t) {
|
||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||
s = arguments[i];
|
||
for (var p in s) {
|
||
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||
}
|
||
}
|
||
return t;
|
||
};
|
||
return __assign.apply(this, arguments);
|
||
};
|
||
var __rest = undefined && undefined.__rest || function (s, e) {
|
||
var t = {};
|
||
for (var p in s) {
|
||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
||
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
||
}
|
||
return t;
|
||
};
|
||
var __importStar = undefined && undefined.__importStar || function (mod) {
|
||
if (mod && mod.__esModule) return mod;
|
||
var result = {};
|
||
if (mod != null) for (var k in mod) {
|
||
if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||
}result["default"] = mod;
|
||
return result;
|
||
};
|
||
var __importDefault = undefined && undefined.__importDefault || function (mod) {
|
||
return mod && mod.__esModule ? mod : { "default": mod };
|
||
};
|
||
Object.defineProperty(exports, "__esModule", { value: true });
|
||
//var React = __importStar(require("react"));
|
||
var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
||
var PropTypes = __importStar(require("prop-types"));
|
||
function normalizeHtml(str) {
|
||
return str && str.replace(/ |\u202F|\u00A0/g, ' ');
|
||
}
|
||
function findLastTextNode(node) {
|
||
if (node.nodeType === Node.TEXT_NODE) return node;
|
||
var children = node.childNodes;
|
||
for (var i = children.length - 1; i >= 0; i--) {
|
||
var textNode = findLastTextNode(children[i]);
|
||
if (textNode !== null) return textNode;
|
||
}
|
||
return null;
|
||
}
|
||
function replaceCaret(el) {
|
||
// Place the caret at the end of the element
|
||
var target = findLastTextNode(el);
|
||
// do not move caret if element was not focused
|
||
var isTargetFocused = document.activeElement === el;
|
||
if (target !== null && target.nodeValue !== null && isTargetFocused) {
|
||
var sel = window.getSelection();
|
||
if (sel !== null) {
|
||
var range = document.createRange();
|
||
range.setStart(target, target.nodeValue.length);
|
||
range.collapse(true);
|
||
sel.removeAllRanges();
|
||
sel.addRange(range);
|
||
}
|
||
if (el instanceof HTMLElement) el.focus();
|
||
}
|
||
}
|
||
/**
|
||
* A simple component for an html element with editable contents.
|
||
*/
|
||
var ContentEditable = /** @class */function (_super) {
|
||
__extends(ContentEditable, _super);
|
||
function ContentEditable() {
|
||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||
_this.lastHtml = _this.props.html;
|
||
_this.el = typeof _this.props.innerRef === 'function' ? { current: null } : React.createRef();
|
||
_this.getEl = function () {
|
||
return (_this.props.innerRef && typeof _this.props.innerRef !== 'function' ? _this.props.innerRef : _this.el).current;
|
||
};
|
||
_this.emitChange = function (originalEvt) {
|
||
var el = _this.getEl();
|
||
if (!el) return;
|
||
var html = el.innerHTML;
|
||
if (_this.props.onChange && html !== _this.lastHtml) {
|
||
// Clone event with Object.assign to avoid
|
||
// "Cannot assign to read only property 'target' of object"
|
||
var evt = Object.assign({}, originalEvt, {
|
||
target: {
|
||
value: html
|
||
}
|
||
});
|
||
_this.props.onChange(evt);
|
||
}
|
||
_this.lastHtml = html;
|
||
};
|
||
return _this;
|
||
}
|
||
ContentEditable.prototype.render = function () {
|
||
var _this = this;
|
||
var _a = this.props,
|
||
tagName = _a.tagName,
|
||
html = _a.html,
|
||
innerRef = _a.innerRef,
|
||
props = __rest(_a, ["tagName", "html", "innerRef"]);
|
||
return React.createElement(tagName || 'div', __assign({}, props, { ref: typeof innerRef === 'function' ? function (current) {
|
||
innerRef(current);
|
||
_this.el.current = current;
|
||
} : innerRef || this.el, onInput: this.emitChange, onBlur: this.props.onBlur || this.emitChange, onKeyUp: this.props.onKeyUp || this.emitChange, onKeyDown: this.props.onKeyDown || this.emitChange, contentEditable: !this.props.disabled, dangerouslySetInnerHTML: { __html: html } }), this.props.children);
|
||
};
|
||
ContentEditable.prototype.shouldComponentUpdate = function (nextProps) {
|
||
var props = this.props;
|
||
var el = this.getEl();
|
||
// We need not rerender if the change of props simply reflects the user's edits.
|
||
// Rerendering in this case would make the cursor/caret jump
|
||
// Rerender if there is no element yet... (somehow?)
|
||
if (!el) return true;
|
||
// ...or if html really changed... (programmatically, not by user edit)
|
||
if (normalizeHtml(nextProps.html) !== normalizeHtml(el.innerHTML)) {
|
||
return true;
|
||
}
|
||
// Handle additional properties
|
||
return props.disabled !== nextProps.disabled || props.tagName !== nextProps.tagName || props.className !== nextProps.className || props.innerRef !== nextProps.innerRef || !fast_deep_equal_1.default(props.style, nextProps.style);
|
||
};
|
||
ContentEditable.prototype.componentDidUpdate = function () {
|
||
var el = this.getEl();
|
||
if (!el) return;
|
||
// Perhaps React (whose VDOM gets outdated because we often prevent
|
||
// rerendering) did not update the DOM. So we update it manually now.
|
||
if (this.props.html !== el.innerHTML) {
|
||
el.innerHTML = this.lastHtml = this.props.html;
|
||
}
|
||
replaceCaret(el);
|
||
};
|
||
ContentEditable.propTypes = {
|
||
html: PropTypes.string.isRequired,
|
||
onChange: PropTypes.func,
|
||
disabled: PropTypes.bool,
|
||
tagName: PropTypes.string,
|
||
className: PropTypes.string,
|
||
style: PropTypes.object,
|
||
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
|
||
};
|
||
return ContentEditable;
|
||
}(React.Component);
|
||
exports.default = ContentEditable;
|
||
|
||
},{"fast-deep-equal":34,"prop-types":42}],59:[function(require,module,exports){
|
||
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _history = require("history");
|
||
|
||
exports.default = (0, _history.createBrowserHistory)();
|
||
|
||
},{"history":37}],60:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
var _contentEditable = require('./contentEditable.js');
|
||
|
||
var _contentEditable2 = _interopRequireDefault(_contentEditable);
|
||
|
||
var _contentEditable3 = require('./contentEditable2.js');
|
||
|
||
var _contentEditable4 = _interopRequireDefault(_contentEditable3);
|
||
|
||
var _contentEditable5 = require('./contentEditable3.js');
|
||
|
||
var _contentEditable6 = _interopRequireDefault(_contentEditable5);
|
||
|
||
var _history = require('./history');
|
||
|
||
var _history2 = _interopRequireDefault(_history);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
var Search = function (_React$Component) {
|
||
_inherits(Search, _React$Component);
|
||
|
||
function Search(props) {
|
||
_classCallCheck(this, Search);
|
||
|
||
var _this = _possibleConstructorReturn(this, (Search.__proto__ || Object.getPrototypeOf(Search)).call(this, props));
|
||
|
||
_this._onFilterChange = _this._onFilterChange.bind(_this);
|
||
_this._onFocus = _this._onFocus.bind(_this);
|
||
_this._onBlur = _this._onBlur.bind(_this);
|
||
_this._clearFilter = _this._clearFilter.bind(_this);
|
||
_this.contentEditable = React.createRef();
|
||
return _this;
|
||
}
|
||
|
||
_createClass(Search, [{
|
||
key: '_onFilterChange',
|
||
value: function _onFilterChange(e) {
|
||
var query = e.target.value;
|
||
console.log('#filter from search component: ' + query);
|
||
|
||
var queryArray = query.split('');
|
||
|
||
// if first two characters are the same (from filter double firing) then send back just one
|
||
if (query.length == 2 && queryArray[0] == queryArray[1]) {
|
||
this.props.onComponentFilterChange(queryArray[0]);
|
||
} else {
|
||
this.props.onComponentFilterChange(query);
|
||
}
|
||
|
||
// if((!history.includes(query)) && (query.length > 4))
|
||
// {
|
||
// history.push(query);
|
||
// }
|
||
}
|
||
}, {
|
||
key: '_onFocus',
|
||
value: function _onFocus() {
|
||
this.props.onFocusBlur(true);
|
||
}
|
||
}, {
|
||
key: '_onBlur',
|
||
value: function _onBlur() {
|
||
this.props.onFocusBlur(false);
|
||
}
|
||
}, {
|
||
key: '_clearFilter',
|
||
value: function _clearFilter() {
|
||
console.log('cleared!');
|
||
this.props.onComponentFilterClear();
|
||
this.contentEditable.current.focus();
|
||
}
|
||
}, {
|
||
key: 'componentDidUpdate',
|
||
value: function componentDidUpdate() {
|
||
if (this.props.query) {
|
||
this.contentEditable.current.focus();
|
||
}
|
||
}
|
||
}, {
|
||
key: 'render',
|
||
value: function render() {
|
||
|
||
return React.createElement(
|
||
'div',
|
||
null,
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'search' },
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'search-control' },
|
||
React.createElement(_contentEditable6.default, {
|
||
className: 'search-div',
|
||
onFocus: this._onFocus,
|
||
onBlur: this._onBlur,
|
||
innerRef: this.contentEditable,
|
||
html: this.props.query // innerHTML of the editable div
|
||
, disabled: false // use true to disable editing
|
||
, onChange: this._onFilterChange // handle innerHTML change
|
||
, tagName: 'div' // Use a custom HTML tag (uses a div by default)
|
||
, spellCheck: 'false'
|
||
}),
|
||
React.createElement('div', { className: 'border' }),
|
||
React.createElement('div', { className: 'cursor' }),
|
||
React.createElement('button', {
|
||
className: 'clear-search',
|
||
onClick: this._clearFilter
|
||
})
|
||
),
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'counter-container' },
|
||
React.createElement(
|
||
'span',
|
||
{ className: 'counter' },
|
||
':',
|
||
this.props.items.length
|
||
)
|
||
)
|
||
)
|
||
);
|
||
}
|
||
}]);
|
||
|
||
return Search;
|
||
}(React.Component);
|
||
|
||
//export default Search;
|
||
|
||
|
||
exports.default = ReactRouterDOM.withRouter(Search);
|
||
|
||
/* <div contenteditable="true"
|
||
className="search-div"
|
||
onChange={this._onFilterChange}
|
||
onFocus={this._onFocus}
|
||
onBlur={this._onBlur}
|
||
>{this.props.query}</div> */
|
||
|
||
},{"./contentEditable.js":56,"./contentEditable2.js":57,"./contentEditable3.js":58,"./history":59}],61:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
var ShirtList = function (_React$Component) {
|
||
_inherits(ShirtList, _React$Component);
|
||
|
||
function ShirtList(props) {
|
||
_classCallCheck(this, ShirtList);
|
||
|
||
return _possibleConstructorReturn(this, (ShirtList.__proto__ || Object.getPrototypeOf(ShirtList)).call(this, props));
|
||
}
|
||
|
||
_createClass(ShirtList, [{
|
||
key: 'render',
|
||
value: function render() {
|
||
|
||
//console.log('ShirtListRender');
|
||
//console.log(this.props.items.length);
|
||
//console.log(this.props.items);
|
||
|
||
var list = this.props.items.map(function (shirt) {
|
||
return React.createElement(
|
||
'li',
|
||
{ key: shirt.id },
|
||
React.createElement(
|
||
'a',
|
||
{ href: shirt.link },
|
||
React.createElement(
|
||
'h1',
|
||
null,
|
||
shirt.title
|
||
),
|
||
React.createElement(
|
||
'div',
|
||
{ className: 'img-container' },
|
||
React.createElement('div', { className: 'img-frame' }),
|
||
React.createElement('img', { src: shirt.image_link, title: shirt.title })
|
||
)
|
||
),
|
||
React.createElement(
|
||
'ul',
|
||
{ className: 'tags' },
|
||
shirt.description.trim().split('ΓÇó').pop().split(',').map(function (tag) {
|
||
tag = tag.trim().toLowerCase();
|
||
|
||
return React.createElement(
|
||
'li',
|
||
{ key: tag },
|
||
'#',
|
||
tag
|
||
);
|
||
})
|
||
)
|
||
);
|
||
});
|
||
|
||
return React.createElement(
|
||
'div',
|
||
{ className: 'list' },
|
||
this.props.items.length !== 0 ? React.createElement(
|
||
'ul',
|
||
{ className: 'items' },
|
||
list
|
||
) : React.createElement(
|
||
'div',
|
||
{ className: 'empty' },
|
||
React.createElement(
|
||
'h1',
|
||
null,
|
||
'sounds like a great idea!'
|
||
),
|
||
React.createElement(
|
||
'p',
|
||
null,
|
||
'(or the gibberings of a madman)'
|
||
),
|
||
React.createElement(
|
||
'p',
|
||
null,
|
||
'Either way, we don\'t sell one of those yet, but if you have an idea for a design ',
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'mailto: team@wearvol.com' },
|
||
'email us'
|
||
),
|
||
' or hit us up on ',
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://twitter.com/wearvol' },
|
||
'Twitter'
|
||
),
|
||
', ',
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://gab.com/wearvol' },
|
||
'Gab'
|
||
),
|
||
', or ',
|
||
React.createElement(
|
||
'a',
|
||
{ href: 'https://minds.com/wearvol' },
|
||
'Minds'
|
||
),
|
||
' and we might be able to create it for you.'
|
||
)
|
||
)
|
||
);
|
||
}
|
||
}]);
|
||
|
||
return ShirtList;
|
||
}(React.Component);
|
||
|
||
exports.default = ShirtList;
|
||
|
||
},{}],62:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
var _history = require('./history');
|
||
|
||
var _history2 = _interopRequireDefault(_history);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
var TagMenu = function (_React$Component) {
|
||
_inherits(TagMenu, _React$Component);
|
||
|
||
function TagMenu(props) {
|
||
_classCallCheck(this, TagMenu);
|
||
|
||
var _this = _possibleConstructorReturn(this, (TagMenu.__proto__ || Object.getPrototypeOf(TagMenu)).call(this, props));
|
||
|
||
_this.onComponentFilterChange = _this.onComponentFilterChange.bind(_this);
|
||
_this.state = { tags: [] };
|
||
return _this;
|
||
}
|
||
|
||
_createClass(TagMenu, [{
|
||
key: 'onComponentFilterChange',
|
||
value: function onComponentFilterChange(tag) {
|
||
_history2.default.push(tag); // move to app, but keep it from firing on every input
|
||
this.props.onComponentFilterChange(tag);
|
||
}
|
||
}, {
|
||
key: 'render',
|
||
value: function render() {
|
||
|
||
var array = [];
|
||
var counts = Object.create(null);
|
||
this.props.items.map(function (item) {
|
||
|
||
item.description.trim().split('ΓÇó').pop().split(',').map(function (tag) {
|
||
|
||
tag = tag.trim().toLowerCase();
|
||
|
||
counts[tag] = counts[tag] ? counts[tag] + 1 : 1;
|
||
|
||
for (var i = 0; i < array.length; i++) {
|
||
if (array[i].tag === tag) {
|
||
array.splice(i, 1);
|
||
i--;
|
||
}
|
||
}
|
||
|
||
array.push({ tag: tag, count: counts[tag] });
|
||
});
|
||
});
|
||
|
||
return React.createElement(
|
||
'ul',
|
||
{ className: 'tag-menu' },
|
||
array.sort(function (a, z) {
|
||
// Ascending: first age less than the previous
|
||
return z.count - a.count || a.tag > z.tag;
|
||
}).map(function (tag) {
|
||
return React.createElement(
|
||
'li',
|
||
{ key: tag.tag },
|
||
React.createElement(
|
||
ReactRouterDOM.Link,
|
||
{ to: "/" + tag.tag },
|
||
React.createElement(
|
||
'span',
|
||
null,
|
||
'#',
|
||
tag.tag
|
||
),
|
||
React.createElement(
|
||
'sup',
|
||
{ className: 'badge' },
|
||
tag.count
|
||
)
|
||
)
|
||
);
|
||
})
|
||
//<a onClick={() => this.onComponentFilterChange(tag.tag)}><span>#{tag.tag}</span><sup className="badge">{tag.count}</sup></a>
|
||
|
||
);
|
||
}
|
||
}]);
|
||
|
||
return TagMenu;
|
||
}(React.Component);
|
||
|
||
exports.default = TagMenu;
|
||
|
||
},{"./history":59}],63:[function(require,module,exports){
|
||
'use strict';
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||
|
||
var _history = require('./history');
|
||
|
||
var _history2 = _interopRequireDefault(_history);
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||
|
||
var TypeMenu = function (_React$Component) {
|
||
_inherits(TypeMenu, _React$Component);
|
||
|
||
function TypeMenu(props) {
|
||
_classCallCheck(this, TypeMenu);
|
||
|
||
var _this = _possibleConstructorReturn(this, (TypeMenu.__proto__ || Object.getPrototypeOf(TypeMenu)).call(this, props));
|
||
|
||
_this.onComponentFilterChange = _this.onComponentFilterChange.bind(_this);
|
||
return _this;
|
||
}
|
||
|
||
_createClass(TypeMenu, [{
|
||
key: 'onComponentFilterChange',
|
||
value: function onComponentFilterChange(type) {
|
||
_history2.default.push(type); // move to app, but keep it from firing on every input
|
||
this.props.onComponentFilterChange(type);
|
||
}
|
||
}, {
|
||
key: 'componentDidMount',
|
||
value: function componentDidMount() {}
|
||
}, {
|
||
key: 'render',
|
||
value: function render() {
|
||
|
||
var types = ['streetwear', 'funny', 'men', 'women', 'kids', 'tees', 'vees', 'tanks', 'hoodies', 'swag'];
|
||
|
||
return React.createElement(
|
||
'ul',
|
||
{ className: 'type-menu' },
|
||
types.map(function (type) {
|
||
return React.createElement(
|
||
'li',
|
||
{ key: type },
|
||
React.createElement(
|
||
ReactRouterDOM.Link,
|
||
{ to: "/style:" + type },
|
||
type
|
||
)
|
||
);
|
||
})
|
||
);
|
||
}
|
||
}]);
|
||
|
||
return TypeMenu;
|
||
}(React.Component);
|
||
|
||
//const typeMenuContainer = document.querySelector('#type-menu--container');
|
||
//ReactDOM.render(<TypeMenu />, typeMenuContainer);
|
||
|
||
|
||
exports.default = TypeMenu;
|
||
|
||
},{"./history":59}]},{},[55]);
|