mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-11-25 17:06:52 +01:00
1ada95e04a
- Convert project to Javascript/Typescript - Allow custom headers to be passed in (optional) - Allow body to be optional
14606 lines
783 KiB
HTML
14606 lines
783 KiB
HTML
<!doctype html><html><head><meta charset="utf-8"></head><body><pre id="__testling_output"></pre><script>var e;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
(function (process){var xws = require('xhr-write-stream');
|
|
var Stream = require('stream');
|
|
var json = typeof JSON === 'object' ? JSON : require('jsonify');
|
|
var inspect = require('object-inspect');
|
|
|
|
process.on = function () {};
|
|
var ws = xws('/__testling/sock');
|
|
ws.write(window.location.hash + '\n');
|
|
|
|
function createChannel (writeListen) {
|
|
var c = new Stream;
|
|
c.writable = true;
|
|
c.write = function (buf) {
|
|
if (writeListen) writeListen(buf);
|
|
return ws.write(String(buf));
|
|
};
|
|
c.destroy = function () {};
|
|
c.end = function (buf) {
|
|
c.emit('close');
|
|
};
|
|
|
|
return c;
|
|
}
|
|
|
|
var lastTestId = 0;
|
|
process.stdout = createChannel(function (buf) {
|
|
var m = /^(?:not )? ok (\d+)/.exec(String(buf));
|
|
if (m) lastTestId = m[1];
|
|
});
|
|
process.stderr = createChannel();
|
|
process.stdout.on('close', function () { ws.end() });
|
|
process.exit = function () { ws.end() };
|
|
|
|
var oldError = window.onerror;
|
|
window.onerror = function (err, url, lineNum) {
|
|
var type = err && err.name || 'Error';
|
|
process.stdout.write(
|
|
'not ok ' + (lastTestId + 1) + ' ' + type + ': '
|
|
+ (err && err.message || String(err))
|
|
+ (lineNum ? ' on line ' + lineNum : '')
|
|
+ '\n'
|
|
);
|
|
if (err && err.stack) {
|
|
var lines = String(err.stack).split('\n');
|
|
var xs = [];
|
|
for (var i = 0; i < lines.length; i++) {
|
|
xs.push(' ' + lines[i]);
|
|
}
|
|
|
|
process.stdout.write([
|
|
' ---',
|
|
' stack:',
|
|
xs.join('\n'),
|
|
' ...'
|
|
].join('\n') + '\n');
|
|
}
|
|
ws.end();
|
|
|
|
if (typeof oldError === 'function') {
|
|
return oldError.apply(this, arguments);
|
|
}
|
|
};
|
|
window.__testlingErrorHandler = onerror;
|
|
|
|
if (typeof console === 'undefined') {
|
|
console = {};
|
|
}
|
|
|
|
var params = (function () {
|
|
var unesc = typeof decodeURIComponent !== 'undefined'
|
|
? decodeURIComponent : unescape
|
|
;
|
|
var parts = (window.location.search || '').replace(/^\?/, '').split('&');
|
|
var opts = {};
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var x = parts[i].split('=');
|
|
opts[unesc(x[0])] = unesc(x[1]);
|
|
}
|
|
return opts;
|
|
})();
|
|
|
|
var originalLog = console.log;
|
|
console.log = function (msg) {
|
|
var index = 1;
|
|
var args = arguments;
|
|
|
|
if (typeof msg === 'string') {
|
|
msg = msg.replace(/(^|[^%])%[sd]/g, function (_, s) {
|
|
return s + args[index++];
|
|
});
|
|
}
|
|
else msg = inspect(msg);
|
|
|
|
for (var i = index; i < args.length; i++) {
|
|
msg += ' ' + inspect(args[i]);
|
|
}
|
|
|
|
if (params.show === undefined || parseBoolean(params.show)) {
|
|
var elem = document.getElementById('__testling_output');
|
|
if (elem) {
|
|
var txt = document.createTextNode(msg + '\n');
|
|
elem.appendChild(txt);
|
|
}
|
|
}
|
|
process.stdout.write(msg + '\n');
|
|
|
|
if (typeof originalLog === 'function') {
|
|
return originalLog.apply(this, arguments);
|
|
}
|
|
else if (originalLog) return originalLog(arguments[0]);
|
|
};
|
|
|
|
window.__testlingConsole = console;
|
|
|
|
function parseBoolean (x) {
|
|
if (x === 'false' || x === '0') return false;
|
|
return true;
|
|
}
|
|
}).call(this,require("/home/substack/projects/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
|
|
},{"/home/substack/projects/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":8,"jsonify":27,"object-inspect":30,"stream":17,"xhr-write-stream":31}],2:[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.
|
|
|
|
function EventEmitter() {
|
|
this._events = this._events || {};
|
|
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.
|
|
EventEmitter.defaultMaxListeners = 10;
|
|
|
|
// 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(n) {
|
|
if (!isNumber(n) || n < 0 || isNaN(n))
|
|
throw TypeError('n must be a positive number');
|
|
this._maxListeners = n;
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.emit = function(type) {
|
|
var er, handler, len, args, i, listeners;
|
|
|
|
if (!this._events)
|
|
this._events = {};
|
|
|
|
// If there is no 'error' event listener then throw.
|
|
if (type === 'error') {
|
|
if (!this._events.error ||
|
|
(isObject(this._events.error) && !this._events.error.length)) {
|
|
er = arguments[1];
|
|
if (er instanceof Error) {
|
|
throw er; // Unhandled 'error' event
|
|
} else {
|
|
throw TypeError('Uncaught, unspecified "error" event.');
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
handler = this._events[type];
|
|
|
|
if (isUndefined(handler))
|
|
return false;
|
|
|
|
if (isFunction(handler)) {
|
|
switch (arguments.length) {
|
|
// fast cases
|
|
case 1:
|
|
handler.call(this);
|
|
break;
|
|
case 2:
|
|
handler.call(this, arguments[1]);
|
|
break;
|
|
case 3:
|
|
handler.call(this, arguments[1], arguments[2]);
|
|
break;
|
|
// slower
|
|
default:
|
|
len = arguments.length;
|
|
args = new Array(len - 1);
|
|
for (i = 1; i < len; i++)
|
|
args[i - 1] = arguments[i];
|
|
handler.apply(this, args);
|
|
}
|
|
} else if (isObject(handler)) {
|
|
len = arguments.length;
|
|
args = new Array(len - 1);
|
|
for (i = 1; i < len; i++)
|
|
args[i - 1] = arguments[i];
|
|
|
|
listeners = handler.slice();
|
|
len = listeners.length;
|
|
for (i = 0; i < len; i++)
|
|
listeners[i].apply(this, args);
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
EventEmitter.prototype.addListener = function(type, listener) {
|
|
var m;
|
|
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
|
|
if (!this._events)
|
|
this._events = {};
|
|
|
|
// To avoid recursion in the case that type === "newListener"! Before
|
|
// adding it to the listeners, first emit "newListener".
|
|
if (this._events.newListener)
|
|
this.emit('newListener', type,
|
|
isFunction(listener.listener) ?
|
|
listener.listener : listener);
|
|
|
|
if (!this._events[type])
|
|
// Optimize the case of one listener. Don't need the extra array object.
|
|
this._events[type] = listener;
|
|
else if (isObject(this._events[type]))
|
|
// If we've already got an array, just append.
|
|
this._events[type].push(listener);
|
|
else
|
|
// Adding the second element, need to change to array.
|
|
this._events[type] = [this._events[type], listener];
|
|
|
|
// Check for listener leak
|
|
if (isObject(this._events[type]) && !this._events[type].warned) {
|
|
var m;
|
|
if (!isUndefined(this._maxListeners)) {
|
|
m = this._maxListeners;
|
|
} else {
|
|
m = EventEmitter.defaultMaxListeners;
|
|
}
|
|
|
|
if (m && m > 0 && this._events[type].length > m) {
|
|
this._events[type].warned = true;
|
|
console.error('(node) warning: possible EventEmitter memory ' +
|
|
'leak detected. %d listeners added. ' +
|
|
'Use emitter.setMaxListeners() to increase limit.',
|
|
this._events[type].length);
|
|
console.trace();
|
|
}
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
|
|
EventEmitter.prototype.once = function(type, listener) {
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
|
|
var fired = false;
|
|
|
|
function g() {
|
|
this.removeListener(type, g);
|
|
|
|
if (!fired) {
|
|
fired = true;
|
|
listener.apply(this, arguments);
|
|
}
|
|
}
|
|
|
|
g.listener = listener;
|
|
this.on(type, g);
|
|
|
|
return this;
|
|
};
|
|
|
|
// emits a 'removeListener' event iff the listener was removed
|
|
EventEmitter.prototype.removeListener = function(type, listener) {
|
|
var list, position, length, i;
|
|
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
|
|
if (!this._events || !this._events[type])
|
|
return this;
|
|
|
|
list = this._events[type];
|
|
length = list.length;
|
|
position = -1;
|
|
|
|
if (list === listener ||
|
|
(isFunction(list.listener) && list.listener === listener)) {
|
|
delete this._events[type];
|
|
if (this._events.removeListener)
|
|
this.emit('removeListener', type, listener);
|
|
|
|
} else if (isObject(list)) {
|
|
for (i = length; i-- > 0;) {
|
|
if (list[i] === listener ||
|
|
(list[i].listener && list[i].listener === listener)) {
|
|
position = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (position < 0)
|
|
return this;
|
|
|
|
if (list.length === 1) {
|
|
list.length = 0;
|
|
delete this._events[type];
|
|
} else {
|
|
list.splice(position, 1);
|
|
}
|
|
|
|
if (this._events.removeListener)
|
|
this.emit('removeListener', type, listener);
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.removeAllListeners = function(type) {
|
|
var key, listeners;
|
|
|
|
if (!this._events)
|
|
return this;
|
|
|
|
// not listening for removeListener, no need to emit
|
|
if (!this._events.removeListener) {
|
|
if (arguments.length === 0)
|
|
this._events = {};
|
|
else if (this._events[type])
|
|
delete this._events[type];
|
|
return this;
|
|
}
|
|
|
|
// emit removeListener for all listeners on all events
|
|
if (arguments.length === 0) {
|
|
for (key in this._events) {
|
|
if (key === 'removeListener') continue;
|
|
this.removeAllListeners(key);
|
|
}
|
|
this.removeAllListeners('removeListener');
|
|
this._events = {};
|
|
return this;
|
|
}
|
|
|
|
listeners = this._events[type];
|
|
|
|
if (isFunction(listeners)) {
|
|
this.removeListener(type, listeners);
|
|
} else {
|
|
// LIFO order
|
|
while (listeners.length)
|
|
this.removeListener(type, listeners[listeners.length - 1]);
|
|
}
|
|
delete this._events[type];
|
|
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.listeners = function(type) {
|
|
var ret;
|
|
if (!this._events || !this._events[type])
|
|
ret = [];
|
|
else if (isFunction(this._events[type]))
|
|
ret = [this._events[type]];
|
|
else
|
|
ret = this._events[type].slice();
|
|
return ret;
|
|
};
|
|
|
|
EventEmitter.listenerCount = function(emitter, type) {
|
|
var ret;
|
|
if (!emitter._events || !emitter._events[type])
|
|
ret = 0;
|
|
else if (isFunction(emitter._events[type]))
|
|
ret = 1;
|
|
else
|
|
ret = emitter._events[type].length;
|
|
return ret;
|
|
};
|
|
|
|
function isFunction(arg) {
|
|
return typeof arg === 'function';
|
|
}
|
|
|
|
function isNumber(arg) {
|
|
return typeof arg === 'number';
|
|
}
|
|
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
|
|
function isUndefined(arg) {
|
|
return arg === void 0;
|
|
}
|
|
|
|
},{}],3:[function(require,module,exports){
|
|
var http = module.exports;
|
|
var EventEmitter = require('events').EventEmitter;
|
|
var Request = require('./lib/request');
|
|
var url = require('url')
|
|
|
|
http.request = function (params, cb) {
|
|
if (typeof params === 'string') {
|
|
params = url.parse(params)
|
|
}
|
|
if (!params) params = {};
|
|
if (!params.host && !params.port) {
|
|
params.port = parseInt(window.location.port, 10);
|
|
}
|
|
if (!params.host && params.hostname) {
|
|
params.host = params.hostname;
|
|
}
|
|
|
|
if (!params.scheme) params.scheme = window.location.protocol.split(':')[0];
|
|
if (!params.host) {
|
|
params.host = window.location.hostname || window.location.host;
|
|
}
|
|
if (/:/.test(params.host)) {
|
|
if (!params.port) {
|
|
params.port = params.host.split(':')[1];
|
|
}
|
|
params.host = params.host.split(':')[0];
|
|
}
|
|
if (!params.port) params.port = params.scheme == 'https' ? 443 : 80;
|
|
|
|
var req = new Request(new xhrHttp, params);
|
|
if (cb) req.on('response', cb);
|
|
return req;
|
|
};
|
|
|
|
http.get = function (params, cb) {
|
|
params.method = 'GET';
|
|
var req = http.request(params, cb);
|
|
req.end();
|
|
return req;
|
|
};
|
|
|
|
http.Agent = function () {};
|
|
http.Agent.defaultMaxSockets = 4;
|
|
|
|
var xhrHttp = (function () {
|
|
if (typeof window === 'undefined') {
|
|
throw new Error('no window object present');
|
|
}
|
|
else if (window.XMLHttpRequest) {
|
|
return window.XMLHttpRequest;
|
|
}
|
|
else if (window.ActiveXObject) {
|
|
var axs = [
|
|
'Msxml2.XMLHTTP.6.0',
|
|
'Msxml2.XMLHTTP.3.0',
|
|
'Microsoft.XMLHTTP'
|
|
];
|
|
for (var i = 0; i < axs.length; i++) {
|
|
try {
|
|
var ax = new(window.ActiveXObject)(axs[i]);
|
|
return function () {
|
|
if (ax) {
|
|
var ax_ = ax;
|
|
ax = null;
|
|
return ax_;
|
|
}
|
|
else {
|
|
return new(window.ActiveXObject)(axs[i]);
|
|
}
|
|
};
|
|
}
|
|
catch (e) {}
|
|
}
|
|
throw new Error('ajax not supported in this browser')
|
|
}
|
|
else {
|
|
throw new Error('ajax not supported in this browser');
|
|
}
|
|
})();
|
|
|
|
},{"./lib/request":4,"events":2,"url":24}],4:[function(require,module,exports){
|
|
var Stream = require('stream');
|
|
var Response = require('./response');
|
|
var Base64 = require('Base64');
|
|
var inherits = require('inherits');
|
|
|
|
var Request = module.exports = function (xhr, params) {
|
|
var self = this;
|
|
self.writable = true;
|
|
self.xhr = xhr;
|
|
self.body = [];
|
|
|
|
self.uri = (params.scheme || 'http') + '://'
|
|
+ params.host
|
|
+ (params.port ? ':' + params.port : '')
|
|
+ (params.path || '/')
|
|
;
|
|
|
|
try { xhr.withCredentials = true }
|
|
catch (e) {}
|
|
|
|
xhr.open(
|
|
params.method || 'GET',
|
|
self.uri,
|
|
true
|
|
);
|
|
|
|
if (params.headers) {
|
|
var keys = objectKeys(params.headers);
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
if (!self.isSafeRequestHeader(key)) continue;
|
|
var value = params.headers[key];
|
|
if (isArray(value)) {
|
|
for (var j = 0; j < value.length; j++) {
|
|
xhr.setRequestHeader(key, value[j]);
|
|
}
|
|
}
|
|
else xhr.setRequestHeader(key, value)
|
|
}
|
|
}
|
|
|
|
if (params.auth) {
|
|
//basic auth
|
|
this.setHeader('Authorization', 'Basic ' + Base64.btoa(params.auth));
|
|
}
|
|
|
|
var res = new Response;
|
|
res.on('close', function () {
|
|
self.emit('close');
|
|
});
|
|
|
|
res.on('ready', function () {
|
|
self.emit('response', res);
|
|
});
|
|
|
|
xhr.onreadystatechange = function () {
|
|
res.handle(xhr);
|
|
};
|
|
};
|
|
|
|
inherits(Request, Stream);
|
|
|
|
Request.prototype.setHeader = function (key, value) {
|
|
if (isArray(value)) {
|
|
for (var i = 0; i < value.length; i++) {
|
|
this.xhr.setRequestHeader(key, value[i]);
|
|
}
|
|
}
|
|
else {
|
|
this.xhr.setRequestHeader(key, value);
|
|
}
|
|
};
|
|
|
|
Request.prototype.write = function (s) {
|
|
this.body.push(s);
|
|
};
|
|
|
|
Request.prototype.destroy = function (s) {
|
|
this.xhr.abort();
|
|
this.emit('close');
|
|
};
|
|
|
|
Request.prototype.end = function (s) {
|
|
if (s !== undefined) this.body.push(s);
|
|
if (this.body.length === 0) {
|
|
this.xhr.send('');
|
|
}
|
|
else if (typeof this.body[0] === 'string') {
|
|
this.xhr.send(this.body.join(''));
|
|
}
|
|
else if (isArray(this.body[0])) {
|
|
var body = [];
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
body.push.apply(body, this.body[i]);
|
|
}
|
|
this.xhr.send(body);
|
|
}
|
|
else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) {
|
|
var len = 0;
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
len += this.body[i].length;
|
|
}
|
|
var body = new(this.body[0].constructor)(len);
|
|
var k = 0;
|
|
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
var b = this.body[i];
|
|
for (var j = 0; j < b.length; j++) {
|
|
body[k++] = b[j];
|
|
}
|
|
}
|
|
this.xhr.send(body);
|
|
}
|
|
else {
|
|
var body = '';
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
body += this.body[i].toString();
|
|
}
|
|
this.xhr.send(body);
|
|
}
|
|
};
|
|
|
|
// Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html
|
|
Request.unsafeHeaders = [
|
|
"accept-charset",
|
|
"accept-encoding",
|
|
"access-control-request-headers",
|
|
"access-control-request-method",
|
|
"connection",
|
|
"content-length",
|
|
"cookie",
|
|
"cookie2",
|
|
"content-transfer-encoding",
|
|
"date",
|
|
"expect",
|
|
"host",
|
|
"keep-alive",
|
|
"origin",
|
|
"referer",
|
|
"te",
|
|
"trailer",
|
|
"transfer-encoding",
|
|
"upgrade",
|
|
"user-agent",
|
|
"via"
|
|
];
|
|
|
|
Request.prototype.isSafeRequestHeader = function (headerName) {
|
|
if (!headerName) return false;
|
|
return indexOf(Request.unsafeHeaders, headerName.toLowerCase()) === -1;
|
|
};
|
|
|
|
var objectKeys = Object.keys || function (obj) {
|
|
var keys = [];
|
|
for (var key in obj) keys.push(key);
|
|
return keys;
|
|
};
|
|
|
|
var isArray = Array.isArray || function (xs) {
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
};
|
|
|
|
var indexOf = function (xs, x) {
|
|
if (xs.indexOf) return xs.indexOf(x);
|
|
for (var i = 0; i < xs.length; i++) {
|
|
if (xs[i] === x) return i;
|
|
}
|
|
return -1;
|
|
};
|
|
|
|
},{"./response":5,"Base64":6,"inherits":7,"stream":17}],5:[function(require,module,exports){
|
|
var Stream = require('stream');
|
|
var util = require('util');
|
|
|
|
var Response = module.exports = function (res) {
|
|
this.offset = 0;
|
|
this.readable = true;
|
|
};
|
|
|
|
util.inherits(Response, Stream);
|
|
|
|
var capable = {
|
|
streaming : true,
|
|
status2 : true
|
|
};
|
|
|
|
function parseHeaders (res) {
|
|
var lines = res.getAllResponseHeaders().split(/\r?\n/);
|
|
var headers = {};
|
|
for (var i = 0; i < lines.length; i++) {
|
|
var line = lines[i];
|
|
if (line === '') continue;
|
|
|
|
var m = line.match(/^([^:]+):\s*(.*)/);
|
|
if (m) {
|
|
var key = m[1].toLowerCase(), value = m[2];
|
|
|
|
if (headers[key] !== undefined) {
|
|
|
|
if (isArray(headers[key])) {
|
|
headers[key].push(value);
|
|
}
|
|
else {
|
|
headers[key] = [ headers[key], value ];
|
|
}
|
|
}
|
|
else {
|
|
headers[key] = value;
|
|
}
|
|
}
|
|
else {
|
|
headers[line] = true;
|
|
}
|
|
}
|
|
return headers;
|
|
}
|
|
|
|
Response.prototype.getResponse = function (xhr) {
|
|
var respType = String(xhr.responseType).toLowerCase();
|
|
if (respType === 'blob') return xhr.responseBlob || xhr.response;
|
|
if (respType === 'arraybuffer') return xhr.response;
|
|
return xhr.responseText;
|
|
}
|
|
|
|
Response.prototype.getHeader = function (key) {
|
|
return this.headers[key.toLowerCase()];
|
|
};
|
|
|
|
Response.prototype.handle = function (res) {
|
|
if (res.readyState === 2 && capable.status2) {
|
|
try {
|
|
this.statusCode = res.status;
|
|
this.headers = parseHeaders(res);
|
|
}
|
|
catch (err) {
|
|
capable.status2 = false;
|
|
}
|
|
|
|
if (capable.status2) {
|
|
this.emit('ready');
|
|
}
|
|
}
|
|
else if (capable.streaming && res.readyState === 3) {
|
|
try {
|
|
if (!this.statusCode) {
|
|
this.statusCode = res.status;
|
|
this.headers = parseHeaders(res);
|
|
this.emit('ready');
|
|
}
|
|
}
|
|
catch (err) {}
|
|
|
|
try {
|
|
this._emitData(res);
|
|
}
|
|
catch (err) {
|
|
capable.streaming = false;
|
|
}
|
|
}
|
|
else if (res.readyState === 4) {
|
|
if (!this.statusCode) {
|
|
this.statusCode = res.status;
|
|
this.emit('ready');
|
|
}
|
|
this._emitData(res);
|
|
|
|
if (res.error) {
|
|
this.emit('error', this.getResponse(res));
|
|
}
|
|
else this.emit('end');
|
|
|
|
this.emit('close');
|
|
}
|
|
};
|
|
|
|
Response.prototype._emitData = function (res) {
|
|
var respBody = this.getResponse(res);
|
|
if (respBody.toString().match(/ArrayBuffer/)) {
|
|
this.emit('data', new Uint8Array(respBody, this.offset));
|
|
this.offset = respBody.byteLength;
|
|
return;
|
|
}
|
|
if (respBody.length > this.offset) {
|
|
this.emit('data', respBody.slice(this.offset));
|
|
this.offset = respBody.length;
|
|
}
|
|
};
|
|
|
|
var isArray = Array.isArray || function (xs) {
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
};
|
|
|
|
},{"stream":17,"util":26}],6:[function(require,module,exports){
|
|
;(function () {
|
|
|
|
var object = typeof exports != 'undefined' ? exports : this; // #8: web workers
|
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
|
|
function InvalidCharacterError(message) {
|
|
this.message = message;
|
|
}
|
|
InvalidCharacterError.prototype = new Error;
|
|
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
|
|
|
// encoder
|
|
// [https://gist.github.com/999166] by [https://github.com/nignag]
|
|
object.btoa || (
|
|
object.btoa = function (input) {
|
|
for (
|
|
// initialize result and counter
|
|
var block, charCode, idx = 0, map = chars, output = '';
|
|
// if the next input index does not exist:
|
|
// change the mapping table to "="
|
|
// check if d has no fractional digits
|
|
input.charAt(idx | 0) || (map = '=', idx % 1);
|
|
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
|
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
|
) {
|
|
charCode = input.charCodeAt(idx += 3/4);
|
|
if (charCode > 0xFF) {
|
|
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
|
}
|
|
block = block << 8 | charCode;
|
|
}
|
|
return output;
|
|
});
|
|
|
|
// decoder
|
|
// [https://gist.github.com/1020396] by [https://github.com/atk]
|
|
object.atob || (
|
|
object.atob = function (input) {
|
|
input = input.replace(/=+$/, '')
|
|
if (input.length % 4 == 1) {
|
|
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
}
|
|
for (
|
|
// initialize result and counters
|
|
var bc = 0, bs, buffer, idx = 0, output = '';
|
|
// get next character
|
|
buffer = input.charAt(idx++);
|
|
// character found in table? initialize bit storage and add its ascii value;
|
|
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
|
// and if not first of each 4 characters,
|
|
// convert the first 8 bits to one ascii character
|
|
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
|
|
) {
|
|
// try to find character in table (0-63, not found => -1)
|
|
buffer = chars.indexOf(buffer);
|
|
}
|
|
return output;
|
|
});
|
|
|
|
}());
|
|
|
|
},{}],7:[function(require,module,exports){
|
|
if (typeof Object.create === 'function') {
|
|
// implementation from standard node.js 'util' module
|
|
module.exports = function inherits(ctor, 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) {
|
|
ctor.super_ = superCtor
|
|
var TempCtor = function () {}
|
|
TempCtor.prototype = superCtor.prototype
|
|
ctor.prototype = new TempCtor()
|
|
ctor.prototype.constructor = ctor
|
|
}
|
|
}
|
|
|
|
},{}],8:[function(require,module,exports){
|
|
// shim for using process in browser
|
|
|
|
var process = module.exports = {};
|
|
|
|
process.nextTick = (function () {
|
|
var canSetImmediate = typeof window !== 'undefined'
|
|
&& window.setImmediate;
|
|
var canPost = typeof window !== 'undefined'
|
|
&& window.postMessage && window.addEventListener
|
|
;
|
|
|
|
if (canSetImmediate) {
|
|
return function (f) { return window.setImmediate(f) };
|
|
}
|
|
|
|
if (canPost) {
|
|
var queue = [];
|
|
window.addEventListener('message', function (ev) {
|
|
var source = ev.source;
|
|
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
ev.stopPropagation();
|
|
if (queue.length > 0) {
|
|
var fn = queue.shift();
|
|
fn();
|
|
}
|
|
}
|
|
}, true);
|
|
|
|
return function nextTick(fn) {
|
|
queue.push(fn);
|
|
window.postMessage('process-tick', '*');
|
|
};
|
|
}
|
|
|
|
return function nextTick(fn) {
|
|
setTimeout(fn, 0);
|
|
};
|
|
})();
|
|
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
}
|
|
|
|
// TODO(shtylman)
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
|
|
},{}],9:[function(require,module,exports){
|
|
var base64 = require('base64-js')
|
|
var ieee754 = require('ieee754')
|
|
|
|
exports.Buffer = Buffer
|
|
exports.SlowBuffer = Buffer
|
|
exports.INSPECT_MAX_BYTES = 50
|
|
Buffer.poolSize = 8192
|
|
|
|
/**
|
|
* If `Buffer._useTypedArrays`:
|
|
* === true Use Uint8Array implementation (fastest)
|
|
* === false Use Object implementation (compatible down to IE6)
|
|
*/
|
|
Buffer._useTypedArrays = (function () {
|
|
// Detect if browser supports Typed Arrays. Supported browsers are IE 10+,
|
|
// Firefox 4+, Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+.
|
|
if (typeof Uint8Array === 'undefined' || typeof ArrayBuffer === 'undefined')
|
|
return false
|
|
|
|
// Does the browser support adding properties to `Uint8Array` instances? If
|
|
// not, then that's the same as no `Uint8Array` support. We need to be able to
|
|
// add all the node Buffer API methods.
|
|
// Relevant Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
|
|
try {
|
|
var arr = new Uint8Array(0)
|
|
arr.foo = function () { return 42 }
|
|
return 42 === arr.foo() &&
|
|
typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
})()
|
|
|
|
/**
|
|
* Class: Buffer
|
|
* =============
|
|
*
|
|
* The Buffer constructor returns instances of `Uint8Array` that are augmented
|
|
* with function properties for all the node `Buffer` API functions. We use
|
|
* `Uint8Array` so that square bracket notation works as expected -- it returns
|
|
* a single octet.
|
|
*
|
|
* By augmenting the instances, we can avoid modifying the `Uint8Array`
|
|
* prototype.
|
|
*/
|
|
function Buffer (subject, encoding, noZero) {
|
|
if (!(this instanceof Buffer))
|
|
return new Buffer(subject, encoding, noZero)
|
|
|
|
var type = typeof subject
|
|
|
|
// Workaround: node's base64 implementation allows for non-padded strings
|
|
// while base64-js does not.
|
|
if (encoding === 'base64' && type === 'string') {
|
|
subject = stringtrim(subject)
|
|
while (subject.length % 4 !== 0) {
|
|
subject = subject + '='
|
|
}
|
|
}
|
|
|
|
// Find the length
|
|
var length
|
|
if (type === 'number')
|
|
length = coerce(subject)
|
|
else if (type === 'string')
|
|
length = Buffer.byteLength(subject, encoding)
|
|
else if (type === 'object')
|
|
length = coerce(subject.length) // Assume object is an array
|
|
else
|
|
throw new Error('First argument needs to be a number, array or string.')
|
|
|
|
var buf
|
|
if (Buffer._useTypedArrays) {
|
|
// Preferred: Return an augmented `Uint8Array` instance for best performance
|
|
buf = augment(new Uint8Array(length))
|
|
} else {
|
|
// Fallback: Return THIS instance of Buffer (created by `new`)
|
|
buf = this
|
|
buf.length = length
|
|
buf._isBuffer = true
|
|
}
|
|
|
|
var i
|
|
if (Buffer._useTypedArrays && typeof Uint8Array === 'function' &&
|
|
subject instanceof Uint8Array) {
|
|
// Speed optimization -- use set if we're copying from a Uint8Array
|
|
buf._set(subject)
|
|
} else if (isArrayish(subject)) {
|
|
// Treat array-ish objects as a byte array
|
|
for (i = 0; i < length; i++) {
|
|
if (Buffer.isBuffer(subject))
|
|
buf[i] = subject.readUInt8(i)
|
|
else
|
|
buf[i] = subject[i]
|
|
}
|
|
} else if (type === 'string') {
|
|
buf.write(subject, 0, encoding)
|
|
} else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
|
|
for (i = 0; i < length; i++) {
|
|
buf[i] = 0
|
|
}
|
|
}
|
|
|
|
return buf
|
|
}
|
|
|
|
// STATIC METHODS
|
|
// ==============
|
|
|
|
Buffer.isEncoding = function (encoding) {
|
|
switch (String(encoding).toLowerCase()) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'raw':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
Buffer.isBuffer = function (b) {
|
|
return !!(b !== null && b !== undefined && b._isBuffer)
|
|
}
|
|
|
|
Buffer.byteLength = function (str, encoding) {
|
|
var ret
|
|
str = str + ''
|
|
switch (encoding || 'utf8') {
|
|
case 'hex':
|
|
ret = str.length / 2
|
|
break
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
ret = utf8ToBytes(str).length
|
|
break
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'raw':
|
|
ret = str.length
|
|
break
|
|
case 'base64':
|
|
ret = base64ToBytes(str).length
|
|
break
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
ret = str.length * 2
|
|
break
|
|
default:
|
|
throw new Error('Unknown encoding')
|
|
}
|
|
return ret
|
|
}
|
|
|
|
Buffer.concat = function (list, totalLength) {
|
|
assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' +
|
|
'list should be an Array.')
|
|
|
|
if (list.length === 0) {
|
|
return new Buffer(0)
|
|
} else if (list.length === 1) {
|
|
return list[0]
|
|
}
|
|
|
|
var i
|
|
if (typeof totalLength !== 'number') {
|
|
totalLength = 0
|
|
for (i = 0; i < list.length; i++) {
|
|
totalLength += list[i].length
|
|
}
|
|
}
|
|
|
|
var buf = new Buffer(totalLength)
|
|
var pos = 0
|
|
for (i = 0; i < list.length; i++) {
|
|
var item = list[i]
|
|
item.copy(buf, pos)
|
|
pos += item.length
|
|
}
|
|
return buf
|
|
}
|
|
|
|
// BUFFER INSTANCE METHODS
|
|
// =======================
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
// must be an even number of digits
|
|
var strLen = string.length
|
|
assert(strLen % 2 === 0, 'Invalid hex string')
|
|
|
|
if (length > strLen / 2) {
|
|
length = strLen / 2
|
|
}
|
|
for (var i = 0; i < length; i++) {
|
|
var byte = parseInt(string.substr(i * 2, 2), 16)
|
|
assert(!isNaN(byte), 'Invalid hex string')
|
|
buf[offset + i] = byte
|
|
}
|
|
Buffer._charsWritten = i * 2
|
|
return i
|
|
}
|
|
|
|
function _utf8Write (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(utf8ToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
function _asciiWrite (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
function _binaryWrite (buf, string, offset, length) {
|
|
return _asciiWrite(buf, string, offset, length)
|
|
}
|
|
|
|
function _base64Write (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
Buffer.prototype.write = function (string, offset, length, encoding) {
|
|
// Support both (string, offset, length, encoding)
|
|
// and the legacy (string, encoding, offset, length)
|
|
if (isFinite(offset)) {
|
|
if (!isFinite(length)) {
|
|
encoding = length
|
|
length = undefined
|
|
}
|
|
} else { // legacy
|
|
var swap = encoding
|
|
encoding = offset
|
|
offset = length
|
|
length = swap
|
|
}
|
|
|
|
offset = Number(offset) || 0
|
|
var remaining = this.length - offset
|
|
if (!length) {
|
|
length = remaining
|
|
} else {
|
|
length = Number(length)
|
|
if (length > remaining) {
|
|
length = remaining
|
|
}
|
|
}
|
|
encoding = String(encoding || 'utf8').toLowerCase()
|
|
|
|
switch (encoding) {
|
|
case 'hex':
|
|
return _hexWrite(this, string, offset, length)
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return _utf8Write(this, string, offset, length)
|
|
case 'ascii':
|
|
return _asciiWrite(this, string, offset, length)
|
|
case 'binary':
|
|
return _binaryWrite(this, string, offset, length)
|
|
case 'base64':
|
|
return _base64Write(this, string, offset, length)
|
|
default:
|
|
throw new Error('Unknown encoding')
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.toString = function (encoding, start, end) {
|
|
var self = this
|
|
|
|
encoding = String(encoding || 'utf8').toLowerCase()
|
|
start = Number(start) || 0
|
|
end = (end !== undefined)
|
|
? Number(end)
|
|
: end = self.length
|
|
|
|
// Fastpath empty strings
|
|
if (end === start)
|
|
return ''
|
|
|
|
switch (encoding) {
|
|
case 'hex':
|
|
return _hexSlice(self, start, end)
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ucs2': // TODO: No support for ucs2 or utf16le encodings yet
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return _utf8Slice(self, start, end)
|
|
case 'ascii':
|
|
return _asciiSlice(self, start, end)
|
|
case 'binary':
|
|
return _binarySlice(self, start, end)
|
|
case 'base64':
|
|
return _base64Slice(self, start, end)
|
|
default:
|
|
throw new Error('Unknown encoding')
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.toJSON = function () {
|
|
return {
|
|
type: 'Buffer',
|
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
}
|
|
}
|
|
|
|
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
Buffer.prototype.copy = function (target, target_start, start, end) {
|
|
var source = this
|
|
|
|
if (!start) start = 0
|
|
if (!end && end !== 0) end = this.length
|
|
if (!target_start) target_start = 0
|
|
|
|
// Copy 0 bytes; we're done
|
|
if (end === start) return
|
|
if (target.length === 0 || source.length === 0) return
|
|
|
|
// Fatal error conditions
|
|
assert(end >= start, 'sourceEnd < sourceStart')
|
|
assert(target_start >= 0 && target_start < target.length,
|
|
'targetStart out of bounds')
|
|
assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
|
|
assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
|
|
|
|
// Are we oob?
|
|
if (end > this.length)
|
|
end = this.length
|
|
if (target.length - target_start < end - start)
|
|
end = target.length - target_start + start
|
|
|
|
// copy!
|
|
for (var i = 0; i < end - start; i++)
|
|
target[i + target_start] = this[i + start]
|
|
}
|
|
|
|
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) {
|
|
var res = ''
|
|
var tmp = ''
|
|
end = Math.min(buf.length, end)
|
|
|
|
for (var i = start; i < end; i++) {
|
|
if (buf[i] <= 0x7F) {
|
|
res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
|
|
tmp = ''
|
|
} else {
|
|
tmp += '%' + buf[i].toString(16)
|
|
}
|
|
}
|
|
|
|
return res + decodeUtf8Char(tmp)
|
|
}
|
|
|
|
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])
|
|
return ret
|
|
}
|
|
|
|
function _binarySlice (buf, start, end) {
|
|
return _asciiSlice(buf, start, end)
|
|
}
|
|
|
|
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 += toHex(buf[i])
|
|
}
|
|
return out
|
|
}
|
|
|
|
// http://nodejs.org/api/buffer.html#buffer_buf_slice_start_end
|
|
Buffer.prototype.slice = function (start, end) {
|
|
var len = this.length
|
|
start = clamp(start, len, 0)
|
|
end = clamp(end, len, len)
|
|
|
|
if (Buffer._useTypedArrays) {
|
|
return augment(this.subarray(start, end))
|
|
} else {
|
|
var sliceLen = end - start
|
|
var newBuf = new Buffer(sliceLen, undefined, true)
|
|
for (var i = 0; i < sliceLen; i++) {
|
|
newBuf[i] = this[i + start]
|
|
}
|
|
return newBuf
|
|
}
|
|
}
|
|
|
|
// `get` will be removed in Node 0.13+
|
|
Buffer.prototype.get = function (offset) {
|
|
console.log('.get() is deprecated. Access using array indexes instead.')
|
|
return this.readUInt8(offset)
|
|
}
|
|
|
|
// `set` will be removed in Node 0.13+
|
|
Buffer.prototype.set = function (v, offset) {
|
|
console.log('.set() is deprecated. Access using array indexes instead.')
|
|
return this.writeUInt8(v, offset)
|
|
}
|
|
|
|
Buffer.prototype.readUInt8 = function (offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset < this.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
if (offset >= this.length)
|
|
return
|
|
|
|
return this[offset]
|
|
}
|
|
|
|
function _readUInt16 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val
|
|
if (littleEndian) {
|
|
val = buf[offset]
|
|
if (offset + 1 < len)
|
|
val |= buf[offset + 1] << 8
|
|
} else {
|
|
val = buf[offset] << 8
|
|
if (offset + 1 < len)
|
|
val |= buf[offset + 1]
|
|
}
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readUInt16LE = function (offset, noAssert) {
|
|
return _readUInt16(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readUInt16BE = function (offset, noAssert) {
|
|
return _readUInt16(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readUInt32 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val
|
|
if (littleEndian) {
|
|
if (offset + 2 < len)
|
|
val = buf[offset + 2] << 16
|
|
if (offset + 1 < len)
|
|
val |= buf[offset + 1] << 8
|
|
val |= buf[offset]
|
|
if (offset + 3 < len)
|
|
val = val + (buf[offset + 3] << 24 >>> 0)
|
|
} else {
|
|
if (offset + 1 < len)
|
|
val = buf[offset + 1] << 16
|
|
if (offset + 2 < len)
|
|
val |= buf[offset + 2] << 8
|
|
if (offset + 3 < len)
|
|
val |= buf[offset + 3]
|
|
val = val + (buf[offset] << 24 >>> 0)
|
|
}
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readUInt32LE = function (offset, noAssert) {
|
|
return _readUInt32(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readUInt32BE = function (offset, noAssert) {
|
|
return _readUInt32(this, offset, false, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readInt8 = function (offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(offset !== undefined && offset !== null,
|
|
'missing offset')
|
|
assert(offset < this.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
if (offset >= this.length)
|
|
return
|
|
|
|
var neg = this[offset] & 0x80
|
|
if (neg)
|
|
return (0xff - this[offset] + 1) * -1
|
|
else
|
|
return this[offset]
|
|
}
|
|
|
|
function _readInt16 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val = _readUInt16(buf, offset, littleEndian, true)
|
|
var neg = val & 0x8000
|
|
if (neg)
|
|
return (0xffff - val + 1) * -1
|
|
else
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readInt16LE = function (offset, noAssert) {
|
|
return _readInt16(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readInt16BE = function (offset, noAssert) {
|
|
return _readInt16(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readInt32 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val = _readUInt32(buf, offset, littleEndian, true)
|
|
var neg = val & 0x80000000
|
|
if (neg)
|
|
return (0xffffffff - val + 1) * -1
|
|
else
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readInt32LE = function (offset, noAssert) {
|
|
return _readInt32(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readInt32BE = function (offset, noAssert) {
|
|
return _readInt32(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readFloat (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
return ieee754.read(buf, offset, littleEndian, 23, 4)
|
|
}
|
|
|
|
Buffer.prototype.readFloatLE = function (offset, noAssert) {
|
|
return _readFloat(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readFloatBE = function (offset, noAssert) {
|
|
return _readFloat(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readDouble (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
return ieee754.read(buf, offset, littleEndian, 52, 8)
|
|
}
|
|
|
|
Buffer.prototype.readDoubleLE = function (offset, noAssert) {
|
|
return _readDouble(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readDoubleBE = function (offset, noAssert) {
|
|
return _readDouble(this, offset, false, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset < this.length, 'trying to write beyond buffer length')
|
|
verifuint(value, 0xff)
|
|
}
|
|
|
|
if (offset >= this.length) return
|
|
|
|
this[offset] = value
|
|
}
|
|
|
|
function _writeUInt16 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
|
|
verifuint(value, 0xffff)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
|
|
buf[offset + i] =
|
|
(value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
(littleEndian ? i : 1 - i) * 8
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
|
|
_writeUInt16(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
|
|
_writeUInt16(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeUInt32 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
|
|
verifuint(value, 0xffffffff)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
|
|
buf[offset + i] =
|
|
(value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
|
|
_writeUInt32(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
|
|
_writeUInt32(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset < this.length, 'Trying to write beyond buffer length')
|
|
verifsint(value, 0x7f, -0x80)
|
|
}
|
|
|
|
if (offset >= this.length)
|
|
return
|
|
|
|
if (value >= 0)
|
|
this.writeUInt8(value, offset, noAssert)
|
|
else
|
|
this.writeUInt8(0xff + value + 1, offset, noAssert)
|
|
}
|
|
|
|
function _writeInt16 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
|
|
verifsint(value, 0x7fff, -0x8000)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
if (value >= 0)
|
|
_writeUInt16(buf, value, offset, littleEndian, noAssert)
|
|
else
|
|
_writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
|
|
_writeInt16(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
|
|
_writeInt16(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeInt32 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
verifsint(value, 0x7fffffff, -0x80000000)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
if (value >= 0)
|
|
_writeUInt32(buf, value, offset, littleEndian, noAssert)
|
|
else
|
|
_writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
|
|
_writeInt32(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
|
|
_writeInt32(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
}
|
|
|
|
Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
|
|
_writeFloat(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
|
|
_writeFloat(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 7 < buf.length,
|
|
'Trying to write beyond buffer length')
|
|
verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
}
|
|
|
|
Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
|
|
_writeDouble(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
|
|
_writeDouble(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
// fill(value, start=0, end=buffer.length)
|
|
Buffer.prototype.fill = function (value, start, end) {
|
|
if (!value) value = 0
|
|
if (!start) start = 0
|
|
if (!end) end = this.length
|
|
|
|
if (typeof value === 'string') {
|
|
value = value.charCodeAt(0)
|
|
}
|
|
|
|
assert(typeof value === 'number' && !isNaN(value), 'value is not a number')
|
|
assert(end >= start, 'end < start')
|
|
|
|
// Fill 0 bytes; we're done
|
|
if (end === start) return
|
|
if (this.length === 0) return
|
|
|
|
assert(start >= 0 && start < this.length, 'start out of bounds')
|
|
assert(end >= 0 && end <= this.length, 'end out of bounds')
|
|
|
|
for (var i = start; i < end; i++) {
|
|
this[i] = value
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.inspect = function () {
|
|
var out = []
|
|
var len = this.length
|
|
for (var i = 0; i < len; i++) {
|
|
out[i] = toHex(this[i])
|
|
if (i === exports.INSPECT_MAX_BYTES) {
|
|
out[i + 1] = '...'
|
|
break
|
|
}
|
|
}
|
|
return '<Buffer ' + out.join(' ') + '>'
|
|
}
|
|
|
|
/**
|
|
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
|
|
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
|
|
*/
|
|
Buffer.prototype.toArrayBuffer = function () {
|
|
if (typeof Uint8Array === 'function') {
|
|
if (Buffer._useTypedArrays) {
|
|
return (new Buffer(this)).buffer
|
|
} else {
|
|
var buf = new Uint8Array(this.length)
|
|
for (var i = 0, len = buf.length; i < len; i += 1)
|
|
buf[i] = this[i]
|
|
return buf.buffer
|
|
}
|
|
} else {
|
|
throw new Error('Buffer.toArrayBuffer not supported in this browser')
|
|
}
|
|
}
|
|
|
|
// HELPER FUNCTIONS
|
|
// ================
|
|
|
|
function stringtrim (str) {
|
|
if (str.trim) return str.trim()
|
|
return str.replace(/^\s+|\s+$/g, '')
|
|
}
|
|
|
|
var BP = Buffer.prototype
|
|
|
|
/**
|
|
* Augment the Uint8Array *instance* (not the class!) with Buffer methods
|
|
*/
|
|
function augment (arr) {
|
|
arr._isBuffer = true
|
|
|
|
// save reference to original Uint8Array get/set methods before overwriting
|
|
arr._get = arr.get
|
|
arr._set = arr.set
|
|
|
|
// deprecated, will be removed in node 0.13+
|
|
arr.get = BP.get
|
|
arr.set = BP.set
|
|
|
|
arr.write = BP.write
|
|
arr.toString = BP.toString
|
|
arr.toLocaleString = BP.toString
|
|
arr.toJSON = BP.toJSON
|
|
arr.copy = BP.copy
|
|
arr.slice = BP.slice
|
|
arr.readUInt8 = BP.readUInt8
|
|
arr.readUInt16LE = BP.readUInt16LE
|
|
arr.readUInt16BE = BP.readUInt16BE
|
|
arr.readUInt32LE = BP.readUInt32LE
|
|
arr.readUInt32BE = BP.readUInt32BE
|
|
arr.readInt8 = BP.readInt8
|
|
arr.readInt16LE = BP.readInt16LE
|
|
arr.readInt16BE = BP.readInt16BE
|
|
arr.readInt32LE = BP.readInt32LE
|
|
arr.readInt32BE = BP.readInt32BE
|
|
arr.readFloatLE = BP.readFloatLE
|
|
arr.readFloatBE = BP.readFloatBE
|
|
arr.readDoubleLE = BP.readDoubleLE
|
|
arr.readDoubleBE = BP.readDoubleBE
|
|
arr.writeUInt8 = BP.writeUInt8
|
|
arr.writeUInt16LE = BP.writeUInt16LE
|
|
arr.writeUInt16BE = BP.writeUInt16BE
|
|
arr.writeUInt32LE = BP.writeUInt32LE
|
|
arr.writeUInt32BE = BP.writeUInt32BE
|
|
arr.writeInt8 = BP.writeInt8
|
|
arr.writeInt16LE = BP.writeInt16LE
|
|
arr.writeInt16BE = BP.writeInt16BE
|
|
arr.writeInt32LE = BP.writeInt32LE
|
|
arr.writeInt32BE = BP.writeInt32BE
|
|
arr.writeFloatLE = BP.writeFloatLE
|
|
arr.writeFloatBE = BP.writeFloatBE
|
|
arr.writeDoubleLE = BP.writeDoubleLE
|
|
arr.writeDoubleBE = BP.writeDoubleBE
|
|
arr.fill = BP.fill
|
|
arr.inspect = BP.inspect
|
|
arr.toArrayBuffer = BP.toArrayBuffer
|
|
|
|
return arr
|
|
}
|
|
|
|
// slice(start, end)
|
|
function clamp (index, len, defaultValue) {
|
|
if (typeof index !== 'number') return defaultValue
|
|
index = ~~index; // Coerce to integer.
|
|
if (index >= len) return len
|
|
if (index >= 0) return index
|
|
index += len
|
|
if (index >= 0) return index
|
|
return 0
|
|
}
|
|
|
|
function coerce (length) {
|
|
// Coerce length to a number (possibly NaN), round up
|
|
// in case it's fractional (e.g. 123.456) then do a
|
|
// double negate to coerce a NaN to 0. Easy, right?
|
|
length = ~~Math.ceil(+length)
|
|
return length < 0 ? 0 : length
|
|
}
|
|
|
|
function isArray (subject) {
|
|
return (Array.isArray || function (subject) {
|
|
return Object.prototype.toString.call(subject) === '[object Array]'
|
|
})(subject)
|
|
}
|
|
|
|
function isArrayish (subject) {
|
|
return isArray(subject) || Buffer.isBuffer(subject) ||
|
|
subject && typeof subject === 'object' &&
|
|
typeof subject.length === 'number'
|
|
}
|
|
|
|
function toHex (n) {
|
|
if (n < 16) return '0' + n.toString(16)
|
|
return n.toString(16)
|
|
}
|
|
|
|
function utf8ToBytes (str) {
|
|
var byteArray = []
|
|
for (var i = 0; i < str.length; i++) {
|
|
var b = str.charCodeAt(i)
|
|
if (b <= 0x7F)
|
|
byteArray.push(str.charCodeAt(i))
|
|
else {
|
|
var start = i
|
|
if (b >= 0xD800 && b <= 0xDFFF) i++
|
|
var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
|
|
for (var j = 0; j < h.length; j++)
|
|
byteArray.push(parseInt(h[j], 16))
|
|
}
|
|
}
|
|
return byteArray
|
|
}
|
|
|
|
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 base64ToBytes (str) {
|
|
return base64.toByteArray(str)
|
|
}
|
|
|
|
function blitBuffer (src, dst, offset, length) {
|
|
var pos
|
|
for (var i = 0; i < length; i++) {
|
|
if ((i + offset >= dst.length) || (i >= src.length))
|
|
break
|
|
dst[i + offset] = src[i]
|
|
}
|
|
return i
|
|
}
|
|
|
|
function decodeUtf8Char (str) {
|
|
try {
|
|
return decodeURIComponent(str)
|
|
} catch (err) {
|
|
return String.fromCharCode(0xFFFD) // UTF 8 invalid char
|
|
}
|
|
}
|
|
|
|
/*
|
|
* We have to make sure that the value is a valid integer. This means that it
|
|
* is non-negative. It has no fractional component and that it does not
|
|
* exceed the maximum allowed value.
|
|
*/
|
|
function verifuint (value, max) {
|
|
assert(typeof value == 'number', 'cannot write a non-number as a number')
|
|
assert(value >= 0,
|
|
'specified a negative value for writing an unsigned value')
|
|
assert(value <= max, 'value is larger than maximum value for type')
|
|
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
}
|
|
|
|
function verifsint(value, max, min) {
|
|
assert(typeof value == 'number', 'cannot write a non-number as a number')
|
|
assert(value <= max, 'value larger than maximum allowed value')
|
|
assert(value >= min, 'value smaller than minimum allowed value')
|
|
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
}
|
|
|
|
function verifIEEE754(value, max, min) {
|
|
assert(typeof value == 'number', 'cannot write a non-number as a number')
|
|
assert(value <= max, 'value larger than maximum allowed value')
|
|
assert(value >= min, 'value smaller than minimum allowed value')
|
|
}
|
|
|
|
function assert (test, message) {
|
|
if (!test) throw new Error(message || 'Failed assertion')
|
|
}
|
|
|
|
},{"base64-js":10,"ieee754":11}],10:[function(require,module,exports){
|
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
|
;(function (exports) {
|
|
'use strict';
|
|
|
|
var Arr = (typeof Uint8Array !== 'undefined')
|
|
? Uint8Array
|
|
: Array
|
|
|
|
var ZERO = '0'.charCodeAt(0)
|
|
var PLUS = '+'.charCodeAt(0)
|
|
var SLASH = '/'.charCodeAt(0)
|
|
var NUMBER = '0'.charCodeAt(0)
|
|
var LOWER = 'a'.charCodeAt(0)
|
|
var UPPER = 'A'.charCodeAt(0)
|
|
|
|
function decode (elt) {
|
|
var code = elt.charCodeAt(0)
|
|
if (code === PLUS)
|
|
return 62 // '+'
|
|
if (code === SLASH)
|
|
return 63 // '/'
|
|
if (code < NUMBER)
|
|
return -1 //no match
|
|
if (code < NUMBER + 10)
|
|
return code - NUMBER + 26 + 26
|
|
if (code < UPPER + 26)
|
|
return code - UPPER
|
|
if (code < LOWER + 26)
|
|
return code - LOWER + 26
|
|
}
|
|
|
|
function b64ToByteArray (b64) {
|
|
var i, j, l, tmp, placeHolders, arr
|
|
|
|
if (b64.length % 4 > 0) {
|
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
}
|
|
|
|
// the number of equal signs (place holders)
|
|
// if there are two placeholders, than the two characters before it
|
|
// represent one byte
|
|
// if there is only one, then the three characters before it represent 2 bytes
|
|
// this is just a cheap hack to not do indexOf twice
|
|
var len = b64.length
|
|
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
|
|
|
// base64 is 4/3 + up to two characters of the original data
|
|
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
|
|
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
|
|
|
var L = 0
|
|
|
|
function push (v) {
|
|
arr[L++] = v
|
|
}
|
|
|
|
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
|
push((tmp & 0xFF0000) >> 16)
|
|
push((tmp & 0xFF00) >> 8)
|
|
push(tmp & 0xFF)
|
|
}
|
|
|
|
if (placeHolders === 2) {
|
|
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
|
push(tmp & 0xFF)
|
|
} else if (placeHolders === 1) {
|
|
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
|
push((tmp >> 8) & 0xFF)
|
|
push(tmp & 0xFF)
|
|
}
|
|
|
|
return arr
|
|
}
|
|
|
|
function uint8ToBase64 (uint8) {
|
|
var i,
|
|
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
|
output = "",
|
|
temp, length
|
|
|
|
function encode (num) {
|
|
return lookup.charAt(num)
|
|
}
|
|
|
|
function tripletToBase64 (num) {
|
|
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
|
}
|
|
|
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
|
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
|
output += tripletToBase64(temp)
|
|
}
|
|
|
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
switch (extraBytes) {
|
|
case 1:
|
|
temp = uint8[uint8.length - 1]
|
|
output += encode(temp >> 2)
|
|
output += encode((temp << 4) & 0x3F)
|
|
output += '=='
|
|
break
|
|
case 2:
|
|
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
|
output += encode(temp >> 10)
|
|
output += encode((temp >> 4) & 0x3F)
|
|
output += encode((temp << 2) & 0x3F)
|
|
output += '='
|
|
break
|
|
}
|
|
|
|
return output
|
|
}
|
|
|
|
module.exports.toByteArray = b64ToByteArray
|
|
module.exports.fromByteArray = uint8ToBase64
|
|
}())
|
|
|
|
},{}],11:[function(require,module,exports){
|
|
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
var e, m,
|
|
eLen = nBytes * 8 - mLen - 1,
|
|
eMax = (1 << eLen) - 1,
|
|
eBias = eMax >> 1,
|
|
nBits = -7,
|
|
i = isLE ? (nBytes - 1) : 0,
|
|
d = isLE ? -1 : 1,
|
|
s = buffer[offset + i];
|
|
|
|
i += d;
|
|
|
|
e = s & ((1 << (-nBits)) - 1);
|
|
s >>= (-nBits);
|
|
nBits += eLen;
|
|
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
|
|
m = e & ((1 << (-nBits)) - 1);
|
|
e >>= (-nBits);
|
|
nBits += mLen;
|
|
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
|
|
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,
|
|
eLen = nBytes * 8 - mLen - 1,
|
|
eMax = (1 << eLen) - 1,
|
|
eBias = eMax >> 1,
|
|
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
|
|
i = isLE ? 0 : (nBytes - 1),
|
|
d = isLE ? 1 : -1,
|
|
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
|
|
|
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;
|
|
};
|
|
|
|
},{}],12:[function(require,module,exports){
|
|
(function (global){/*! http://mths.be/punycode v1.2.3 by @mathias */
|
|
;(function(root) {
|
|
|
|
/** Detect free variables */
|
|
var freeExports = typeof exports == 'object' && exports;
|
|
var freeModule = typeof module == 'object' && module &&
|
|
module.exports == freeExports && module;
|
|
var freeGlobal = typeof global == 'object' && global;
|
|
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
|
root = freeGlobal;
|
|
}
|
|
|
|
/**
|
|
* The `punycode` object.
|
|
* @name punycode
|
|
* @type Object
|
|
*/
|
|
var punycode,
|
|
|
|
/** Highest positive signed 32-bit float value */
|
|
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
|
|
|
/** Bootstring parameters */
|
|
base = 36,
|
|
tMin = 1,
|
|
tMax = 26,
|
|
skew = 38,
|
|
damp = 700,
|
|
initialBias = 72,
|
|
initialN = 128, // 0x80
|
|
delimiter = '-', // '\x2D'
|
|
|
|
/** Regular expressions */
|
|
regexPunycode = /^xn--/,
|
|
regexNonASCII = /[^ -~]/, // unprintable ASCII chars + non-ASCII chars
|
|
regexSeparators = /\x2E|\u3002|\uFF0E|\uFF61/g, // RFC 3490 separators
|
|
|
|
/** Error messages */
|
|
errors = {
|
|
'overflow': 'Overflow: input needs wider integers to process',
|
|
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
'invalid-input': 'Invalid input'
|
|
},
|
|
|
|
/** Convenience shortcuts */
|
|
baseMinusTMin = base - tMin,
|
|
floor = Math.floor,
|
|
stringFromCharCode = String.fromCharCode,
|
|
|
|
/** Temporary variable */
|
|
key;
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* A generic error utility function.
|
|
* @private
|
|
* @param {String} type The error type.
|
|
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
|
*/
|
|
function error(type) {
|
|
throw RangeError(errors[type]);
|
|
}
|
|
|
|
/**
|
|
* A generic `Array#map` utility function.
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} callback The function that gets called for every array
|
|
* item.
|
|
* @returns {Array} A new array of values returned by the callback function.
|
|
*/
|
|
function map(array, fn) {
|
|
var length = array.length;
|
|
while (length--) {
|
|
array[length] = fn(array[length]);
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* A simple `Array#map`-like wrapper to work with domain name strings.
|
|
* @private
|
|
* @param {String} domain The domain name.
|
|
* @param {Function} callback The function that gets called for every
|
|
* character.
|
|
* @returns {Array} A new string of characters returned by the callback
|
|
* function.
|
|
*/
|
|
function mapDomain(string, fn) {
|
|
return map(string.split(regexSeparators), fn).join('.');
|
|
}
|
|
|
|
/**
|
|
* Creates an array containing the numeric code points of each Unicode
|
|
* character in the string. While JavaScript uses UCS-2 internally,
|
|
* this function will convert a pair of surrogate halves (each of which
|
|
* UCS-2 exposes as separate characters) into a single code point,
|
|
* matching UTF-16.
|
|
* @see `punycode.ucs2.encode`
|
|
* @see <http://mathiasbynens.be/notes/javascript-encoding>
|
|
* @memberOf punycode.ucs2
|
|
* @name decode
|
|
* @param {String} string The Unicode input string (UCS-2).
|
|
* @returns {Array} The new array of code points.
|
|
*/
|
|
function ucs2decode(string) {
|
|
var output = [],
|
|
counter = 0,
|
|
length = string.length,
|
|
value,
|
|
extra;
|
|
while (counter < length) {
|
|
value = string.charCodeAt(counter++);
|
|
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
// high surrogate, and there is a next character
|
|
extra = string.charCodeAt(counter++);
|
|
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
|
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
} else {
|
|
// unmatched surrogate; only append this code unit, in case the next
|
|
// code unit is the high surrogate of a surrogate pair
|
|
output.push(value);
|
|
counter--;
|
|
}
|
|
} else {
|
|
output.push(value);
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
|
|
/**
|
|
* Creates a string based on an array of numeric code points.
|
|
* @see `punycode.ucs2.decode`
|
|
* @memberOf punycode.ucs2
|
|
* @name encode
|
|
* @param {Array} codePoints The array of numeric code points.
|
|
* @returns {String} The new Unicode string (UCS-2).
|
|
*/
|
|
function ucs2encode(array) {
|
|
return map(array, function(value) {
|
|
var output = '';
|
|
if (value > 0xFFFF) {
|
|
value -= 0x10000;
|
|
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
|
value = 0xDC00 | value & 0x3FF;
|
|
}
|
|
output += stringFromCharCode(value);
|
|
return output;
|
|
}).join('');
|
|
}
|
|
|
|
/**
|
|
* Converts a basic code point into a digit/integer.
|
|
* @see `digitToBasic()`
|
|
* @private
|
|
* @param {Number} codePoint The basic numeric code point value.
|
|
* @returns {Number} The numeric value of a basic code point (for use in
|
|
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
* the code point does not represent a value.
|
|
*/
|
|
function basicToDigit(codePoint) {
|
|
if (codePoint - 48 < 10) {
|
|
return codePoint - 22;
|
|
}
|
|
if (codePoint - 65 < 26) {
|
|
return codePoint - 65;
|
|
}
|
|
if (codePoint - 97 < 26) {
|
|
return codePoint - 97;
|
|
}
|
|
return base;
|
|
}
|
|
|
|
/**
|
|
* Converts a digit/integer into a basic code point.
|
|
* @see `basicToDigit()`
|
|
* @private
|
|
* @param {Number} digit The numeric value of a basic code point.
|
|
* @returns {Number} The basic code point whose value (when used for
|
|
* representing integers) is `digit`, which needs to be in the range
|
|
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
* used; else, the lowercase form is used. The behavior is undefined
|
|
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
*/
|
|
function digitToBasic(digit, flag) {
|
|
// 0..25 map to ASCII a..z or A..Z
|
|
// 26..35 map to ASCII 0..9
|
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
}
|
|
|
|
/**
|
|
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
* http://tools.ietf.org/html/rfc3492#section-3.4
|
|
* @private
|
|
*/
|
|
function adapt(delta, numPoints, firstTime) {
|
|
var k = 0;
|
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
delta += floor(delta / numPoints);
|
|
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
delta = floor(delta / baseMinusTMin);
|
|
}
|
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
}
|
|
|
|
/**
|
|
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
|
* symbols.
|
|
* @memberOf punycode
|
|
* @param {String} input The Punycode string of ASCII-only symbols.
|
|
* @returns {String} The resulting string of Unicode symbols.
|
|
*/
|
|
function decode(input) {
|
|
// Don't use UCS-2
|
|
var output = [],
|
|
inputLength = input.length,
|
|
out,
|
|
i = 0,
|
|
n = initialN,
|
|
bias = initialBias,
|
|
basic,
|
|
j,
|
|
index,
|
|
oldi,
|
|
w,
|
|
k,
|
|
digit,
|
|
t,
|
|
length,
|
|
/** Cached calculation results */
|
|
baseMinusT;
|
|
|
|
// Handle the basic code points: let `basic` be the number of input code
|
|
// points before the last delimiter, or `0` if there is none, then copy
|
|
// the first basic code points to the output.
|
|
|
|
basic = input.lastIndexOf(delimiter);
|
|
if (basic < 0) {
|
|
basic = 0;
|
|
}
|
|
|
|
for (j = 0; j < basic; ++j) {
|
|
// if it's not a basic code point
|
|
if (input.charCodeAt(j) >= 0x80) {
|
|
error('not-basic');
|
|
}
|
|
output.push(input.charCodeAt(j));
|
|
}
|
|
|
|
// Main decoding loop: start just after the last delimiter if any basic code
|
|
// points were copied; start at the beginning otherwise.
|
|
|
|
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
|
|
|
// `index` is the index of the next character to be consumed.
|
|
// Decode a generalized variable-length integer into `delta`,
|
|
// which gets added to `i`. The overflow checking is easier
|
|
// if we increase `i` as we go, then subtract off its starting
|
|
// value at the end to obtain `delta`.
|
|
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
|
|
|
if (index >= inputLength) {
|
|
error('invalid-input');
|
|
}
|
|
|
|
digit = basicToDigit(input.charCodeAt(index++));
|
|
|
|
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
error('overflow');
|
|
}
|
|
|
|
i += digit * w;
|
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
|
|
if (digit < t) {
|
|
break;
|
|
}
|
|
|
|
baseMinusT = base - t;
|
|
if (w > floor(maxInt / baseMinusT)) {
|
|
error('overflow');
|
|
}
|
|
|
|
w *= baseMinusT;
|
|
|
|
}
|
|
|
|
out = output.length + 1;
|
|
bias = adapt(i - oldi, out, oldi == 0);
|
|
|
|
// `i` was supposed to wrap around from `out` to `0`,
|
|
// incrementing `n` each time, so we'll fix that now:
|
|
if (floor(i / out) > maxInt - n) {
|
|
error('overflow');
|
|
}
|
|
|
|
n += floor(i / out);
|
|
i %= out;
|
|
|
|
// Insert `n` at position `i` of the output
|
|
output.splice(i++, 0, n);
|
|
|
|
}
|
|
|
|
return ucs2encode(output);
|
|
}
|
|
|
|
/**
|
|
* Converts a string of Unicode symbols to a Punycode string of ASCII-only
|
|
* symbols.
|
|
* @memberOf punycode
|
|
* @param {String} input The string of Unicode symbols.
|
|
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
|
*/
|
|
function encode(input) {
|
|
var n,
|
|
delta,
|
|
handledCPCount,
|
|
basicLength,
|
|
bias,
|
|
j,
|
|
m,
|
|
q,
|
|
k,
|
|
t,
|
|
currentValue,
|
|
output = [],
|
|
/** `inputLength` will hold the number of code points in `input`. */
|
|
inputLength,
|
|
/** Cached calculation results */
|
|
handledCPCountPlusOne,
|
|
baseMinusT,
|
|
qMinusT;
|
|
|
|
// Convert the input in UCS-2 to Unicode
|
|
input = ucs2decode(input);
|
|
|
|
// Cache the length
|
|
inputLength = input.length;
|
|
|
|
// Initialize the state
|
|
n = initialN;
|
|
delta = 0;
|
|
bias = initialBias;
|
|
|
|
// Handle the basic code points
|
|
for (j = 0; j < inputLength; ++j) {
|
|
currentValue = input[j];
|
|
if (currentValue < 0x80) {
|
|
output.push(stringFromCharCode(currentValue));
|
|
}
|
|
}
|
|
|
|
handledCPCount = basicLength = output.length;
|
|
|
|
// `handledCPCount` is the number of code points that have been handled;
|
|
// `basicLength` is the number of basic code points.
|
|
|
|
// Finish the basic string - if it is not empty - with a delimiter
|
|
if (basicLength) {
|
|
output.push(delimiter);
|
|
}
|
|
|
|
// Main encoding loop:
|
|
while (handledCPCount < inputLength) {
|
|
|
|
// All non-basic code points < n have been handled already. Find the next
|
|
// larger one:
|
|
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
|
currentValue = input[j];
|
|
if (currentValue >= n && currentValue < m) {
|
|
m = currentValue;
|
|
}
|
|
}
|
|
|
|
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
// but guard against overflow
|
|
handledCPCountPlusOne = handledCPCount + 1;
|
|
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
error('overflow');
|
|
}
|
|
|
|
delta += (m - n) * handledCPCountPlusOne;
|
|
n = m;
|
|
|
|
for (j = 0; j < inputLength; ++j) {
|
|
currentValue = input[j];
|
|
|
|
if (currentValue < n && ++delta > maxInt) {
|
|
error('overflow');
|
|
}
|
|
|
|
if (currentValue == n) {
|
|
// Represent delta as a generalized variable-length integer
|
|
for (q = delta, k = base; /* no condition */; k += base) {
|
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
if (q < t) {
|
|
break;
|
|
}
|
|
qMinusT = q - t;
|
|
baseMinusT = base - t;
|
|
output.push(
|
|
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
);
|
|
q = floor(qMinusT / baseMinusT);
|
|
}
|
|
|
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
delta = 0;
|
|
++handledCPCount;
|
|
}
|
|
}
|
|
|
|
++delta;
|
|
++n;
|
|
|
|
}
|
|
return output.join('');
|
|
}
|
|
|
|
/**
|
|
* Converts a Punycode string representing a domain name to Unicode. Only the
|
|
* Punycoded parts of the domain name will be converted, i.e. it doesn't
|
|
* matter if you call it on a string that has already been converted to
|
|
* Unicode.
|
|
* @memberOf punycode
|
|
* @param {String} domain The Punycode domain name to convert to Unicode.
|
|
* @returns {String} The Unicode representation of the given Punycode
|
|
* string.
|
|
*/
|
|
function toUnicode(domain) {
|
|
return mapDomain(domain, function(string) {
|
|
return regexPunycode.test(string)
|
|
? decode(string.slice(4).toLowerCase())
|
|
: string;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Converts a Unicode string representing a domain name to Punycode. Only the
|
|
* non-ASCII parts of the domain name will be converted, i.e. it doesn't
|
|
* matter if you call it with a domain that's already in ASCII.
|
|
* @memberOf punycode
|
|
* @param {String} domain The domain name to convert, as a Unicode string.
|
|
* @returns {String} The Punycode representation of the given domain name.
|
|
*/
|
|
function toASCII(domain) {
|
|
return mapDomain(domain, function(string) {
|
|
return regexNonASCII.test(string)
|
|
? 'xn--' + encode(string)
|
|
: string;
|
|
});
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/** Define the public API */
|
|
punycode = {
|
|
/**
|
|
* A string representing the current Punycode.js version number.
|
|
* @memberOf punycode
|
|
* @type String
|
|
*/
|
|
'version': '1.2.3',
|
|
/**
|
|
* An object of methods to convert from JavaScript's internal character
|
|
* representation (UCS-2) to Unicode code points, and back.
|
|
* @see <http://mathiasbynens.be/notes/javascript-encoding>
|
|
* @memberOf punycode
|
|
* @type Object
|
|
*/
|
|
'ucs2': {
|
|
'decode': ucs2decode,
|
|
'encode': ucs2encode
|
|
},
|
|
'decode': decode,
|
|
'encode': encode,
|
|
'toASCII': toASCII,
|
|
'toUnicode': toUnicode
|
|
};
|
|
|
|
/** Expose `punycode` */
|
|
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
// like the following:
|
|
if (
|
|
typeof define == 'function' &&
|
|
typeof define.amd == 'object' &&
|
|
define.amd
|
|
) {
|
|
define(function() {
|
|
return punycode;
|
|
});
|
|
} else if (freeExports && !freeExports.nodeType) {
|
|
if (freeModule) { // in Node.js or RingoJS v0.8.0+
|
|
freeModule.exports = punycode;
|
|
} else { // in Narwhal or RingoJS v0.7.0-
|
|
for (key in punycode) {
|
|
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
}
|
|
}
|
|
} else { // in Rhino or a web browser
|
|
root.punycode = punycode;
|
|
}
|
|
|
|
}(this));
|
|
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{}],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.
|
|
|
|
'use strict';
|
|
|
|
// If obj.hasOwnProperty has been overridden, then calling
|
|
// obj.hasOwnProperty(prop) will break.
|
|
// See: https://github.com/joyent/node/issues/1707
|
|
function hasOwnProperty(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
|
|
module.exports = function(qs, sep, eq, options) {
|
|
sep = sep || '&';
|
|
eq = eq || '=';
|
|
var obj = {};
|
|
|
|
if (typeof qs !== 'string' || qs.length === 0) {
|
|
return obj;
|
|
}
|
|
|
|
var regexp = /\+/g;
|
|
qs = qs.split(sep);
|
|
|
|
var maxKeys = 1000;
|
|
if (options && typeof options.maxKeys === 'number') {
|
|
maxKeys = options.maxKeys;
|
|
}
|
|
|
|
var len = qs.length;
|
|
// maxKeys <= 0 means that we should not limit keys count
|
|
if (maxKeys > 0 && len > maxKeys) {
|
|
len = maxKeys;
|
|
}
|
|
|
|
for (var i = 0; i < len; ++i) {
|
|
var x = qs[i].replace(regexp, '%20'),
|
|
idx = x.indexOf(eq),
|
|
kstr, vstr, k, v;
|
|
|
|
if (idx >= 0) {
|
|
kstr = x.substr(0, idx);
|
|
vstr = x.substr(idx + 1);
|
|
} else {
|
|
kstr = x;
|
|
vstr = '';
|
|
}
|
|
|
|
k = decodeURIComponent(kstr);
|
|
v = decodeURIComponent(vstr);
|
|
|
|
if (!hasOwnProperty(obj, k)) {
|
|
obj[k] = v;
|
|
} else if (isArray(obj[k])) {
|
|
obj[k].push(v);
|
|
} else {
|
|
obj[k] = [obj[k], v];
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
var isArray = Array.isArray || function (xs) {
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
};
|
|
|
|
},{}],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.
|
|
|
|
'use strict';
|
|
|
|
var stringifyPrimitive = function(v) {
|
|
switch (typeof v) {
|
|
case 'string':
|
|
return v;
|
|
|
|
case 'boolean':
|
|
return v ? 'true' : 'false';
|
|
|
|
case 'number':
|
|
return isFinite(v) ? v : '';
|
|
|
|
default:
|
|
return '';
|
|
}
|
|
};
|
|
|
|
module.exports = function(obj, sep, eq, name) {
|
|
sep = sep || '&';
|
|
eq = eq || '=';
|
|
if (obj === null) {
|
|
obj = undefined;
|
|
}
|
|
|
|
if (typeof obj === 'object') {
|
|
return map(objectKeys(obj), function(k) {
|
|
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
|
if (isArray(obj[k])) {
|
|
return obj[k].map(function(v) {
|
|
return ks + encodeURIComponent(stringifyPrimitive(v));
|
|
}).join(sep);
|
|
} else {
|
|
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
|
}
|
|
}).join(sep);
|
|
|
|
}
|
|
|
|
if (!name) return '';
|
|
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
|
encodeURIComponent(stringifyPrimitive(obj));
|
|
};
|
|
|
|
var isArray = Array.isArray || function (xs) {
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
};
|
|
|
|
function map (xs, f) {
|
|
if (xs.map) return xs.map(f);
|
|
var res = [];
|
|
for (var i = 0; i < xs.length; i++) {
|
|
res.push(f(xs[i], i));
|
|
}
|
|
return res;
|
|
}
|
|
|
|
var objectKeys = Object.keys || function (obj) {
|
|
var res = [];
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
|
|
}
|
|
return res;
|
|
};
|
|
|
|
},{}],15:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
exports.decode = exports.parse = require('./decode');
|
|
exports.encode = exports.stringify = require('./encode');
|
|
|
|
},{"./decode":13,"./encode":14}],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 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.
|
|
|
|
module.exports = Duplex;
|
|
var inherits = require('inherits');
|
|
var setImmediate = require('process/browser.js').nextTick;
|
|
var Readable = require('./readable.js');
|
|
var Writable = require('./writable.js');
|
|
|
|
inherits(Duplex, Readable);
|
|
|
|
Duplex.prototype.write = Writable.prototype.write;
|
|
Duplex.prototype.end = Writable.prototype.end;
|
|
Duplex.prototype._write = Writable.prototype._write;
|
|
|
|
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);
|
|
}
|
|
|
|
// 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.
|
|
var self = this;
|
|
setImmediate(function () {
|
|
self.end();
|
|
});
|
|
}
|
|
|
|
},{"./readable.js":20,"./writable.js":22,"inherits":7,"process/browser.js":18}],17:[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.js');
|
|
Stream.Writable = require('./writable.js');
|
|
Stream.Duplex = require('./duplex.js');
|
|
Stream.Transform = require('./transform.js');
|
|
Stream.PassThrough = require('./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;
|
|
};
|
|
|
|
},{"./duplex.js":16,"./passthrough.js":19,"./readable.js":20,"./transform.js":21,"./writable.js":22,"events":2,"inherits":7}],18:[function(require,module,exports){
|
|
module.exports=require(8)
|
|
},{}],19:[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.
|
|
|
|
module.exports = PassThrough;
|
|
|
|
var Transform = require('./transform.js');
|
|
var inherits = require('inherits');
|
|
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);
|
|
};
|
|
|
|
},{"./transform.js":21,"inherits":7}],20:[function(require,module,exports){
|
|
(function (process){// 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 = Readable;
|
|
Readable.ReadableState = ReadableState;
|
|
|
|
var EE = require('events').EventEmitter;
|
|
var Stream = require('./index.js');
|
|
var Buffer = require('buffer').Buffer;
|
|
var setImmediate = require('process/browser.js').nextTick;
|
|
var StringDecoder;
|
|
|
|
var inherits = require('inherits');
|
|
inherits(Readable, Stream);
|
|
|
|
function ReadableState(options, stream) {
|
|
options = options || {};
|
|
|
|
// the point at which it stops calling _read() to fill the buffer
|
|
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
var hwm = options.highWaterMark;
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
|
|
|
// cast to ints.
|
|
this.highWaterMark = ~~this.highWaterMark;
|
|
|
|
this.buffer = [];
|
|
this.length = 0;
|
|
this.pipes = null;
|
|
this.pipesCount = 0;
|
|
this.flowing = false;
|
|
this.ended = false;
|
|
this.endEmitted = false;
|
|
this.reading = false;
|
|
|
|
// In streams that never have any data, and do push(null) right away,
|
|
// the consumer can miss the 'end' event if they do some I/O before
|
|
// consuming the stream. So, we don't emit('end') until some reading
|
|
// happens.
|
|
this.calledRead = false;
|
|
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
// or on a later tick. We set this to true at first, becuase any
|
|
// actions that shouldn't happen until "later" should generally also
|
|
// not happen before the first write 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;
|
|
|
|
|
|
// 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;
|
|
|
|
// 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';
|
|
|
|
// when piping, we only care about 'readable' events that happen
|
|
// after read()ing all the bytes and not getting any pushback.
|
|
this.ranOut = false;
|
|
|
|
// 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) {
|
|
if (!(this instanceof Readable))
|
|
return new Readable(options);
|
|
|
|
this._readableState = new ReadableState(options, this);
|
|
|
|
// legacy
|
|
this.readable = true;
|
|
|
|
Stream.call(this);
|
|
}
|
|
|
|
// 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;
|
|
|
|
if (typeof chunk === 'string' && !state.objectMode) {
|
|
encoding = encoding || state.defaultEncoding;
|
|
if (encoding !== state.encoding) {
|
|
chunk = new Buffer(chunk, encoding);
|
|
encoding = '';
|
|
}
|
|
}
|
|
|
|
return readableAddChunk(this, state, chunk, encoding, false);
|
|
};
|
|
|
|
// Unshift should *always* be something directly out of read()
|
|
Readable.prototype.unshift = function(chunk) {
|
|
var state = this._readableState;
|
|
return readableAddChunk(this, state, chunk, '', true);
|
|
};
|
|
|
|
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
|
var er = chunkInvalid(state, chunk);
|
|
if (er) {
|
|
stream.emit('error', er);
|
|
} else if (chunk === null || chunk === undefined) {
|
|
state.reading = false;
|
|
if (!state.ended)
|
|
onEofChunk(stream, state);
|
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
if (state.ended && !addToFront) {
|
|
var e = new Error('stream.push() after EOF');
|
|
stream.emit('error', e);
|
|
} else if (state.endEmitted && addToFront) {
|
|
var e = new Error('stream.unshift() after end event');
|
|
stream.emit('error', e);
|
|
} else {
|
|
if (state.decoder && !addToFront && !encoding)
|
|
chunk = state.decoder.write(chunk);
|
|
|
|
// update the buffer info.
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
if (addToFront) {
|
|
state.buffer.unshift(chunk);
|
|
} else {
|
|
state.reading = false;
|
|
state.buffer.push(chunk);
|
|
}
|
|
|
|
if (state.needReadable)
|
|
emitReadable(stream);
|
|
|
|
maybeReadMore(stream, state);
|
|
}
|
|
} else if (!addToFront) {
|
|
state.reading = false;
|
|
}
|
|
|
|
return needMoreData(state);
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
}
|
|
|
|
// backwards compatibility.
|
|
Readable.prototype.setEncoding = function(enc) {
|
|
if (!StringDecoder)
|
|
StringDecoder = require('string_decoder').StringDecoder;
|
|
this._readableState.decoder = new StringDecoder(enc);
|
|
this._readableState.encoding = enc;
|
|
};
|
|
|
|
// Don't raise the hwm > 128MB
|
|
var MAX_HWM = 0x800000;
|
|
function roundUpToNextPowerOf2(n) {
|
|
if (n >= MAX_HWM) {
|
|
n = MAX_HWM;
|
|
} else {
|
|
// Get the next highest power of 2
|
|
n--;
|
|
for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
|
n++;
|
|
}
|
|
return n;
|
|
}
|
|
|
|
function howMuchToRead(n, state) {
|
|
if (state.length === 0 && state.ended)
|
|
return 0;
|
|
|
|
if (state.objectMode)
|
|
return n === 0 ? 0 : 1;
|
|
|
|
if (isNaN(n) || n === null) {
|
|
// only flow one buffer at a time
|
|
if (state.flowing && state.buffer.length)
|
|
return state.buffer[0].length;
|
|
else
|
|
return state.length;
|
|
}
|
|
|
|
if (n <= 0)
|
|
return 0;
|
|
|
|
// If we're asking for more than the target buffer level,
|
|
// then raise the water mark. Bump up to the next highest
|
|
// power of 2, to prevent increasing it excessively in tiny
|
|
// amounts.
|
|
if (n > state.highWaterMark)
|
|
state.highWaterMark = roundUpToNextPowerOf2(n);
|
|
|
|
// don't have that much. return null, unless we've ended.
|
|
if (n > state.length) {
|
|
if (!state.ended) {
|
|
state.needReadable = true;
|
|
return 0;
|
|
} else
|
|
return state.length;
|
|
}
|
|
|
|
return n;
|
|
}
|
|
|
|
// you can override either this method, or the async _read(n) below.
|
|
Readable.prototype.read = function(n) {
|
|
var state = this._readableState;
|
|
state.calledRead = true;
|
|
var nOrig = n;
|
|
|
|
if (typeof n !== 'number' || 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)) {
|
|
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;
|
|
|
|
// if we currently have less than the highWaterMark, then also read some
|
|
if (state.length - n <= state.highWaterMark)
|
|
doRead = true;
|
|
|
|
// 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;
|
|
|
|
if (doRead) {
|
|
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 called its callback synchronously, then `reading`
|
|
// will be false, and we need to re-evaluate how much data we
|
|
// can return to the user.
|
|
if (doRead && !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;
|
|
}
|
|
|
|
state.length -= n;
|
|
|
|
// If we have nothing in the buffer, then we want to know
|
|
// as soon as we *do* get something into the buffer.
|
|
if (state.length === 0 && !state.ended)
|
|
state.needReadable = true;
|
|
|
|
// If we happened to read() exactly the remaining amount in the
|
|
// buffer, and the EOF has been seen at this point, then make sure
|
|
// that we emit 'end' on the very next tick.
|
|
if (state.ended && !state.endEmitted && state.length === 0)
|
|
endReadable(this);
|
|
|
|
return ret;
|
|
};
|
|
|
|
function chunkInvalid(state, chunk) {
|
|
var er = null;
|
|
if (!Buffer.isBuffer(chunk) &&
|
|
'string' !== typeof chunk &&
|
|
chunk !== null &&
|
|
chunk !== undefined &&
|
|
!state.objectMode &&
|
|
!er) {
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
}
|
|
return er;
|
|
}
|
|
|
|
|
|
function onEofChunk(stream, state) {
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length) {
|
|
state.buffer.push(chunk);
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
}
|
|
}
|
|
state.ended = true;
|
|
|
|
// if we've ended and we have some data left, then emit
|
|
// 'readable' now to make sure it gets picked up.
|
|
if (state.length > 0)
|
|
emitReadable(stream);
|
|
else
|
|
endReadable(stream);
|
|
}
|
|
|
|
// 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)
|
|
return;
|
|
|
|
state.emittedReadable = true;
|
|
if (state.sync)
|
|
setImmediate(function() {
|
|
emitReadable_(stream);
|
|
});
|
|
else
|
|
emitReadable_(stream);
|
|
}
|
|
|
|
function emitReadable_(stream) {
|
|
stream.emit('readable');
|
|
}
|
|
|
|
|
|
// 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;
|
|
setImmediate(function() {
|
|
maybeReadMore_(stream, state);
|
|
});
|
|
}
|
|
}
|
|
|
|
function maybeReadMore_(stream, state) {
|
|
var len = state.length;
|
|
while (!state.reading && !state.flowing && !state.ended &&
|
|
state.length < state.highWaterMark) {
|
|
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('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;
|
|
|
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
|
dest !== process.stdout &&
|
|
dest !== process.stderr;
|
|
|
|
var endFn = doEnd ? onend : cleanup;
|
|
if (state.endEmitted)
|
|
setImmediate(endFn);
|
|
else
|
|
src.once('end', endFn);
|
|
|
|
dest.on('unpipe', onunpipe);
|
|
function onunpipe(readable) {
|
|
if (readable !== src) return;
|
|
cleanup();
|
|
}
|
|
|
|
function 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);
|
|
|
|
function 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', cleanup);
|
|
|
|
// if the reader is waiting for a drain event from this
|
|
// specific writer, then it would cause it to never start
|
|
// flowing again.
|
|
// So, if this is awaiting a drain, then we just call it now.
|
|
// If we don't know, then assume that we are waiting for one.
|
|
if (!dest._writableState || dest._writableState.needDrain)
|
|
ondrain();
|
|
}
|
|
|
|
// if the dest has an error, then stop piping into it.
|
|
// however, don't suppress the throwing behavior for this.
|
|
// check for listeners before emit removes one-time listeners.
|
|
var errListeners = EE.listenerCount(dest, 'error');
|
|
function onerror(er) {
|
|
unpipe();
|
|
if (errListeners === 0 && EE.listenerCount(dest, 'error') === 0)
|
|
dest.emit('error', er);
|
|
}
|
|
dest.once('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() {
|
|
dest.removeListener('close', onclose);
|
|
unpipe();
|
|
}
|
|
dest.once('finish', onfinish);
|
|
|
|
function 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) {
|
|
// the handler that waits for readable events after all
|
|
// the data gets sucked out in flow.
|
|
// This would be easier to follow with a .once() handler
|
|
// in flow(), but that is too slow.
|
|
this.on('readable', pipeOnReadable);
|
|
|
|
state.flowing = true;
|
|
setImmediate(function() {
|
|
flow(src);
|
|
});
|
|
}
|
|
|
|
return dest;
|
|
};
|
|
|
|
function pipeOnDrain(src) {
|
|
return function() {
|
|
var dest = this;
|
|
var state = src._readableState;
|
|
state.awaitDrain--;
|
|
if (state.awaitDrain === 0)
|
|
flow(src);
|
|
};
|
|
}
|
|
|
|
function flow(src) {
|
|
var state = src._readableState;
|
|
var chunk;
|
|
state.awaitDrain = 0;
|
|
|
|
function write(dest, i, list) {
|
|
var written = dest.write(chunk);
|
|
if (false === written) {
|
|
state.awaitDrain++;
|
|
}
|
|
}
|
|
|
|
while (state.pipesCount && null !== (chunk = src.read())) {
|
|
|
|
if (state.pipesCount === 1)
|
|
write(state.pipes, 0, null);
|
|
else
|
|
forEach(state.pipes, write);
|
|
|
|
src.emit('data', chunk);
|
|
|
|
// if anyone needs a drain, then we have to wait for that.
|
|
if (state.awaitDrain > 0)
|
|
return;
|
|
}
|
|
|
|
// if every destination was unpiped, either before entering this
|
|
// function, or in the while loop, then stop flowing.
|
|
//
|
|
// NB: This is a pretty rare edge case.
|
|
if (state.pipesCount === 0) {
|
|
state.flowing = false;
|
|
|
|
// if there were data event listeners added, then switch to old mode.
|
|
if (EE.listenerCount(src, 'data') > 0)
|
|
emitDataEvents(src);
|
|
return;
|
|
}
|
|
|
|
// at this point, no one needed a drain, so we just ran out of data
|
|
// on the next readable event, start it over again.
|
|
state.ranOut = true;
|
|
}
|
|
|
|
function pipeOnReadable() {
|
|
if (this._readableState.ranOut) {
|
|
this._readableState.ranOut = false;
|
|
flow(this);
|
|
}
|
|
}
|
|
|
|
|
|
Readable.prototype.unpipe = function(dest) {
|
|
var state = this._readableState;
|
|
|
|
// 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;
|
|
this.removeListener('readable', pipeOnReadable);
|
|
state.flowing = false;
|
|
if (dest)
|
|
dest.emit('unpipe', this);
|
|
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;
|
|
this.removeListener('readable', pipeOnReadable);
|
|
state.flowing = false;
|
|
|
|
for (var i = 0; i < len; i++)
|
|
dests[i].emit('unpipe', this);
|
|
return this;
|
|
}
|
|
|
|
// try to find the right one.
|
|
var i = indexOf(state.pipes, dest);
|
|
if (i === -1)
|
|
return this;
|
|
|
|
state.pipes.splice(i, 1);
|
|
state.pipesCount -= 1;
|
|
if (state.pipesCount === 1)
|
|
state.pipes = state.pipes[0];
|
|
|
|
dest.emit('unpipe', this);
|
|
|
|
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' && !this._readableState.flowing)
|
|
emitDataEvents(this);
|
|
|
|
if (ev === 'readable' && this.readable) {
|
|
var state = this._readableState;
|
|
if (!state.readableListening) {
|
|
state.readableListening = true;
|
|
state.emittedReadable = false;
|
|
state.needReadable = true;
|
|
if (!state.reading) {
|
|
this.read(0);
|
|
} else if (state.length) {
|
|
emitReadable(this, state);
|
|
}
|
|
}
|
|
}
|
|
|
|
return res;
|
|
};
|
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
|
|
// pause() and resume() are remnants of the legacy readable stream API
|
|
// If the user uses them, then switch into old mode.
|
|
Readable.prototype.resume = function() {
|
|
emitDataEvents(this);
|
|
this.read(0);
|
|
this.emit('resume');
|
|
};
|
|
|
|
Readable.prototype.pause = function() {
|
|
emitDataEvents(this, true);
|
|
this.emit('pause');
|
|
};
|
|
|
|
function emitDataEvents(stream, startPaused) {
|
|
var state = stream._readableState;
|
|
|
|
if (state.flowing) {
|
|
// https://github.com/isaacs/readable-stream/issues/16
|
|
throw new Error('Cannot switch to old mode now.');
|
|
}
|
|
|
|
var paused = startPaused || false;
|
|
var readable = false;
|
|
|
|
// convert to an old-style stream.
|
|
stream.readable = true;
|
|
stream.pipe = Stream.prototype.pipe;
|
|
stream.on = stream.addListener = Stream.prototype.on;
|
|
|
|
stream.on('readable', function() {
|
|
readable = true;
|
|
|
|
var c;
|
|
while (!paused && (null !== (c = stream.read())))
|
|
stream.emit('data', c);
|
|
|
|
if (c === null) {
|
|
readable = false;
|
|
stream._readableState.needReadable = true;
|
|
}
|
|
});
|
|
|
|
stream.pause = function() {
|
|
paused = true;
|
|
this.emit('pause');
|
|
};
|
|
|
|
stream.resume = function() {
|
|
paused = false;
|
|
if (readable)
|
|
setImmediate(function() {
|
|
stream.emit('readable');
|
|
});
|
|
else
|
|
this.read(0);
|
|
this.emit('resume');
|
|
};
|
|
|
|
// now make it start, just in case it hadn't already.
|
|
stream.emit('readable');
|
|
}
|
|
|
|
// wrap an old-style stream as the async data source.
|
|
// This is *not* part of the readable stream interface.
|
|
// It is an ugly unfortunate mess of history.
|
|
Readable.prototype.wrap = function(stream) {
|
|
var state = this._readableState;
|
|
var paused = false;
|
|
|
|
var self = this;
|
|
stream.on('end', function() {
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length)
|
|
self.push(chunk);
|
|
}
|
|
|
|
self.push(null);
|
|
});
|
|
|
|
stream.on('data', function(chunk) {
|
|
if (state.decoder)
|
|
chunk = state.decoder.write(chunk);
|
|
if (!chunk || !state.objectMode && !chunk.length)
|
|
return;
|
|
|
|
var ret = self.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 (typeof stream[i] === 'function' &&
|
|
typeof this[i] === 'undefined') {
|
|
this[i] = function(method) { return function() {
|
|
return stream[method].apply(stream, arguments);
|
|
}}(i);
|
|
}
|
|
}
|
|
|
|
// proxy certain important events.
|
|
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
forEach(events, function(ev) {
|
|
stream.on(ev, function (x) {
|
|
return self.emit.apply(self, ev, x);
|
|
});
|
|
});
|
|
|
|
// when we try to consume some more bytes, simply unpause the
|
|
// underlying stream.
|
|
self._read = function(n) {
|
|
if (paused) {
|
|
paused = false;
|
|
stream.resume();
|
|
}
|
|
};
|
|
|
|
return self;
|
|
};
|
|
|
|
|
|
|
|
// 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.
|
|
function fromList(n, state) {
|
|
var list = state.buffer;
|
|
var length = state.length;
|
|
var stringMode = !!state.decoder;
|
|
var objectMode = !!state.objectMode;
|
|
var ret;
|
|
|
|
// nothing in the list, definitely empty.
|
|
if (list.length === 0)
|
|
return null;
|
|
|
|
if (length === 0)
|
|
ret = null;
|
|
else if (objectMode)
|
|
ret = list.shift();
|
|
else if (!n || n >= length) {
|
|
// read it all, truncate the array.
|
|
if (stringMode)
|
|
ret = list.join('');
|
|
else
|
|
ret = Buffer.concat(list, length);
|
|
list.length = 0;
|
|
} else {
|
|
// read just some of it.
|
|
if (n < list[0].length) {
|
|
// just take a part of the first list item.
|
|
// slice is the same for buffers and strings.
|
|
var buf = list[0];
|
|
ret = buf.slice(0, n);
|
|
list[0] = buf.slice(n);
|
|
} else if (n === list[0].length) {
|
|
// first list is a perfect match
|
|
ret = list.shift();
|
|
} else {
|
|
// complex case.
|
|
// we have enough to cover it, but it spans past the first buffer.
|
|
if (stringMode)
|
|
ret = '';
|
|
else
|
|
ret = new Buffer(n);
|
|
|
|
var c = 0;
|
|
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
|
var buf = list[0];
|
|
var cpy = Math.min(n - c, buf.length);
|
|
|
|
if (stringMode)
|
|
ret += buf.slice(0, cpy);
|
|
else
|
|
buf.copy(ret, c, 0, cpy);
|
|
|
|
if (cpy < buf.length)
|
|
list[0] = buf.slice(cpy);
|
|
else
|
|
list.shift();
|
|
|
|
c += cpy;
|
|
}
|
|
}
|
|
}
|
|
|
|
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.calledRead) {
|
|
state.ended = true;
|
|
setImmediate(function() {
|
|
// 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 forEach (xs, f) {
|
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
f(xs[i], i);
|
|
}
|
|
}
|
|
|
|
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("/home/substack/projects/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
|
|
},{"./index.js":17,"/home/substack/projects/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":8,"buffer":9,"events":2,"inherits":7,"process/browser.js":18,"string_decoder":23}],21:[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.
|
|
|
|
module.exports = Transform;
|
|
|
|
var Duplex = require('./duplex.js');
|
|
var inherits = require('inherits');
|
|
inherits(Transform, Duplex);
|
|
|
|
|
|
function TransformState(options, stream) {
|
|
this.afterTransform = function(er, data) {
|
|
return afterTransform(stream, er, data);
|
|
};
|
|
|
|
this.needTransform = false;
|
|
this.transforming = false;
|
|
this.writecb = null;
|
|
this.writechunk = null;
|
|
}
|
|
|
|
function afterTransform(stream, er, data) {
|
|
var ts = stream._transformState;
|
|
ts.transforming = false;
|
|
|
|
var cb = ts.writecb;
|
|
|
|
if (!cb)
|
|
return stream.emit('error', new Error('no writecb in Transform class'));
|
|
|
|
ts.writechunk = null;
|
|
ts.writecb = null;
|
|
|
|
if (data !== null && data !== undefined)
|
|
stream.push(data);
|
|
|
|
if (cb)
|
|
cb(er);
|
|
|
|
var rs = stream._readableState;
|
|
rs.reading = false;
|
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
stream._read(rs.highWaterMark);
|
|
}
|
|
}
|
|
|
|
|
|
function Transform(options) {
|
|
if (!(this instanceof Transform))
|
|
return new Transform(options);
|
|
|
|
Duplex.call(this, options);
|
|
|
|
var ts = this._transformState = new TransformState(options, this);
|
|
|
|
// when the writable side finishes, then flush out anything remaining.
|
|
var stream = this;
|
|
|
|
// 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;
|
|
|
|
this.once('finish', function() {
|
|
if ('function' === typeof this._flush)
|
|
this._flush(function(er) {
|
|
done(stream, er);
|
|
});
|
|
else
|
|
done(stream);
|
|
});
|
|
}
|
|
|
|
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('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 && 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;
|
|
}
|
|
};
|
|
|
|
|
|
function done(stream, er) {
|
|
if (er)
|
|
return stream.emit('error', er);
|
|
|
|
// if there's nothing in the write buffer, then that means
|
|
// that nothing more will ever be provided
|
|
var ws = stream._writableState;
|
|
var rs = stream._readableState;
|
|
var ts = stream._transformState;
|
|
|
|
if (ws.length)
|
|
throw new Error('calling transform done when ws.length != 0');
|
|
|
|
if (ts.transforming)
|
|
throw new Error('calling transform done when still transforming');
|
|
|
|
return stream.push(null);
|
|
}
|
|
|
|
},{"./duplex.js":16,"inherits":7}],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.
|
|
|
|
// A bit simpler than readable streams.
|
|
// Implement an async ._write(chunk, cb), and it'll handle all
|
|
// the drain event emission and buffering.
|
|
|
|
module.exports = Writable;
|
|
Writable.WritableState = WritableState;
|
|
|
|
var isUint8Array = typeof Uint8Array !== 'undefined'
|
|
? function (x) { return x instanceof Uint8Array }
|
|
: function (x) {
|
|
return x && x.constructor && x.constructor.name === 'Uint8Array'
|
|
}
|
|
;
|
|
var isArrayBuffer = typeof ArrayBuffer !== 'undefined'
|
|
? function (x) { return x instanceof ArrayBuffer }
|
|
: function (x) {
|
|
return x && x.constructor && x.constructor.name === 'ArrayBuffer'
|
|
}
|
|
;
|
|
|
|
var inherits = require('inherits');
|
|
var Stream = require('./index.js');
|
|
var setImmediate = require('process/browser.js').nextTick;
|
|
var Buffer = require('buffer').Buffer;
|
|
|
|
inherits(Writable, Stream);
|
|
|
|
function WriteReq(chunk, encoding, cb) {
|
|
this.chunk = chunk;
|
|
this.encoding = encoding;
|
|
this.callback = cb;
|
|
}
|
|
|
|
function WritableState(options, stream) {
|
|
options = options || {};
|
|
|
|
// the point at which write() starts returning false
|
|
// Note: 0 is a valid value, means that we always return false if
|
|
// the entire buffer is not flushed immediately on write()
|
|
var hwm = options.highWaterMark;
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
|
|
|
// object stream flag to indicate whether or not this stream
|
|
// contains buffers or objects.
|
|
this.objectMode = !!options.objectMode;
|
|
|
|
// cast to ints.
|
|
this.highWaterMark = ~~this.highWaterMark;
|
|
|
|
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;
|
|
|
|
// 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;
|
|
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
// or on a later tick. We set this to true at first, becuase any
|
|
// 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.buffer = [];
|
|
}
|
|
|
|
function Writable(options) {
|
|
// Writable ctor is applied to Duplexes, though they're not
|
|
// instanceof Writable, they're instanceof Readable.
|
|
if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
|
|
return new Writable(options);
|
|
|
|
this._writableState = new WritableState(options, this);
|
|
|
|
// legacy.
|
|
this.writable = true;
|
|
|
|
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, state, cb) {
|
|
var er = new Error('write after end');
|
|
// TODO: defer error events consistently everywhere, not just the cb
|
|
stream.emit('error', er);
|
|
setImmediate(function() {
|
|
cb(er);
|
|
});
|
|
}
|
|
|
|
// If we get something that is not a buffer, string, null, or undefined,
|
|
// and we're not in objectMode, then that's an error.
|
|
// Otherwise stream chunks are all considered to be of length=1, and the
|
|
// watermarks determine how many objects to keep in the buffer, rather than
|
|
// how many bytes or characters.
|
|
function validChunk(stream, state, chunk, cb) {
|
|
var valid = true;
|
|
if (!Buffer.isBuffer(chunk) &&
|
|
'string' !== typeof chunk &&
|
|
chunk !== null &&
|
|
chunk !== undefined &&
|
|
!state.objectMode) {
|
|
var er = new TypeError('Invalid non-string/buffer chunk');
|
|
stream.emit('error', er);
|
|
setImmediate(function() {
|
|
cb(er);
|
|
});
|
|
valid = false;
|
|
}
|
|
return valid;
|
|
}
|
|
|
|
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
var state = this._writableState;
|
|
var ret = false;
|
|
|
|
if (typeof encoding === 'function') {
|
|
cb = encoding;
|
|
encoding = null;
|
|
}
|
|
|
|
if (!Buffer.isBuffer(chunk) && isUint8Array(chunk))
|
|
chunk = new Buffer(chunk);
|
|
if (isArrayBuffer(chunk) && typeof Uint8Array !== 'undefined')
|
|
chunk = new Buffer(new Uint8Array(chunk));
|
|
|
|
if (Buffer.isBuffer(chunk))
|
|
encoding = 'buffer';
|
|
else if (!encoding)
|
|
encoding = state.defaultEncoding;
|
|
|
|
if (typeof cb !== 'function')
|
|
cb = function() {};
|
|
|
|
if (state.ended)
|
|
writeAfterEnd(this, state, cb);
|
|
else if (validChunk(this, state, chunk, cb))
|
|
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
|
|
|
return ret;
|
|
};
|
|
|
|
function decodeChunk(state, chunk, encoding) {
|
|
if (!state.objectMode &&
|
|
state.decodeStrings !== false &&
|
|
typeof chunk === 'string') {
|
|
chunk = new Buffer(chunk, encoding);
|
|
}
|
|
return chunk;
|
|
}
|
|
|
|
// 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, chunk, encoding, cb) {
|
|
chunk = decodeChunk(state, chunk, encoding);
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
state.length += len;
|
|
|
|
var ret = state.length < state.highWaterMark;
|
|
state.needDrain = !ret;
|
|
|
|
if (state.writing)
|
|
state.buffer.push(new WriteReq(chunk, encoding, cb));
|
|
else
|
|
doWrite(stream, state, len, chunk, encoding, cb);
|
|
|
|
return ret;
|
|
}
|
|
|
|
function doWrite(stream, state, len, chunk, encoding, cb) {
|
|
state.writelen = len;
|
|
state.writecb = cb;
|
|
state.writing = true;
|
|
state.sync = true;
|
|
stream._write(chunk, encoding, state.onwrite);
|
|
state.sync = false;
|
|
}
|
|
|
|
function onwriteError(stream, state, sync, er, cb) {
|
|
if (sync)
|
|
setImmediate(function() {
|
|
cb(er);
|
|
});
|
|
else
|
|
cb(er);
|
|
|
|
stream.emit('error', er);
|
|
}
|
|
|
|
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(stream, state);
|
|
|
|
if (!finished && !state.bufferProcessing && state.buffer.length)
|
|
clearBuffer(stream, state);
|
|
|
|
if (sync) {
|
|
setImmediate(function() {
|
|
afterWrite(stream, state, finished, cb);
|
|
});
|
|
} else {
|
|
afterWrite(stream, state, finished, cb);
|
|
}
|
|
}
|
|
}
|
|
|
|
function afterWrite(stream, state, finished, cb) {
|
|
if (!finished)
|
|
onwriteDrain(stream, state);
|
|
cb();
|
|
if (finished)
|
|
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;
|
|
|
|
for (var c = 0; c < state.buffer.length; c++) {
|
|
var entry = state.buffer[c];
|
|
var chunk = entry.chunk;
|
|
var encoding = entry.encoding;
|
|
var cb = entry.callback;
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
doWrite(stream, state, len, chunk, encoding, cb);
|
|
|
|
// if we didn't call the onwrite immediately, then
|
|
// it means that we need to wait until it does.
|
|
// also, that means that the chunk and cb are currently
|
|
// being processed, so move the buffer counter past them.
|
|
if (state.writing) {
|
|
c++;
|
|
break;
|
|
}
|
|
}
|
|
|
|
state.bufferProcessing = false;
|
|
if (c < state.buffer.length)
|
|
state.buffer = state.buffer.slice(c);
|
|
else
|
|
state.buffer.length = 0;
|
|
}
|
|
|
|
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
cb(new Error('not implemented'));
|
|
};
|
|
|
|
Writable.prototype.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 (typeof chunk !== 'undefined' && chunk !== null)
|
|
this.write(chunk, encoding);
|
|
|
|
// ignore unnecessary end() calls.
|
|
if (!state.ending && !state.finished)
|
|
endWritable(this, state, cb);
|
|
};
|
|
|
|
|
|
function needFinish(stream, state) {
|
|
return (state.ending &&
|
|
state.length === 0 &&
|
|
!state.finished &&
|
|
!state.writing);
|
|
}
|
|
|
|
function finishMaybe(stream, state) {
|
|
var need = needFinish(stream, state);
|
|
if (need) {
|
|
state.finished = true;
|
|
stream.emit('finish');
|
|
}
|
|
return need;
|
|
}
|
|
|
|
function endWritable(stream, state, cb) {
|
|
state.ending = true;
|
|
finishMaybe(stream, state);
|
|
if (cb) {
|
|
if (state.finished)
|
|
setImmediate(cb);
|
|
else
|
|
stream.once('finish', cb);
|
|
}
|
|
state.ended = true;
|
|
}
|
|
|
|
},{"./index.js":17,"buffer":9,"inherits":7,"process/browser.js":18}],23:[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 Buffer = require('buffer').Buffer;
|
|
|
|
function assertEncoding(encoding) {
|
|
if (encoding && !Buffer.isEncoding(encoding)) {
|
|
throw new Error('Unknown encoding: ' + encoding);
|
|
}
|
|
}
|
|
|
|
var StringDecoder = exports.StringDecoder = function(encoding) {
|
|
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
|
assertEncoding(encoding);
|
|
switch (this.encoding) {
|
|
case 'utf8':
|
|
// CESU-8 represents each of Surrogate Pair by 3-bytes
|
|
this.surrogateSize = 3;
|
|
break;
|
|
case 'ucs2':
|
|
case 'utf16le':
|
|
// UTF-16 represents each of Surrogate Pair by 2-bytes
|
|
this.surrogateSize = 2;
|
|
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
|
break;
|
|
case 'base64':
|
|
// Base-64 stores 3 bytes in 4 chars, and pads the remainder.
|
|
this.surrogateSize = 3;
|
|
this.detectIncompleteChar = base64DetectIncompleteChar;
|
|
break;
|
|
default:
|
|
this.write = passThroughWrite;
|
|
return;
|
|
}
|
|
|
|
this.charBuffer = new Buffer(6);
|
|
this.charReceived = 0;
|
|
this.charLength = 0;
|
|
};
|
|
|
|
|
|
StringDecoder.prototype.write = function(buffer) {
|
|
var charStr = '';
|
|
var offset = 0;
|
|
|
|
// if our last write ended with an incomplete multibyte character
|
|
while (this.charLength) {
|
|
// determine how many remaining bytes this buffer has to offer for this char
|
|
var i = (buffer.length >= this.charLength - this.charReceived) ?
|
|
this.charLength - this.charReceived :
|
|
buffer.length;
|
|
|
|
// add the new bytes to the char buffer
|
|
buffer.copy(this.charBuffer, this.charReceived, offset, i);
|
|
this.charReceived += (i - offset);
|
|
offset = i;
|
|
|
|
if (this.charReceived < this.charLength) {
|
|
// still not enough chars in this buffer? wait for more ...
|
|
return '';
|
|
}
|
|
|
|
// get the character that was split
|
|
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
|
|
|
// lead surrogate (D800-DBFF) is also the incomplete character
|
|
var charCode = charStr.charCodeAt(charStr.length - 1);
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
this.charLength += this.surrogateSize;
|
|
charStr = '';
|
|
continue;
|
|
}
|
|
this.charReceived = this.charLength = 0;
|
|
|
|
// if there are no more bytes in this buffer, just emit our char
|
|
if (i == buffer.length) return charStr;
|
|
|
|
// otherwise cut off the characters end from the beginning of this buffer
|
|
buffer = buffer.slice(i, buffer.length);
|
|
break;
|
|
}
|
|
|
|
var lenIncomplete = this.detectIncompleteChar(buffer);
|
|
|
|
var end = buffer.length;
|
|
if (this.charLength) {
|
|
// buffer the incomplete character bytes we got
|
|
buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);
|
|
this.charReceived = lenIncomplete;
|
|
end -= lenIncomplete;
|
|
}
|
|
|
|
charStr += buffer.toString(this.encoding, 0, end);
|
|
|
|
var end = charStr.length - 1;
|
|
var charCode = charStr.charCodeAt(end);
|
|
// lead surrogate (D800-DBFF) is also the incomplete character
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
var size = this.surrogateSize;
|
|
this.charLength += size;
|
|
this.charReceived += size;
|
|
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
|
this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);
|
|
return charStr.substring(0, end);
|
|
}
|
|
|
|
// or just emit the charStr
|
|
return charStr;
|
|
};
|
|
|
|
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
|
// determine how many bytes we have to check at the end of this buffer
|
|
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
|
|
|
// Figure out if one of the last i bytes of our buffer announces an
|
|
// incomplete char.
|
|
for (; i > 0; i--) {
|
|
var c = buffer[buffer.length - i];
|
|
|
|
// See http://en.wikipedia.org/wiki/UTF-8#Description
|
|
|
|
// 110XXXXX
|
|
if (i == 1 && c >> 5 == 0x06) {
|
|
this.charLength = 2;
|
|
break;
|
|
}
|
|
|
|
// 1110XXXX
|
|
if (i <= 2 && c >> 4 == 0x0E) {
|
|
this.charLength = 3;
|
|
break;
|
|
}
|
|
|
|
// 11110XXX
|
|
if (i <= 3 && c >> 3 == 0x1E) {
|
|
this.charLength = 4;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return i;
|
|
};
|
|
|
|
StringDecoder.prototype.end = function(buffer) {
|
|
var res = '';
|
|
if (buffer && buffer.length)
|
|
res = this.write(buffer);
|
|
|
|
if (this.charReceived) {
|
|
var cr = this.charReceived;
|
|
var buf = this.charBuffer;
|
|
var enc = this.encoding;
|
|
res += buf.slice(0, cr).toString(enc);
|
|
}
|
|
|
|
return res;
|
|
};
|
|
|
|
function passThroughWrite(buffer) {
|
|
return buffer.toString(this.encoding);
|
|
}
|
|
|
|
function utf16DetectIncompleteChar(buffer) {
|
|
var incomplete = this.charReceived = buffer.length % 2;
|
|
this.charLength = incomplete ? 2 : 0;
|
|
return incomplete;
|
|
}
|
|
|
|
function base64DetectIncompleteChar(buffer) {
|
|
var incomplete = this.charReceived = buffer.length % 3;
|
|
this.charLength = incomplete ? 3 : 0;
|
|
return incomplete;
|
|
}
|
|
|
|
},{"buffer":9}],24:[function(require,module,exports){
|
|
/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
|
|
(function () {
|
|
"use strict";
|
|
|
|
// 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 punycode = require('punycode');
|
|
|
|
exports.parse = urlParse;
|
|
exports.resolve = urlResolve;
|
|
exports.resolveObject = urlResolveObject;
|
|
exports.format = urlFormat;
|
|
|
|
// Reference: RFC 3986, RFC 1808, RFC 2396
|
|
|
|
// define these here so at least they only have to be
|
|
// compiled once on the first module load.
|
|
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
|
portPattern = /:[0-9]*$/,
|
|
|
|
// RFC 2396: characters reserved for delimiting URLs.
|
|
// We actually just auto-escape these.
|
|
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
|
|
|
// RFC 2396: characters not allowed for various reasons.
|
|
unwise = ['{', '}', '|', '\\', '^', '~', '`'].concat(delims),
|
|
|
|
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
|
autoEscape = ['\''].concat(delims),
|
|
// Characters that are never ever allowed in a hostname.
|
|
// Note that any invalid chars are also handled, but these
|
|
// are the ones that are *expected* to be seen, so we fast-path
|
|
// them.
|
|
nonHostChars = ['%', '/', '?', ';', '#']
|
|
.concat(unwise).concat(autoEscape),
|
|
nonAuthChars = ['/', '@', '?', '#'].concat(delims),
|
|
hostnameMaxLen = 255,
|
|
hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,
|
|
hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,
|
|
// protocols that can allow "unsafe" and "unwise" chars.
|
|
unsafeProtocol = {
|
|
'javascript': true,
|
|
'javascript:': true
|
|
},
|
|
// protocols that never have a hostname.
|
|
hostlessProtocol = {
|
|
'javascript': true,
|
|
'javascript:': true
|
|
},
|
|
// protocols that always have a path component.
|
|
pathedProtocol = {
|
|
'http': true,
|
|
'https': true,
|
|
'ftp': true,
|
|
'gopher': true,
|
|
'file': true,
|
|
'http:': true,
|
|
'ftp:': true,
|
|
'gopher:': true,
|
|
'file:': true
|
|
},
|
|
// protocols that always contain a // bit.
|
|
slashedProtocol = {
|
|
'http': true,
|
|
'https': true,
|
|
'ftp': true,
|
|
'gopher': true,
|
|
'file': true,
|
|
'http:': true,
|
|
'https:': true,
|
|
'ftp:': true,
|
|
'gopher:': true,
|
|
'file:': true
|
|
},
|
|
querystring = require('querystring');
|
|
|
|
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
|
if (url && typeof(url) === 'object' && url.href) return url;
|
|
|
|
if (typeof url !== 'string') {
|
|
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
|
}
|
|
|
|
var out = {},
|
|
rest = url;
|
|
|
|
// trim before proceeding.
|
|
// This is to support parse stuff like " http://foo.com \n"
|
|
rest = rest.trim();
|
|
|
|
var proto = protocolPattern.exec(rest);
|
|
if (proto) {
|
|
proto = proto[0];
|
|
var lowerProto = proto.toLowerCase();
|
|
out.protocol = lowerProto;
|
|
rest = rest.substr(proto.length);
|
|
}
|
|
|
|
// figure out if it's got a host
|
|
// user@server is *always* interpreted as a hostname, and url
|
|
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
|
// how the browser resolves relative URLs.
|
|
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
var slashes = rest.substr(0, 2) === '//';
|
|
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
rest = rest.substr(2);
|
|
out.slashes = true;
|
|
}
|
|
}
|
|
|
|
if (!hostlessProtocol[proto] &&
|
|
(slashes || (proto && !slashedProtocol[proto]))) {
|
|
// there's a hostname.
|
|
// the first instance of /, ?, ;, or # ends the host.
|
|
// don't enforce full RFC correctness, just be unstupid about it.
|
|
|
|
// If there is an @ in the hostname, then non-host chars *are* allowed
|
|
// to the left of the first @ sign, unless some non-auth character
|
|
// comes *before* the @-sign.
|
|
// URLs are obnoxious.
|
|
var atSign = rest.indexOf('@');
|
|
if (atSign !== -1) {
|
|
var auth = rest.slice(0, atSign);
|
|
|
|
// there *may be* an auth
|
|
var hasAuth = true;
|
|
for (var i = 0, l = nonAuthChars.length; i < l; i++) {
|
|
if (auth.indexOf(nonAuthChars[i]) !== -1) {
|
|
// not a valid auth. Something like http://foo.com/bar@baz/
|
|
hasAuth = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (hasAuth) {
|
|
// pluck off the auth portion.
|
|
out.auth = decodeURIComponent(auth);
|
|
rest = rest.substr(atSign + 1);
|
|
}
|
|
}
|
|
|
|
var firstNonHost = -1;
|
|
for (var i = 0, l = nonHostChars.length; i < l; i++) {
|
|
var index = rest.indexOf(nonHostChars[i]);
|
|
if (index !== -1 &&
|
|
(firstNonHost < 0 || index < firstNonHost)) firstNonHost = index;
|
|
}
|
|
|
|
if (firstNonHost !== -1) {
|
|
out.host = rest.substr(0, firstNonHost);
|
|
rest = rest.substr(firstNonHost);
|
|
} else {
|
|
out.host = rest;
|
|
rest = '';
|
|
}
|
|
|
|
// pull out port.
|
|
var p = parseHost(out.host);
|
|
var keys = Object.keys(p);
|
|
for (var i = 0, l = keys.length; i < l; i++) {
|
|
var key = keys[i];
|
|
out[key] = p[key];
|
|
}
|
|
|
|
// we've indicated that there is a hostname,
|
|
// so even if it's empty, it has to be present.
|
|
out.hostname = out.hostname || '';
|
|
|
|
// if hostname begins with [ and ends with ]
|
|
// assume that it's an IPv6 address.
|
|
var ipv6Hostname = out.hostname[0] === '[' &&
|
|
out.hostname[out.hostname.length - 1] === ']';
|
|
|
|
// validate a little.
|
|
if (out.hostname.length > hostnameMaxLen) {
|
|
out.hostname = '';
|
|
} else if (!ipv6Hostname) {
|
|
var hostparts = out.hostname.split(/\./);
|
|
for (var i = 0, l = hostparts.length; i < l; i++) {
|
|
var part = hostparts[i];
|
|
if (!part) continue;
|
|
if (!part.match(hostnamePartPattern)) {
|
|
var newpart = '';
|
|
for (var j = 0, k = part.length; j < k; j++) {
|
|
if (part.charCodeAt(j) > 127) {
|
|
// we replace non-ASCII char with a temporary placeholder
|
|
// we need this to make sure size of hostname is not
|
|
// broken by replacing non-ASCII by nothing
|
|
newpart += 'x';
|
|
} else {
|
|
newpart += part[j];
|
|
}
|
|
}
|
|
// we test again with ASCII char only
|
|
if (!newpart.match(hostnamePartPattern)) {
|
|
var validParts = hostparts.slice(0, i);
|
|
var notHost = hostparts.slice(i + 1);
|
|
var bit = part.match(hostnamePartStart);
|
|
if (bit) {
|
|
validParts.push(bit[1]);
|
|
notHost.unshift(bit[2]);
|
|
}
|
|
if (notHost.length) {
|
|
rest = '/' + notHost.join('.') + rest;
|
|
}
|
|
out.hostname = validParts.join('.');
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// hostnames are always lower case.
|
|
out.hostname = out.hostname.toLowerCase();
|
|
|
|
if (!ipv6Hostname) {
|
|
// IDNA Support: Returns a puny coded representation of "domain".
|
|
// It only converts the part of the domain name that
|
|
// has non ASCII characters. I.e. it dosent matter if
|
|
// you call it with a domain that already is in ASCII.
|
|
var domainArray = out.hostname.split('.');
|
|
var newOut = [];
|
|
for (var i = 0; i < domainArray.length; ++i) {
|
|
var s = domainArray[i];
|
|
newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
|
|
'xn--' + punycode.encode(s) : s);
|
|
}
|
|
out.hostname = newOut.join('.');
|
|
}
|
|
|
|
out.host = (out.hostname || '') +
|
|
((out.port) ? ':' + out.port : '');
|
|
out.href += out.host;
|
|
|
|
// strip [ and ] from the hostname
|
|
if (ipv6Hostname) {
|
|
out.hostname = out.hostname.substr(1, out.hostname.length - 2);
|
|
if (rest[0] !== '/') {
|
|
rest = '/' + rest;
|
|
}
|
|
}
|
|
}
|
|
|
|
// now rest is set to the post-host stuff.
|
|
// chop off any delim chars.
|
|
if (!unsafeProtocol[lowerProto]) {
|
|
|
|
// First, make 100% sure that any "autoEscape" chars get
|
|
// escaped, even if encodeURIComponent doesn't think they
|
|
// need to be.
|
|
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
|
var ae = autoEscape[i];
|
|
var esc = encodeURIComponent(ae);
|
|
if (esc === ae) {
|
|
esc = escape(ae);
|
|
}
|
|
rest = rest.split(ae).join(esc);
|
|
}
|
|
}
|
|
|
|
|
|
// chop off from the tail first.
|
|
var hash = rest.indexOf('#');
|
|
if (hash !== -1) {
|
|
// got a fragment string.
|
|
out.hash = rest.substr(hash);
|
|
rest = rest.slice(0, hash);
|
|
}
|
|
var qm = rest.indexOf('?');
|
|
if (qm !== -1) {
|
|
out.search = rest.substr(qm);
|
|
out.query = rest.substr(qm + 1);
|
|
if (parseQueryString) {
|
|
out.query = querystring.parse(out.query);
|
|
}
|
|
rest = rest.slice(0, qm);
|
|
} else if (parseQueryString) {
|
|
// no query string, but parseQueryString still requested
|
|
out.search = '';
|
|
out.query = {};
|
|
}
|
|
if (rest) out.pathname = rest;
|
|
if (slashedProtocol[proto] &&
|
|
out.hostname && !out.pathname) {
|
|
out.pathname = '/';
|
|
}
|
|
|
|
//to support http.request
|
|
if (out.pathname || out.search) {
|
|
out.path = (out.pathname ? out.pathname : '') +
|
|
(out.search ? out.search : '');
|
|
}
|
|
|
|
// finally, reconstruct the href based on what has been validated.
|
|
out.href = urlFormat(out);
|
|
return out;
|
|
}
|
|
|
|
// format a parsed object into a url string
|
|
function urlFormat(obj) {
|
|
// ensure it's an object, and not a string url.
|
|
// If it's an obj, this is a no-op.
|
|
// this way, you can call url_format() on strings
|
|
// to clean up potentially wonky urls.
|
|
if (typeof(obj) === 'string') obj = urlParse(obj);
|
|
|
|
var auth = obj.auth || '';
|
|
if (auth) {
|
|
auth = encodeURIComponent(auth);
|
|
auth = auth.replace(/%3A/i, ':');
|
|
auth += '@';
|
|
}
|
|
|
|
var protocol = obj.protocol || '',
|
|
pathname = obj.pathname || '',
|
|
hash = obj.hash || '',
|
|
host = false,
|
|
query = '';
|
|
|
|
if (obj.host !== undefined) {
|
|
host = auth + obj.host;
|
|
} else if (obj.hostname !== undefined) {
|
|
host = auth + (obj.hostname.indexOf(':') === -1 ?
|
|
obj.hostname :
|
|
'[' + obj.hostname + ']');
|
|
if (obj.port) {
|
|
host += ':' + obj.port;
|
|
}
|
|
}
|
|
|
|
if (obj.query && typeof obj.query === 'object' &&
|
|
Object.keys(obj.query).length) {
|
|
query = querystring.stringify(obj.query);
|
|
}
|
|
|
|
var search = obj.search || (query && ('?' + query)) || '';
|
|
|
|
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
|
|
|
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
|
// unless they had them to begin with.
|
|
if (obj.slashes ||
|
|
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
|
host = '//' + (host || '');
|
|
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
|
} else if (!host) {
|
|
host = '';
|
|
}
|
|
|
|
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
|
if (search && search.charAt(0) !== '?') search = '?' + search;
|
|
|
|
return protocol + host + pathname + search + hash;
|
|
}
|
|
|
|
function urlResolve(source, relative) {
|
|
return urlFormat(urlResolveObject(source, relative));
|
|
}
|
|
|
|
function urlResolveObject(source, relative) {
|
|
if (!source) return relative;
|
|
|
|
source = urlParse(urlFormat(source), false, true);
|
|
relative = urlParse(urlFormat(relative), false, true);
|
|
|
|
// hash is always overridden, no matter what.
|
|
source.hash = relative.hash;
|
|
|
|
if (relative.href === '') {
|
|
source.href = urlFormat(source);
|
|
return source;
|
|
}
|
|
|
|
// hrefs like //foo/bar always cut to the protocol.
|
|
if (relative.slashes && !relative.protocol) {
|
|
relative.protocol = source.protocol;
|
|
//urlParse appends trailing / to urls like http://www.example.com
|
|
if (slashedProtocol[relative.protocol] &&
|
|
relative.hostname && !relative.pathname) {
|
|
relative.path = relative.pathname = '/';
|
|
}
|
|
relative.href = urlFormat(relative);
|
|
return relative;
|
|
}
|
|
|
|
if (relative.protocol && relative.protocol !== source.protocol) {
|
|
// if it's a known url protocol, then changing
|
|
// the protocol does weird things
|
|
// first, if it's not file:, then we MUST have a host,
|
|
// and if there was a path
|
|
// to begin with, then we MUST have a path.
|
|
// if it is file:, then the host is dropped,
|
|
// because that's known to be hostless.
|
|
// anything else is assumed to be absolute.
|
|
if (!slashedProtocol[relative.protocol]) {
|
|
relative.href = urlFormat(relative);
|
|
return relative;
|
|
}
|
|
source.protocol = relative.protocol;
|
|
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
|
var relPath = (relative.pathname || '').split('/');
|
|
while (relPath.length && !(relative.host = relPath.shift()));
|
|
if (!relative.host) relative.host = '';
|
|
if (!relative.hostname) relative.hostname = '';
|
|
if (relPath[0] !== '') relPath.unshift('');
|
|
if (relPath.length < 2) relPath.unshift('');
|
|
relative.pathname = relPath.join('/');
|
|
}
|
|
source.pathname = relative.pathname;
|
|
source.search = relative.search;
|
|
source.query = relative.query;
|
|
source.host = relative.host || '';
|
|
source.auth = relative.auth;
|
|
source.hostname = relative.hostname || relative.host;
|
|
source.port = relative.port;
|
|
//to support http.request
|
|
if (source.pathname !== undefined || source.search !== undefined) {
|
|
source.path = (source.pathname ? source.pathname : '') +
|
|
(source.search ? source.search : '');
|
|
}
|
|
source.slashes = source.slashes || relative.slashes;
|
|
source.href = urlFormat(source);
|
|
return source;
|
|
}
|
|
|
|
var isSourceAbs = (source.pathname && source.pathname.charAt(0) === '/'),
|
|
isRelAbs = (
|
|
relative.host !== undefined ||
|
|
relative.pathname && relative.pathname.charAt(0) === '/'
|
|
),
|
|
mustEndAbs = (isRelAbs || isSourceAbs ||
|
|
(source.host && relative.pathname)),
|
|
removeAllDots = mustEndAbs,
|
|
srcPath = source.pathname && source.pathname.split('/') || [],
|
|
relPath = relative.pathname && relative.pathname.split('/') || [],
|
|
psychotic = source.protocol &&
|
|
!slashedProtocol[source.protocol];
|
|
|
|
// if the url is a non-slashed url, then relative
|
|
// links like ../.. should be able
|
|
// to crawl up to the hostname, as well. This is strange.
|
|
// source.protocol has already been set by now.
|
|
// Later on, put the first path part into the host field.
|
|
if (psychotic) {
|
|
|
|
delete source.hostname;
|
|
delete source.port;
|
|
if (source.host) {
|
|
if (srcPath[0] === '') srcPath[0] = source.host;
|
|
else srcPath.unshift(source.host);
|
|
}
|
|
delete source.host;
|
|
if (relative.protocol) {
|
|
delete relative.hostname;
|
|
delete relative.port;
|
|
if (relative.host) {
|
|
if (relPath[0] === '') relPath[0] = relative.host;
|
|
else relPath.unshift(relative.host);
|
|
}
|
|
delete relative.host;
|
|
}
|
|
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
|
}
|
|
|
|
if (isRelAbs) {
|
|
// it's absolute.
|
|
source.host = (relative.host || relative.host === '') ?
|
|
relative.host : source.host;
|
|
source.hostname = (relative.hostname || relative.hostname === '') ?
|
|
relative.hostname : source.hostname;
|
|
source.search = relative.search;
|
|
source.query = relative.query;
|
|
srcPath = relPath;
|
|
// fall through to the dot-handling below.
|
|
} else if (relPath.length) {
|
|
// it's relative
|
|
// throw away the existing file, and take the new path instead.
|
|
if (!srcPath) srcPath = [];
|
|
srcPath.pop();
|
|
srcPath = srcPath.concat(relPath);
|
|
source.search = relative.search;
|
|
source.query = relative.query;
|
|
} else if ('search' in relative) {
|
|
// just pull out the search.
|
|
// like href='?foo'.
|
|
// Put this after the other two cases because it simplifies the booleans
|
|
if (psychotic) {
|
|
source.hostname = source.host = srcPath.shift();
|
|
//occationaly the auth can get stuck only in host
|
|
//this especialy happens in cases like
|
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
var authInHost = source.host && source.host.indexOf('@') > 0 ?
|
|
source.host.split('@') : false;
|
|
if (authInHost) {
|
|
source.auth = authInHost.shift();
|
|
source.host = source.hostname = authInHost.shift();
|
|
}
|
|
}
|
|
source.search = relative.search;
|
|
source.query = relative.query;
|
|
//to support http.request
|
|
if (source.pathname !== undefined || source.search !== undefined) {
|
|
source.path = (source.pathname ? source.pathname : '') +
|
|
(source.search ? source.search : '');
|
|
}
|
|
source.href = urlFormat(source);
|
|
return source;
|
|
}
|
|
if (!srcPath.length) {
|
|
// no path at all. easy.
|
|
// we've already handled the other stuff above.
|
|
delete source.pathname;
|
|
//to support http.request
|
|
if (!source.search) {
|
|
source.path = '/' + source.search;
|
|
} else {
|
|
delete source.path;
|
|
}
|
|
source.href = urlFormat(source);
|
|
return source;
|
|
}
|
|
// if a url ENDs in . or .., then it must get a trailing slash.
|
|
// however, if it ends in anything else non-slashy,
|
|
// then it must NOT get a trailing slash.
|
|
var last = srcPath.slice(-1)[0];
|
|
var hasTrailingSlash = (
|
|
(source.host || relative.host) && (last === '.' || last === '..') ||
|
|
last === '');
|
|
|
|
// strip single dots, resolve double dots to parent dir
|
|
// if the path tries to go above the root, `up` ends up > 0
|
|
var up = 0;
|
|
for (var i = srcPath.length; i >= 0; i--) {
|
|
last = srcPath[i];
|
|
if (last == '.') {
|
|
srcPath.splice(i, 1);
|
|
} else if (last === '..') {
|
|
srcPath.splice(i, 1);
|
|
up++;
|
|
} else if (up) {
|
|
srcPath.splice(i, 1);
|
|
up--;
|
|
}
|
|
}
|
|
|
|
// if the path is allowed to go above the root, restore leading ..s
|
|
if (!mustEndAbs && !removeAllDots) {
|
|
for (; up--; up) {
|
|
srcPath.unshift('..');
|
|
}
|
|
}
|
|
|
|
if (mustEndAbs && srcPath[0] !== '' &&
|
|
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
|
srcPath.unshift('');
|
|
}
|
|
|
|
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
|
srcPath.push('');
|
|
}
|
|
|
|
var isAbsolute = srcPath[0] === '' ||
|
|
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
|
|
|
// put the host back
|
|
if (psychotic) {
|
|
source.hostname = source.host = isAbsolute ? '' :
|
|
srcPath.length ? srcPath.shift() : '';
|
|
//occationaly the auth can get stuck only in host
|
|
//this especialy happens in cases like
|
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
var authInHost = source.host && source.host.indexOf('@') > 0 ?
|
|
source.host.split('@') : false;
|
|
if (authInHost) {
|
|
source.auth = authInHost.shift();
|
|
source.host = source.hostname = authInHost.shift();
|
|
}
|
|
}
|
|
|
|
mustEndAbs = mustEndAbs || (source.host && srcPath.length);
|
|
|
|
if (mustEndAbs && !isAbsolute) {
|
|
srcPath.unshift('');
|
|
}
|
|
|
|
source.pathname = srcPath.join('/');
|
|
//to support request.http
|
|
if (source.pathname !== undefined || source.search !== undefined) {
|
|
source.path = (source.pathname ? source.pathname : '') +
|
|
(source.search ? source.search : '');
|
|
}
|
|
source.auth = relative.auth || source.auth;
|
|
source.slashes = source.slashes || relative.slashes;
|
|
source.href = urlFormat(source);
|
|
return source;
|
|
}
|
|
|
|
function parseHost(host) {
|
|
var out = {};
|
|
var port = portPattern.exec(host);
|
|
if (port) {
|
|
port = port[0];
|
|
if (port !== ':') {
|
|
out.port = port.substr(1);
|
|
}
|
|
host = host.substr(0, host.length - port.length);
|
|
}
|
|
if (host) out.hostname = host;
|
|
return out;
|
|
}
|
|
|
|
}());
|
|
|
|
},{"punycode":12,"querystring":15}],25:[function(require,module,exports){
|
|
module.exports = function isBuffer(arg) {
|
|
return arg && typeof arg === 'object'
|
|
&& typeof arg.copy === 'function'
|
|
&& typeof arg.fill === 'function'
|
|
&& typeof arg.readUInt8 === 'function';
|
|
}
|
|
},{}],26:[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.
|
|
|
|
var formatRegExp = /%[sdj%]/g;
|
|
exports.format = function(f) {
|
|
if (!isString(f)) {
|
|
var objects = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
objects.push(inspect(arguments[i]));
|
|
}
|
|
return objects.join(' ');
|
|
}
|
|
|
|
var i = 1;
|
|
var args = arguments;
|
|
var len = args.length;
|
|
var str = String(f).replace(formatRegExp, function(x) {
|
|
if (x === '%%') return '%';
|
|
if (i >= len) return x;
|
|
switch (x) {
|
|
case '%s': return String(args[i++]);
|
|
case '%d': return Number(args[i++]);
|
|
case '%j':
|
|
try {
|
|
return JSON.stringify(args[i++]);
|
|
} catch (_) {
|
|
return '[Circular]';
|
|
}
|
|
default:
|
|
return x;
|
|
}
|
|
});
|
|
for (var x = args[i]; i < len; x = args[++i]) {
|
|
if (isNull(x) || !isObject(x)) {
|
|
str += ' ' + x;
|
|
} else {
|
|
str += ' ' + inspect(x);
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
|
|
|
|
// Mark that a method should not be used.
|
|
// Returns a modified function which warns once by default.
|
|
// If --no-deprecation is set, then it is a no-op.
|
|
exports.deprecate = function(fn, msg) {
|
|
// Allow for deprecating things in the process of starting up.
|
|
if (isUndefined(global.process)) {
|
|
return function() {
|
|
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
if (process.noDeprecation === true) {
|
|
return fn;
|
|
}
|
|
|
|
var warned = false;
|
|
function deprecated() {
|
|
if (!warned) {
|
|
if (process.throwDeprecation) {
|
|
throw new Error(msg);
|
|
} else if (process.traceDeprecation) {
|
|
console.trace(msg);
|
|
} else {
|
|
console.error(msg);
|
|
}
|
|
warned = true;
|
|
}
|
|
return fn.apply(this, arguments);
|
|
}
|
|
|
|
return deprecated;
|
|
};
|
|
|
|
|
|
var debugs = {};
|
|
var debugEnviron;
|
|
exports.debuglog = function(set) {
|
|
if (isUndefined(debugEnviron))
|
|
debugEnviron = process.env.NODE_DEBUG || '';
|
|
set = set.toUpperCase();
|
|
if (!debugs[set]) {
|
|
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
|
var pid = process.pid;
|
|
debugs[set] = function() {
|
|
var msg = exports.format.apply(exports, arguments);
|
|
console.error('%s %d: %s', set, pid, msg);
|
|
};
|
|
} else {
|
|
debugs[set] = function() {};
|
|
}
|
|
}
|
|
return debugs[set];
|
|
};
|
|
|
|
|
|
/**
|
|
* Echos the value of a value. Trys to print the value out
|
|
* in the best way possible given the different types.
|
|
*
|
|
* @param {Object} obj The object to print out.
|
|
* @param {Object} opts Optional options object that alters the output.
|
|
*/
|
|
/* legacy: obj, showHidden, depth, colors*/
|
|
function inspect(obj, opts) {
|
|
// default options
|
|
var ctx = {
|
|
seen: [],
|
|
stylize: stylizeNoColor
|
|
};
|
|
// legacy...
|
|
if (arguments.length >= 3) ctx.depth = arguments[2];
|
|
if (arguments.length >= 4) ctx.colors = arguments[3];
|
|
if (isBoolean(opts)) {
|
|
// legacy...
|
|
ctx.showHidden = opts;
|
|
} else if (opts) {
|
|
// got an "options" object
|
|
exports._extend(ctx, opts);
|
|
}
|
|
// set default options
|
|
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
|
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
|
if (isUndefined(ctx.colors)) ctx.colors = false;
|
|
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
|
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
|
return formatValue(ctx, obj, ctx.depth);
|
|
}
|
|
exports.inspect = inspect;
|
|
|
|
|
|
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
|
inspect.colors = {
|
|
'bold' : [1, 22],
|
|
'italic' : [3, 23],
|
|
'underline' : [4, 24],
|
|
'inverse' : [7, 27],
|
|
'white' : [37, 39],
|
|
'grey' : [90, 39],
|
|
'black' : [30, 39],
|
|
'blue' : [34, 39],
|
|
'cyan' : [36, 39],
|
|
'green' : [32, 39],
|
|
'magenta' : [35, 39],
|
|
'red' : [31, 39],
|
|
'yellow' : [33, 39]
|
|
};
|
|
|
|
// Don't use 'blue' not visible on cmd.exe
|
|
inspect.styles = {
|
|
'special': 'cyan',
|
|
'number': 'yellow',
|
|
'boolean': 'yellow',
|
|
'undefined': 'grey',
|
|
'null': 'bold',
|
|
'string': 'green',
|
|
'date': 'magenta',
|
|
// "name": intentionally not styling
|
|
'regexp': 'red'
|
|
};
|
|
|
|
|
|
function stylizeWithColor(str, styleType) {
|
|
var style = inspect.styles[styleType];
|
|
|
|
if (style) {
|
|
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
|
'\u001b[' + inspect.colors[style][1] + 'm';
|
|
} else {
|
|
return str;
|
|
}
|
|
}
|
|
|
|
|
|
function stylizeNoColor(str, styleType) {
|
|
return str;
|
|
}
|
|
|
|
|
|
function arrayToHash(array) {
|
|
var hash = {};
|
|
|
|
array.forEach(function(val, idx) {
|
|
hash[val] = true;
|
|
});
|
|
|
|
return hash;
|
|
}
|
|
|
|
|
|
function formatValue(ctx, value, recurseTimes) {
|
|
// Provide a hook for user-specified inspect functions.
|
|
// Check that value is an object with an inspect function on it
|
|
if (ctx.customInspect &&
|
|
value &&
|
|
isFunction(value.inspect) &&
|
|
// Filter out the util module, it's inspect function is special
|
|
value.inspect !== exports.inspect &&
|
|
// Also filter out any prototype objects using the circular check.
|
|
!(value.constructor && value.constructor.prototype === value)) {
|
|
var ret = value.inspect(recurseTimes, ctx);
|
|
if (!isString(ret)) {
|
|
ret = formatValue(ctx, ret, recurseTimes);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
// Primitive types cannot have properties
|
|
var primitive = formatPrimitive(ctx, value);
|
|
if (primitive) {
|
|
return primitive;
|
|
}
|
|
|
|
// Look up the keys of the object.
|
|
var keys = Object.keys(value);
|
|
var visibleKeys = arrayToHash(keys);
|
|
|
|
if (ctx.showHidden) {
|
|
keys = Object.getOwnPropertyNames(value);
|
|
}
|
|
|
|
// IE doesn't make error fields non-enumerable
|
|
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
|
if (isError(value)
|
|
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
|
return formatError(value);
|
|
}
|
|
|
|
// Some type of object without properties can be shortcutted.
|
|
if (keys.length === 0) {
|
|
if (isFunction(value)) {
|
|
var name = value.name ? ': ' + value.name : '';
|
|
return ctx.stylize('[Function' + name + ']', 'special');
|
|
}
|
|
if (isRegExp(value)) {
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
}
|
|
if (isDate(value)) {
|
|
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
|
}
|
|
if (isError(value)) {
|
|
return formatError(value);
|
|
}
|
|
}
|
|
|
|
var base = '', array = false, braces = ['{', '}'];
|
|
|
|
// Make Array say that they are Array
|
|
if (isArray(value)) {
|
|
array = true;
|
|
braces = ['[', ']'];
|
|
}
|
|
|
|
// Make functions say that they are functions
|
|
if (isFunction(value)) {
|
|
var n = value.name ? ': ' + value.name : '';
|
|
base = ' [Function' + n + ']';
|
|
}
|
|
|
|
// Make RegExps say that they are RegExps
|
|
if (isRegExp(value)) {
|
|
base = ' ' + RegExp.prototype.toString.call(value);
|
|
}
|
|
|
|
// Make dates with properties first say the date
|
|
if (isDate(value)) {
|
|
base = ' ' + Date.prototype.toUTCString.call(value);
|
|
}
|
|
|
|
// Make error with message first say the error
|
|
if (isError(value)) {
|
|
base = ' ' + formatError(value);
|
|
}
|
|
|
|
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
return braces[0] + base + braces[1];
|
|
}
|
|
|
|
if (recurseTimes < 0) {
|
|
if (isRegExp(value)) {
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
} else {
|
|
return ctx.stylize('[Object]', 'special');
|
|
}
|
|
}
|
|
|
|
ctx.seen.push(value);
|
|
|
|
var output;
|
|
if (array) {
|
|
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
} else {
|
|
output = keys.map(function(key) {
|
|
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
});
|
|
}
|
|
|
|
ctx.seen.pop();
|
|
|
|
return reduceToSingleString(output, base, braces);
|
|
}
|
|
|
|
|
|
function formatPrimitive(ctx, value) {
|
|
if (isUndefined(value))
|
|
return ctx.stylize('undefined', 'undefined');
|
|
if (isString(value)) {
|
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
|
.replace(/'/g, "\\'")
|
|
.replace(/\\"/g, '"') + '\'';
|
|
return ctx.stylize(simple, 'string');
|
|
}
|
|
if (isNumber(value))
|
|
return ctx.stylize('' + value, 'number');
|
|
if (isBoolean(value))
|
|
return ctx.stylize('' + value, 'boolean');
|
|
// For some reason typeof null is "object", so special case here.
|
|
if (isNull(value))
|
|
return ctx.stylize('null', 'null');
|
|
}
|
|
|
|
|
|
function formatError(value) {
|
|
return '[' + Error.prototype.toString.call(value) + ']';
|
|
}
|
|
|
|
|
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
var output = [];
|
|
for (var i = 0, l = value.length; i < l; ++i) {
|
|
if (hasOwnProperty(value, String(i))) {
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
String(i), true));
|
|
} else {
|
|
output.push('');
|
|
}
|
|
}
|
|
keys.forEach(function(key) {
|
|
if (!key.match(/^\d+$/)) {
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
key, true));
|
|
}
|
|
});
|
|
return output;
|
|
}
|
|
|
|
|
|
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
var name, str, desc;
|
|
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
if (desc.get) {
|
|
if (desc.set) {
|
|
str = ctx.stylize('[Getter/Setter]', 'special');
|
|
} else {
|
|
str = ctx.stylize('[Getter]', 'special');
|
|
}
|
|
} else {
|
|
if (desc.set) {
|
|
str = ctx.stylize('[Setter]', 'special');
|
|
}
|
|
}
|
|
if (!hasOwnProperty(visibleKeys, key)) {
|
|
name = '[' + key + ']';
|
|
}
|
|
if (!str) {
|
|
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
if (isNull(recurseTimes)) {
|
|
str = formatValue(ctx, desc.value, null);
|
|
} else {
|
|
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
}
|
|
if (str.indexOf('\n') > -1) {
|
|
if (array) {
|
|
str = str.split('\n').map(function(line) {
|
|
return ' ' + line;
|
|
}).join('\n').substr(2);
|
|
} else {
|
|
str = '\n' + str.split('\n').map(function(line) {
|
|
return ' ' + line;
|
|
}).join('\n');
|
|
}
|
|
}
|
|
} else {
|
|
str = ctx.stylize('[Circular]', 'special');
|
|
}
|
|
}
|
|
if (isUndefined(name)) {
|
|
if (array && key.match(/^\d+$/)) {
|
|
return str;
|
|
}
|
|
name = JSON.stringify('' + key);
|
|
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
name = name.substr(1, name.length - 2);
|
|
name = ctx.stylize(name, 'name');
|
|
} else {
|
|
name = name.replace(/'/g, "\\'")
|
|
.replace(/\\"/g, '"')
|
|
.replace(/(^"|"$)/g, "'");
|
|
name = ctx.stylize(name, 'string');
|
|
}
|
|
}
|
|
|
|
return name + ': ' + str;
|
|
}
|
|
|
|
|
|
function reduceToSingleString(output, base, braces) {
|
|
var numLinesEst = 0;
|
|
var length = output.reduce(function(prev, cur) {
|
|
numLinesEst++;
|
|
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
|
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
|
}, 0);
|
|
|
|
if (length > 60) {
|
|
return braces[0] +
|
|
(base === '' ? '' : base + '\n ') +
|
|
' ' +
|
|
output.join(',\n ') +
|
|
' ' +
|
|
braces[1];
|
|
}
|
|
|
|
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
|
}
|
|
|
|
|
|
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
// because it is fragile and can be easily faked with `Object.create()`.
|
|
function isArray(ar) {
|
|
return Array.isArray(ar);
|
|
}
|
|
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 isObject(re) && objectToString(re) === '[object RegExp]';
|
|
}
|
|
exports.isRegExp = isRegExp;
|
|
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
exports.isObject = isObject;
|
|
|
|
function isDate(d) {
|
|
return isObject(d) && objectToString(d) === '[object Date]';
|
|
}
|
|
exports.isDate = isDate;
|
|
|
|
function isError(e) {
|
|
return isObject(e) &&
|
|
(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 = require('./support/isBuffer');
|
|
|
|
function objectToString(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
|
|
|
|
function pad(n) {
|
|
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
|
}
|
|
|
|
|
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
|
'Oct', 'Nov', 'Dec'];
|
|
|
|
// 26 Feb 16:19:34
|
|
function timestamp() {
|
|
var d = new Date();
|
|
var time = [pad(d.getHours()),
|
|
pad(d.getMinutes()),
|
|
pad(d.getSeconds())].join(':');
|
|
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
|
}
|
|
|
|
|
|
// log is just a thin wrapper to console.log that prepends a timestamp
|
|
exports.log = function() {
|
|
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
|
};
|
|
|
|
|
|
/**
|
|
* Inherit the prototype methods from one constructor into another.
|
|
*
|
|
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
* during bootstrapping this function needs to be rewritten using some native
|
|
* functions as prototype setup using normal JavaScript does not work as
|
|
* expected during bootstrapping (see mirror.js in r114903).
|
|
*
|
|
* @param {function} ctor Constructor function which needs to inherit the
|
|
* prototype.
|
|
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
*/
|
|
exports.inherits = require('inherits');
|
|
|
|
exports._extend = function(origin, add) {
|
|
// Don't do anything if add isn't an object
|
|
if (!add || !isObject(add)) return origin;
|
|
|
|
var keys = Object.keys(add);
|
|
var i = keys.length;
|
|
while (i--) {
|
|
origin[keys[i]] = add[keys[i]];
|
|
}
|
|
return origin;
|
|
};
|
|
|
|
function hasOwnProperty(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
}).call(this,require("/home/substack/projects/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"./support/isBuffer":25,"/home/substack/projects/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":8,"inherits":7}],27:[function(require,module,exports){
|
|
exports.parse = require('./lib/parse');
|
|
exports.stringify = require('./lib/stringify');
|
|
|
|
},{"./lib/parse":28,"./lib/stringify":29}],28:[function(require,module,exports){
|
|
var at, // The index of the current character
|
|
ch, // The current character
|
|
escapee = {
|
|
'"': '"',
|
|
'\\': '\\',
|
|
'/': '/',
|
|
b: '\b',
|
|
f: '\f',
|
|
n: '\n',
|
|
r: '\r',
|
|
t: '\t'
|
|
},
|
|
text,
|
|
|
|
error = function (m) {
|
|
// Call error when something is wrong.
|
|
throw {
|
|
name: 'SyntaxError',
|
|
message: m,
|
|
at: at,
|
|
text: text
|
|
};
|
|
},
|
|
|
|
next = function (c) {
|
|
// If a c parameter is provided, verify that it matches the current character.
|
|
if (c && c !== ch) {
|
|
error("Expected '" + c + "' instead of '" + ch + "'");
|
|
}
|
|
|
|
// Get the next character. When there are no more characters,
|
|
// return the empty string.
|
|
|
|
ch = text.charAt(at);
|
|
at += 1;
|
|
return ch;
|
|
},
|
|
|
|
number = function () {
|
|
// Parse a number value.
|
|
var number,
|
|
string = '';
|
|
|
|
if (ch === '-') {
|
|
string = '-';
|
|
next('-');
|
|
}
|
|
while (ch >= '0' && ch <= '9') {
|
|
string += ch;
|
|
next();
|
|
}
|
|
if (ch === '.') {
|
|
string += '.';
|
|
while (next() && ch >= '0' && ch <= '9') {
|
|
string += ch;
|
|
}
|
|
}
|
|
if (ch === 'e' || ch === 'E') {
|
|
string += ch;
|
|
next();
|
|
if (ch === '-' || ch === '+') {
|
|
string += ch;
|
|
next();
|
|
}
|
|
while (ch >= '0' && ch <= '9') {
|
|
string += ch;
|
|
next();
|
|
}
|
|
}
|
|
number = +string;
|
|
if (!isFinite(number)) {
|
|
error("Bad number");
|
|
} else {
|
|
return number;
|
|
}
|
|
},
|
|
|
|
string = function () {
|
|
// Parse a string value.
|
|
var hex,
|
|
i,
|
|
string = '',
|
|
uffff;
|
|
|
|
// When parsing for string values, we must look for " and \ characters.
|
|
if (ch === '"') {
|
|
while (next()) {
|
|
if (ch === '"') {
|
|
next();
|
|
return string;
|
|
} else if (ch === '\\') {
|
|
next();
|
|
if (ch === 'u') {
|
|
uffff = 0;
|
|
for (i = 0; i < 4; i += 1) {
|
|
hex = parseInt(next(), 16);
|
|
if (!isFinite(hex)) {
|
|
break;
|
|
}
|
|
uffff = uffff * 16 + hex;
|
|
}
|
|
string += String.fromCharCode(uffff);
|
|
} else if (typeof escapee[ch] === 'string') {
|
|
string += escapee[ch];
|
|
} else {
|
|
break;
|
|
}
|
|
} else {
|
|
string += ch;
|
|
}
|
|
}
|
|
}
|
|
error("Bad string");
|
|
},
|
|
|
|
white = function () {
|
|
|
|
// Skip whitespace.
|
|
|
|
while (ch && ch <= ' ') {
|
|
next();
|
|
}
|
|
},
|
|
|
|
word = function () {
|
|
|
|
// true, false, or null.
|
|
|
|
switch (ch) {
|
|
case 't':
|
|
next('t');
|
|
next('r');
|
|
next('u');
|
|
next('e');
|
|
return true;
|
|
case 'f':
|
|
next('f');
|
|
next('a');
|
|
next('l');
|
|
next('s');
|
|
next('e');
|
|
return false;
|
|
case 'n':
|
|
next('n');
|
|
next('u');
|
|
next('l');
|
|
next('l');
|
|
return null;
|
|
}
|
|
error("Unexpected '" + ch + "'");
|
|
},
|
|
|
|
value, // Place holder for the value function.
|
|
|
|
array = function () {
|
|
|
|
// Parse an array value.
|
|
|
|
var array = [];
|
|
|
|
if (ch === '[') {
|
|
next('[');
|
|
white();
|
|
if (ch === ']') {
|
|
next(']');
|
|
return array; // empty array
|
|
}
|
|
while (ch) {
|
|
array.push(value());
|
|
white();
|
|
if (ch === ']') {
|
|
next(']');
|
|
return array;
|
|
}
|
|
next(',');
|
|
white();
|
|
}
|
|
}
|
|
error("Bad array");
|
|
},
|
|
|
|
object = function () {
|
|
|
|
// Parse an object value.
|
|
|
|
var key,
|
|
object = {};
|
|
|
|
if (ch === '{') {
|
|
next('{');
|
|
white();
|
|
if (ch === '}') {
|
|
next('}');
|
|
return object; // empty object
|
|
}
|
|
while (ch) {
|
|
key = string();
|
|
white();
|
|
next(':');
|
|
if (Object.hasOwnProperty.call(object, key)) {
|
|
error('Duplicate key "' + key + '"');
|
|
}
|
|
object[key] = value();
|
|
white();
|
|
if (ch === '}') {
|
|
next('}');
|
|
return object;
|
|
}
|
|
next(',');
|
|
white();
|
|
}
|
|
}
|
|
error("Bad object");
|
|
};
|
|
|
|
value = function () {
|
|
|
|
// Parse a JSON value. It could be an object, an array, a string, a number,
|
|
// or a word.
|
|
|
|
white();
|
|
switch (ch) {
|
|
case '{':
|
|
return object();
|
|
case '[':
|
|
return array();
|
|
case '"':
|
|
return string();
|
|
case '-':
|
|
return number();
|
|
default:
|
|
return ch >= '0' && ch <= '9' ? number() : word();
|
|
}
|
|
};
|
|
|
|
// Return the json_parse function. It will have access to all of the above
|
|
// functions and variables.
|
|
|
|
module.exports = function (source, reviver) {
|
|
var result;
|
|
|
|
text = source;
|
|
at = 0;
|
|
ch = ' ';
|
|
result = value();
|
|
white();
|
|
if (ch) {
|
|
error("Syntax error");
|
|
}
|
|
|
|
// If there is a reviver function, we recursively walk the new structure,
|
|
// passing each name/value pair to the reviver function for possible
|
|
// transformation, starting with a temporary root object that holds the result
|
|
// in an empty key. If there is not a reviver function, we simply return the
|
|
// result.
|
|
|
|
return typeof reviver === 'function' ? (function walk(holder, key) {
|
|
var k, v, value = holder[key];
|
|
if (value && typeof value === 'object') {
|
|
for (k in value) {
|
|
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
v = walk(value, k);
|
|
if (v !== undefined) {
|
|
value[k] = v;
|
|
} else {
|
|
delete value[k];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return reviver.call(holder, key, value);
|
|
}({'': result}, '')) : result;
|
|
};
|
|
|
|
},{}],29:[function(require,module,exports){
|
|
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
|
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
|
gap,
|
|
indent,
|
|
meta = { // table of character substitutions
|
|
'\b': '\\b',
|
|
'\t': '\\t',
|
|
'\n': '\\n',
|
|
'\f': '\\f',
|
|
'\r': '\\r',
|
|
'"' : '\\"',
|
|
'\\': '\\\\'
|
|
},
|
|
rep;
|
|
|
|
function quote(string) {
|
|
// If the string contains no control characters, no quote characters, and no
|
|
// backslash characters, then we can safely slap some quotes around it.
|
|
// Otherwise we must also replace the offending characters with safe escape
|
|
// sequences.
|
|
|
|
escapable.lastIndex = 0;
|
|
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
|
var c = meta[a];
|
|
return typeof c === 'string' ? c :
|
|
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
|
}) + '"' : '"' + string + '"';
|
|
}
|
|
|
|
function str(key, holder) {
|
|
// Produce a string from holder[key].
|
|
var i, // The loop counter.
|
|
k, // The member key.
|
|
v, // The member value.
|
|
length,
|
|
mind = gap,
|
|
partial,
|
|
value = holder[key];
|
|
|
|
// If the value has a toJSON method, call it to obtain a replacement value.
|
|
if (value && typeof value === 'object' &&
|
|
typeof value.toJSON === 'function') {
|
|
value = value.toJSON(key);
|
|
}
|
|
|
|
// If we were called with a replacer function, then call the replacer to
|
|
// obtain a replacement value.
|
|
if (typeof rep === 'function') {
|
|
value = rep.call(holder, key, value);
|
|
}
|
|
|
|
// What happens next depends on the value's type.
|
|
switch (typeof value) {
|
|
case 'string':
|
|
return quote(value);
|
|
|
|
case 'number':
|
|
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
return isFinite(value) ? String(value) : 'null';
|
|
|
|
case 'boolean':
|
|
case 'null':
|
|
// If the value is a boolean or null, convert it to a string. Note:
|
|
// typeof null does not produce 'null'. The case is included here in
|
|
// the remote chance that this gets fixed someday.
|
|
return String(value);
|
|
|
|
case 'object':
|
|
if (!value) return 'null';
|
|
gap += indent;
|
|
partial = [];
|
|
|
|
// Array.isArray
|
|
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
|
length = value.length;
|
|
for (i = 0; i < length; i += 1) {
|
|
partial[i] = str(i, value) || 'null';
|
|
}
|
|
|
|
// Join all of the elements together, separated with commas, and
|
|
// wrap them in brackets.
|
|
v = partial.length === 0 ? '[]' : gap ?
|
|
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
|
|
'[' + partial.join(',') + ']';
|
|
gap = mind;
|
|
return v;
|
|
}
|
|
|
|
// If the replacer is an array, use it to select the members to be
|
|
// stringified.
|
|
if (rep && typeof rep === 'object') {
|
|
length = rep.length;
|
|
for (i = 0; i < length; i += 1) {
|
|
k = rep[i];
|
|
if (typeof k === 'string') {
|
|
v = str(k, value);
|
|
if (v) {
|
|
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// Otherwise, iterate through all of the keys in the object.
|
|
for (k in value) {
|
|
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
v = str(k, value);
|
|
if (v) {
|
|
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Join all of the member texts together, separated with commas,
|
|
// and wrap them in braces.
|
|
|
|
v = partial.length === 0 ? '{}' : gap ?
|
|
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
|
|
'{' + partial.join(',') + '}';
|
|
gap = mind;
|
|
return v;
|
|
}
|
|
}
|
|
|
|
module.exports = function (value, replacer, space) {
|
|
var i;
|
|
gap = '';
|
|
indent = '';
|
|
|
|
// If the space parameter is a number, make an indent string containing that
|
|
// many spaces.
|
|
if (typeof space === 'number') {
|
|
for (i = 0; i < space; i += 1) {
|
|
indent += ' ';
|
|
}
|
|
}
|
|
// If the space parameter is a string, it will be used as the indent string.
|
|
else if (typeof space === 'string') {
|
|
indent = space;
|
|
}
|
|
|
|
// If there is a replacer, it must be a function or an array.
|
|
// Otherwise, throw an error.
|
|
rep = replacer;
|
|
if (replacer && typeof replacer !== 'function'
|
|
&& (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
|
|
throw new Error('JSON.stringify');
|
|
}
|
|
|
|
// Make a fake root object containing our value under the key of ''.
|
|
// Return the result of stringifying the value.
|
|
return str('', {'': value});
|
|
};
|
|
|
|
},{}],30:[function(require,module,exports){
|
|
module.exports = function inspect_ (obj, opts, depth, seen) {
|
|
if (!opts) opts = {};
|
|
|
|
var maxDepth = opts.depth === undefined ? 5 : opts.depth;
|
|
if (depth === undefined) depth = 0;
|
|
if (depth > maxDepth && maxDepth > 0) return '...';
|
|
|
|
if (seen === undefined) seen = [];
|
|
else if (indexOf(seen, obj) >= 0) {
|
|
return '[Circular]';
|
|
}
|
|
|
|
function inspect (value, from) {
|
|
if (from) {
|
|
seen = seen.slice();
|
|
seen.push(from);
|
|
}
|
|
return inspect_(value, opts, depth + 1, seen);
|
|
}
|
|
|
|
if (typeof obj === 'string') {
|
|
return "'" + obj.replace(/(['\\])/g, '\\$1') + "'";
|
|
}
|
|
else if (typeof obj === 'function') {
|
|
var name = nameOf(obj);
|
|
return '[Function' + (name ? ': ' + name : '') + ']';
|
|
}
|
|
else if (isElement(obj)) {
|
|
var s = '<' + String(obj.nodeName).toLowerCase();
|
|
var attrs = obj.attributes || [];
|
|
for (var i = 0; i < attrs.length; i++) {
|
|
s += ' ' + attrs[i].name + '="' + quote(attrs[i].value) + '"';
|
|
}
|
|
s += '>';
|
|
if (obj.childNodes && obj.childNodes.length) s += '...';
|
|
s += '</' + String(obj.tagName).toLowerCase() + '>';
|
|
return s;
|
|
}
|
|
else if (isArray(obj)) {
|
|
var xs = Array(obj.length);
|
|
for (var i = 0; i < obj.length; i++) {
|
|
xs[i] = inspect(obj[i], obj);
|
|
}
|
|
return '[ ' + xs.join(', ') + ' ]';
|
|
}
|
|
else if (typeof obj === 'object' && !isDate(obj) && !isRegExp(obj)) {
|
|
var xs = [];
|
|
for (var key in obj) {
|
|
if (!has(obj, key)) continue;
|
|
if (/[^\w$]/.test(key)) {
|
|
xs.push(inspect(key) + ': ' + inspect(obj[key], obj));
|
|
}
|
|
else xs.push(key + ': ' + inspect(obj[key], obj));
|
|
}
|
|
return '{ ' + xs.join(', ') + ' }';
|
|
}
|
|
else return String(obj);
|
|
};
|
|
|
|
function quote (s) {
|
|
return String(s).replace(/"/g, '"');
|
|
}
|
|
|
|
function isArray (obj) {
|
|
return {}.toString.call(obj) === '[object Array]';
|
|
}
|
|
|
|
function isDate (obj) {
|
|
return {}.toString.call(obj) === '[object Date]';
|
|
}
|
|
|
|
function isRegExp (obj) {
|
|
return {}.toString.call(obj) === '[object RegExp]';
|
|
}
|
|
|
|
function has (obj, key) {
|
|
if (!{}.hasOwnProperty) return true;
|
|
return {}.hasOwnProperty.call(obj, key);
|
|
}
|
|
|
|
function nameOf (f) {
|
|
if (f.name) return f.name;
|
|
var m = f.toString().match(/^function\s*([\w$]+)/);
|
|
if (m) return m[1];
|
|
}
|
|
|
|
function indexOf (xs, x) {
|
|
if (xs.indexOf) return xs.indexOf(x);
|
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
if (xs[i] === x) return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
function isElement (x) {
|
|
if (!x || typeof x !== 'object') return false;
|
|
if (typeof HTMLElement !== 'undefined') {
|
|
return x instanceof HTMLElement;
|
|
}
|
|
else return typeof x.nodeName === 'string'
|
|
&& typeof x.getAttribute === 'function'
|
|
;
|
|
}
|
|
|
|
},{}],31:[function(require,module,exports){
|
|
var http = require('http');
|
|
var Stream = require('stream');
|
|
var encode = typeof encodeURIComponent !== 'undefined'
|
|
? encodeURIComponent : escape
|
|
;
|
|
|
|
module.exports = function (opts) {
|
|
if (typeof opts === 'string') {
|
|
opts = { path : opts };
|
|
}
|
|
if (!opts) opts = {};
|
|
if (!opts.id) {
|
|
opts.id = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
|
|
}
|
|
|
|
var stream = new Stream;
|
|
stream.writable = true;
|
|
stream.order = 0;
|
|
|
|
stream.write = function (msg) {
|
|
if (stream.ended) return;
|
|
var data = 'order=' + stream.order
|
|
+ '&data=' + encode(msg)
|
|
+ '&id=' + encode(opts.id)
|
|
;
|
|
stream.order ++;
|
|
send(data);
|
|
};
|
|
|
|
stream.destroy = function () {
|
|
stream.ended = true;
|
|
stream.emit('close');
|
|
};
|
|
|
|
stream.end = function (msg) {
|
|
if (stream.ended) return;
|
|
|
|
var data = 'order=' + stream.order
|
|
+ '&id=' + encode(opts.id)
|
|
+ '&end=true'
|
|
;
|
|
if (msg !== undefined) data += '&data=' + encode(msg);
|
|
stream.order ++;
|
|
send(data);
|
|
stream.ended = true;
|
|
stream.emit('close');
|
|
};
|
|
|
|
function send (data) {
|
|
var params = {
|
|
method : 'POST',
|
|
host : opts.host || window.location.hostname,
|
|
port : opts.port || window.location.port,
|
|
path : opts.path || '/',
|
|
headers : {
|
|
'content-type' : 'application/x-www-form-urlencoded'
|
|
}
|
|
};
|
|
var req = http.request(params);
|
|
req.end(data);
|
|
}
|
|
|
|
return stream
|
|
};
|
|
|
|
},{"http":3,"stream":17}]},{},[1])</script><script>(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var ToInteger = require('es-abstract/2018/ToInteger');
|
|
var ToLength = require('es-abstract/2018/ToLength');
|
|
var ToObject = require('es-abstract/2018/ToObject');
|
|
var SameValueZero = require('es-abstract/2018/SameValueZero');
|
|
var $isNaN = require('es-abstract/helpers/isNaN');
|
|
var $isFinite = require('es-abstract/helpers/isFinite');
|
|
var GetIntrinsic = require('es-abstract/GetIntrinsic');
|
|
var callBind = require('es-abstract/helpers/callBind');
|
|
|
|
var $indexOf = callBind.apply(GetIntrinsic('%Array.prototype.indexOf%'));
|
|
|
|
module.exports = function includes(searchElement) {
|
|
var fromIndex = arguments.length > 1 ? ToInteger(arguments[1]) : 0;
|
|
if ($indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
|
|
return $indexOf(this, arguments) > -1;
|
|
}
|
|
|
|
var O = ToObject(this);
|
|
var length = ToLength(O.length);
|
|
if (length === 0) {
|
|
return false;
|
|
}
|
|
var k = fromIndex >= 0 ? fromIndex : Math.max(0, length + fromIndex);
|
|
while (k < length) {
|
|
if (SameValueZero(searchElement, O[k])) {
|
|
return true;
|
|
}
|
|
k += 1;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
},{"es-abstract/2018/SameValueZero":10,"es-abstract/2018/ToInteger":11,"es-abstract/2018/ToLength":12,"es-abstract/2018/ToObject":14,"es-abstract/GetIntrinsic":20,"es-abstract/helpers/callBind":21,"es-abstract/helpers/isFinite":23,"es-abstract/helpers/isNaN":24}],2:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var define = require('define-properties');
|
|
var RequireObjectCoercible = require('es-abstract/2018/RequireObjectCoercible');
|
|
var callBound = require('es-abstract/helpers/callBound');
|
|
|
|
var implementation = require('./implementation');
|
|
var getPolyfill = require('./polyfill');
|
|
var polyfill = getPolyfill();
|
|
var shim = require('./shim');
|
|
|
|
var $slice = callBound('Array.prototype.slice');
|
|
|
|
/* eslint-disable no-unused-vars */
|
|
var boundIncludesShim = function includes(array, searchElement) {
|
|
/* eslint-enable no-unused-vars */
|
|
RequireObjectCoercible(array);
|
|
return polyfill.apply(array, $slice(arguments, 1));
|
|
};
|
|
define(boundIncludesShim, {
|
|
getPolyfill: getPolyfill,
|
|
implementation: implementation,
|
|
shim: shim
|
|
});
|
|
|
|
module.exports = boundIncludesShim;
|
|
|
|
},{"./implementation":1,"./polyfill":80,"./shim":81,"define-properties":7,"es-abstract/2018/RequireObjectCoercible":9,"es-abstract/helpers/callBound":22}],3:[function(require,module,exports){
|
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
|
;(function (exports) {
|
|
'use strict';
|
|
|
|
var Arr = (typeof Uint8Array !== 'undefined')
|
|
? Uint8Array
|
|
: Array
|
|
|
|
var PLUS = '+'.charCodeAt(0)
|
|
var SLASH = '/'.charCodeAt(0)
|
|
var NUMBER = '0'.charCodeAt(0)
|
|
var LOWER = 'a'.charCodeAt(0)
|
|
var UPPER = 'A'.charCodeAt(0)
|
|
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
|
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
|
|
|
function decode (elt) {
|
|
var code = elt.charCodeAt(0)
|
|
if (code === PLUS ||
|
|
code === PLUS_URL_SAFE)
|
|
return 62 // '+'
|
|
if (code === SLASH ||
|
|
code === SLASH_URL_SAFE)
|
|
return 63 // '/'
|
|
if (code < NUMBER)
|
|
return -1 //no match
|
|
if (code < NUMBER + 10)
|
|
return code - NUMBER + 26 + 26
|
|
if (code < UPPER + 26)
|
|
return code - UPPER
|
|
if (code < LOWER + 26)
|
|
return code - LOWER + 26
|
|
}
|
|
|
|
function b64ToByteArray (b64) {
|
|
var i, j, l, tmp, placeHolders, arr
|
|
|
|
if (b64.length % 4 > 0) {
|
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
}
|
|
|
|
// the number of equal signs (place holders)
|
|
// if there are two placeholders, than the two characters before it
|
|
// represent one byte
|
|
// if there is only one, then the three characters before it represent 2 bytes
|
|
// this is just a cheap hack to not do indexOf twice
|
|
var len = b64.length
|
|
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
|
|
|
// base64 is 4/3 + up to two characters of the original data
|
|
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
|
|
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
|
|
|
var L = 0
|
|
|
|
function push (v) {
|
|
arr[L++] = v
|
|
}
|
|
|
|
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
|
push((tmp & 0xFF0000) >> 16)
|
|
push((tmp & 0xFF00) >> 8)
|
|
push(tmp & 0xFF)
|
|
}
|
|
|
|
if (placeHolders === 2) {
|
|
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
|
push(tmp & 0xFF)
|
|
} else if (placeHolders === 1) {
|
|
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
|
push((tmp >> 8) & 0xFF)
|
|
push(tmp & 0xFF)
|
|
}
|
|
|
|
return arr
|
|
}
|
|
|
|
function uint8ToBase64 (uint8) {
|
|
var i,
|
|
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
|
output = "",
|
|
temp, length
|
|
|
|
function encode (num) {
|
|
return lookup.charAt(num)
|
|
}
|
|
|
|
function tripletToBase64 (num) {
|
|
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
|
}
|
|
|
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
|
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
|
output += tripletToBase64(temp)
|
|
}
|
|
|
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
switch (extraBytes) {
|
|
case 1:
|
|
temp = uint8[uint8.length - 1]
|
|
output += encode(temp >> 2)
|
|
output += encode((temp << 4) & 0x3F)
|
|
output += '=='
|
|
break
|
|
case 2:
|
|
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
|
output += encode(temp >> 10)
|
|
output += encode((temp >> 4) & 0x3F)
|
|
output += encode((temp << 2) & 0x3F)
|
|
output += '='
|
|
break
|
|
}
|
|
|
|
return output
|
|
}
|
|
|
|
exports.toByteArray = b64ToByteArray
|
|
exports.fromByteArray = uint8ToBase64
|
|
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
|
|
|
},{}],4:[function(require,module,exports){
|
|
|
|
},{}],5:[function(require,module,exports){
|
|
/*!
|
|
* The buffer module from node.js, for the browser.
|
|
*
|
|
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
* @license MIT
|
|
*/
|
|
|
|
var base64 = require('base64-js')
|
|
var ieee754 = require('ieee754')
|
|
|
|
exports.Buffer = Buffer
|
|
exports.SlowBuffer = Buffer
|
|
exports.INSPECT_MAX_BYTES = 50
|
|
Buffer.poolSize = 8192
|
|
|
|
/**
|
|
* If `Buffer._useTypedArrays`:
|
|
* === true Use Uint8Array implementation (fastest)
|
|
* === false Use Object implementation (compatible down to IE6)
|
|
*/
|
|
Buffer._useTypedArrays = (function () {
|
|
// Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
|
|
// Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
|
|
// properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
|
|
// because we need to be able to add all the node Buffer API methods. This is an issue
|
|
// in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
|
|
try {
|
|
var buf = new ArrayBuffer(0)
|
|
var arr = new Uint8Array(buf)
|
|
arr.foo = function () { return 42 }
|
|
return 42 === arr.foo() &&
|
|
typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
})()
|
|
|
|
/**
|
|
* Class: Buffer
|
|
* =============
|
|
*
|
|
* The Buffer constructor returns instances of `Uint8Array` that are augmented
|
|
* with function properties for all the node `Buffer` API functions. We use
|
|
* `Uint8Array` so that square bracket notation works as expected -- it returns
|
|
* a single octet.
|
|
*
|
|
* By augmenting the instances, we can avoid modifying the `Uint8Array`
|
|
* prototype.
|
|
*/
|
|
function Buffer (subject, encoding, noZero) {
|
|
if (!(this instanceof Buffer))
|
|
return new Buffer(subject, encoding, noZero)
|
|
|
|
var type = typeof subject
|
|
|
|
// Workaround: node's base64 implementation allows for non-padded strings
|
|
// while base64-js does not.
|
|
if (encoding === 'base64' && type === 'string') {
|
|
subject = stringtrim(subject)
|
|
while (subject.length % 4 !== 0) {
|
|
subject = subject + '='
|
|
}
|
|
}
|
|
|
|
// Find the length
|
|
var length
|
|
if (type === 'number')
|
|
length = coerce(subject)
|
|
else if (type === 'string')
|
|
length = Buffer.byteLength(subject, encoding)
|
|
else if (type === 'object')
|
|
length = coerce(subject.length) // assume that object is array-like
|
|
else
|
|
throw new Error('First argument needs to be a number, array or string.')
|
|
|
|
var buf
|
|
if (Buffer._useTypedArrays) {
|
|
// Preferred: Return an augmented `Uint8Array` instance for best performance
|
|
buf = Buffer._augment(new Uint8Array(length))
|
|
} else {
|
|
// Fallback: Return THIS instance of Buffer (created by `new`)
|
|
buf = this
|
|
buf.length = length
|
|
buf._isBuffer = true
|
|
}
|
|
|
|
var i
|
|
if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
|
|
// Speed optimization -- use set if we're copying from a typed array
|
|
buf._set(subject)
|
|
} else if (isArrayish(subject)) {
|
|
// Treat array-ish objects as a byte array
|
|
for (i = 0; i < length; i++) {
|
|
if (Buffer.isBuffer(subject))
|
|
buf[i] = subject.readUInt8(i)
|
|
else
|
|
buf[i] = subject[i]
|
|
}
|
|
} else if (type === 'string') {
|
|
buf.write(subject, 0, encoding)
|
|
} else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
|
|
for (i = 0; i < length; i++) {
|
|
buf[i] = 0
|
|
}
|
|
}
|
|
|
|
return buf
|
|
}
|
|
|
|
// STATIC METHODS
|
|
// ==============
|
|
|
|
Buffer.isEncoding = function (encoding) {
|
|
switch (String(encoding).toLowerCase()) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'raw':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
Buffer.isBuffer = function (b) {
|
|
return !!(b !== null && b !== undefined && b._isBuffer)
|
|
}
|
|
|
|
Buffer.byteLength = function (str, encoding) {
|
|
var ret
|
|
str = str + ''
|
|
switch (encoding || 'utf8') {
|
|
case 'hex':
|
|
ret = str.length / 2
|
|
break
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
ret = utf8ToBytes(str).length
|
|
break
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'raw':
|
|
ret = str.length
|
|
break
|
|
case 'base64':
|
|
ret = base64ToBytes(str).length
|
|
break
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
ret = str.length * 2
|
|
break
|
|
default:
|
|
throw new Error('Unknown encoding')
|
|
}
|
|
return ret
|
|
}
|
|
|
|
Buffer.concat = function (list, totalLength) {
|
|
assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' +
|
|
'list should be an Array.')
|
|
|
|
if (list.length === 0) {
|
|
return new Buffer(0)
|
|
} else if (list.length === 1) {
|
|
return list[0]
|
|
}
|
|
|
|
var i
|
|
if (typeof totalLength !== 'number') {
|
|
totalLength = 0
|
|
for (i = 0; i < list.length; i++) {
|
|
totalLength += list[i].length
|
|
}
|
|
}
|
|
|
|
var buf = new Buffer(totalLength)
|
|
var pos = 0
|
|
for (i = 0; i < list.length; i++) {
|
|
var item = list[i]
|
|
item.copy(buf, pos)
|
|
pos += item.length
|
|
}
|
|
return buf
|
|
}
|
|
|
|
// BUFFER INSTANCE METHODS
|
|
// =======================
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
// must be an even number of digits
|
|
var strLen = string.length
|
|
assert(strLen % 2 === 0, 'Invalid hex string')
|
|
|
|
if (length > strLen / 2) {
|
|
length = strLen / 2
|
|
}
|
|
for (var i = 0; i < length; i++) {
|
|
var byte = parseInt(string.substr(i * 2, 2), 16)
|
|
assert(!isNaN(byte), 'Invalid hex string')
|
|
buf[offset + i] = byte
|
|
}
|
|
Buffer._charsWritten = i * 2
|
|
return i
|
|
}
|
|
|
|
function _utf8Write (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(utf8ToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
function _asciiWrite (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
function _binaryWrite (buf, string, offset, length) {
|
|
return _asciiWrite(buf, string, offset, length)
|
|
}
|
|
|
|
function _base64Write (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
function _utf16leWrite (buf, string, offset, length) {
|
|
var charsWritten = Buffer._charsWritten =
|
|
blitBuffer(utf16leToBytes(string), buf, offset, length)
|
|
return charsWritten
|
|
}
|
|
|
|
Buffer.prototype.write = function (string, offset, length, encoding) {
|
|
// Support both (string, offset, length, encoding)
|
|
// and the legacy (string, encoding, offset, length)
|
|
if (isFinite(offset)) {
|
|
if (!isFinite(length)) {
|
|
encoding = length
|
|
length = undefined
|
|
}
|
|
} else { // legacy
|
|
var swap = encoding
|
|
encoding = offset
|
|
offset = length
|
|
length = swap
|
|
}
|
|
|
|
offset = Number(offset) || 0
|
|
var remaining = this.length - offset
|
|
if (!length) {
|
|
length = remaining
|
|
} else {
|
|
length = Number(length)
|
|
if (length > remaining) {
|
|
length = remaining
|
|
}
|
|
}
|
|
encoding = String(encoding || 'utf8').toLowerCase()
|
|
|
|
var ret
|
|
switch (encoding) {
|
|
case 'hex':
|
|
ret = _hexWrite(this, string, offset, length)
|
|
break
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
ret = _utf8Write(this, string, offset, length)
|
|
break
|
|
case 'ascii':
|
|
ret = _asciiWrite(this, string, offset, length)
|
|
break
|
|
case 'binary':
|
|
ret = _binaryWrite(this, string, offset, length)
|
|
break
|
|
case 'base64':
|
|
ret = _base64Write(this, string, offset, length)
|
|
break
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
ret = _utf16leWrite(this, string, offset, length)
|
|
break
|
|
default:
|
|
throw new Error('Unknown encoding')
|
|
}
|
|
return ret
|
|
}
|
|
|
|
Buffer.prototype.toString = function (encoding, start, end) {
|
|
var self = this
|
|
|
|
encoding = String(encoding || 'utf8').toLowerCase()
|
|
start = Number(start) || 0
|
|
end = (end !== undefined)
|
|
? Number(end)
|
|
: end = self.length
|
|
|
|
// Fastpath empty strings
|
|
if (end === start)
|
|
return ''
|
|
|
|
var ret
|
|
switch (encoding) {
|
|
case 'hex':
|
|
ret = _hexSlice(self, start, end)
|
|
break
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
ret = _utf8Slice(self, start, end)
|
|
break
|
|
case 'ascii':
|
|
ret = _asciiSlice(self, start, end)
|
|
break
|
|
case 'binary':
|
|
ret = _binarySlice(self, start, end)
|
|
break
|
|
case 'base64':
|
|
ret = _base64Slice(self, start, end)
|
|
break
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
ret = _utf16leSlice(self, start, end)
|
|
break
|
|
default:
|
|
throw new Error('Unknown encoding')
|
|
}
|
|
return ret
|
|
}
|
|
|
|
Buffer.prototype.toJSON = function () {
|
|
return {
|
|
type: 'Buffer',
|
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
}
|
|
}
|
|
|
|
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
Buffer.prototype.copy = function (target, target_start, start, end) {
|
|
var source = this
|
|
|
|
if (!start) start = 0
|
|
if (!end && end !== 0) end = this.length
|
|
if (!target_start) target_start = 0
|
|
|
|
// Copy 0 bytes; we're done
|
|
if (end === start) return
|
|
if (target.length === 0 || source.length === 0) return
|
|
|
|
// Fatal error conditions
|
|
assert(end >= start, 'sourceEnd < sourceStart')
|
|
assert(target_start >= 0 && target_start < target.length,
|
|
'targetStart out of bounds')
|
|
assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
|
|
assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
|
|
|
|
// Are we oob?
|
|
if (end > this.length)
|
|
end = this.length
|
|
if (target.length - target_start < end - start)
|
|
end = target.length - target_start + start
|
|
|
|
var len = end - start
|
|
|
|
if (len < 100 || !Buffer._useTypedArrays) {
|
|
for (var i = 0; i < len; i++)
|
|
target[i + target_start] = this[i + start]
|
|
} else {
|
|
target._set(this.subarray(start, start + len), target_start)
|
|
}
|
|
}
|
|
|
|
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) {
|
|
var res = ''
|
|
var tmp = ''
|
|
end = Math.min(buf.length, end)
|
|
|
|
for (var i = start; i < end; i++) {
|
|
if (buf[i] <= 0x7F) {
|
|
res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
|
|
tmp = ''
|
|
} else {
|
|
tmp += '%' + buf[i].toString(16)
|
|
}
|
|
}
|
|
|
|
return res + decodeUtf8Char(tmp)
|
|
}
|
|
|
|
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])
|
|
return ret
|
|
}
|
|
|
|
function _binarySlice (buf, start, end) {
|
|
return _asciiSlice(buf, start, end)
|
|
}
|
|
|
|
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 += toHex(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 (start, end) {
|
|
var len = this.length
|
|
start = clamp(start, len, 0)
|
|
end = clamp(end, len, len)
|
|
|
|
if (Buffer._useTypedArrays) {
|
|
return Buffer._augment(this.subarray(start, end))
|
|
} else {
|
|
var sliceLen = end - start
|
|
var newBuf = new Buffer(sliceLen, undefined, true)
|
|
for (var i = 0; i < sliceLen; i++) {
|
|
newBuf[i] = this[i + start]
|
|
}
|
|
return newBuf
|
|
}
|
|
}
|
|
|
|
// `get` will be removed in Node 0.13+
|
|
Buffer.prototype.get = function (offset) {
|
|
console.log('.get() is deprecated. Access using array indexes instead.')
|
|
return this.readUInt8(offset)
|
|
}
|
|
|
|
// `set` will be removed in Node 0.13+
|
|
Buffer.prototype.set = function (v, offset) {
|
|
console.log('.set() is deprecated. Access using array indexes instead.')
|
|
return this.writeUInt8(v, offset)
|
|
}
|
|
|
|
Buffer.prototype.readUInt8 = function (offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset < this.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
if (offset >= this.length)
|
|
return
|
|
|
|
return this[offset]
|
|
}
|
|
|
|
function _readUInt16 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val
|
|
if (littleEndian) {
|
|
val = buf[offset]
|
|
if (offset + 1 < len)
|
|
val |= buf[offset + 1] << 8
|
|
} else {
|
|
val = buf[offset] << 8
|
|
if (offset + 1 < len)
|
|
val |= buf[offset + 1]
|
|
}
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readUInt16LE = function (offset, noAssert) {
|
|
return _readUInt16(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readUInt16BE = function (offset, noAssert) {
|
|
return _readUInt16(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readUInt32 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val
|
|
if (littleEndian) {
|
|
if (offset + 2 < len)
|
|
val = buf[offset + 2] << 16
|
|
if (offset + 1 < len)
|
|
val |= buf[offset + 1] << 8
|
|
val |= buf[offset]
|
|
if (offset + 3 < len)
|
|
val = val + (buf[offset + 3] << 24 >>> 0)
|
|
} else {
|
|
if (offset + 1 < len)
|
|
val = buf[offset + 1] << 16
|
|
if (offset + 2 < len)
|
|
val |= buf[offset + 2] << 8
|
|
if (offset + 3 < len)
|
|
val |= buf[offset + 3]
|
|
val = val + (buf[offset] << 24 >>> 0)
|
|
}
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readUInt32LE = function (offset, noAssert) {
|
|
return _readUInt32(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readUInt32BE = function (offset, noAssert) {
|
|
return _readUInt32(this, offset, false, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readInt8 = function (offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(offset !== undefined && offset !== null,
|
|
'missing offset')
|
|
assert(offset < this.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
if (offset >= this.length)
|
|
return
|
|
|
|
var neg = this[offset] & 0x80
|
|
if (neg)
|
|
return (0xff - this[offset] + 1) * -1
|
|
else
|
|
return this[offset]
|
|
}
|
|
|
|
function _readInt16 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val = _readUInt16(buf, offset, littleEndian, true)
|
|
var neg = val & 0x8000
|
|
if (neg)
|
|
return (0xffff - val + 1) * -1
|
|
else
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readInt16LE = function (offset, noAssert) {
|
|
return _readInt16(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readInt16BE = function (offset, noAssert) {
|
|
return _readInt16(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readInt32 (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
var val = _readUInt32(buf, offset, littleEndian, true)
|
|
var neg = val & 0x80000000
|
|
if (neg)
|
|
return (0xffffffff - val + 1) * -1
|
|
else
|
|
return val
|
|
}
|
|
|
|
Buffer.prototype.readInt32LE = function (offset, noAssert) {
|
|
return _readInt32(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readInt32BE = function (offset, noAssert) {
|
|
return _readInt32(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readFloat (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
return ieee754.read(buf, offset, littleEndian, 23, 4)
|
|
}
|
|
|
|
Buffer.prototype.readFloatLE = function (offset, noAssert) {
|
|
return _readFloat(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readFloatBE = function (offset, noAssert) {
|
|
return _readFloat(this, offset, false, noAssert)
|
|
}
|
|
|
|
function _readDouble (buf, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
|
|
}
|
|
|
|
return ieee754.read(buf, offset, littleEndian, 52, 8)
|
|
}
|
|
|
|
Buffer.prototype.readDoubleLE = function (offset, noAssert) {
|
|
return _readDouble(this, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.readDoubleBE = function (offset, noAssert) {
|
|
return _readDouble(this, offset, false, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset < this.length, 'trying to write beyond buffer length')
|
|
verifuint(value, 0xff)
|
|
}
|
|
|
|
if (offset >= this.length) return
|
|
|
|
this[offset] = value
|
|
}
|
|
|
|
function _writeUInt16 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
|
|
verifuint(value, 0xffff)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
|
|
buf[offset + i] =
|
|
(value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
(littleEndian ? i : 1 - i) * 8
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
|
|
_writeUInt16(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
|
|
_writeUInt16(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeUInt32 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
|
|
verifuint(value, 0xffffffff)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
|
|
buf[offset + i] =
|
|
(value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
|
|
_writeUInt32(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
|
|
_writeUInt32(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset < this.length, 'Trying to write beyond buffer length')
|
|
verifsint(value, 0x7f, -0x80)
|
|
}
|
|
|
|
if (offset >= this.length)
|
|
return
|
|
|
|
if (value >= 0)
|
|
this.writeUInt8(value, offset, noAssert)
|
|
else
|
|
this.writeUInt8(0xff + value + 1, offset, noAssert)
|
|
}
|
|
|
|
function _writeInt16 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
|
|
verifsint(value, 0x7fff, -0x8000)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
if (value >= 0)
|
|
_writeUInt16(buf, value, offset, littleEndian, noAssert)
|
|
else
|
|
_writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
|
|
_writeInt16(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
|
|
_writeInt16(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeInt32 (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
verifsint(value, 0x7fffffff, -0x80000000)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
if (value >= 0)
|
|
_writeUInt32(buf, value, offset, littleEndian, noAssert)
|
|
else
|
|
_writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
|
|
_writeInt32(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
|
|
_writeInt32(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
}
|
|
|
|
Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
|
|
_writeFloat(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
|
|
_writeFloat(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
function _writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
assert(value !== undefined && value !== null, 'missing value')
|
|
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
assert(offset + 7 < buf.length,
|
|
'Trying to write beyond buffer length')
|
|
verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
}
|
|
|
|
var len = buf.length
|
|
if (offset >= len)
|
|
return
|
|
|
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
}
|
|
|
|
Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
|
|
_writeDouble(this, value, offset, true, noAssert)
|
|
}
|
|
|
|
Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
|
|
_writeDouble(this, value, offset, false, noAssert)
|
|
}
|
|
|
|
// fill(value, start=0, end=buffer.length)
|
|
Buffer.prototype.fill = function (value, start, end) {
|
|
if (!value) value = 0
|
|
if (!start) start = 0
|
|
if (!end) end = this.length
|
|
|
|
if (typeof value === 'string') {
|
|
value = value.charCodeAt(0)
|
|
}
|
|
|
|
assert(typeof value === 'number' && !isNaN(value), 'value is not a number')
|
|
assert(end >= start, 'end < start')
|
|
|
|
// Fill 0 bytes; we're done
|
|
if (end === start) return
|
|
if (this.length === 0) return
|
|
|
|
assert(start >= 0 && start < this.length, 'start out of bounds')
|
|
assert(end >= 0 && end <= this.length, 'end out of bounds')
|
|
|
|
for (var i = start; i < end; i++) {
|
|
this[i] = value
|
|
}
|
|
}
|
|
|
|
Buffer.prototype.inspect = function () {
|
|
var out = []
|
|
var len = this.length
|
|
for (var i = 0; i < len; i++) {
|
|
out[i] = toHex(this[i])
|
|
if (i === exports.INSPECT_MAX_BYTES) {
|
|
out[i + 1] = '...'
|
|
break
|
|
}
|
|
}
|
|
return '<Buffer ' + out.join(' ') + '>'
|
|
}
|
|
|
|
/**
|
|
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
|
|
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
|
|
*/
|
|
Buffer.prototype.toArrayBuffer = function () {
|
|
if (typeof Uint8Array !== 'undefined') {
|
|
if (Buffer._useTypedArrays) {
|
|
return (new Buffer(this)).buffer
|
|
} else {
|
|
var buf = new Uint8Array(this.length)
|
|
for (var i = 0, len = buf.length; i < len; i += 1)
|
|
buf[i] = this[i]
|
|
return buf.buffer
|
|
}
|
|
} else {
|
|
throw new Error('Buffer.toArrayBuffer not supported in this browser')
|
|
}
|
|
}
|
|
|
|
// HELPER FUNCTIONS
|
|
// ================
|
|
|
|
function stringtrim (str) {
|
|
if (str.trim) return str.trim()
|
|
return str.replace(/^\s+|\s+$/g, '')
|
|
}
|
|
|
|
var BP = Buffer.prototype
|
|
|
|
/**
|
|
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
|
*/
|
|
Buffer._augment = function (arr) {
|
|
arr._isBuffer = true
|
|
|
|
// save reference to original Uint8Array get/set methods before overwriting
|
|
arr._get = arr.get
|
|
arr._set = arr.set
|
|
|
|
// deprecated, will be removed in node 0.13+
|
|
arr.get = BP.get
|
|
arr.set = BP.set
|
|
|
|
arr.write = BP.write
|
|
arr.toString = BP.toString
|
|
arr.toLocaleString = BP.toString
|
|
arr.toJSON = BP.toJSON
|
|
arr.copy = BP.copy
|
|
arr.slice = BP.slice
|
|
arr.readUInt8 = BP.readUInt8
|
|
arr.readUInt16LE = BP.readUInt16LE
|
|
arr.readUInt16BE = BP.readUInt16BE
|
|
arr.readUInt32LE = BP.readUInt32LE
|
|
arr.readUInt32BE = BP.readUInt32BE
|
|
arr.readInt8 = BP.readInt8
|
|
arr.readInt16LE = BP.readInt16LE
|
|
arr.readInt16BE = BP.readInt16BE
|
|
arr.readInt32LE = BP.readInt32LE
|
|
arr.readInt32BE = BP.readInt32BE
|
|
arr.readFloatLE = BP.readFloatLE
|
|
arr.readFloatBE = BP.readFloatBE
|
|
arr.readDoubleLE = BP.readDoubleLE
|
|
arr.readDoubleBE = BP.readDoubleBE
|
|
arr.writeUInt8 = BP.writeUInt8
|
|
arr.writeUInt16LE = BP.writeUInt16LE
|
|
arr.writeUInt16BE = BP.writeUInt16BE
|
|
arr.writeUInt32LE = BP.writeUInt32LE
|
|
arr.writeUInt32BE = BP.writeUInt32BE
|
|
arr.writeInt8 = BP.writeInt8
|
|
arr.writeInt16LE = BP.writeInt16LE
|
|
arr.writeInt16BE = BP.writeInt16BE
|
|
arr.writeInt32LE = BP.writeInt32LE
|
|
arr.writeInt32BE = BP.writeInt32BE
|
|
arr.writeFloatLE = BP.writeFloatLE
|
|
arr.writeFloatBE = BP.writeFloatBE
|
|
arr.writeDoubleLE = BP.writeDoubleLE
|
|
arr.writeDoubleBE = BP.writeDoubleBE
|
|
arr.fill = BP.fill
|
|
arr.inspect = BP.inspect
|
|
arr.toArrayBuffer = BP.toArrayBuffer
|
|
|
|
return arr
|
|
}
|
|
|
|
// slice(start, end)
|
|
function clamp (index, len, defaultValue) {
|
|
if (typeof index !== 'number') return defaultValue
|
|
index = ~~index; // Coerce to integer.
|
|
if (index >= len) return len
|
|
if (index >= 0) return index
|
|
index += len
|
|
if (index >= 0) return index
|
|
return 0
|
|
}
|
|
|
|
function coerce (length) {
|
|
// Coerce length to a number (possibly NaN), round up
|
|
// in case it's fractional (e.g. 123.456) then do a
|
|
// double negate to coerce a NaN to 0. Easy, right?
|
|
length = ~~Math.ceil(+length)
|
|
return length < 0 ? 0 : length
|
|
}
|
|
|
|
function isArray (subject) {
|
|
return (Array.isArray || function (subject) {
|
|
return Object.prototype.toString.call(subject) === '[object Array]'
|
|
})(subject)
|
|
}
|
|
|
|
function isArrayish (subject) {
|
|
return isArray(subject) || Buffer.isBuffer(subject) ||
|
|
subject && typeof subject === 'object' &&
|
|
typeof subject.length === 'number'
|
|
}
|
|
|
|
function toHex (n) {
|
|
if (n < 16) return '0' + n.toString(16)
|
|
return n.toString(16)
|
|
}
|
|
|
|
function utf8ToBytes (str) {
|
|
var byteArray = []
|
|
for (var i = 0; i < str.length; i++) {
|
|
var b = str.charCodeAt(i)
|
|
if (b <= 0x7F)
|
|
byteArray.push(str.charCodeAt(i))
|
|
else {
|
|
var start = i
|
|
if (b >= 0xD800 && b <= 0xDFFF) i++
|
|
var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
|
|
for (var j = 0; j < h.length; j++)
|
|
byteArray.push(parseInt(h[j], 16))
|
|
}
|
|
}
|
|
return byteArray
|
|
}
|
|
|
|
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) {
|
|
var c, hi, lo
|
|
var byteArray = []
|
|
for (var i = 0; i < str.length; i++) {
|
|
c = str.charCodeAt(i)
|
|
hi = c >> 8
|
|
lo = c % 256
|
|
byteArray.push(lo)
|
|
byteArray.push(hi)
|
|
}
|
|
|
|
return byteArray
|
|
}
|
|
|
|
function base64ToBytes (str) {
|
|
return base64.toByteArray(str)
|
|
}
|
|
|
|
function blitBuffer (src, dst, offset, length) {
|
|
var pos
|
|
for (var i = 0; i < length; i++) {
|
|
if ((i + offset >= dst.length) || (i >= src.length))
|
|
break
|
|
dst[i + offset] = src[i]
|
|
}
|
|
return i
|
|
}
|
|
|
|
function decodeUtf8Char (str) {
|
|
try {
|
|
return decodeURIComponent(str)
|
|
} catch (err) {
|
|
return String.fromCharCode(0xFFFD) // UTF 8 invalid char
|
|
}
|
|
}
|
|
|
|
/*
|
|
* We have to make sure that the value is a valid integer. This means that it
|
|
* is non-negative. It has no fractional component and that it does not
|
|
* exceed the maximum allowed value.
|
|
*/
|
|
function verifuint (value, max) {
|
|
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
assert(value >= 0, 'specified a negative value for writing an unsigned value')
|
|
assert(value <= max, 'value is larger than maximum value for type')
|
|
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
}
|
|
|
|
function verifsint (value, max, min) {
|
|
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
assert(value <= max, 'value larger than maximum allowed value')
|
|
assert(value >= min, 'value smaller than minimum allowed value')
|
|
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
}
|
|
|
|
function verifIEEE754 (value, max, min) {
|
|
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
assert(value <= max, 'value larger than maximum allowed value')
|
|
assert(value >= min, 'value smaller than minimum allowed value')
|
|
}
|
|
|
|
function assert (test, message) {
|
|
if (!test) throw new Error(message || 'Failed assertion')
|
|
}
|
|
|
|
},{"base64-js":3,"ieee754":39}],6:[function(require,module,exports){
|
|
var objectKeys = require('object-keys');
|
|
var isArguments = require('is-arguments');
|
|
var is = require('object-is');
|
|
var isRegex = require('is-regex');
|
|
var flags = require('regexp.prototype.flags');
|
|
var isDate = require('is-date-object');
|
|
|
|
var getTime = Date.prototype.getTime;
|
|
|
|
function deepEqual(actual, expected, options) {
|
|
var opts = options || {};
|
|
|
|
// 7.1. All identical values are equivalent, as determined by ===.
|
|
if (opts.strict ? is(actual, expected) : actual === expected) {
|
|
return true;
|
|
}
|
|
|
|
// 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==.
|
|
if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) {
|
|
return opts.strict ? is(actual, expected) : actual == expected;
|
|
}
|
|
|
|
/*
|
|
* 7.4. For all other Object pairs, including Array objects, equivalence is
|
|
* determined by having the same number of owned properties (as verified
|
|
* with Object.prototype.hasOwnProperty.call), the same set of keys
|
|
* (although not necessarily the same order), equivalent values for every
|
|
* corresponding key, and an identical 'prototype' property. Note: this
|
|
* accounts for both named and indexed properties on Arrays.
|
|
*/
|
|
// eslint-disable-next-line no-use-before-define
|
|
return objEquiv(actual, expected, opts);
|
|
}
|
|
|
|
function isUndefinedOrNull(value) {
|
|
return value === null || value === undefined;
|
|
}
|
|
|
|
function isBuffer(x) {
|
|
if (!x || typeof x !== 'object' || typeof x.length !== 'number') {
|
|
return false;
|
|
}
|
|
if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
|
|
return false;
|
|
}
|
|
if (x.length > 0 && typeof x[0] !== 'number') {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function objEquiv(a, b, opts) {
|
|
/* eslint max-statements: [2, 50] */
|
|
var i, key;
|
|
if (typeof a !== typeof b) { return false; }
|
|
if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) { return false; }
|
|
|
|
// an identical 'prototype' property.
|
|
if (a.prototype !== b.prototype) { return false; }
|
|
|
|
if (isArguments(a) !== isArguments(b)) { return false; }
|
|
|
|
var aIsRegex = isRegex(a);
|
|
var bIsRegex = isRegex(b);
|
|
if (aIsRegex !== bIsRegex) { return false; }
|
|
if (aIsRegex || bIsRegex) {
|
|
return a.source === b.source && flags(a) === flags(b);
|
|
}
|
|
|
|
if (isDate(a) && isDate(b)) {
|
|
return getTime.call(a) === getTime.call(b);
|
|
}
|
|
|
|
var aIsBuffer = isBuffer(a);
|
|
var bIsBuffer = isBuffer(b);
|
|
if (aIsBuffer !== bIsBuffer) { return false; }
|
|
if (aIsBuffer || bIsBuffer) { // && would work too, because both are true or both false here
|
|
if (a.length !== b.length) { return false; }
|
|
for (i = 0; i < a.length; i++) {
|
|
if (a[i] !== b[i]) { return false; }
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if (typeof a !== typeof b) { return false; }
|
|
|
|
try {
|
|
var ka = objectKeys(a);
|
|
var kb = objectKeys(b);
|
|
} catch (e) { // happens when one is a string literal and the other isn't
|
|
return false;
|
|
}
|
|
// having the same number of owned properties (keys incorporates hasOwnProperty)
|
|
if (ka.length !== kb.length) { return false; }
|
|
|
|
// the same set of keys (although not necessarily the same order),
|
|
ka.sort();
|
|
kb.sort();
|
|
// ~~~cheap key test
|
|
for (i = ka.length - 1; i >= 0; i--) {
|
|
if (ka[i] != kb[i]) { return false; }
|
|
}
|
|
// equivalent values for every corresponding key, and ~~~possibly expensive deep test
|
|
for (i = ka.length - 1; i >= 0; i--) {
|
|
key = ka[i];
|
|
if (!deepEqual(a[key], b[key], opts)) { return false; }
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
module.exports = deepEqual;
|
|
|
|
},{"is-arguments":41,"is-date-object":43,"is-regex":44,"object-is":48,"object-keys":50,"regexp.prototype.flags":55}],7:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var keys = require('object-keys');
|
|
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var concat = Array.prototype.concat;
|
|
var origDefineProperty = Object.defineProperty;
|
|
|
|
var isFunction = function (fn) {
|
|
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
|
|
};
|
|
|
|
var arePropertyDescriptorsSupported = function () {
|
|
var obj = {};
|
|
try {
|
|
origDefineProperty(obj, 'x', { enumerable: false, value: obj });
|
|
// eslint-disable-next-line no-unused-vars, no-restricted-syntax
|
|
for (var _ in obj) { // jscs:ignore disallowUnusedVariables
|
|
return false;
|
|
}
|
|
return obj.x === obj;
|
|
} catch (e) { /* this is IE 8. */
|
|
return false;
|
|
}
|
|
};
|
|
var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
|
|
|
|
var defineProperty = function (object, name, value, predicate) {
|
|
if (name in object && (!isFunction(predicate) || !predicate())) {
|
|
return;
|
|
}
|
|
if (supportsDescriptors) {
|
|
origDefineProperty(object, name, {
|
|
configurable: true,
|
|
enumerable: false,
|
|
value: value,
|
|
writable: true
|
|
});
|
|
} else {
|
|
object[name] = value;
|
|
}
|
|
};
|
|
|
|
var defineProperties = function (object, map) {
|
|
var predicates = arguments.length > 2 ? arguments[2] : {};
|
|
var props = keys(map);
|
|
if (hasSymbols) {
|
|
props = concat.call(props, Object.getOwnPropertySymbols(map));
|
|
}
|
|
for (var i = 0; i < props.length; i += 1) {
|
|
defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
|
|
}
|
|
};
|
|
|
|
defineProperties.supportsDescriptors = !!supportsDescriptors;
|
|
|
|
module.exports = defineProperties;
|
|
|
|
},{"object-keys":50}],8:[function(require,module,exports){
|
|
module.exports = function () {
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
if (arguments[i] !== undefined) return arguments[i];
|
|
}
|
|
};
|
|
|
|
},{}],9:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = require('../5/CheckObjectCoercible');
|
|
|
|
},{"../5/CheckObjectCoercible":17}],10:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var $isNaN = require('../helpers/isNaN');
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-samevaluezero
|
|
|
|
module.exports = function SameValueZero(x, y) {
|
|
return (x === y) || ($isNaN(x) && $isNaN(y));
|
|
};
|
|
|
|
},{"../helpers/isNaN":24}],11:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var ES5ToInteger = require('../5/ToInteger');
|
|
|
|
var ToNumber = require('./ToNumber');
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-tointeger
|
|
|
|
module.exports = function ToInteger(value) {
|
|
var number = ToNumber(value);
|
|
return ES5ToInteger(number);
|
|
};
|
|
|
|
},{"../5/ToInteger":18,"./ToNumber":13}],12:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
|
|
|
|
var ToInteger = require('./ToInteger');
|
|
|
|
module.exports = function ToLength(argument) {
|
|
var len = ToInteger(argument);
|
|
if (len <= 0) { return 0; } // includes converting -0 to +0
|
|
if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
|
|
return len;
|
|
};
|
|
|
|
},{"../helpers/maxSafeInteger":26,"./ToInteger":11}],13:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $TypeError = GetIntrinsic('%TypeError%');
|
|
var $Number = GetIntrinsic('%Number%');
|
|
var $RegExp = GetIntrinsic('%RegExp%');
|
|
var $parseInteger = GetIntrinsic('%parseInt%');
|
|
|
|
var callBound = require('../helpers/callBound');
|
|
var regexTester = require('../helpers/regexTester');
|
|
var isPrimitive = require('../helpers/isPrimitive');
|
|
|
|
var $strSlice = callBound('String.prototype.slice');
|
|
var isBinary = regexTester(/^0b[01]+$/i);
|
|
var isOctal = regexTester(/^0o[0-7]+$/i);
|
|
var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i);
|
|
var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
|
|
var nonWSregex = new $RegExp('[' + nonWS + ']', 'g');
|
|
var hasNonWS = regexTester(nonWSregex);
|
|
|
|
// whitespace from: https://es5.github.io/#x15.5.4.20
|
|
// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
|
|
var ws = [
|
|
'\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
|
|
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028',
|
|
'\u2029\uFEFF'
|
|
].join('');
|
|
var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
|
|
var $replace = callBound('String.prototype.replace');
|
|
var $trim = function (value) {
|
|
return $replace(value, trimRegex, '');
|
|
};
|
|
|
|
var ToPrimitive = require('./ToPrimitive');
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-tonumber
|
|
|
|
module.exports = function ToNumber(argument) {
|
|
var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number);
|
|
if (typeof value === 'symbol') {
|
|
throw new $TypeError('Cannot convert a Symbol value to a number');
|
|
}
|
|
if (typeof value === 'string') {
|
|
if (isBinary(value)) {
|
|
return ToNumber($parseInteger($strSlice(value, 2), 2));
|
|
} else if (isOctal(value)) {
|
|
return ToNumber($parseInteger($strSlice(value, 2), 8));
|
|
} else if (hasNonWS(value) || isInvalidHexLiteral(value)) {
|
|
return NaN;
|
|
} else {
|
|
var trimmed = $trim(value);
|
|
if (trimmed !== value) {
|
|
return ToNumber(trimmed);
|
|
}
|
|
}
|
|
}
|
|
return $Number(value);
|
|
};
|
|
|
|
},{"../GetIntrinsic":20,"../helpers/callBound":22,"../helpers/isPrimitive":25,"../helpers/regexTester":27,"./ToPrimitive":15}],14:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $Object = GetIntrinsic('%Object%');
|
|
|
|
var RequireObjectCoercible = require('./RequireObjectCoercible');
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-toobject
|
|
|
|
module.exports = function ToObject(value) {
|
|
RequireObjectCoercible(value);
|
|
return $Object(value);
|
|
};
|
|
|
|
},{"../GetIntrinsic":20,"./RequireObjectCoercible":9}],15:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var toPrimitive = require('es-to-primitive/es2015');
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
|
|
|
|
module.exports = function ToPrimitive(input) {
|
|
if (arguments.length > 1) {
|
|
return toPrimitive(input, arguments[1]);
|
|
}
|
|
return toPrimitive(input);
|
|
};
|
|
|
|
},{"es-to-primitive/es2015":29}],16:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $String = GetIntrinsic('%String%');
|
|
var $TypeError = GetIntrinsic('%TypeError%');
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-tostring
|
|
|
|
module.exports = function ToString(argument) {
|
|
if (typeof argument === 'symbol') {
|
|
throw new $TypeError('Cannot convert a Symbol value to a string');
|
|
}
|
|
return $String(argument);
|
|
};
|
|
|
|
},{"../GetIntrinsic":20}],17:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $TypeError = GetIntrinsic('%TypeError%');
|
|
|
|
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.10
|
|
|
|
module.exports = function CheckObjectCoercible(value, optMessage) {
|
|
if (value == null) {
|
|
throw new $TypeError(optMessage || ('Cannot call method on ' + value));
|
|
}
|
|
return value;
|
|
};
|
|
|
|
},{"../GetIntrinsic":20}],18:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $Math = GetIntrinsic('%Math%');
|
|
|
|
var ToNumber = require('./ToNumber');
|
|
var $isNaN = require('../helpers/isNaN');
|
|
var $isFinite = require('../helpers/isFinite');
|
|
var $sign = require('../helpers/sign');
|
|
|
|
var $floor = $Math.floor;
|
|
var $abs = $Math.abs;
|
|
|
|
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.4
|
|
|
|
module.exports = function ToInteger(value) {
|
|
var number = ToNumber(value);
|
|
if ($isNaN(number)) { return 0; }
|
|
if (number === 0 || !$isFinite(number)) { return number; }
|
|
return $sign(number) * $floor($abs(number));
|
|
};
|
|
|
|
},{"../GetIntrinsic":20,"../helpers/isFinite":23,"../helpers/isNaN":24,"../helpers/sign":28,"./ToNumber":19}],19:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.3
|
|
|
|
module.exports = function ToNumber(value) {
|
|
return +value; // eslint-disable-line no-implicit-coercion
|
|
};
|
|
|
|
},{}],20:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
/* globals
|
|
Atomics,
|
|
SharedArrayBuffer,
|
|
*/
|
|
|
|
var undefined;
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
var throwTypeError = function () { throw new $TypeError(); };
|
|
var ThrowTypeError = $gOPD
|
|
? (function () {
|
|
try {
|
|
// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
|
|
arguments.callee; // IE 8 does not throw here
|
|
return throwTypeError;
|
|
} catch (calleeThrows) {
|
|
try {
|
|
// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
|
|
return $gOPD(arguments, 'callee').get;
|
|
} catch (gOPDthrows) {
|
|
return throwTypeError;
|
|
}
|
|
}
|
|
}())
|
|
: throwTypeError;
|
|
if ($gOPD) {
|
|
try {
|
|
$gOPD({}, '');
|
|
} catch (e) {
|
|
$gOPD = null; // this is IE 8, which has a broken gOPD
|
|
}
|
|
}
|
|
|
|
var hasSymbols = require('has-symbols')();
|
|
|
|
var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
|
|
|
|
var generator; // = function * () {};
|
|
var generatorFunction = generator ? getProto(generator) : undefined;
|
|
var asyncFn; // async function() {};
|
|
var asyncFunction = asyncFn ? asyncFn.constructor : undefined;
|
|
var asyncGen; // async function * () {};
|
|
var asyncGenFunction = asyncGen ? getProto(asyncGen) : undefined;
|
|
var asyncGenIterator = asyncGen ? asyncGen() : undefined;
|
|
|
|
var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
|
|
|
|
var INTRINSICS = {
|
|
'$ %Array%': Array,
|
|
'$ %ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
|
|
'$ %ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer.prototype,
|
|
'$ %ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
|
|
'$ %ArrayPrototype%': Array.prototype,
|
|
'$ %ArrayProto_entries%': Array.prototype.entries,
|
|
'$ %ArrayProto_forEach%': Array.prototype.forEach,
|
|
'$ %ArrayProto_keys%': Array.prototype.keys,
|
|
'$ %ArrayProto_values%': Array.prototype.values,
|
|
'$ %AsyncFromSyncIteratorPrototype%': undefined,
|
|
'$ %AsyncFunction%': asyncFunction,
|
|
'$ %AsyncFunctionPrototype%': asyncFunction ? asyncFunction.prototype : undefined,
|
|
'$ %AsyncGenerator%': asyncGen ? getProto(asyncGenIterator) : undefined,
|
|
'$ %AsyncGeneratorFunction%': asyncGenFunction,
|
|
'$ %AsyncGeneratorPrototype%': asyncGenFunction ? asyncGenFunction.prototype : undefined,
|
|
'$ %AsyncIteratorPrototype%': asyncGenIterator && hasSymbols && Symbol.asyncIterator ? asyncGenIterator[Symbol.asyncIterator]() : undefined,
|
|
'$ %Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
|
|
'$ %Boolean%': Boolean,
|
|
'$ %BooleanPrototype%': Boolean.prototype,
|
|
'$ %DataView%': typeof DataView === 'undefined' ? undefined : DataView,
|
|
'$ %DataViewPrototype%': typeof DataView === 'undefined' ? undefined : DataView.prototype,
|
|
'$ %Date%': Date,
|
|
'$ %DatePrototype%': Date.prototype,
|
|
'$ %decodeURI%': decodeURI,
|
|
'$ %decodeURIComponent%': decodeURIComponent,
|
|
'$ %encodeURI%': encodeURI,
|
|
'$ %encodeURIComponent%': encodeURIComponent,
|
|
'$ %Error%': Error,
|
|
'$ %ErrorPrototype%': Error.prototype,
|
|
'$ %eval%': eval, // eslint-disable-line no-eval
|
|
'$ %EvalError%': EvalError,
|
|
'$ %EvalErrorPrototype%': EvalError.prototype,
|
|
'$ %Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
|
|
'$ %Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined : Float32Array.prototype,
|
|
'$ %Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
|
|
'$ %Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined : Float64Array.prototype,
|
|
'$ %Function%': Function,
|
|
'$ %FunctionPrototype%': Function.prototype,
|
|
'$ %Generator%': generator ? getProto(generator()) : undefined,
|
|
'$ %GeneratorFunction%': generatorFunction,
|
|
'$ %GeneratorPrototype%': generatorFunction ? generatorFunction.prototype : undefined,
|
|
'$ %Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
|
|
'$ %Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined : Int8Array.prototype,
|
|
'$ %Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
|
|
'$ %Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined : Int8Array.prototype,
|
|
'$ %Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
|
|
'$ %Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined : Int32Array.prototype,
|
|
'$ %isFinite%': isFinite,
|
|
'$ %isNaN%': isNaN,
|
|
'$ %IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
|
'$ %JSON%': typeof JSON === 'object' ? JSON : undefined,
|
|
'$ %JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined,
|
|
'$ %Map%': typeof Map === 'undefined' ? undefined : Map,
|
|
'$ %MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
|
'$ %MapPrototype%': typeof Map === 'undefined' ? undefined : Map.prototype,
|
|
'$ %Math%': Math,
|
|
'$ %Number%': Number,
|
|
'$ %NumberPrototype%': Number.prototype,
|
|
'$ %Object%': Object,
|
|
'$ %ObjectPrototype%': Object.prototype,
|
|
'$ %ObjProto_toString%': Object.prototype.toString,
|
|
'$ %ObjProto_valueOf%': Object.prototype.valueOf,
|
|
'$ %parseFloat%': parseFloat,
|
|
'$ %parseInt%': parseInt,
|
|
'$ %Promise%': typeof Promise === 'undefined' ? undefined : Promise,
|
|
'$ %PromisePrototype%': typeof Promise === 'undefined' ? undefined : Promise.prototype,
|
|
'$ %PromiseProto_then%': typeof Promise === 'undefined' ? undefined : Promise.prototype.then,
|
|
'$ %Promise_all%': typeof Promise === 'undefined' ? undefined : Promise.all,
|
|
'$ %Promise_reject%': typeof Promise === 'undefined' ? undefined : Promise.reject,
|
|
'$ %Promise_resolve%': typeof Promise === 'undefined' ? undefined : Promise.resolve,
|
|
'$ %Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
|
|
'$ %RangeError%': RangeError,
|
|
'$ %RangeErrorPrototype%': RangeError.prototype,
|
|
'$ %ReferenceError%': ReferenceError,
|
|
'$ %ReferenceErrorPrototype%': ReferenceError.prototype,
|
|
'$ %Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
|
|
'$ %RegExp%': RegExp,
|
|
'$ %RegExpPrototype%': RegExp.prototype,
|
|
'$ %Set%': typeof Set === 'undefined' ? undefined : Set,
|
|
'$ %SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
|
|
'$ %SetPrototype%': typeof Set === 'undefined' ? undefined : Set.prototype,
|
|
'$ %SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
|
|
'$ %SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer.prototype,
|
|
'$ %String%': String,
|
|
'$ %StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
|
|
'$ %StringPrototype%': String.prototype,
|
|
'$ %Symbol%': hasSymbols ? Symbol : undefined,
|
|
'$ %SymbolPrototype%': hasSymbols ? Symbol.prototype : undefined,
|
|
'$ %SyntaxError%': SyntaxError,
|
|
'$ %SyntaxErrorPrototype%': SyntaxError.prototype,
|
|
'$ %ThrowTypeError%': ThrowTypeError,
|
|
'$ %TypedArray%': TypedArray,
|
|
'$ %TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined,
|
|
'$ %TypeError%': $TypeError,
|
|
'$ %TypeErrorPrototype%': $TypeError.prototype,
|
|
'$ %Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
|
|
'$ %Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array.prototype,
|
|
'$ %Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
|
|
'$ %Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray.prototype,
|
|
'$ %Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
|
|
'$ %Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array.prototype,
|
|
'$ %Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
|
|
'$ %Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array.prototype,
|
|
'$ %URIError%': URIError,
|
|
'$ %URIErrorPrototype%': URIError.prototype,
|
|
'$ %WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
|
|
'$ %WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined : WeakMap.prototype,
|
|
'$ %WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet,
|
|
'$ %WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined : WeakSet.prototype
|
|
};
|
|
|
|
var bind = require('function-bind');
|
|
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
|
|
/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
|
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
|
|
var stringToPath = function stringToPath(string) {
|
|
var result = [];
|
|
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
|
|
});
|
|
return result;
|
|
};
|
|
/* end adaptation */
|
|
|
|
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
var key = '$ ' + name;
|
|
if (!(key in INTRINSICS)) {
|
|
throw new SyntaxError('intrinsic ' + name + ' does not exist!');
|
|
}
|
|
|
|
// istanbul ignore if // hopefully this is impossible to test :-)
|
|
if (typeof INTRINSICS[key] === 'undefined' && !allowMissing) {
|
|
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
}
|
|
|
|
return INTRINSICS[key];
|
|
};
|
|
|
|
module.exports = function GetIntrinsic(name, allowMissing) {
|
|
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
throw new TypeError('"allowMissing" argument must be a boolean');
|
|
}
|
|
|
|
var parts = stringToPath(name);
|
|
|
|
if (parts.length === 0) {
|
|
return getBaseIntrinsic(name, allowMissing);
|
|
}
|
|
|
|
var value = getBaseIntrinsic('%' + parts[0] + '%', allowMissing);
|
|
for (var i = 1; i < parts.length; i += 1) {
|
|
if (value != null) {
|
|
if ($gOPD && (i + 1) >= parts.length) {
|
|
var desc = $gOPD(value, parts[i]);
|
|
value = desc ? (desc.get || desc.value) : value[parts[i]];
|
|
} else {
|
|
value = value[parts[i]];
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
|
|
},{"function-bind":34,"has-symbols":36}],21:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var bind = require('function-bind');
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $Function = GetIntrinsic('%Function%');
|
|
var $apply = $Function.apply;
|
|
var $call = $Function.call;
|
|
|
|
module.exports = function callBind() {
|
|
return bind.apply($call, arguments);
|
|
};
|
|
|
|
module.exports.apply = function applyBind() {
|
|
return bind.apply($apply, arguments);
|
|
};
|
|
|
|
},{"../GetIntrinsic":20,"function-bind":34}],22:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var callBind = require('./callBind');
|
|
|
|
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
|
|
|
module.exports = function callBoundIntrinsic(name, allowMissing) {
|
|
var intrinsic = GetIntrinsic(name, !!allowMissing);
|
|
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')) {
|
|
return callBind(intrinsic);
|
|
}
|
|
return intrinsic;
|
|
};
|
|
|
|
},{"../GetIntrinsic":20,"./callBind":21}],23:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var $isNaN = Number.isNaN || function (a) { return a !== a; };
|
|
|
|
module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; };
|
|
|
|
},{}],24:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = Number.isNaN || function isNaN(a) {
|
|
return a !== a;
|
|
};
|
|
|
|
},{}],25:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = function isPrimitive(value) {
|
|
return value === null || (typeof value !== 'function' && typeof value !== 'object');
|
|
};
|
|
|
|
},{}],26:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $Math = GetIntrinsic('%Math%');
|
|
var $Number = GetIntrinsic('%Number%');
|
|
|
|
module.exports = $Number.MAX_SAFE_INTEGER || $Math.pow(2, 53) - 1;
|
|
|
|
},{"../GetIntrinsic":20}],27:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $test = GetIntrinsic('RegExp.prototype.test');
|
|
|
|
var callBind = require('./callBind');
|
|
|
|
module.exports = function regexTester(regex) {
|
|
return callBind($test, regex);
|
|
};
|
|
|
|
},{"../GetIntrinsic":20,"./callBind":21}],28:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = function sign(number) {
|
|
return number >= 0 ? 1 : -1;
|
|
};
|
|
|
|
},{}],29:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
|
|
|
|
var isPrimitive = require('./helpers/isPrimitive');
|
|
var isCallable = require('is-callable');
|
|
var isDate = require('is-date-object');
|
|
var isSymbol = require('is-symbol');
|
|
|
|
var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
|
|
if (typeof O === 'undefined' || O === null) {
|
|
throw new TypeError('Cannot call method on ' + O);
|
|
}
|
|
if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
|
|
throw new TypeError('hint must be "string" or "number"');
|
|
}
|
|
var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
|
|
var method, result, i;
|
|
for (i = 0; i < methodNames.length; ++i) {
|
|
method = O[methodNames[i]];
|
|
if (isCallable(method)) {
|
|
result = method.call(O);
|
|
if (isPrimitive(result)) {
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
throw new TypeError('No default value');
|
|
};
|
|
|
|
var GetMethod = function GetMethod(O, P) {
|
|
var func = O[P];
|
|
if (func !== null && typeof func !== 'undefined') {
|
|
if (!isCallable(func)) {
|
|
throw new TypeError(func + ' returned for property ' + P + ' of object ' + O + ' is not a function');
|
|
}
|
|
return func;
|
|
}
|
|
return void 0;
|
|
};
|
|
|
|
// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
|
|
module.exports = function ToPrimitive(input) {
|
|
if (isPrimitive(input)) {
|
|
return input;
|
|
}
|
|
var hint = 'default';
|
|
if (arguments.length > 1) {
|
|
if (arguments[1] === String) {
|
|
hint = 'string';
|
|
} else if (arguments[1] === Number) {
|
|
hint = 'number';
|
|
}
|
|
}
|
|
|
|
var exoticToPrim;
|
|
if (hasSymbols) {
|
|
if (Symbol.toPrimitive) {
|
|
exoticToPrim = GetMethod(input, Symbol.toPrimitive);
|
|
} else if (isSymbol(input)) {
|
|
exoticToPrim = Symbol.prototype.valueOf;
|
|
}
|
|
}
|
|
if (typeof exoticToPrim !== 'undefined') {
|
|
var result = exoticToPrim.call(input, hint);
|
|
if (isPrimitive(result)) {
|
|
return result;
|
|
}
|
|
throw new TypeError('unable to convert exotic object to primitive');
|
|
}
|
|
if (hint === 'default' && (isDate(input) || isSymbol(input))) {
|
|
hint = 'string';
|
|
}
|
|
return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint);
|
|
};
|
|
|
|
},{"./helpers/isPrimitive":30,"is-callable":42,"is-date-object":43,"is-symbol":45}],30:[function(require,module,exports){
|
|
module.exports=require(25)
|
|
},{}],31:[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.
|
|
|
|
function EventEmitter() {
|
|
this._events = this._events || {};
|
|
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.
|
|
EventEmitter.defaultMaxListeners = 10;
|
|
|
|
// 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(n) {
|
|
if (!isNumber(n) || n < 0 || isNaN(n))
|
|
throw TypeError('n must be a positive number');
|
|
this._maxListeners = n;
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.emit = function(type) {
|
|
var er, handler, len, args, i, listeners;
|
|
|
|
if (!this._events)
|
|
this._events = {};
|
|
|
|
// If there is no 'error' event listener then throw.
|
|
if (type === 'error') {
|
|
if (!this._events.error ||
|
|
(isObject(this._events.error) && !this._events.error.length)) {
|
|
er = arguments[1];
|
|
if (er instanceof Error) {
|
|
throw er; // Unhandled 'error' event
|
|
}
|
|
throw TypeError('Uncaught, unspecified "error" event.');
|
|
}
|
|
}
|
|
|
|
handler = this._events[type];
|
|
|
|
if (isUndefined(handler))
|
|
return false;
|
|
|
|
if (isFunction(handler)) {
|
|
switch (arguments.length) {
|
|
// fast cases
|
|
case 1:
|
|
handler.call(this);
|
|
break;
|
|
case 2:
|
|
handler.call(this, arguments[1]);
|
|
break;
|
|
case 3:
|
|
handler.call(this, arguments[1], arguments[2]);
|
|
break;
|
|
// slower
|
|
default:
|
|
len = arguments.length;
|
|
args = new Array(len - 1);
|
|
for (i = 1; i < len; i++)
|
|
args[i - 1] = arguments[i];
|
|
handler.apply(this, args);
|
|
}
|
|
} else if (isObject(handler)) {
|
|
len = arguments.length;
|
|
args = new Array(len - 1);
|
|
for (i = 1; i < len; i++)
|
|
args[i - 1] = arguments[i];
|
|
|
|
listeners = handler.slice();
|
|
len = listeners.length;
|
|
for (i = 0; i < len; i++)
|
|
listeners[i].apply(this, args);
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
EventEmitter.prototype.addListener = function(type, listener) {
|
|
var m;
|
|
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
|
|
if (!this._events)
|
|
this._events = {};
|
|
|
|
// To avoid recursion in the case that type === "newListener"! Before
|
|
// adding it to the listeners, first emit "newListener".
|
|
if (this._events.newListener)
|
|
this.emit('newListener', type,
|
|
isFunction(listener.listener) ?
|
|
listener.listener : listener);
|
|
|
|
if (!this._events[type])
|
|
// Optimize the case of one listener. Don't need the extra array object.
|
|
this._events[type] = listener;
|
|
else if (isObject(this._events[type]))
|
|
// If we've already got an array, just append.
|
|
this._events[type].push(listener);
|
|
else
|
|
// Adding the second element, need to change to array.
|
|
this._events[type] = [this._events[type], listener];
|
|
|
|
// Check for listener leak
|
|
if (isObject(this._events[type]) && !this._events[type].warned) {
|
|
var m;
|
|
if (!isUndefined(this._maxListeners)) {
|
|
m = this._maxListeners;
|
|
} else {
|
|
m = EventEmitter.defaultMaxListeners;
|
|
}
|
|
|
|
if (m && m > 0 && this._events[type].length > m) {
|
|
this._events[type].warned = true;
|
|
console.error('(node) warning: possible EventEmitter memory ' +
|
|
'leak detected. %d listeners added. ' +
|
|
'Use emitter.setMaxListeners() to increase limit.',
|
|
this._events[type].length);
|
|
if (typeof console.trace === 'function') {
|
|
// not supported in IE 10
|
|
console.trace();
|
|
}
|
|
}
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
|
|
EventEmitter.prototype.once = function(type, listener) {
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
|
|
var fired = false;
|
|
|
|
function g() {
|
|
this.removeListener(type, g);
|
|
|
|
if (!fired) {
|
|
fired = true;
|
|
listener.apply(this, arguments);
|
|
}
|
|
}
|
|
|
|
g.listener = listener;
|
|
this.on(type, g);
|
|
|
|
return this;
|
|
};
|
|
|
|
// emits a 'removeListener' event iff the listener was removed
|
|
EventEmitter.prototype.removeListener = function(type, listener) {
|
|
var list, position, length, i;
|
|
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
|
|
if (!this._events || !this._events[type])
|
|
return this;
|
|
|
|
list = this._events[type];
|
|
length = list.length;
|
|
position = -1;
|
|
|
|
if (list === listener ||
|
|
(isFunction(list.listener) && list.listener === listener)) {
|
|
delete this._events[type];
|
|
if (this._events.removeListener)
|
|
this.emit('removeListener', type, listener);
|
|
|
|
} else if (isObject(list)) {
|
|
for (i = length; i-- > 0;) {
|
|
if (list[i] === listener ||
|
|
(list[i].listener && list[i].listener === listener)) {
|
|
position = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (position < 0)
|
|
return this;
|
|
|
|
if (list.length === 1) {
|
|
list.length = 0;
|
|
delete this._events[type];
|
|
} else {
|
|
list.splice(position, 1);
|
|
}
|
|
|
|
if (this._events.removeListener)
|
|
this.emit('removeListener', type, listener);
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.removeAllListeners = function(type) {
|
|
var key, listeners;
|
|
|
|
if (!this._events)
|
|
return this;
|
|
|
|
// not listening for removeListener, no need to emit
|
|
if (!this._events.removeListener) {
|
|
if (arguments.length === 0)
|
|
this._events = {};
|
|
else if (this._events[type])
|
|
delete this._events[type];
|
|
return this;
|
|
}
|
|
|
|
// emit removeListener for all listeners on all events
|
|
if (arguments.length === 0) {
|
|
for (key in this._events) {
|
|
if (key === 'removeListener') continue;
|
|
this.removeAllListeners(key);
|
|
}
|
|
this.removeAllListeners('removeListener');
|
|
this._events = {};
|
|
return this;
|
|
}
|
|
|
|
listeners = this._events[type];
|
|
|
|
if (isFunction(listeners)) {
|
|
this.removeListener(type, listeners);
|
|
} else {
|
|
// LIFO order
|
|
while (listeners.length)
|
|
this.removeListener(type, listeners[listeners.length - 1]);
|
|
}
|
|
delete this._events[type];
|
|
|
|
return this;
|
|
};
|
|
|
|
EventEmitter.prototype.listeners = function(type) {
|
|
var ret;
|
|
if (!this._events || !this._events[type])
|
|
ret = [];
|
|
else if (isFunction(this._events[type]))
|
|
ret = [this._events[type]];
|
|
else
|
|
ret = this._events[type].slice();
|
|
return ret;
|
|
};
|
|
|
|
EventEmitter.listenerCount = function(emitter, type) {
|
|
var ret;
|
|
if (!emitter._events || !emitter._events[type])
|
|
ret = 0;
|
|
else if (isFunction(emitter._events[type]))
|
|
ret = 1;
|
|
else
|
|
ret = emitter._events[type].length;
|
|
return ret;
|
|
};
|
|
|
|
function isFunction(arg) {
|
|
return typeof arg === 'function';
|
|
}
|
|
|
|
function isNumber(arg) {
|
|
return typeof arg === 'number';
|
|
}
|
|
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
|
|
function isUndefined(arg) {
|
|
return arg === void 0;
|
|
}
|
|
|
|
},{}],32:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var isCallable = require('is-callable');
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
|
var forEachArray = function forEachArray(array, iterator, receiver) {
|
|
for (var i = 0, len = array.length; i < len; i++) {
|
|
if (hasOwnProperty.call(array, i)) {
|
|
if (receiver == null) {
|
|
iterator(array[i], i, array);
|
|
} else {
|
|
iterator.call(receiver, array[i], i, array);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var forEachString = function forEachString(string, iterator, receiver) {
|
|
for (var i = 0, len = string.length; i < len; i++) {
|
|
// no such thing as a sparse string.
|
|
if (receiver == null) {
|
|
iterator(string.charAt(i), i, string);
|
|
} else {
|
|
iterator.call(receiver, string.charAt(i), i, string);
|
|
}
|
|
}
|
|
};
|
|
|
|
var forEachObject = function forEachObject(object, iterator, receiver) {
|
|
for (var k in object) {
|
|
if (hasOwnProperty.call(object, k)) {
|
|
if (receiver == null) {
|
|
iterator(object[k], k, object);
|
|
} else {
|
|
iterator.call(receiver, object[k], k, object);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var forEach = function forEach(list, iterator, thisArg) {
|
|
if (!isCallable(iterator)) {
|
|
throw new TypeError('iterator must be a function');
|
|
}
|
|
|
|
var receiver;
|
|
if (arguments.length >= 3) {
|
|
receiver = thisArg;
|
|
}
|
|
|
|
if (toStr.call(list) === '[object Array]') {
|
|
forEachArray(list, iterator, receiver);
|
|
} else if (typeof list === 'string') {
|
|
forEachString(list, iterator, receiver);
|
|
} else {
|
|
forEachObject(list, iterator, receiver);
|
|
}
|
|
};
|
|
|
|
module.exports = forEach;
|
|
|
|
},{"is-callable":42}],33:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
/* eslint no-invalid-this: 1 */
|
|
|
|
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
var slice = Array.prototype.slice;
|
|
var toStr = Object.prototype.toString;
|
|
var funcType = '[object Function]';
|
|
|
|
module.exports = function bind(that) {
|
|
var target = this;
|
|
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
|
|
throw new TypeError(ERROR_MESSAGE + target);
|
|
}
|
|
var args = slice.call(arguments, 1);
|
|
|
|
var bound;
|
|
var binder = function () {
|
|
if (this instanceof bound) {
|
|
var result = target.apply(
|
|
this,
|
|
args.concat(slice.call(arguments))
|
|
);
|
|
if (Object(result) === result) {
|
|
return result;
|
|
}
|
|
return this;
|
|
} else {
|
|
return target.apply(
|
|
that,
|
|
args.concat(slice.call(arguments))
|
|
);
|
|
}
|
|
};
|
|
|
|
var boundLength = Math.max(0, target.length - args.length);
|
|
var boundArgs = [];
|
|
for (var i = 0; i < boundLength; i++) {
|
|
boundArgs.push('$' + i);
|
|
}
|
|
|
|
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
|
|
if (target.prototype) {
|
|
var Empty = function Empty() {};
|
|
Empty.prototype = target.prototype;
|
|
bound.prototype = new Empty();
|
|
Empty.prototype = null;
|
|
}
|
|
|
|
return bound;
|
|
};
|
|
|
|
},{}],34:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var implementation = require('./implementation');
|
|
|
|
module.exports = Function.prototype.bind || implementation;
|
|
|
|
},{"./implementation":33}],35:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var functionsHaveNames = function functionsHaveNames() {
|
|
return typeof function f() {}.name === 'string';
|
|
};
|
|
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
functionsHaveNames.functionsHaveConfigurableNames = function functionsHaveConfigurableNames() {
|
|
return functionsHaveNames() && gOPD && !!gOPD(function () {}, 'name').configurable;
|
|
};
|
|
|
|
var $bind = Function.prototype.bind;
|
|
|
|
functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() {
|
|
return functionsHaveNames() && typeof $bind === 'function' && function f() {}.bind().name !== '';
|
|
};
|
|
|
|
module.exports = functionsHaveNames;
|
|
|
|
},{}],36:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var origSymbol = global.Symbol;
|
|
var hasSymbolSham = require('./shams');
|
|
|
|
module.exports = function hasNativeSymbols() {
|
|
if (typeof origSymbol !== 'function') { return false; }
|
|
if (typeof Symbol !== 'function') { return false; }
|
|
if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
|
if (typeof Symbol('bar') !== 'symbol') { return false; }
|
|
|
|
return hasSymbolSham();
|
|
};
|
|
|
|
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"./shams":37}],37:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
module.exports = function hasSymbols() {
|
|
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
|
if (typeof Symbol.iterator === 'symbol') { return true; }
|
|
|
|
var obj = {};
|
|
var sym = Symbol('test');
|
|
var symObj = Object(sym);
|
|
if (typeof sym === 'string') { return false; }
|
|
|
|
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
|
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
|
|
|
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
// if (sym instanceof Symbol) { return false; }
|
|
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
// if (!(symObj instanceof Symbol)) { return false; }
|
|
|
|
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
|
|
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
|
|
|
|
var symVal = 42;
|
|
obj[sym] = symVal;
|
|
for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
|
|
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
|
|
|
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
|
|
|
var syms = Object.getOwnPropertySymbols(obj);
|
|
if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
|
|
|
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
|
|
|
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
},{}],38:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var bind = require('function-bind');
|
|
|
|
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
|
|
|
},{"function-bind":34}],39:[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
|
|
}
|
|
|
|
},{}],40:[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
|
|
}
|
|
}
|
|
}
|
|
|
|
},{}],41:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
var toStr = Object.prototype.toString;
|
|
|
|
var isStandardArguments = function isArguments(value) {
|
|
if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
|
|
return false;
|
|
}
|
|
return toStr.call(value) === '[object Arguments]';
|
|
};
|
|
|
|
var isLegacyArguments = function isArguments(value) {
|
|
if (isStandardArguments(value)) {
|
|
return true;
|
|
}
|
|
return value !== null &&
|
|
typeof value === 'object' &&
|
|
typeof value.length === 'number' &&
|
|
value.length >= 0 &&
|
|
toStr.call(value) !== '[object Array]' &&
|
|
toStr.call(value.callee) === '[object Function]';
|
|
};
|
|
|
|
var supportsStandardArguments = (function () {
|
|
return isStandardArguments(arguments);
|
|
}());
|
|
|
|
isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
|
|
|
|
module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
|
|
|
|
},{}],42:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var fnToStr = Function.prototype.toString;
|
|
|
|
var constructorRegex = /^\s*class\b/;
|
|
var isES6ClassFn = function isES6ClassFunction(value) {
|
|
try {
|
|
var fnStr = fnToStr.call(value);
|
|
return constructorRegex.test(fnStr);
|
|
} catch (e) {
|
|
return false; // not a function
|
|
}
|
|
};
|
|
|
|
var tryFunctionObject = function tryFunctionToStr(value) {
|
|
try {
|
|
if (isES6ClassFn(value)) { return false; }
|
|
fnToStr.call(value);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
var toStr = Object.prototype.toString;
|
|
var fnClass = '[object Function]';
|
|
var genClass = '[object GeneratorFunction]';
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
|
|
module.exports = function isCallable(value) {
|
|
if (!value) { return false; }
|
|
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
|
|
if (typeof value === 'function' && !value.prototype) { return true; }
|
|
if (hasToStringTag) { return tryFunctionObject(value); }
|
|
if (isES6ClassFn(value)) { return false; }
|
|
var strClass = toStr.call(value);
|
|
return strClass === fnClass || strClass === genClass;
|
|
};
|
|
|
|
},{}],43:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var getDay = Date.prototype.getDay;
|
|
var tryDateObject = function tryDateObject(value) {
|
|
try {
|
|
getDay.call(value);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var dateClass = '[object Date]';
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
|
|
module.exports = function isDateObject(value) {
|
|
if (typeof value !== 'object' || value === null) { return false; }
|
|
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
|
|
};
|
|
|
|
},{}],44:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var has = require('has');
|
|
var regexExec = RegExp.prototype.exec;
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
var tryRegexExecCall = function tryRegexExec(value) {
|
|
try {
|
|
var lastIndex = value.lastIndex;
|
|
value.lastIndex = 0;
|
|
|
|
regexExec.call(value);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
} finally {
|
|
value.lastIndex = lastIndex;
|
|
}
|
|
};
|
|
var toStr = Object.prototype.toString;
|
|
var regexClass = '[object RegExp]';
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
|
|
module.exports = function isRegex(value) {
|
|
if (!value || typeof value !== 'object') {
|
|
return false;
|
|
}
|
|
if (!hasToStringTag) {
|
|
return toStr.call(value) === regexClass;
|
|
}
|
|
|
|
var descriptor = gOPD(value, 'lastIndex');
|
|
var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
|
|
if (!hasLastIndexDataProperty) {
|
|
return false;
|
|
}
|
|
|
|
return tryRegexExecCall(value);
|
|
};
|
|
|
|
},{"has":38}],45:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var hasSymbols = require('has-symbols')();
|
|
|
|
if (hasSymbols) {
|
|
var symToStr = Symbol.prototype.toString;
|
|
var symStringRegex = /^Symbol\(.*\)$/;
|
|
var isSymbolObject = function isRealSymbolObject(value) {
|
|
if (typeof value.valueOf() !== 'symbol') {
|
|
return false;
|
|
}
|
|
return symStringRegex.test(symToStr.call(value));
|
|
};
|
|
|
|
module.exports = function isSymbol(value) {
|
|
if (typeof value === 'symbol') {
|
|
return true;
|
|
}
|
|
if (toStr.call(value) !== '[object Symbol]') {
|
|
return false;
|
|
}
|
|
try {
|
|
return isSymbolObject(value);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
} else {
|
|
|
|
module.exports = function isSymbol(value) {
|
|
// this environment does not support Symbols.
|
|
return false && value;
|
|
};
|
|
}
|
|
|
|
},{"has-symbols":36}],46:[function(require,module,exports){
|
|
var hasMap = typeof Map === 'function' && Map.prototype;
|
|
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
|
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
|
var mapForEach = hasMap && Map.prototype.forEach;
|
|
var hasSet = typeof Set === 'function' && Set.prototype;
|
|
var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
|
|
var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
|
|
var setForEach = hasSet && Set.prototype.forEach;
|
|
var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
|
|
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
|
|
var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
|
|
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
|
|
var booleanValueOf = Boolean.prototype.valueOf;
|
|
var objectToString = Object.prototype.toString;
|
|
var match = String.prototype.match;
|
|
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
|
|
|
var inspectCustom = require('./util.inspect').custom;
|
|
var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
|
|
|
|
module.exports = function inspect_(obj, options, depth, seen) {
|
|
var opts = options || {};
|
|
|
|
if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
|
|
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
|
}
|
|
|
|
if (typeof obj === 'undefined') {
|
|
return 'undefined';
|
|
}
|
|
if (obj === null) {
|
|
return 'null';
|
|
}
|
|
if (typeof obj === 'boolean') {
|
|
return obj ? 'true' : 'false';
|
|
}
|
|
|
|
if (typeof obj === 'string') {
|
|
return inspectString(obj, opts);
|
|
}
|
|
if (typeof obj === 'number') {
|
|
if (obj === 0) {
|
|
return Infinity / obj > 0 ? '0' : '-0';
|
|
}
|
|
return String(obj);
|
|
}
|
|
if (typeof obj === 'bigint') { // eslint-disable-line valid-typeof
|
|
return String(obj) + 'n';
|
|
}
|
|
|
|
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
|
|
if (typeof depth === 'undefined') { depth = 0; }
|
|
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
|
return '[Object]';
|
|
}
|
|
|
|
if (typeof seen === 'undefined') {
|
|
seen = [];
|
|
} else if (indexOf(seen, obj) >= 0) {
|
|
return '[Circular]';
|
|
}
|
|
|
|
function inspect(value, from) {
|
|
if (from) {
|
|
seen = seen.slice();
|
|
seen.push(from);
|
|
}
|
|
return inspect_(value, opts, depth + 1, seen);
|
|
}
|
|
|
|
if (typeof obj === 'function') {
|
|
var name = nameOf(obj);
|
|
return '[Function' + (name ? ': ' + name : '') + ']';
|
|
}
|
|
if (isSymbol(obj)) {
|
|
var symString = Symbol.prototype.toString.call(obj);
|
|
return typeof obj === 'object' ? markBoxed(symString) : symString;
|
|
}
|
|
if (isElement(obj)) {
|
|
var s = '<' + String(obj.nodeName).toLowerCase();
|
|
var attrs = obj.attributes || [];
|
|
for (var i = 0; i < attrs.length; i++) {
|
|
s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
|
|
}
|
|
s += '>';
|
|
if (obj.childNodes && obj.childNodes.length) { s += '...'; }
|
|
s += '</' + String(obj.nodeName).toLowerCase() + '>';
|
|
return s;
|
|
}
|
|
if (isArray(obj)) {
|
|
if (obj.length === 0) { return '[]'; }
|
|
return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]';
|
|
}
|
|
if (isError(obj)) {
|
|
var parts = arrObjKeys(obj, inspect);
|
|
if (parts.length === 0) { return '[' + String(obj) + ']'; }
|
|
return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
|
|
}
|
|
if (typeof obj === 'object') {
|
|
if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
|
|
return obj[inspectSymbol]();
|
|
} else if (typeof obj.inspect === 'function') {
|
|
return obj.inspect();
|
|
}
|
|
}
|
|
if (isMap(obj)) {
|
|
var mapParts = [];
|
|
mapForEach.call(obj, function (value, key) {
|
|
mapParts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
|
|
});
|
|
return collectionOf('Map', mapSize.call(obj), mapParts);
|
|
}
|
|
if (isSet(obj)) {
|
|
var setParts = [];
|
|
setForEach.call(obj, function (value) {
|
|
setParts.push(inspect(value, obj));
|
|
});
|
|
return collectionOf('Set', setSize.call(obj), setParts);
|
|
}
|
|
if (isWeakMap(obj)) {
|
|
return weakCollectionOf('WeakMap');
|
|
}
|
|
if (isWeakSet(obj)) {
|
|
return weakCollectionOf('WeakSet');
|
|
}
|
|
if (isNumber(obj)) {
|
|
return markBoxed(inspect(Number(obj)));
|
|
}
|
|
if (isBigInt(obj)) {
|
|
return markBoxed(inspect(bigIntValueOf.call(obj)));
|
|
}
|
|
if (isBoolean(obj)) {
|
|
return markBoxed(booleanValueOf.call(obj));
|
|
}
|
|
if (isString(obj)) {
|
|
return markBoxed(inspect(String(obj)));
|
|
}
|
|
if (!isDate(obj) && !isRegExp(obj)) {
|
|
var xs = arrObjKeys(obj, inspect);
|
|
if (xs.length === 0) { return '{}'; }
|
|
return '{ ' + xs.join(', ') + ' }';
|
|
}
|
|
return String(obj);
|
|
};
|
|
|
|
function wrapQuotes(s, defaultStyle, opts) {
|
|
var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
|
|
return quoteChar + s + quoteChar;
|
|
}
|
|
|
|
function quote(s) {
|
|
return String(s).replace(/"/g, '"');
|
|
}
|
|
|
|
function isArray(obj) { return toStr(obj) === '[object Array]'; }
|
|
function isDate(obj) { return toStr(obj) === '[object Date]'; }
|
|
function isRegExp(obj) { return toStr(obj) === '[object RegExp]'; }
|
|
function isError(obj) { return toStr(obj) === '[object Error]'; }
|
|
function isSymbol(obj) { return toStr(obj) === '[object Symbol]'; }
|
|
function isString(obj) { return toStr(obj) === '[object String]'; }
|
|
function isNumber(obj) { return toStr(obj) === '[object Number]'; }
|
|
function isBigInt(obj) { return toStr(obj) === '[object BigInt]'; }
|
|
function isBoolean(obj) { return toStr(obj) === '[object Boolean]'; }
|
|
|
|
var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
|
|
function has(obj, key) {
|
|
return hasOwn.call(obj, key);
|
|
}
|
|
|
|
function toStr(obj) {
|
|
return objectToString.call(obj);
|
|
}
|
|
|
|
function nameOf(f) {
|
|
if (f.name) { return f.name; }
|
|
var m = match.call(f, /^function\s*([\w$]+)/);
|
|
if (m) { return m[1]; }
|
|
return null;
|
|
}
|
|
|
|
function indexOf(xs, x) {
|
|
if (xs.indexOf) { return xs.indexOf(x); }
|
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
if (xs[i] === x) { return i; }
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
function isMap(x) {
|
|
if (!mapSize || !x || typeof x !== 'object') {
|
|
return false;
|
|
}
|
|
try {
|
|
mapSize.call(x);
|
|
try {
|
|
setSize.call(x);
|
|
} catch (s) {
|
|
return true;
|
|
}
|
|
return x instanceof Map; // core-js workaround, pre-v2.5.0
|
|
} catch (e) {}
|
|
return false;
|
|
}
|
|
|
|
function isWeakMap(x) {
|
|
if (!weakMapHas || !x || typeof x !== 'object') {
|
|
return false;
|
|
}
|
|
try {
|
|
weakMapHas.call(x, weakMapHas);
|
|
try {
|
|
weakSetHas.call(x, weakSetHas);
|
|
} catch (s) {
|
|
return true;
|
|
}
|
|
return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
|
|
} catch (e) {}
|
|
return false;
|
|
}
|
|
|
|
function isSet(x) {
|
|
if (!setSize || !x || typeof x !== 'object') {
|
|
return false;
|
|
}
|
|
try {
|
|
setSize.call(x);
|
|
try {
|
|
mapSize.call(x);
|
|
} catch (m) {
|
|
return true;
|
|
}
|
|
return x instanceof Set; // core-js workaround, pre-v2.5.0
|
|
} catch (e) {}
|
|
return false;
|
|
}
|
|
|
|
function isWeakSet(x) {
|
|
if (!weakSetHas || !x || typeof x !== 'object') {
|
|
return false;
|
|
}
|
|
try {
|
|
weakSetHas.call(x, weakSetHas);
|
|
try {
|
|
weakMapHas.call(x, weakMapHas);
|
|
} catch (s) {
|
|
return true;
|
|
}
|
|
return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
|
|
} catch (e) {}
|
|
return false;
|
|
}
|
|
|
|
function isElement(x) {
|
|
if (!x || typeof x !== 'object') { return false; }
|
|
if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
|
|
return true;
|
|
}
|
|
return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
|
|
}
|
|
|
|
function inspectString(str, opts) {
|
|
// eslint-disable-next-line no-control-regex
|
|
var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
|
|
return wrapQuotes(s, 'single', opts);
|
|
}
|
|
|
|
function lowbyte(c) {
|
|
var n = c.charCodeAt(0);
|
|
var x = {
|
|
8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r'
|
|
}[n];
|
|
if (x) { return '\\' + x; }
|
|
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
|
|
}
|
|
|
|
function markBoxed(str) {
|
|
return 'Object(' + str + ')';
|
|
}
|
|
|
|
function weakCollectionOf(type) {
|
|
return type + ' { ? }';
|
|
}
|
|
|
|
function collectionOf(type, size, entries) {
|
|
return type + ' (' + size + ') {' + entries.join(', ') + '}';
|
|
}
|
|
|
|
function arrObjKeys(obj, inspect) {
|
|
var isArr = isArray(obj);
|
|
var xs = [];
|
|
if (isArr) {
|
|
xs.length = obj.length;
|
|
for (var i = 0; i < obj.length; i++) {
|
|
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
|
|
}
|
|
}
|
|
for (var key in obj) { // eslint-disable-line no-restricted-syntax
|
|
if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
|
|
if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
|
|
if ((/[^\w$]/).test(key)) {
|
|
xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
|
|
} else {
|
|
xs.push(key + ': ' + inspect(obj[key], obj));
|
|
}
|
|
}
|
|
return xs;
|
|
}
|
|
|
|
},{"./util.inspect":47}],47:[function(require,module,exports){
|
|
module.exports = require('util').inspect;
|
|
|
|
},{"util":79}],48:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
// http://www.ecma-international.org/ecma-262/6.0/#sec-object.is
|
|
|
|
var numberIsNaN = function (value) {
|
|
return value !== value;
|
|
};
|
|
|
|
module.exports = function is(a, b) {
|
|
if (a === 0 && b === 0) {
|
|
return 1 / a === 1 / b;
|
|
}
|
|
if (a === b) {
|
|
return true;
|
|
}
|
|
if (numberIsNaN(a) && numberIsNaN(b)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
|
|
},{}],49:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var keysShim;
|
|
if (!Object.keys) {
|
|
// modified from https://github.com/es-shims/es5-shim
|
|
var has = Object.prototype.hasOwnProperty;
|
|
var toStr = Object.prototype.toString;
|
|
var isArgs = require('./isArguments'); // eslint-disable-line global-require
|
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
|
|
var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
|
|
var dontEnums = [
|
|
'toString',
|
|
'toLocaleString',
|
|
'valueOf',
|
|
'hasOwnProperty',
|
|
'isPrototypeOf',
|
|
'propertyIsEnumerable',
|
|
'constructor'
|
|
];
|
|
var equalsConstructorPrototype = function (o) {
|
|
var ctor = o.constructor;
|
|
return ctor && ctor.prototype === o;
|
|
};
|
|
var excludedKeys = {
|
|
$applicationCache: true,
|
|
$console: true,
|
|
$external: true,
|
|
$frame: true,
|
|
$frameElement: true,
|
|
$frames: true,
|
|
$innerHeight: true,
|
|
$innerWidth: true,
|
|
$onmozfullscreenchange: true,
|
|
$onmozfullscreenerror: true,
|
|
$outerHeight: true,
|
|
$outerWidth: true,
|
|
$pageXOffset: true,
|
|
$pageYOffset: true,
|
|
$parent: true,
|
|
$scrollLeft: true,
|
|
$scrollTop: true,
|
|
$scrollX: true,
|
|
$scrollY: true,
|
|
$self: true,
|
|
$webkitIndexedDB: true,
|
|
$webkitStorageInfo: true,
|
|
$window: true
|
|
};
|
|
var hasAutomationEqualityBug = (function () {
|
|
/* global window */
|
|
if (typeof window === 'undefined') { return false; }
|
|
for (var k in window) {
|
|
try {
|
|
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
|
try {
|
|
equalsConstructorPrototype(window[k]);
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
}
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}());
|
|
var equalsConstructorPrototypeIfNotBuggy = function (o) {
|
|
/* global window */
|
|
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
|
|
return equalsConstructorPrototype(o);
|
|
}
|
|
try {
|
|
return equalsConstructorPrototype(o);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
keysShim = function keys(object) {
|
|
var isObject = object !== null && typeof object === 'object';
|
|
var isFunction = toStr.call(object) === '[object Function]';
|
|
var isArguments = isArgs(object);
|
|
var isString = isObject && toStr.call(object) === '[object String]';
|
|
var theKeys = [];
|
|
|
|
if (!isObject && !isFunction && !isArguments) {
|
|
throw new TypeError('Object.keys called on a non-object');
|
|
}
|
|
|
|
var skipProto = hasProtoEnumBug && isFunction;
|
|
if (isString && object.length > 0 && !has.call(object, 0)) {
|
|
for (var i = 0; i < object.length; ++i) {
|
|
theKeys.push(String(i));
|
|
}
|
|
}
|
|
|
|
if (isArguments && object.length > 0) {
|
|
for (var j = 0; j < object.length; ++j) {
|
|
theKeys.push(String(j));
|
|
}
|
|
} else {
|
|
for (var name in object) {
|
|
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
|
|
theKeys.push(String(name));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (hasDontEnumBug) {
|
|
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
|
|
|
for (var k = 0; k < dontEnums.length; ++k) {
|
|
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
|
|
theKeys.push(dontEnums[k]);
|
|
}
|
|
}
|
|
}
|
|
return theKeys;
|
|
};
|
|
}
|
|
module.exports = keysShim;
|
|
|
|
},{"./isArguments":51}],50:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var slice = Array.prototype.slice;
|
|
var isArgs = require('./isArguments');
|
|
|
|
var origKeys = Object.keys;
|
|
var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
|
|
|
|
var originalKeys = Object.keys;
|
|
|
|
keysShim.shim = function shimObjectKeys() {
|
|
if (Object.keys) {
|
|
var keysWorksWithArguments = (function () {
|
|
// Safari 5.0 bug
|
|
var args = Object.keys(arguments);
|
|
return args && args.length === arguments.length;
|
|
}(1, 2));
|
|
if (!keysWorksWithArguments) {
|
|
Object.keys = function keys(object) { // eslint-disable-line func-name-matching
|
|
if (isArgs(object)) {
|
|
return originalKeys(slice.call(object));
|
|
}
|
|
return originalKeys(object);
|
|
};
|
|
}
|
|
} else {
|
|
Object.keys = keysShim;
|
|
}
|
|
return Object.keys || keysShim;
|
|
};
|
|
|
|
module.exports = keysShim;
|
|
|
|
},{"./implementation":49,"./isArguments":51}],51:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var toStr = Object.prototype.toString;
|
|
|
|
module.exports = function isArguments(value) {
|
|
var str = toStr.call(value);
|
|
var isArgs = str === '[object Arguments]';
|
|
if (!isArgs) {
|
|
isArgs = str !== '[object Array]' &&
|
|
value !== null &&
|
|
typeof value === 'object' &&
|
|
typeof value.length === 'number' &&
|
|
value.length >= 0 &&
|
|
toStr.call(value.callee) === '[object Function]';
|
|
}
|
|
return isArgs;
|
|
};
|
|
|
|
},{}],52:[function(require,module,exports){
|
|
(function (process){
|
|
// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
|
|
// backported and transplited with Babel, with backwards-compat fixes
|
|
|
|
// 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.
|
|
|
|
// resolves . and .. elements in a path array with directory names there
|
|
// must be no slashes, empty elements, or device names (c:\) in the array
|
|
// (so also no leading and trailing slashes - it does not distinguish
|
|
// relative and absolute paths)
|
|
function normalizeArray(parts, allowAboveRoot) {
|
|
// if the path tries to go above the root, `up` ends up > 0
|
|
var up = 0;
|
|
for (var i = parts.length - 1; i >= 0; i--) {
|
|
var last = parts[i];
|
|
if (last === '.') {
|
|
parts.splice(i, 1);
|
|
} else if (last === '..') {
|
|
parts.splice(i, 1);
|
|
up++;
|
|
} else if (up) {
|
|
parts.splice(i, 1);
|
|
up--;
|
|
}
|
|
}
|
|
|
|
// if the path is allowed to go above the root, restore leading ..s
|
|
if (allowAboveRoot) {
|
|
for (; up--; up) {
|
|
parts.unshift('..');
|
|
}
|
|
}
|
|
|
|
return parts;
|
|
}
|
|
|
|
// path.resolve([from ...], to)
|
|
// posix version
|
|
exports.resolve = function() {
|
|
var resolvedPath = '',
|
|
resolvedAbsolute = false;
|
|
|
|
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
var path = (i >= 0) ? arguments[i] : process.cwd();
|
|
|
|
// Skip empty and invalid entries
|
|
if (typeof path !== 'string') {
|
|
throw new TypeError('Arguments to path.resolve must be strings');
|
|
} else if (!path) {
|
|
continue;
|
|
}
|
|
|
|
resolvedPath = path + '/' + resolvedPath;
|
|
resolvedAbsolute = path.charAt(0) === '/';
|
|
}
|
|
|
|
// At this point the path should be resolved to a full absolute path, but
|
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
|
|
// Normalize the path
|
|
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
|
return !!p;
|
|
}), !resolvedAbsolute).join('/');
|
|
|
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
|
};
|
|
|
|
// path.normalize(path)
|
|
// posix version
|
|
exports.normalize = function(path) {
|
|
var isAbsolute = exports.isAbsolute(path),
|
|
trailingSlash = substr(path, -1) === '/';
|
|
|
|
// Normalize the path
|
|
path = normalizeArray(filter(path.split('/'), function(p) {
|
|
return !!p;
|
|
}), !isAbsolute).join('/');
|
|
|
|
if (!path && !isAbsolute) {
|
|
path = '.';
|
|
}
|
|
if (path && trailingSlash) {
|
|
path += '/';
|
|
}
|
|
|
|
return (isAbsolute ? '/' : '') + path;
|
|
};
|
|
|
|
// posix version
|
|
exports.isAbsolute = function(path) {
|
|
return path.charAt(0) === '/';
|
|
};
|
|
|
|
// posix version
|
|
exports.join = function() {
|
|
var paths = Array.prototype.slice.call(arguments, 0);
|
|
return exports.normalize(filter(paths, function(p, index) {
|
|
if (typeof p !== 'string') {
|
|
throw new TypeError('Arguments to path.join must be strings');
|
|
}
|
|
return p;
|
|
}).join('/'));
|
|
};
|
|
|
|
|
|
// path.relative(from, to)
|
|
// posix version
|
|
exports.relative = function(from, to) {
|
|
from = exports.resolve(from).substr(1);
|
|
to = exports.resolve(to).substr(1);
|
|
|
|
function trim(arr) {
|
|
var start = 0;
|
|
for (; start < arr.length; start++) {
|
|
if (arr[start] !== '') break;
|
|
}
|
|
|
|
var end = arr.length - 1;
|
|
for (; end >= 0; end--) {
|
|
if (arr[end] !== '') break;
|
|
}
|
|
|
|
if (start > end) return [];
|
|
return arr.slice(start, end - start + 1);
|
|
}
|
|
|
|
var fromParts = trim(from.split('/'));
|
|
var toParts = trim(to.split('/'));
|
|
|
|
var length = Math.min(fromParts.length, toParts.length);
|
|
var samePartsLength = length;
|
|
for (var i = 0; i < length; i++) {
|
|
if (fromParts[i] !== toParts[i]) {
|
|
samePartsLength = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
var outputParts = [];
|
|
for (var i = samePartsLength; i < fromParts.length; i++) {
|
|
outputParts.push('..');
|
|
}
|
|
|
|
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
|
|
return outputParts.join('/');
|
|
};
|
|
|
|
exports.sep = '/';
|
|
exports.delimiter = ':';
|
|
|
|
exports.dirname = function (path) {
|
|
if (typeof path !== 'string') path = path + '';
|
|
if (path.length === 0) return '.';
|
|
var code = path.charCodeAt(0);
|
|
var hasRoot = code === 47 /*/*/;
|
|
var end = -1;
|
|
var matchedSlash = true;
|
|
for (var i = path.length - 1; i >= 1; --i) {
|
|
code = path.charCodeAt(i);
|
|
if (code === 47 /*/*/) {
|
|
if (!matchedSlash) {
|
|
end = i;
|
|
break;
|
|
}
|
|
} else {
|
|
// We saw the first non-path separator
|
|
matchedSlash = false;
|
|
}
|
|
}
|
|
|
|
if (end === -1) return hasRoot ? '/' : '.';
|
|
if (hasRoot && end === 1) {
|
|
// return '//';
|
|
// Backwards-compat fix:
|
|
return '/';
|
|
}
|
|
return path.slice(0, end);
|
|
};
|
|
|
|
function basename(path) {
|
|
if (typeof path !== 'string') path = path + '';
|
|
|
|
var start = 0;
|
|
var end = -1;
|
|
var matchedSlash = true;
|
|
var i;
|
|
|
|
for (i = path.length - 1; i >= 0; --i) {
|
|
if (path.charCodeAt(i) === 47 /*/*/) {
|
|
// If we reached a path separator that was not part of a set of path
|
|
// separators at the end of the string, stop now
|
|
if (!matchedSlash) {
|
|
start = i + 1;
|
|
break;
|
|
}
|
|
} else if (end === -1) {
|
|
// We saw the first non-path separator, mark this as the end of our
|
|
// path component
|
|
matchedSlash = false;
|
|
end = i + 1;
|
|
}
|
|
}
|
|
|
|
if (end === -1) return '';
|
|
return path.slice(start, end);
|
|
}
|
|
|
|
// Uses a mixed approach for backwards-compatibility, as ext behavior changed
|
|
// in new Node.js versions, so only basename() above is backported here
|
|
exports.basename = function (path, ext) {
|
|
var f = basename(path);
|
|
if (ext && f.substr(-1 * ext.length) === ext) {
|
|
f = f.substr(0, f.length - ext.length);
|
|
}
|
|
return f;
|
|
};
|
|
|
|
exports.extname = function (path) {
|
|
if (typeof path !== 'string') path = path + '';
|
|
var startDot = -1;
|
|
var startPart = 0;
|
|
var end = -1;
|
|
var matchedSlash = true;
|
|
// Track the state of characters (if any) we see before our first dot and
|
|
// after any path separator we find
|
|
var preDotState = 0;
|
|
for (var i = path.length - 1; i >= 0; --i) {
|
|
var code = path.charCodeAt(i);
|
|
if (code === 47 /*/*/) {
|
|
// If we reached a path separator that was not part of a set of path
|
|
// separators at the end of the string, stop now
|
|
if (!matchedSlash) {
|
|
startPart = i + 1;
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
if (end === -1) {
|
|
// We saw the first non-path separator, mark this as the end of our
|
|
// extension
|
|
matchedSlash = false;
|
|
end = i + 1;
|
|
}
|
|
if (code === 46 /*.*/) {
|
|
// If this is our first dot, mark it as the start of our extension
|
|
if (startDot === -1)
|
|
startDot = i;
|
|
else if (preDotState !== 1)
|
|
preDotState = 1;
|
|
} else if (startDot !== -1) {
|
|
// We saw a non-dot and non-path separator before our dot, so we should
|
|
// have a good chance at having a non-empty extension
|
|
preDotState = -1;
|
|
}
|
|
}
|
|
|
|
if (startDot === -1 || end === -1 ||
|
|
// We saw a non-dot character immediately before the dot
|
|
preDotState === 0 ||
|
|
// The (right-most) trimmed path component is exactly '..'
|
|
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
return '';
|
|
}
|
|
return path.slice(startDot, end);
|
|
};
|
|
|
|
function filter (xs, f) {
|
|
if (xs.filter) return xs.filter(f);
|
|
var res = [];
|
|
for (var i = 0; i < xs.length; i++) {
|
|
if (f(xs[i], i, xs)) res.push(xs[i]);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// String.prototype.substr - negative index don't work in IE8
|
|
var substr = 'ab'.substr(-1) === 'b'
|
|
? function (str, start, len) { return str.substr(start, len) }
|
|
: function (str, start, len) {
|
|
if (start < 0) start = str.length + start;
|
|
return str.substr(start, len);
|
|
}
|
|
;
|
|
|
|
}).call(this,require("g5I+bs"))
|
|
},{"g5I+bs":53}],53:[function(require,module,exports){
|
|
// shim for using process in browser
|
|
|
|
var process = module.exports = {};
|
|
|
|
process.nextTick = (function () {
|
|
var canSetImmediate = typeof window !== 'undefined'
|
|
&& window.setImmediate;
|
|
var canPost = typeof window !== 'undefined'
|
|
&& window.postMessage && window.addEventListener
|
|
;
|
|
|
|
if (canSetImmediate) {
|
|
return function (f) { return window.setImmediate(f) };
|
|
}
|
|
|
|
if (canPost) {
|
|
var queue = [];
|
|
window.addEventListener('message', function (ev) {
|
|
var source = ev.source;
|
|
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
ev.stopPropagation();
|
|
if (queue.length > 0) {
|
|
var fn = queue.shift();
|
|
fn();
|
|
}
|
|
}
|
|
}, true);
|
|
|
|
return function nextTick(fn) {
|
|
queue.push(fn);
|
|
window.postMessage('process-tick', '*');
|
|
};
|
|
}
|
|
|
|
return function nextTick(fn) {
|
|
setTimeout(fn, 0);
|
|
};
|
|
})();
|
|
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
|
|
function noop() {}
|
|
|
|
process.on = noop;
|
|
process.addListener = noop;
|
|
process.once = noop;
|
|
process.off = noop;
|
|
process.removeListener = noop;
|
|
process.removeAllListeners = noop;
|
|
process.emit = noop;
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
}
|
|
|
|
// TODO(shtylman)
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
|
|
},{}],54:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var $Object = Object;
|
|
var $TypeError = TypeError;
|
|
|
|
module.exports = function flags() {
|
|
if (this != null && this !== $Object(this)) {
|
|
throw new $TypeError('RegExp.prototype.flags getter called on non-object');
|
|
}
|
|
var result = '';
|
|
if (this.global) {
|
|
result += 'g';
|
|
}
|
|
if (this.ignoreCase) {
|
|
result += 'i';
|
|
}
|
|
if (this.multiline) {
|
|
result += 'm';
|
|
}
|
|
if (this.dotAll) {
|
|
result += 's';
|
|
}
|
|
if (this.unicode) {
|
|
result += 'u';
|
|
}
|
|
if (this.sticky) {
|
|
result += 'y';
|
|
}
|
|
return result;
|
|
};
|
|
|
|
},{}],55:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var define = require('define-properties');
|
|
var callBind = require('es-abstract/helpers/callBind');
|
|
|
|
var implementation = require('./implementation');
|
|
var getPolyfill = require('./polyfill');
|
|
var shim = require('./shim');
|
|
|
|
var flagsBound = callBind(implementation);
|
|
|
|
define(flagsBound, {
|
|
getPolyfill: getPolyfill,
|
|
implementation: implementation,
|
|
shim: shim
|
|
});
|
|
|
|
module.exports = flagsBound;
|
|
|
|
},{"./implementation":54,"./polyfill":56,"./shim":57,"define-properties":7,"es-abstract/helpers/callBind":21}],56:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var implementation = require('./implementation');
|
|
|
|
var supportsDescriptors = require('define-properties').supportsDescriptors;
|
|
var $gOPD = Object.getOwnPropertyDescriptor;
|
|
var $TypeError = TypeError;
|
|
|
|
module.exports = function getPolyfill() {
|
|
if (!supportsDescriptors) {
|
|
throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
|
}
|
|
if ((/a/mig).flags === 'gim') {
|
|
var descriptor = $gOPD(RegExp.prototype, 'flags');
|
|
if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') {
|
|
return descriptor.get;
|
|
}
|
|
}
|
|
return implementation;
|
|
};
|
|
|
|
},{"./implementation":54,"define-properties":7}],57:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var supportsDescriptors = require('define-properties').supportsDescriptors;
|
|
var getPolyfill = require('./polyfill');
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
var defineProperty = Object.defineProperty;
|
|
var TypeErr = TypeError;
|
|
var getProto = Object.getPrototypeOf;
|
|
var regex = /a/;
|
|
|
|
module.exports = function shimFlags() {
|
|
if (!supportsDescriptors || !getProto) {
|
|
throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
|
}
|
|
var polyfill = getPolyfill();
|
|
var proto = getProto(regex);
|
|
var descriptor = gOPD(proto, 'flags');
|
|
if (!descriptor || descriptor.get !== polyfill) {
|
|
defineProperty(proto, 'flags', {
|
|
configurable: true,
|
|
enumerable: false,
|
|
get: polyfill
|
|
});
|
|
}
|
|
return polyfill;
|
|
};
|
|
|
|
},{"./polyfill":56,"define-properties":7}],58:[function(require,module,exports){
|
|
(function (process){
|
|
var through = require('through');
|
|
var nextTick = typeof setImmediate !== 'undefined'
|
|
? setImmediate
|
|
: process.nextTick
|
|
;
|
|
|
|
module.exports = function (write, end) {
|
|
var tr = through(write, end);
|
|
tr.pause();
|
|
var resume = tr.resume;
|
|
var pause = tr.pause;
|
|
var paused = false;
|
|
|
|
tr.pause = function () {
|
|
paused = true;
|
|
return pause.apply(this, arguments);
|
|
};
|
|
|
|
tr.resume = function () {
|
|
paused = false;
|
|
return resume.apply(this, arguments);
|
|
};
|
|
|
|
nextTick(function () {
|
|
if (!paused) tr.resume();
|
|
});
|
|
|
|
return tr;
|
|
};
|
|
|
|
}).call(this,require("g5I+bs"))
|
|
},{"g5I+bs":53,"through":76}],59:[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.
|
|
|
|
module.exports = Duplex;
|
|
var inherits = require('inherits');
|
|
var setImmediate = require('process/browser.js').nextTick;
|
|
var Readable = require('./readable.js');
|
|
var Writable = require('./writable.js');
|
|
|
|
inherits(Duplex, Readable);
|
|
|
|
Duplex.prototype.write = Writable.prototype.write;
|
|
Duplex.prototype.end = Writable.prototype.end;
|
|
Duplex.prototype._write = Writable.prototype._write;
|
|
|
|
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);
|
|
}
|
|
|
|
// 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.
|
|
var self = this;
|
|
setImmediate(function () {
|
|
self.end();
|
|
});
|
|
}
|
|
|
|
},{"./readable.js":63,"./writable.js":65,"inherits":40,"process/browser.js":61}],60:[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.js');
|
|
Stream.Writable = require('./writable.js');
|
|
Stream.Duplex = require('./duplex.js');
|
|
Stream.Transform = require('./transform.js');
|
|
Stream.PassThrough = require('./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;
|
|
};
|
|
|
|
},{"./duplex.js":59,"./passthrough.js":62,"./readable.js":63,"./transform.js":64,"./writable.js":65,"events":31,"inherits":40}],61:[function(require,module,exports){
|
|
// shim for using process in browser
|
|
|
|
var process = module.exports = {};
|
|
|
|
process.nextTick = (function () {
|
|
var canSetImmediate = typeof window !== 'undefined'
|
|
&& window.setImmediate;
|
|
var canPost = typeof window !== 'undefined'
|
|
&& window.postMessage && window.addEventListener
|
|
;
|
|
|
|
if (canSetImmediate) {
|
|
return function (f) { return window.setImmediate(f) };
|
|
}
|
|
|
|
if (canPost) {
|
|
var queue = [];
|
|
window.addEventListener('message', function (ev) {
|
|
var source = ev.source;
|
|
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
ev.stopPropagation();
|
|
if (queue.length > 0) {
|
|
var fn = queue.shift();
|
|
fn();
|
|
}
|
|
}
|
|
}, true);
|
|
|
|
return function nextTick(fn) {
|
|
queue.push(fn);
|
|
window.postMessage('process-tick', '*');
|
|
};
|
|
}
|
|
|
|
return function nextTick(fn) {
|
|
setTimeout(fn, 0);
|
|
};
|
|
})();
|
|
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
}
|
|
|
|
// TODO(shtylman)
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
|
|
},{}],62:[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.
|
|
|
|
module.exports = PassThrough;
|
|
|
|
var Transform = require('./transform.js');
|
|
var inherits = require('inherits');
|
|
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);
|
|
};
|
|
|
|
},{"./transform.js":64,"inherits":40}],63:[function(require,module,exports){
|
|
(function (process){
|
|
// 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 = Readable;
|
|
Readable.ReadableState = ReadableState;
|
|
|
|
var EE = require('events').EventEmitter;
|
|
var Stream = require('./index.js');
|
|
var Buffer = require('buffer').Buffer;
|
|
var setImmediate = require('process/browser.js').nextTick;
|
|
var StringDecoder;
|
|
|
|
var inherits = require('inherits');
|
|
inherits(Readable, Stream);
|
|
|
|
function ReadableState(options, stream) {
|
|
options = options || {};
|
|
|
|
// the point at which it stops calling _read() to fill the buffer
|
|
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
var hwm = options.highWaterMark;
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
|
|
|
// cast to ints.
|
|
this.highWaterMark = ~~this.highWaterMark;
|
|
|
|
this.buffer = [];
|
|
this.length = 0;
|
|
this.pipes = null;
|
|
this.pipesCount = 0;
|
|
this.flowing = false;
|
|
this.ended = false;
|
|
this.endEmitted = false;
|
|
this.reading = false;
|
|
|
|
// In streams that never have any data, and do push(null) right away,
|
|
// the consumer can miss the 'end' event if they do some I/O before
|
|
// consuming the stream. So, we don't emit('end') until some reading
|
|
// happens.
|
|
this.calledRead = false;
|
|
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
// or on a later tick. We set this to true at first, becuase any
|
|
// actions that shouldn't happen until "later" should generally also
|
|
// not happen before the first write 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;
|
|
|
|
|
|
// 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;
|
|
|
|
// 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';
|
|
|
|
// when piping, we only care about 'readable' events that happen
|
|
// after read()ing all the bytes and not getting any pushback.
|
|
this.ranOut = false;
|
|
|
|
// 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) {
|
|
if (!(this instanceof Readable))
|
|
return new Readable(options);
|
|
|
|
this._readableState = new ReadableState(options, this);
|
|
|
|
// legacy
|
|
this.readable = true;
|
|
|
|
Stream.call(this);
|
|
}
|
|
|
|
// 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;
|
|
|
|
if (typeof chunk === 'string' && !state.objectMode) {
|
|
encoding = encoding || state.defaultEncoding;
|
|
if (encoding !== state.encoding) {
|
|
chunk = new Buffer(chunk, encoding);
|
|
encoding = '';
|
|
}
|
|
}
|
|
|
|
return readableAddChunk(this, state, chunk, encoding, false);
|
|
};
|
|
|
|
// Unshift should *always* be something directly out of read()
|
|
Readable.prototype.unshift = function(chunk) {
|
|
var state = this._readableState;
|
|
return readableAddChunk(this, state, chunk, '', true);
|
|
};
|
|
|
|
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
|
var er = chunkInvalid(state, chunk);
|
|
if (er) {
|
|
stream.emit('error', er);
|
|
} else if (chunk === null || chunk === undefined) {
|
|
state.reading = false;
|
|
if (!state.ended)
|
|
onEofChunk(stream, state);
|
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
if (state.ended && !addToFront) {
|
|
var e = new Error('stream.push() after EOF');
|
|
stream.emit('error', e);
|
|
} else if (state.endEmitted && addToFront) {
|
|
var e = new Error('stream.unshift() after end event');
|
|
stream.emit('error', e);
|
|
} else {
|
|
if (state.decoder && !addToFront && !encoding)
|
|
chunk = state.decoder.write(chunk);
|
|
|
|
// update the buffer info.
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
if (addToFront) {
|
|
state.buffer.unshift(chunk);
|
|
} else {
|
|
state.reading = false;
|
|
state.buffer.push(chunk);
|
|
}
|
|
|
|
if (state.needReadable)
|
|
emitReadable(stream);
|
|
|
|
maybeReadMore(stream, state);
|
|
}
|
|
} else if (!addToFront) {
|
|
state.reading = false;
|
|
}
|
|
|
|
return needMoreData(state);
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
}
|
|
|
|
// backwards compatibility.
|
|
Readable.prototype.setEncoding = function(enc) {
|
|
if (!StringDecoder)
|
|
StringDecoder = require('string_decoder').StringDecoder;
|
|
this._readableState.decoder = new StringDecoder(enc);
|
|
this._readableState.encoding = enc;
|
|
};
|
|
|
|
// Don't raise the hwm > 128MB
|
|
var MAX_HWM = 0x800000;
|
|
function roundUpToNextPowerOf2(n) {
|
|
if (n >= MAX_HWM) {
|
|
n = MAX_HWM;
|
|
} else {
|
|
// Get the next highest power of 2
|
|
n--;
|
|
for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
|
n++;
|
|
}
|
|
return n;
|
|
}
|
|
|
|
function howMuchToRead(n, state) {
|
|
if (state.length === 0 && state.ended)
|
|
return 0;
|
|
|
|
if (state.objectMode)
|
|
return n === 0 ? 0 : 1;
|
|
|
|
if (isNaN(n) || n === null) {
|
|
// only flow one buffer at a time
|
|
if (state.flowing && state.buffer.length)
|
|
return state.buffer[0].length;
|
|
else
|
|
return state.length;
|
|
}
|
|
|
|
if (n <= 0)
|
|
return 0;
|
|
|
|
// If we're asking for more than the target buffer level,
|
|
// then raise the water mark. Bump up to the next highest
|
|
// power of 2, to prevent increasing it excessively in tiny
|
|
// amounts.
|
|
if (n > state.highWaterMark)
|
|
state.highWaterMark = roundUpToNextPowerOf2(n);
|
|
|
|
// don't have that much. return null, unless we've ended.
|
|
if (n > state.length) {
|
|
if (!state.ended) {
|
|
state.needReadable = true;
|
|
return 0;
|
|
} else
|
|
return state.length;
|
|
}
|
|
|
|
return n;
|
|
}
|
|
|
|
// you can override either this method, or the async _read(n) below.
|
|
Readable.prototype.read = function(n) {
|
|
var state = this._readableState;
|
|
state.calledRead = true;
|
|
var nOrig = n;
|
|
|
|
if (typeof n !== 'number' || 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)) {
|
|
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;
|
|
|
|
// if we currently have less than the highWaterMark, then also read some
|
|
if (state.length - n <= state.highWaterMark)
|
|
doRead = true;
|
|
|
|
// 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;
|
|
|
|
if (doRead) {
|
|
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 called its callback synchronously, then `reading`
|
|
// will be false, and we need to re-evaluate how much data we
|
|
// can return to the user.
|
|
if (doRead && !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;
|
|
}
|
|
|
|
state.length -= n;
|
|
|
|
// If we have nothing in the buffer, then we want to know
|
|
// as soon as we *do* get something into the buffer.
|
|
if (state.length === 0 && !state.ended)
|
|
state.needReadable = true;
|
|
|
|
// If we happened to read() exactly the remaining amount in the
|
|
// buffer, and the EOF has been seen at this point, then make sure
|
|
// that we emit 'end' on the very next tick.
|
|
if (state.ended && !state.endEmitted && state.length === 0)
|
|
endReadable(this);
|
|
|
|
return ret;
|
|
};
|
|
|
|
function chunkInvalid(state, chunk) {
|
|
var er = null;
|
|
if (!Buffer.isBuffer(chunk) &&
|
|
'string' !== typeof chunk &&
|
|
chunk !== null &&
|
|
chunk !== undefined &&
|
|
!state.objectMode &&
|
|
!er) {
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
}
|
|
return er;
|
|
}
|
|
|
|
|
|
function onEofChunk(stream, state) {
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length) {
|
|
state.buffer.push(chunk);
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
}
|
|
}
|
|
state.ended = true;
|
|
|
|
// if we've ended and we have some data left, then emit
|
|
// 'readable' now to make sure it gets picked up.
|
|
if (state.length > 0)
|
|
emitReadable(stream);
|
|
else
|
|
endReadable(stream);
|
|
}
|
|
|
|
// 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)
|
|
return;
|
|
|
|
state.emittedReadable = true;
|
|
if (state.sync)
|
|
setImmediate(function() {
|
|
emitReadable_(stream);
|
|
});
|
|
else
|
|
emitReadable_(stream);
|
|
}
|
|
|
|
function emitReadable_(stream) {
|
|
stream.emit('readable');
|
|
}
|
|
|
|
|
|
// 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;
|
|
setImmediate(function() {
|
|
maybeReadMore_(stream, state);
|
|
});
|
|
}
|
|
}
|
|
|
|
function maybeReadMore_(stream, state) {
|
|
var len = state.length;
|
|
while (!state.reading && !state.flowing && !state.ended &&
|
|
state.length < state.highWaterMark) {
|
|
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('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;
|
|
|
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
|
dest !== process.stdout &&
|
|
dest !== process.stderr;
|
|
|
|
var endFn = doEnd ? onend : cleanup;
|
|
if (state.endEmitted)
|
|
setImmediate(endFn);
|
|
else
|
|
src.once('end', endFn);
|
|
|
|
dest.on('unpipe', onunpipe);
|
|
function onunpipe(readable) {
|
|
if (readable !== src) return;
|
|
cleanup();
|
|
}
|
|
|
|
function 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);
|
|
|
|
function 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', cleanup);
|
|
|
|
// if the reader is waiting for a drain event from this
|
|
// specific writer, then it would cause it to never start
|
|
// flowing again.
|
|
// So, if this is awaiting a drain, then we just call it now.
|
|
// If we don't know, then assume that we are waiting for one.
|
|
if (!dest._writableState || dest._writableState.needDrain)
|
|
ondrain();
|
|
}
|
|
|
|
// if the dest has an error, then stop piping into it.
|
|
// however, don't suppress the throwing behavior for this.
|
|
// check for listeners before emit removes one-time listeners.
|
|
var errListeners = EE.listenerCount(dest, 'error');
|
|
function onerror(er) {
|
|
unpipe();
|
|
if (errListeners === 0 && EE.listenerCount(dest, 'error') === 0)
|
|
dest.emit('error', er);
|
|
}
|
|
dest.once('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() {
|
|
dest.removeListener('close', onclose);
|
|
unpipe();
|
|
}
|
|
dest.once('finish', onfinish);
|
|
|
|
function 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) {
|
|
// the handler that waits for readable events after all
|
|
// the data gets sucked out in flow.
|
|
// This would be easier to follow with a .once() handler
|
|
// in flow(), but that is too slow.
|
|
this.on('readable', pipeOnReadable);
|
|
|
|
state.flowing = true;
|
|
setImmediate(function() {
|
|
flow(src);
|
|
});
|
|
}
|
|
|
|
return dest;
|
|
};
|
|
|
|
function pipeOnDrain(src) {
|
|
return function() {
|
|
var dest = this;
|
|
var state = src._readableState;
|
|
state.awaitDrain--;
|
|
if (state.awaitDrain === 0)
|
|
flow(src);
|
|
};
|
|
}
|
|
|
|
function flow(src) {
|
|
var state = src._readableState;
|
|
var chunk;
|
|
state.awaitDrain = 0;
|
|
|
|
function write(dest, i, list) {
|
|
var written = dest.write(chunk);
|
|
if (false === written) {
|
|
state.awaitDrain++;
|
|
}
|
|
}
|
|
|
|
while (state.pipesCount && null !== (chunk = src.read())) {
|
|
|
|
if (state.pipesCount === 1)
|
|
write(state.pipes, 0, null);
|
|
else
|
|
forEach(state.pipes, write);
|
|
|
|
src.emit('data', chunk);
|
|
|
|
// if anyone needs a drain, then we have to wait for that.
|
|
if (state.awaitDrain > 0)
|
|
return;
|
|
}
|
|
|
|
// if every destination was unpiped, either before entering this
|
|
// function, or in the while loop, then stop flowing.
|
|
//
|
|
// NB: This is a pretty rare edge case.
|
|
if (state.pipesCount === 0) {
|
|
state.flowing = false;
|
|
|
|
// if there were data event listeners added, then switch to old mode.
|
|
if (EE.listenerCount(src, 'data') > 0)
|
|
emitDataEvents(src);
|
|
return;
|
|
}
|
|
|
|
// at this point, no one needed a drain, so we just ran out of data
|
|
// on the next readable event, start it over again.
|
|
state.ranOut = true;
|
|
}
|
|
|
|
function pipeOnReadable() {
|
|
if (this._readableState.ranOut) {
|
|
this._readableState.ranOut = false;
|
|
flow(this);
|
|
}
|
|
}
|
|
|
|
|
|
Readable.prototype.unpipe = function(dest) {
|
|
var state = this._readableState;
|
|
|
|
// 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;
|
|
this.removeListener('readable', pipeOnReadable);
|
|
state.flowing = false;
|
|
if (dest)
|
|
dest.emit('unpipe', this);
|
|
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;
|
|
this.removeListener('readable', pipeOnReadable);
|
|
state.flowing = false;
|
|
|
|
for (var i = 0; i < len; i++)
|
|
dests[i].emit('unpipe', this);
|
|
return this;
|
|
}
|
|
|
|
// try to find the right one.
|
|
var i = indexOf(state.pipes, dest);
|
|
if (i === -1)
|
|
return this;
|
|
|
|
state.pipes.splice(i, 1);
|
|
state.pipesCount -= 1;
|
|
if (state.pipesCount === 1)
|
|
state.pipes = state.pipes[0];
|
|
|
|
dest.emit('unpipe', this);
|
|
|
|
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' && !this._readableState.flowing)
|
|
emitDataEvents(this);
|
|
|
|
if (ev === 'readable' && this.readable) {
|
|
var state = this._readableState;
|
|
if (!state.readableListening) {
|
|
state.readableListening = true;
|
|
state.emittedReadable = false;
|
|
state.needReadable = true;
|
|
if (!state.reading) {
|
|
this.read(0);
|
|
} else if (state.length) {
|
|
emitReadable(this, state);
|
|
}
|
|
}
|
|
}
|
|
|
|
return res;
|
|
};
|
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
|
|
// pause() and resume() are remnants of the legacy readable stream API
|
|
// If the user uses them, then switch into old mode.
|
|
Readable.prototype.resume = function() {
|
|
emitDataEvents(this);
|
|
this.read(0);
|
|
this.emit('resume');
|
|
};
|
|
|
|
Readable.prototype.pause = function() {
|
|
emitDataEvents(this, true);
|
|
this.emit('pause');
|
|
};
|
|
|
|
function emitDataEvents(stream, startPaused) {
|
|
var state = stream._readableState;
|
|
|
|
if (state.flowing) {
|
|
// https://github.com/isaacs/readable-stream/issues/16
|
|
throw new Error('Cannot switch to old mode now.');
|
|
}
|
|
|
|
var paused = startPaused || false;
|
|
var readable = false;
|
|
|
|
// convert to an old-style stream.
|
|
stream.readable = true;
|
|
stream.pipe = Stream.prototype.pipe;
|
|
stream.on = stream.addListener = Stream.prototype.on;
|
|
|
|
stream.on('readable', function() {
|
|
readable = true;
|
|
|
|
var c;
|
|
while (!paused && (null !== (c = stream.read())))
|
|
stream.emit('data', c);
|
|
|
|
if (c === null) {
|
|
readable = false;
|
|
stream._readableState.needReadable = true;
|
|
}
|
|
});
|
|
|
|
stream.pause = function() {
|
|
paused = true;
|
|
this.emit('pause');
|
|
};
|
|
|
|
stream.resume = function() {
|
|
paused = false;
|
|
if (readable)
|
|
setImmediate(function() {
|
|
stream.emit('readable');
|
|
});
|
|
else
|
|
this.read(0);
|
|
this.emit('resume');
|
|
};
|
|
|
|
// now make it start, just in case it hadn't already.
|
|
stream.emit('readable');
|
|
}
|
|
|
|
// wrap an old-style stream as the async data source.
|
|
// This is *not* part of the readable stream interface.
|
|
// It is an ugly unfortunate mess of history.
|
|
Readable.prototype.wrap = function(stream) {
|
|
var state = this._readableState;
|
|
var paused = false;
|
|
|
|
var self = this;
|
|
stream.on('end', function() {
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length)
|
|
self.push(chunk);
|
|
}
|
|
|
|
self.push(null);
|
|
});
|
|
|
|
stream.on('data', function(chunk) {
|
|
if (state.decoder)
|
|
chunk = state.decoder.write(chunk);
|
|
if (!chunk || !state.objectMode && !chunk.length)
|
|
return;
|
|
|
|
var ret = self.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 (typeof stream[i] === 'function' &&
|
|
typeof this[i] === 'undefined') {
|
|
this[i] = function(method) { return function() {
|
|
return stream[method].apply(stream, arguments);
|
|
}}(i);
|
|
}
|
|
}
|
|
|
|
// proxy certain important events.
|
|
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
forEach(events, function(ev) {
|
|
stream.on(ev, function (x) {
|
|
return self.emit.apply(self, ev, x);
|
|
});
|
|
});
|
|
|
|
// when we try to consume some more bytes, simply unpause the
|
|
// underlying stream.
|
|
self._read = function(n) {
|
|
if (paused) {
|
|
paused = false;
|
|
stream.resume();
|
|
}
|
|
};
|
|
|
|
return self;
|
|
};
|
|
|
|
|
|
|
|
// 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.
|
|
function fromList(n, state) {
|
|
var list = state.buffer;
|
|
var length = state.length;
|
|
var stringMode = !!state.decoder;
|
|
var objectMode = !!state.objectMode;
|
|
var ret;
|
|
|
|
// nothing in the list, definitely empty.
|
|
if (list.length === 0)
|
|
return null;
|
|
|
|
if (length === 0)
|
|
ret = null;
|
|
else if (objectMode)
|
|
ret = list.shift();
|
|
else if (!n || n >= length) {
|
|
// read it all, truncate the array.
|
|
if (stringMode)
|
|
ret = list.join('');
|
|
else
|
|
ret = Buffer.concat(list, length);
|
|
list.length = 0;
|
|
} else {
|
|
// read just some of it.
|
|
if (n < list[0].length) {
|
|
// just take a part of the first list item.
|
|
// slice is the same for buffers and strings.
|
|
var buf = list[0];
|
|
ret = buf.slice(0, n);
|
|
list[0] = buf.slice(n);
|
|
} else if (n === list[0].length) {
|
|
// first list is a perfect match
|
|
ret = list.shift();
|
|
} else {
|
|
// complex case.
|
|
// we have enough to cover it, but it spans past the first buffer.
|
|
if (stringMode)
|
|
ret = '';
|
|
else
|
|
ret = new Buffer(n);
|
|
|
|
var c = 0;
|
|
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
|
var buf = list[0];
|
|
var cpy = Math.min(n - c, buf.length);
|
|
|
|
if (stringMode)
|
|
ret += buf.slice(0, cpy);
|
|
else
|
|
buf.copy(ret, c, 0, cpy);
|
|
|
|
if (cpy < buf.length)
|
|
list[0] = buf.slice(cpy);
|
|
else
|
|
list.shift();
|
|
|
|
c += cpy;
|
|
}
|
|
}
|
|
}
|
|
|
|
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.calledRead) {
|
|
state.ended = true;
|
|
setImmediate(function() {
|
|
// 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 forEach (xs, f) {
|
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
f(xs[i], i);
|
|
}
|
|
}
|
|
|
|
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("g5I+bs"))
|
|
},{"./index.js":60,"buffer":5,"events":31,"g5I+bs":53,"inherits":40,"process/browser.js":61,"string_decoder":70}],64:[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.
|
|
|
|
module.exports = Transform;
|
|
|
|
var Duplex = require('./duplex.js');
|
|
var inherits = require('inherits');
|
|
inherits(Transform, Duplex);
|
|
|
|
|
|
function TransformState(options, stream) {
|
|
this.afterTransform = function(er, data) {
|
|
return afterTransform(stream, er, data);
|
|
};
|
|
|
|
this.needTransform = false;
|
|
this.transforming = false;
|
|
this.writecb = null;
|
|
this.writechunk = null;
|
|
}
|
|
|
|
function afterTransform(stream, er, data) {
|
|
var ts = stream._transformState;
|
|
ts.transforming = false;
|
|
|
|
var cb = ts.writecb;
|
|
|
|
if (!cb)
|
|
return stream.emit('error', new Error('no writecb in Transform class'));
|
|
|
|
ts.writechunk = null;
|
|
ts.writecb = null;
|
|
|
|
if (data !== null && data !== undefined)
|
|
stream.push(data);
|
|
|
|
if (cb)
|
|
cb(er);
|
|
|
|
var rs = stream._readableState;
|
|
rs.reading = false;
|
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
stream._read(rs.highWaterMark);
|
|
}
|
|
}
|
|
|
|
|
|
function Transform(options) {
|
|
if (!(this instanceof Transform))
|
|
return new Transform(options);
|
|
|
|
Duplex.call(this, options);
|
|
|
|
var ts = this._transformState = new TransformState(options, this);
|
|
|
|
// when the writable side finishes, then flush out anything remaining.
|
|
var stream = this;
|
|
|
|
// 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;
|
|
|
|
this.once('finish', function() {
|
|
if ('function' === typeof this._flush)
|
|
this._flush(function(er) {
|
|
done(stream, er);
|
|
});
|
|
else
|
|
done(stream);
|
|
});
|
|
}
|
|
|
|
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('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 && 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;
|
|
}
|
|
};
|
|
|
|
|
|
function done(stream, er) {
|
|
if (er)
|
|
return stream.emit('error', er);
|
|
|
|
// if there's nothing in the write buffer, then that means
|
|
// that nothing more will ever be provided
|
|
var ws = stream._writableState;
|
|
var rs = stream._readableState;
|
|
var ts = stream._transformState;
|
|
|
|
if (ws.length)
|
|
throw new Error('calling transform done when ws.length != 0');
|
|
|
|
if (ts.transforming)
|
|
throw new Error('calling transform done when still transforming');
|
|
|
|
return stream.push(null);
|
|
}
|
|
|
|
},{"./duplex.js":59,"inherits":40}],65:[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 bit simpler than readable streams.
|
|
// Implement an async ._write(chunk, cb), and it'll handle all
|
|
// the drain event emission and buffering.
|
|
|
|
module.exports = Writable;
|
|
Writable.WritableState = WritableState;
|
|
|
|
var isUint8Array = typeof Uint8Array !== 'undefined'
|
|
? function (x) { return x instanceof Uint8Array }
|
|
: function (x) {
|
|
return x && x.constructor && x.constructor.name === 'Uint8Array'
|
|
}
|
|
;
|
|
var isArrayBuffer = typeof ArrayBuffer !== 'undefined'
|
|
? function (x) { return x instanceof ArrayBuffer }
|
|
: function (x) {
|
|
return x && x.constructor && x.constructor.name === 'ArrayBuffer'
|
|
}
|
|
;
|
|
|
|
var inherits = require('inherits');
|
|
var Stream = require('./index.js');
|
|
var setImmediate = require('process/browser.js').nextTick;
|
|
var Buffer = require('buffer').Buffer;
|
|
|
|
inherits(Writable, Stream);
|
|
|
|
function WriteReq(chunk, encoding, cb) {
|
|
this.chunk = chunk;
|
|
this.encoding = encoding;
|
|
this.callback = cb;
|
|
}
|
|
|
|
function WritableState(options, stream) {
|
|
options = options || {};
|
|
|
|
// the point at which write() starts returning false
|
|
// Note: 0 is a valid value, means that we always return false if
|
|
// the entire buffer is not flushed immediately on write()
|
|
var hwm = options.highWaterMark;
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
|
|
|
// object stream flag to indicate whether or not this stream
|
|
// contains buffers or objects.
|
|
this.objectMode = !!options.objectMode;
|
|
|
|
// cast to ints.
|
|
this.highWaterMark = ~~this.highWaterMark;
|
|
|
|
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;
|
|
|
|
// 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;
|
|
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
// or on a later tick. We set this to true at first, becuase any
|
|
// 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.buffer = [];
|
|
}
|
|
|
|
function Writable(options) {
|
|
// Writable ctor is applied to Duplexes, though they're not
|
|
// instanceof Writable, they're instanceof Readable.
|
|
if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
|
|
return new Writable(options);
|
|
|
|
this._writableState = new WritableState(options, this);
|
|
|
|
// legacy.
|
|
this.writable = true;
|
|
|
|
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, state, cb) {
|
|
var er = new Error('write after end');
|
|
// TODO: defer error events consistently everywhere, not just the cb
|
|
stream.emit('error', er);
|
|
setImmediate(function() {
|
|
cb(er);
|
|
});
|
|
}
|
|
|
|
// If we get something that is not a buffer, string, null, or undefined,
|
|
// and we're not in objectMode, then that's an error.
|
|
// Otherwise stream chunks are all considered to be of length=1, and the
|
|
// watermarks determine how many objects to keep in the buffer, rather than
|
|
// how many bytes or characters.
|
|
function validChunk(stream, state, chunk, cb) {
|
|
var valid = true;
|
|
if (!Buffer.isBuffer(chunk) &&
|
|
'string' !== typeof chunk &&
|
|
chunk !== null &&
|
|
chunk !== undefined &&
|
|
!state.objectMode) {
|
|
var er = new TypeError('Invalid non-string/buffer chunk');
|
|
stream.emit('error', er);
|
|
setImmediate(function() {
|
|
cb(er);
|
|
});
|
|
valid = false;
|
|
}
|
|
return valid;
|
|
}
|
|
|
|
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
var state = this._writableState;
|
|
var ret = false;
|
|
|
|
if (typeof encoding === 'function') {
|
|
cb = encoding;
|
|
encoding = null;
|
|
}
|
|
|
|
if (!Buffer.isBuffer(chunk) && isUint8Array(chunk))
|
|
chunk = new Buffer(chunk);
|
|
if (isArrayBuffer(chunk) && typeof Uint8Array !== 'undefined')
|
|
chunk = new Buffer(new Uint8Array(chunk));
|
|
|
|
if (Buffer.isBuffer(chunk))
|
|
encoding = 'buffer';
|
|
else if (!encoding)
|
|
encoding = state.defaultEncoding;
|
|
|
|
if (typeof cb !== 'function')
|
|
cb = function() {};
|
|
|
|
if (state.ended)
|
|
writeAfterEnd(this, state, cb);
|
|
else if (validChunk(this, state, chunk, cb))
|
|
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
|
|
|
return ret;
|
|
};
|
|
|
|
function decodeChunk(state, chunk, encoding) {
|
|
if (!state.objectMode &&
|
|
state.decodeStrings !== false &&
|
|
typeof chunk === 'string') {
|
|
chunk = new Buffer(chunk, encoding);
|
|
}
|
|
return chunk;
|
|
}
|
|
|
|
// 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, chunk, encoding, cb) {
|
|
chunk = decodeChunk(state, chunk, encoding);
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
state.length += len;
|
|
|
|
var ret = state.length < state.highWaterMark;
|
|
state.needDrain = !ret;
|
|
|
|
if (state.writing)
|
|
state.buffer.push(new WriteReq(chunk, encoding, cb));
|
|
else
|
|
doWrite(stream, state, len, chunk, encoding, cb);
|
|
|
|
return ret;
|
|
}
|
|
|
|
function doWrite(stream, state, len, chunk, encoding, cb) {
|
|
state.writelen = len;
|
|
state.writecb = cb;
|
|
state.writing = true;
|
|
state.sync = true;
|
|
stream._write(chunk, encoding, state.onwrite);
|
|
state.sync = false;
|
|
}
|
|
|
|
function onwriteError(stream, state, sync, er, cb) {
|
|
if (sync)
|
|
setImmediate(function() {
|
|
cb(er);
|
|
});
|
|
else
|
|
cb(er);
|
|
|
|
stream.emit('error', er);
|
|
}
|
|
|
|
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(stream, state);
|
|
|
|
if (!finished && !state.bufferProcessing && state.buffer.length)
|
|
clearBuffer(stream, state);
|
|
|
|
if (sync) {
|
|
setImmediate(function() {
|
|
afterWrite(stream, state, finished, cb);
|
|
});
|
|
} else {
|
|
afterWrite(stream, state, finished, cb);
|
|
}
|
|
}
|
|
}
|
|
|
|
function afterWrite(stream, state, finished, cb) {
|
|
if (!finished)
|
|
onwriteDrain(stream, state);
|
|
cb();
|
|
if (finished)
|
|
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;
|
|
|
|
for (var c = 0; c < state.buffer.length; c++) {
|
|
var entry = state.buffer[c];
|
|
var chunk = entry.chunk;
|
|
var encoding = entry.encoding;
|
|
var cb = entry.callback;
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
doWrite(stream, state, len, chunk, encoding, cb);
|
|
|
|
// if we didn't call the onwrite immediately, then
|
|
// it means that we need to wait until it does.
|
|
// also, that means that the chunk and cb are currently
|
|
// being processed, so move the buffer counter past them.
|
|
if (state.writing) {
|
|
c++;
|
|
break;
|
|
}
|
|
}
|
|
|
|
state.bufferProcessing = false;
|
|
if (c < state.buffer.length)
|
|
state.buffer = state.buffer.slice(c);
|
|
else
|
|
state.buffer.length = 0;
|
|
}
|
|
|
|
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
cb(new Error('not implemented'));
|
|
};
|
|
|
|
Writable.prototype.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 (typeof chunk !== 'undefined' && chunk !== null)
|
|
this.write(chunk, encoding);
|
|
|
|
// ignore unnecessary end() calls.
|
|
if (!state.ending && !state.finished)
|
|
endWritable(this, state, cb);
|
|
};
|
|
|
|
|
|
function needFinish(stream, state) {
|
|
return (state.ending &&
|
|
state.length === 0 &&
|
|
!state.finished &&
|
|
!state.writing);
|
|
}
|
|
|
|
function finishMaybe(stream, state) {
|
|
var need = needFinish(stream, state);
|
|
if (need) {
|
|
state.finished = true;
|
|
stream.emit('finish');
|
|
}
|
|
return need;
|
|
}
|
|
|
|
function endWritable(stream, state, cb) {
|
|
state.ending = true;
|
|
finishMaybe(stream, state);
|
|
if (cb) {
|
|
if (state.finished)
|
|
setImmediate(cb);
|
|
else
|
|
stream.once('finish', cb);
|
|
}
|
|
state.ended = true;
|
|
}
|
|
|
|
},{"./index.js":60,"buffer":5,"inherits":40,"process/browser.js":61}],66:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var CheckObjectCoercible = require('es-abstract/5/CheckObjectCoercible');
|
|
var ToString = require('es-abstract/2019/ToString');
|
|
var callBound = require('es-abstract/helpers/callBound');
|
|
var $replace = callBound('String.prototype.replace');
|
|
|
|
/* eslint-disable no-control-regex */
|
|
var leftWhitespace = /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/;
|
|
var rightWhitespace = /[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;
|
|
/* eslint-enable no-control-regex */
|
|
|
|
module.exports = function trim() {
|
|
var S = ToString(CheckObjectCoercible(this));
|
|
return $replace($replace(S, leftWhitespace, ''), rightWhitespace, '');
|
|
};
|
|
|
|
},{"es-abstract/2019/ToString":16,"es-abstract/5/CheckObjectCoercible":17,"es-abstract/helpers/callBound":22}],67:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var callBind = require('es-abstract/helpers/callBind');
|
|
var define = require('define-properties');
|
|
|
|
var implementation = require('./implementation');
|
|
var getPolyfill = require('./polyfill');
|
|
var shim = require('./shim');
|
|
|
|
var boundTrim = callBind(getPolyfill());
|
|
|
|
define(boundTrim, {
|
|
getPolyfill: getPolyfill,
|
|
implementation: implementation,
|
|
shim: shim
|
|
});
|
|
|
|
module.exports = boundTrim;
|
|
|
|
},{"./implementation":66,"./polyfill":68,"./shim":69,"define-properties":7,"es-abstract/helpers/callBind":21}],68:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var implementation = require('./implementation');
|
|
|
|
var zeroWidthSpace = '\u200b';
|
|
|
|
module.exports = function getPolyfill() {
|
|
if (String.prototype.trim && zeroWidthSpace.trim() === zeroWidthSpace) {
|
|
return String.prototype.trim;
|
|
}
|
|
return implementation;
|
|
};
|
|
|
|
},{"./implementation":66}],69:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var define = require('define-properties');
|
|
var getPolyfill = require('./polyfill');
|
|
|
|
module.exports = function shimStringTrim() {
|
|
var polyfill = getPolyfill();
|
|
define(String.prototype, { trim: polyfill }, {
|
|
trim: function testTrim() {
|
|
return String.prototype.trim !== polyfill;
|
|
}
|
|
});
|
|
return polyfill;
|
|
};
|
|
|
|
},{"./polyfill":68,"define-properties":7}],70:[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 Buffer = require('buffer').Buffer;
|
|
|
|
function assertEncoding(encoding) {
|
|
if (encoding && !Buffer.isEncoding(encoding)) {
|
|
throw new Error('Unknown encoding: ' + encoding);
|
|
}
|
|
}
|
|
|
|
var StringDecoder = exports.StringDecoder = function(encoding) {
|
|
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
|
assertEncoding(encoding);
|
|
switch (this.encoding) {
|
|
case 'utf8':
|
|
// CESU-8 represents each of Surrogate Pair by 3-bytes
|
|
this.surrogateSize = 3;
|
|
break;
|
|
case 'ucs2':
|
|
case 'utf16le':
|
|
// UTF-16 represents each of Surrogate Pair by 2-bytes
|
|
this.surrogateSize = 2;
|
|
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
|
break;
|
|
case 'base64':
|
|
// Base-64 stores 3 bytes in 4 chars, and pads the remainder.
|
|
this.surrogateSize = 3;
|
|
this.detectIncompleteChar = base64DetectIncompleteChar;
|
|
break;
|
|
default:
|
|
this.write = passThroughWrite;
|
|
return;
|
|
}
|
|
|
|
this.charBuffer = new Buffer(6);
|
|
this.charReceived = 0;
|
|
this.charLength = 0;
|
|
};
|
|
|
|
|
|
StringDecoder.prototype.write = function(buffer) {
|
|
var charStr = '';
|
|
var offset = 0;
|
|
|
|
// if our last write ended with an incomplete multibyte character
|
|
while (this.charLength) {
|
|
// determine how many remaining bytes this buffer has to offer for this char
|
|
var i = (buffer.length >= this.charLength - this.charReceived) ?
|
|
this.charLength - this.charReceived :
|
|
buffer.length;
|
|
|
|
// add the new bytes to the char buffer
|
|
buffer.copy(this.charBuffer, this.charReceived, offset, i);
|
|
this.charReceived += (i - offset);
|
|
offset = i;
|
|
|
|
if (this.charReceived < this.charLength) {
|
|
// still not enough chars in this buffer? wait for more ...
|
|
return '';
|
|
}
|
|
|
|
// get the character that was split
|
|
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
|
|
|
// lead surrogate (D800-DBFF) is also the incomplete character
|
|
var charCode = charStr.charCodeAt(charStr.length - 1);
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
this.charLength += this.surrogateSize;
|
|
charStr = '';
|
|
continue;
|
|
}
|
|
this.charReceived = this.charLength = 0;
|
|
|
|
// if there are no more bytes in this buffer, just emit our char
|
|
if (i == buffer.length) return charStr;
|
|
|
|
// otherwise cut off the characters end from the beginning of this buffer
|
|
buffer = buffer.slice(i, buffer.length);
|
|
break;
|
|
}
|
|
|
|
var lenIncomplete = this.detectIncompleteChar(buffer);
|
|
|
|
var end = buffer.length;
|
|
if (this.charLength) {
|
|
// buffer the incomplete character bytes we got
|
|
buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);
|
|
this.charReceived = lenIncomplete;
|
|
end -= lenIncomplete;
|
|
}
|
|
|
|
charStr += buffer.toString(this.encoding, 0, end);
|
|
|
|
var end = charStr.length - 1;
|
|
var charCode = charStr.charCodeAt(end);
|
|
// lead surrogate (D800-DBFF) is also the incomplete character
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
var size = this.surrogateSize;
|
|
this.charLength += size;
|
|
this.charReceived += size;
|
|
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
|
this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);
|
|
return charStr.substring(0, end);
|
|
}
|
|
|
|
// or just emit the charStr
|
|
return charStr;
|
|
};
|
|
|
|
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
|
// determine how many bytes we have to check at the end of this buffer
|
|
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
|
|
|
// Figure out if one of the last i bytes of our buffer announces an
|
|
// incomplete char.
|
|
for (; i > 0; i--) {
|
|
var c = buffer[buffer.length - i];
|
|
|
|
// See http://en.wikipedia.org/wiki/UTF-8#Description
|
|
|
|
// 110XXXXX
|
|
if (i == 1 && c >> 5 == 0x06) {
|
|
this.charLength = 2;
|
|
break;
|
|
}
|
|
|
|
// 1110XXXX
|
|
if (i <= 2 && c >> 4 == 0x0E) {
|
|
this.charLength = 3;
|
|
break;
|
|
}
|
|
|
|
// 11110XXX
|
|
if (i <= 3 && c >> 3 == 0x1E) {
|
|
this.charLength = 4;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return i;
|
|
};
|
|
|
|
StringDecoder.prototype.end = function(buffer) {
|
|
var res = '';
|
|
if (buffer && buffer.length)
|
|
res = this.write(buffer);
|
|
|
|
if (this.charReceived) {
|
|
var cr = this.charReceived;
|
|
var buf = this.charBuffer;
|
|
var enc = this.encoding;
|
|
res += buf.slice(0, cr).toString(enc);
|
|
}
|
|
|
|
return res;
|
|
};
|
|
|
|
function passThroughWrite(buffer) {
|
|
return buffer.toString(this.encoding);
|
|
}
|
|
|
|
function utf16DetectIncompleteChar(buffer) {
|
|
var incomplete = this.charReceived = buffer.length % 2;
|
|
this.charLength = incomplete ? 2 : 0;
|
|
return incomplete;
|
|
}
|
|
|
|
function base64DetectIncompleteChar(buffer) {
|
|
var incomplete = this.charReceived = buffer.length % 3;
|
|
this.charLength = incomplete ? 3 : 0;
|
|
return incomplete;
|
|
}
|
|
|
|
},{"buffer":5}],71:[function(require,module,exports){
|
|
(function (process){
|
|
var defined = require('defined');
|
|
var createDefaultStream = require('./lib/default_stream');
|
|
var Test = require('./lib/test');
|
|
var createResult = require('./lib/results');
|
|
var through = require('through');
|
|
|
|
var canEmitExit = typeof process !== 'undefined' && process
|
|
&& typeof process.on === 'function' && process.browser !== true
|
|
;
|
|
var canExit = typeof process !== 'undefined' && process
|
|
&& typeof process.exit === 'function'
|
|
;
|
|
|
|
var nextTick = typeof setImmediate !== 'undefined'
|
|
? setImmediate
|
|
: process.nextTick
|
|
;
|
|
|
|
exports = module.exports = (function () {
|
|
var harness;
|
|
var lazyLoad = function () {
|
|
return getHarness().apply(this, arguments);
|
|
};
|
|
|
|
lazyLoad.only = function () {
|
|
return getHarness().only.apply(this, arguments);
|
|
};
|
|
|
|
lazyLoad.createStream = function (opts) {
|
|
if (!opts) opts = {};
|
|
if (!harness) {
|
|
var output = through();
|
|
getHarness({ stream: output, objectMode: opts.objectMode });
|
|
return output;
|
|
}
|
|
return harness.createStream(opts);
|
|
};
|
|
|
|
lazyLoad.onFinish = function () {
|
|
return getHarness().onFinish.apply(this, arguments);
|
|
};
|
|
|
|
lazyLoad.onFailure = function () {
|
|
return getHarness().onFailure.apply(this, arguments);
|
|
};
|
|
|
|
lazyLoad.getHarness = getHarness;
|
|
|
|
return lazyLoad;
|
|
|
|
function getHarness(opts) {
|
|
if (!opts) opts = {};
|
|
opts.autoclose = !canEmitExit;
|
|
if (!harness) harness = createExitHarness(opts);
|
|
return harness;
|
|
}
|
|
})();
|
|
|
|
function createExitHarness(conf) {
|
|
if (!conf) conf = {};
|
|
var harness = createHarness({
|
|
autoclose: defined(conf.autoclose, false)
|
|
});
|
|
|
|
var stream = harness.createStream({ objectMode: conf.objectMode });
|
|
var es = stream.pipe(conf.stream || createDefaultStream());
|
|
if (canEmitExit) {
|
|
es.on('error', function (err) { harness._exitCode = 1; });
|
|
}
|
|
|
|
var ended = false;
|
|
stream.on('end', function () { ended = true; });
|
|
|
|
if (conf.exit === false) return harness;
|
|
if (!canEmitExit || !canExit) return harness;
|
|
|
|
process.on('exit', function (code) {
|
|
// let the process exit cleanly.
|
|
if (code !== 0) {
|
|
return;
|
|
}
|
|
|
|
if (!ended) {
|
|
var only = harness._results._only;
|
|
for (var i = 0; i < harness._tests.length; i++) {
|
|
var t = harness._tests[i];
|
|
if (only && t !== only) continue;
|
|
t._exit();
|
|
}
|
|
}
|
|
harness.close();
|
|
process.exit(code || harness._exitCode);
|
|
});
|
|
|
|
return harness;
|
|
}
|
|
|
|
exports.createHarness = createHarness;
|
|
exports.Test = Test;
|
|
exports.test = exports; // tap compat
|
|
exports.test.skip = Test.skip;
|
|
|
|
var exitInterval;
|
|
|
|
function createHarness(conf_) {
|
|
if (!conf_) conf_ = {};
|
|
var results = createResult();
|
|
if (conf_.autoclose !== false) {
|
|
results.once('done', function () { results.close(); });
|
|
}
|
|
|
|
var test = function (name, conf, cb) {
|
|
var t = new Test(name, conf, cb);
|
|
test._tests.push(t);
|
|
|
|
(function inspectCode(st) {
|
|
st.on('test', function sub(st_) {
|
|
inspectCode(st_);
|
|
});
|
|
st.on('result', function (r) {
|
|
if (!r.todo && !r.ok && typeof r !== 'string') test._exitCode = 1;
|
|
});
|
|
})(t);
|
|
|
|
results.push(t);
|
|
return t;
|
|
};
|
|
test._results = results;
|
|
|
|
test._tests = [];
|
|
|
|
test.createStream = function (opts) {
|
|
return results.createStream(opts);
|
|
};
|
|
|
|
test.onFinish = function (cb) {
|
|
results.on('done', cb);
|
|
};
|
|
|
|
test.onFailure = function (cb) {
|
|
results.on('fail', cb);
|
|
};
|
|
|
|
var only = false;
|
|
test.only = function () {
|
|
if (only) throw new Error('there can only be one only test');
|
|
only = true;
|
|
var t = test.apply(null, arguments);
|
|
results.only(t);
|
|
return t;
|
|
};
|
|
test._exitCode = 0;
|
|
|
|
test.close = function () { results.close(); };
|
|
|
|
return test;
|
|
}
|
|
|
|
}).call(this,require("g5I+bs"))
|
|
},{"./lib/default_stream":72,"./lib/results":73,"./lib/test":74,"defined":8,"g5I+bs":53,"through":76}],72:[function(require,module,exports){
|
|
(function (process){
|
|
var through = require('through');
|
|
var fs = require('fs');
|
|
|
|
module.exports = function () {
|
|
var line = '';
|
|
var stream = through(write, flush);
|
|
return stream;
|
|
|
|
function write(buf) {
|
|
for (var i = 0; i < buf.length; i++) {
|
|
var c = typeof buf === 'string'
|
|
? buf.charAt(i)
|
|
: String.fromCharCode(buf[i])
|
|
;
|
|
if (c === '\n') flush();
|
|
else line += c;
|
|
}
|
|
}
|
|
|
|
function flush() {
|
|
if (fs.writeSync && /^win/.test(process.platform)) {
|
|
try { fs.writeSync(1, line + '\n'); }
|
|
catch (e) { stream.emit('error', e); }
|
|
} else {
|
|
try { console.log(line); }
|
|
catch (e) { stream.emit('error', e); }
|
|
}
|
|
line = '';
|
|
}
|
|
};
|
|
|
|
}).call(this,require("g5I+bs"))
|
|
},{"fs":4,"g5I+bs":53,"through":76}],73:[function(require,module,exports){
|
|
(function (process){
|
|
var defined = require('defined');
|
|
var EventEmitter = require('events').EventEmitter;
|
|
var inherits = require('inherits');
|
|
var through = require('through');
|
|
var resumer = require('resumer');
|
|
var inspect = require('object-inspect');
|
|
var bind = require('function-bind');
|
|
var has = require('has');
|
|
var regexpTest = bind.call(Function.call, RegExp.prototype.test);
|
|
var yamlIndicators = /\:|\-|\?/;
|
|
var nextTick = typeof setImmediate !== 'undefined'
|
|
? setImmediate
|
|
: process.nextTick
|
|
;
|
|
|
|
module.exports = Results;
|
|
inherits(Results, EventEmitter);
|
|
|
|
function coalesceWhiteSpaces(str) {
|
|
return String(str).replace(/\s+/g, ' ');
|
|
}
|
|
|
|
function Results() {
|
|
if (!(this instanceof Results)) return new Results;
|
|
this.count = 0;
|
|
this.fail = 0;
|
|
this.pass = 0;
|
|
this.todo = 0;
|
|
this._stream = through();
|
|
this.tests = [];
|
|
this._only = null;
|
|
this._isRunning = false;
|
|
}
|
|
|
|
Results.prototype.createStream = function (opts) {
|
|
if (!opts) opts = {};
|
|
var self = this;
|
|
var output, testId = 0;
|
|
if (opts.objectMode) {
|
|
output = through();
|
|
self.on('_push', function ontest(t, extra) {
|
|
if (!extra) extra = {};
|
|
var id = testId++;
|
|
t.once('prerun', function () {
|
|
var row = {
|
|
type: 'test',
|
|
name: t.name,
|
|
id: id,
|
|
skip: t._skip,
|
|
todo: t._todo
|
|
};
|
|
if (has(extra, 'parent')) {
|
|
row.parent = extra.parent;
|
|
}
|
|
output.queue(row);
|
|
});
|
|
t.on('test', function (st) {
|
|
ontest(st, { parent: id });
|
|
});
|
|
t.on('result', function (res) {
|
|
res.test = id;
|
|
res.type = 'assert';
|
|
output.queue(res);
|
|
});
|
|
t.on('end', function () {
|
|
output.queue({ type: 'end', test: id });
|
|
});
|
|
});
|
|
self.on('done', function () { output.queue(null); });
|
|
} else {
|
|
output = resumer();
|
|
output.queue('TAP version 13\n');
|
|
self._stream.pipe(output);
|
|
}
|
|
|
|
if (!this._isRunning) {
|
|
this._isRunning = true;
|
|
nextTick(function next() {
|
|
var t;
|
|
while (t = getNextTest(self)) {
|
|
t.run();
|
|
if (!t.ended) return t.once('end', function () { nextTick(next); });
|
|
}
|
|
self.emit('done');
|
|
});
|
|
}
|
|
|
|
return output;
|
|
};
|
|
|
|
Results.prototype.push = function (t) {
|
|
var self = this;
|
|
self.tests.push(t);
|
|
self._watch(t);
|
|
self.emit('_push', t);
|
|
};
|
|
|
|
Results.prototype.only = function (t) {
|
|
this._only = t;
|
|
};
|
|
|
|
Results.prototype._watch = function (t) {
|
|
var self = this;
|
|
var write = function (s) { self._stream.queue(s); };
|
|
t.once('prerun', function () {
|
|
var premsg = '';
|
|
if (t._skip) premsg = 'SKIP ';
|
|
else if (t._todo) premsg = 'TODO ';
|
|
write('# ' + premsg + coalesceWhiteSpaces(t.name) + '\n');
|
|
});
|
|
|
|
t.on('result', function (res) {
|
|
if (typeof res === 'string') {
|
|
write('# ' + res + '\n');
|
|
return;
|
|
}
|
|
write(encodeResult(res, self.count + 1));
|
|
self.count ++;
|
|
|
|
if (res.ok || res.todo) self.pass ++;
|
|
else {
|
|
self.fail ++;
|
|
self.emit('fail');
|
|
}
|
|
});
|
|
|
|
t.on('test', function (st) { self._watch(st); });
|
|
};
|
|
|
|
Results.prototype.close = function () {
|
|
var self = this;
|
|
if (self.closed) self._stream.emit('error', new Error('ALREADY CLOSED'));
|
|
self.closed = true;
|
|
var write = function (s) { self._stream.queue(s); };
|
|
|
|
write('\n1..' + self.count + '\n');
|
|
write('# tests ' + self.count + '\n');
|
|
write('# pass ' + (self.pass + self.todo) + '\n');
|
|
if (self.todo) write('# todo ' + self.todo + '\n');
|
|
if (self.fail) write('# fail ' + self.fail + '\n');
|
|
else write('\n# ok\n');
|
|
|
|
self._stream.queue(null);
|
|
};
|
|
|
|
function encodeResult(res, count) {
|
|
var output = '';
|
|
output += (res.ok ? 'ok ' : 'not ok ') + count;
|
|
output += res.name ? ' ' + coalesceWhiteSpaces(res.name) : '';
|
|
|
|
if (res.skip) {
|
|
output += ' # SKIP' + ((typeof res.skip === 'string') ? ' ' + coalesceWhiteSpaces(res.skip) : '');
|
|
} else if (res.todo) {
|
|
output += ' # TODO' + ((typeof res.todo === 'string') ? ' ' + coalesceWhiteSpaces(res.todo) : '');
|
|
};
|
|
|
|
output += '\n';
|
|
if (res.ok) return output;
|
|
|
|
var outer = ' ';
|
|
var inner = outer + ' ';
|
|
output += outer + '---\n';
|
|
output += inner + 'operator: ' + res.operator + '\n';
|
|
|
|
if (has(res, 'expected') || has(res, 'actual')) {
|
|
var ex = inspect(res.expected, {depth: res.objectPrintDepth});
|
|
var ac = inspect(res.actual, {depth: res.objectPrintDepth});
|
|
|
|
if (Math.max(ex.length, ac.length) > 65 || invalidYaml(ex) || invalidYaml(ac)) {
|
|
output += inner + 'expected: |-\n' + inner + ' ' + ex + '\n';
|
|
output += inner + 'actual: |-\n' + inner + ' ' + ac + '\n';
|
|
} else {
|
|
output += inner + 'expected: ' + ex + '\n';
|
|
output += inner + 'actual: ' + ac + '\n';
|
|
}
|
|
}
|
|
if (res.at) {
|
|
output += inner + 'at: ' + res.at + '\n';
|
|
}
|
|
|
|
var actualStack = res.actual && (typeof res.actual === 'object' || typeof res.actual === 'function') ? res.actual.stack : undefined;
|
|
var errorStack = res.error && res.error.stack;
|
|
var stack = defined(actualStack, errorStack);
|
|
if (stack) {
|
|
var lines = String(stack).split('\n');
|
|
output += inner + 'stack: |-\n';
|
|
for (var i = 0; i < lines.length; i++) {
|
|
output += inner + ' ' + lines[i] + '\n';
|
|
}
|
|
}
|
|
|
|
output += outer + '...\n';
|
|
return output;
|
|
}
|
|
|
|
function getNextTest(results) {
|
|
if (!results._only) {
|
|
return results.tests.shift();
|
|
}
|
|
|
|
do {
|
|
var t = results.tests.shift();
|
|
if (!t) continue;
|
|
if (results._only === t) {
|
|
return t;
|
|
}
|
|
} while (results.tests.length !== 0);
|
|
}
|
|
|
|
function invalidYaml(str) {
|
|
return regexpTest(yamlIndicators, str);
|
|
}
|
|
|
|
}).call(this,require("g5I+bs"))
|
|
},{"defined":8,"events":31,"function-bind":34,"g5I+bs":53,"has":38,"inherits":40,"object-inspect":46,"resumer":58,"through":76}],74:[function(require,module,exports){
|
|
(function (process,__dirname){
|
|
var deepEqual = require('deep-equal');
|
|
var defined = require('defined');
|
|
var path = require('path');
|
|
var inherits = require('inherits');
|
|
var EventEmitter = require('events').EventEmitter;
|
|
var has = require('has');
|
|
var isRegExp = require('is-regex');
|
|
var trim = require('string.prototype.trim');
|
|
var bind = require('function-bind');
|
|
var forEach = require('for-each');
|
|
var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
|
|
var toLowerCase = bind.call(Function.call, String.prototype.toLowerCase);
|
|
|
|
module.exports = Test;
|
|
|
|
var nextTick = typeof setImmediate !== 'undefined'
|
|
? setImmediate
|
|
: process.nextTick;
|
|
var safeSetTimeout = setTimeout;
|
|
var safeClearTimeout = clearTimeout;
|
|
|
|
inherits(Test, EventEmitter);
|
|
|
|
var getTestArgs = function (name_, opts_, cb_) {
|
|
var name = '(anonymous)';
|
|
var opts = {};
|
|
var cb;
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
var arg = arguments[i];
|
|
var t = typeof arg;
|
|
if (t === 'string') {
|
|
name = arg;
|
|
} else if (t === 'object') {
|
|
opts = arg || opts;
|
|
} else if (t === 'function') {
|
|
cb = arg;
|
|
}
|
|
}
|
|
return { name: name, opts: opts, cb: cb };
|
|
};
|
|
|
|
function Test(name_, opts_, cb_) {
|
|
if (! (this instanceof Test)) {
|
|
return new Test(name_, opts_, cb_);
|
|
}
|
|
|
|
var args = getTestArgs(name_, opts_, cb_);
|
|
|
|
this.readable = true;
|
|
this.name = args.name || '(anonymous)';
|
|
this.assertCount = 0;
|
|
this.pendingCount = 0;
|
|
this._skip = args.opts.skip || false;
|
|
this._todo = args.opts.todo || false;
|
|
this._timeout = args.opts.timeout;
|
|
this._plan = undefined;
|
|
this._cb = args.cb;
|
|
this._progeny = [];
|
|
this._ok = true;
|
|
var depthEnvVar = process.env.NODE_TAPE_OBJECT_PRINT_DEPTH;
|
|
if (args.opts.objectPrintDepth) {
|
|
this._objectPrintDepth = args.opts.objectPrintDepth;
|
|
} else if (depthEnvVar) {
|
|
if (toLowerCase(depthEnvVar) === 'infinity') {
|
|
this._objectPrintDepth = Infinity;
|
|
} else {
|
|
this._objectPrintDepth = depthEnvVar;
|
|
}
|
|
} else {
|
|
this._objectPrintDepth = 5;
|
|
}
|
|
|
|
for (var prop in this) {
|
|
this[prop] = (function bind(self, val) {
|
|
if (typeof val === 'function') {
|
|
return function bound() {
|
|
return val.apply(self, arguments);
|
|
};
|
|
}
|
|
return val;
|
|
})(this, this[prop]);
|
|
}
|
|
}
|
|
|
|
Test.prototype.run = function () {
|
|
this.emit('prerun');
|
|
if (!this._cb || this._skip) {
|
|
return this._end();
|
|
}
|
|
if (this._timeout != null) {
|
|
this.timeoutAfter(this._timeout);
|
|
}
|
|
this._cb(this);
|
|
this.emit('run');
|
|
};
|
|
|
|
Test.prototype.test = function (name, opts, cb) {
|
|
var self = this;
|
|
var t = new Test(name, opts, cb);
|
|
this._progeny.push(t);
|
|
this.pendingCount++;
|
|
this.emit('test', t);
|
|
t.on('prerun', function () {
|
|
self.assertCount++;
|
|
});
|
|
|
|
if (!self._pendingAsserts()) {
|
|
nextTick(function () {
|
|
self._end();
|
|
});
|
|
}
|
|
|
|
nextTick(function () {
|
|
if (!self._plan && self.pendingCount == self._progeny.length) {
|
|
self._end();
|
|
}
|
|
});
|
|
};
|
|
|
|
Test.prototype.comment = function (msg) {
|
|
var that = this;
|
|
forEach(trim(msg).split('\n'), function (aMsg) {
|
|
that.emit('result', trim(aMsg).replace(/^#\s*/, ''));
|
|
});
|
|
};
|
|
|
|
Test.prototype.plan = function (n) {
|
|
this._plan = n;
|
|
this.emit('plan', n);
|
|
};
|
|
|
|
Test.prototype.timeoutAfter = function (ms) {
|
|
if (!ms) throw new Error('timeoutAfter requires a timespan');
|
|
var self = this;
|
|
var timeout = safeSetTimeout(function () {
|
|
self.fail('test timed out after ' + ms + 'ms');
|
|
self.end();
|
|
}, ms);
|
|
this.once('end', function () {
|
|
safeClearTimeout(timeout);
|
|
});
|
|
};
|
|
|
|
Test.prototype.end = function (err) {
|
|
var self = this;
|
|
if (arguments.length >= 1 && !!err) {
|
|
this.ifError(err);
|
|
}
|
|
|
|
if (this.calledEnd) {
|
|
this.fail('.end() called twice');
|
|
}
|
|
this.calledEnd = true;
|
|
this._end();
|
|
};
|
|
|
|
Test.prototype._end = function (err) {
|
|
var self = this;
|
|
if (this._progeny.length) {
|
|
var t = this._progeny.shift();
|
|
t.on('end', function () { self._end(); });
|
|
t.run();
|
|
return;
|
|
}
|
|
|
|
if (!this.ended) this.emit('end');
|
|
var pendingAsserts = this._pendingAsserts();
|
|
if (!this._planError && this._plan !== undefined && pendingAsserts) {
|
|
this._planError = true;
|
|
this.fail('plan != count', {
|
|
expected : this._plan,
|
|
actual : this.assertCount
|
|
});
|
|
}
|
|
this.ended = true;
|
|
};
|
|
|
|
Test.prototype._exit = function () {
|
|
if (this._plan !== undefined &&
|
|
!this._planError && this.assertCount !== this._plan) {
|
|
this._planError = true;
|
|
this.fail('plan != count', {
|
|
expected : this._plan,
|
|
actual : this.assertCount,
|
|
exiting : true
|
|
});
|
|
} else if (!this.ended) {
|
|
this.fail('test exited without ending', {
|
|
exiting: true
|
|
});
|
|
}
|
|
};
|
|
|
|
Test.prototype._pendingAsserts = function () {
|
|
if (this._plan === undefined) {
|
|
return 1;
|
|
}
|
|
return this._plan - (this._progeny.length + this.assertCount);
|
|
};
|
|
|
|
Test.prototype._assert = function assert(ok, opts) {
|
|
var self = this;
|
|
var extra = opts.extra || {};
|
|
|
|
ok = !!ok || !!extra.skip;
|
|
|
|
var res = {
|
|
id: self.assertCount++,
|
|
ok: ok,
|
|
skip: defined(extra.skip, opts.skip),
|
|
todo: defined(extra.todo, opts.todo, self._todo),
|
|
name: defined(extra.message, opts.message, '(unnamed assert)'),
|
|
operator: defined(extra.operator, opts.operator),
|
|
objectPrintDepth: self._objectPrintDepth
|
|
};
|
|
if (has(opts, 'actual') || has(extra, 'actual')) {
|
|
res.actual = defined(extra.actual, opts.actual);
|
|
}
|
|
if (has(opts, 'expected') || has(extra, 'expected')) {
|
|
res.expected = defined(extra.expected, opts.expected);
|
|
}
|
|
this._ok = !!(this._ok && ok);
|
|
|
|
if (!ok && !res.todo) {
|
|
res.error = defined(extra.error, opts.error, new Error(res.name));
|
|
}
|
|
|
|
if (!ok) {
|
|
var e = new Error('exception');
|
|
var err = (e.stack || '').split('\n');
|
|
var dir = __dirname + path.sep;
|
|
|
|
for (var i = 0; i < err.length; i++) {
|
|
/*
|
|
Stack trace lines may resemble one of the following. We need
|
|
to should correctly extract a function name (if any) and
|
|
path / line no. for each line.
|
|
|
|
at myFunction (/path/to/file.js:123:45)
|
|
at myFunction (/path/to/file.other-ext:123:45)
|
|
at myFunction (/path to/file.js:123:45)
|
|
at myFunction (C:\path\to\file.js:123:45)
|
|
at myFunction (/path/to/file.js:123)
|
|
at Test.<anonymous> (/path/to/file.js:123:45)
|
|
at Test.bound [as run] (/path/to/file.js:123:45)
|
|
at /path/to/file.js:123:45
|
|
|
|
Regex has three parts. First is non-capturing group for 'at '
|
|
(plus anything preceding it).
|
|
|
|
/^(?:[^\s]*\s*\bat\s+)/
|
|
|
|
Second captures function call description (optional). This is
|
|
not necessarily a valid JS function name, but just what the
|
|
stack trace is using to represent a function call. It may look
|
|
like `<anonymous>` or 'Test.bound [as run]'.
|
|
|
|
For our purposes, we assume that, if there is a function
|
|
name, it's everything leading up to the first open
|
|
parentheses (trimmed) before our pathname.
|
|
|
|
/(?:(.*)\s+\()?/
|
|
|
|
Last part captures file path plus line no (and optional
|
|
column no).
|
|
|
|
/((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/
|
|
*/
|
|
var re = /^(?:[^\s]*\s*\bat\s+)(?:(.*)\s+\()?((?:\/|[a-zA-Z]:\\)[^:\)]+:(\d+)(?::(\d+))?)/;
|
|
var m = re.exec(err[i]);
|
|
|
|
if (!m) {
|
|
continue;
|
|
}
|
|
|
|
var callDescription = m[1] || '<anonymous>';
|
|
var filePath = m[2];
|
|
|
|
if (filePath.slice(0, dir.length) === dir) {
|
|
continue;
|
|
}
|
|
|
|
// Function call description may not (just) be a function name.
|
|
// Try to extract function name by looking at first "word" only.
|
|
res.functionName = callDescription.split(/\s+/)[0];
|
|
res.file = filePath;
|
|
res.line = Number(m[3]);
|
|
if (m[4]) res.column = Number(m[4]);
|
|
|
|
res.at = callDescription + ' (' + filePath + ')';
|
|
break;
|
|
}
|
|
}
|
|
|
|
self.emit('result', res);
|
|
|
|
var pendingAsserts = self._pendingAsserts();
|
|
if (!pendingAsserts) {
|
|
if (extra.exiting) {
|
|
self._end();
|
|
} else {
|
|
nextTick(function () {
|
|
self._end();
|
|
});
|
|
}
|
|
}
|
|
|
|
if (!self._planError && pendingAsserts < 0) {
|
|
self._planError = true;
|
|
self.fail('plan != count', {
|
|
expected : self._plan,
|
|
actual : self._plan - pendingAsserts
|
|
});
|
|
}
|
|
};
|
|
|
|
Test.prototype.fail = function (msg, extra) {
|
|
this._assert(false, {
|
|
message : msg,
|
|
operator : 'fail',
|
|
extra : extra
|
|
});
|
|
};
|
|
|
|
Test.prototype.pass = function (msg, extra) {
|
|
this._assert(true, {
|
|
message : msg,
|
|
operator : 'pass',
|
|
extra : extra
|
|
});
|
|
};
|
|
|
|
Test.prototype.skip = function (msg, extra) {
|
|
this._assert(true, {
|
|
message : msg,
|
|
operator : 'skip',
|
|
skip : true,
|
|
extra : extra
|
|
});
|
|
};
|
|
|
|
function assert(value, msg, extra) {
|
|
this._assert(value, {
|
|
message : defined(msg, 'should be truthy'),
|
|
operator : 'ok',
|
|
expected : true,
|
|
actual : value,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.ok
|
|
= Test.prototype['true']
|
|
= Test.prototype.assert
|
|
= assert;
|
|
|
|
function notOK(value, msg, extra) {
|
|
this._assert(!value, {
|
|
message : defined(msg, 'should be falsy'),
|
|
operator : 'notOk',
|
|
expected : false,
|
|
actual : value,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.notOk
|
|
= Test.prototype['false']
|
|
= Test.prototype.notok
|
|
= notOK;
|
|
|
|
function error(err, msg, extra) {
|
|
this._assert(!err, {
|
|
message : defined(msg, String(err)),
|
|
operator : 'error',
|
|
actual : err,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.error
|
|
= Test.prototype.ifError
|
|
= Test.prototype.ifErr
|
|
= Test.prototype.iferror
|
|
= error;
|
|
|
|
function equal(a, b, msg, extra) {
|
|
this._assert(a === b, {
|
|
message : defined(msg, 'should be equal'),
|
|
operator : 'equal',
|
|
actual : a,
|
|
expected : b,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.equal
|
|
= Test.prototype.equals
|
|
= Test.prototype.isEqual
|
|
= Test.prototype.is
|
|
= Test.prototype.strictEqual
|
|
= Test.prototype.strictEquals
|
|
= equal;
|
|
|
|
function notEqual(a, b, msg, extra) {
|
|
this._assert(a !== b, {
|
|
message : defined(msg, 'should not be equal'),
|
|
operator : 'notEqual',
|
|
actual : a,
|
|
expected : b,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.notEqual
|
|
= Test.prototype.notEquals
|
|
= Test.prototype.notStrictEqual
|
|
= Test.prototype.notStrictEquals
|
|
= Test.prototype.isNotEqual
|
|
= Test.prototype.isNot
|
|
= Test.prototype.not
|
|
= Test.prototype.doesNotEqual
|
|
= Test.prototype.isInequal
|
|
= notEqual;
|
|
|
|
function tapeDeepEqual(a, b, msg, extra) {
|
|
this._assert(deepEqual(a, b, { strict: true }), {
|
|
message : defined(msg, 'should be equivalent'),
|
|
operator : 'deepEqual',
|
|
actual : a,
|
|
expected : b,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.deepEqual
|
|
= Test.prototype.deepEquals
|
|
= Test.prototype.isEquivalent
|
|
= Test.prototype.same
|
|
= tapeDeepEqual;
|
|
|
|
function deepLooseEqual(a, b, msg, extra) {
|
|
this._assert(deepEqual(a, b), {
|
|
message : defined(msg, 'should be equivalent'),
|
|
operator : 'deepLooseEqual',
|
|
actual : a,
|
|
expected : b,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.deepLooseEqual
|
|
= Test.prototype.looseEqual
|
|
= Test.prototype.looseEquals
|
|
= deepLooseEqual;
|
|
|
|
function notDeepEqual(a, b, msg, extra) {
|
|
this._assert(!deepEqual(a, b, { strict: true }), {
|
|
message : defined(msg, 'should not be equivalent'),
|
|
operator : 'notDeepEqual',
|
|
actual : a,
|
|
expected : b,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.notDeepEqual
|
|
= Test.prototype.notDeepEquals
|
|
= Test.prototype.notEquivalent
|
|
= Test.prototype.notDeeply
|
|
= Test.prototype.notSame
|
|
= Test.prototype.isNotDeepEqual
|
|
= Test.prototype.isNotDeeply
|
|
= Test.prototype.isNotEquivalent
|
|
= Test.prototype.isInequivalent
|
|
= notDeepEqual;
|
|
|
|
function notDeepLooseEqual(a, b, msg, extra) {
|
|
this._assert(!deepEqual(a, b), {
|
|
message : defined(msg, 'should be equivalent'),
|
|
operator : 'notDeepLooseEqual',
|
|
actual : a,
|
|
expected : b,
|
|
extra : extra
|
|
});
|
|
}
|
|
Test.prototype.notDeepLooseEqual
|
|
= Test.prototype.notLooseEqual
|
|
= Test.prototype.notLooseEquals
|
|
= notDeepLooseEqual;
|
|
|
|
Test.prototype['throws'] = function (fn, expected, msg, extra) {
|
|
if (typeof expected === 'string') {
|
|
msg = expected;
|
|
expected = undefined;
|
|
}
|
|
|
|
var caught = undefined;
|
|
|
|
try {
|
|
fn();
|
|
} catch (err) {
|
|
caught = { error : err };
|
|
if ((err != null) && (!isEnumerable(err, 'message') || !has(err, 'message'))) {
|
|
var message = err.message;
|
|
delete err.message;
|
|
err.message = message;
|
|
}
|
|
}
|
|
|
|
var passed = caught;
|
|
|
|
if (isRegExp(expected)) {
|
|
passed = expected.test(caught && caught.error);
|
|
expected = String(expected);
|
|
}
|
|
|
|
if (typeof expected === 'function' && caught) {
|
|
passed = caught.error instanceof expected;
|
|
}
|
|
|
|
this._assert(typeof fn === 'function' && passed, {
|
|
message : defined(msg, 'should throw'),
|
|
operator : 'throws',
|
|
actual : caught && caught.error,
|
|
expected : expected,
|
|
error: !passed && caught && caught.error,
|
|
extra : extra
|
|
});
|
|
};
|
|
|
|
Test.prototype.doesNotThrow = function (fn, expected, msg, extra) {
|
|
if (typeof expected === 'string') {
|
|
msg = expected;
|
|
expected = undefined;
|
|
}
|
|
var caught = undefined;
|
|
try {
|
|
fn();
|
|
}
|
|
catch (err) {
|
|
caught = { error : err };
|
|
}
|
|
this._assert(!caught, {
|
|
message : defined(msg, 'should not throw'),
|
|
operator : 'throws',
|
|
actual : caught && caught.error,
|
|
expected : expected,
|
|
error : caught && caught.error,
|
|
extra : extra
|
|
});
|
|
};
|
|
|
|
Test.skip = function (name_, _opts, _cb) {
|
|
var args = getTestArgs.apply(null, arguments);
|
|
args.opts.skip = true;
|
|
return Test(args.name, args.opts, args.cb);
|
|
};
|
|
|
|
// vim: set softtabstop=4 shiftwidth=4:
|
|
|
|
}).call(this,require("g5I+bs"),"/../node_modules/tape/lib")
|
|
},{"deep-equal":6,"defined":8,"events":31,"for-each":32,"function-bind":34,"g5I+bs":53,"has":38,"inherits":40,"is-regex":75,"path":52,"string.prototype.trim":67}],75:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var has = require('has');
|
|
var regexExec = RegExp.prototype.exec;
|
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
|
|
var tryRegexExecCall = function tryRegexExec(value) {
|
|
try {
|
|
var lastIndex = value.lastIndex;
|
|
value.lastIndex = 0; // eslint-disable-line no-param-reassign
|
|
|
|
regexExec.call(value);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
} finally {
|
|
value.lastIndex = lastIndex; // eslint-disable-line no-param-reassign
|
|
}
|
|
};
|
|
var toStr = Object.prototype.toString;
|
|
var regexClass = '[object RegExp]';
|
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
|
|
module.exports = function isRegex(value) {
|
|
if (!value || typeof value !== 'object') {
|
|
return false;
|
|
}
|
|
if (!hasToStringTag) {
|
|
return toStr.call(value) === regexClass;
|
|
}
|
|
|
|
var descriptor = gOPD(value, 'lastIndex');
|
|
var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
|
|
if (!hasLastIndexDataProperty) {
|
|
return false;
|
|
}
|
|
|
|
return tryRegexExecCall(value);
|
|
};
|
|
|
|
},{"has":38}],76:[function(require,module,exports){
|
|
(function (process){
|
|
var Stream = require('stream')
|
|
|
|
// through
|
|
//
|
|
// a stream that does nothing but re-emit the input.
|
|
// useful for aggregating a series of changing but not ending streams into one stream)
|
|
|
|
exports = module.exports = through
|
|
through.through = through
|
|
|
|
//create a readable writable stream.
|
|
|
|
function through (write, end, opts) {
|
|
write = write || function (data) { this.queue(data) }
|
|
end = end || function () { this.queue(null) }
|
|
|
|
var ended = false, destroyed = false, buffer = [], _ended = false
|
|
var stream = new Stream()
|
|
stream.readable = stream.writable = true
|
|
stream.paused = false
|
|
|
|
// stream.autoPause = !(opts && opts.autoPause === false)
|
|
stream.autoDestroy = !(opts && opts.autoDestroy === false)
|
|
|
|
stream.write = function (data) {
|
|
write.call(this, data)
|
|
return !stream.paused
|
|
}
|
|
|
|
function drain() {
|
|
while(buffer.length && !stream.paused) {
|
|
var data = buffer.shift()
|
|
if(null === data)
|
|
return stream.emit('end')
|
|
else
|
|
stream.emit('data', data)
|
|
}
|
|
}
|
|
|
|
stream.queue = stream.push = function (data) {
|
|
// console.error(ended)
|
|
if(_ended) return stream
|
|
if(data === null) _ended = true
|
|
buffer.push(data)
|
|
drain()
|
|
return stream
|
|
}
|
|
|
|
//this will be registered as the first 'end' listener
|
|
//must call destroy next tick, to make sure we're after any
|
|
//stream piped from here.
|
|
//this is only a problem if end is not emitted synchronously.
|
|
//a nicer way to do this is to make sure this is the last listener for 'end'
|
|
|
|
stream.on('end', function () {
|
|
stream.readable = false
|
|
if(!stream.writable && stream.autoDestroy)
|
|
process.nextTick(function () {
|
|
stream.destroy()
|
|
})
|
|
})
|
|
|
|
function _end () {
|
|
stream.writable = false
|
|
end.call(stream)
|
|
if(!stream.readable && stream.autoDestroy)
|
|
stream.destroy()
|
|
}
|
|
|
|
stream.end = function (data) {
|
|
if(ended) return
|
|
ended = true
|
|
if(arguments.length) stream.write(data)
|
|
_end() // will emit or queue
|
|
return stream
|
|
}
|
|
|
|
stream.destroy = function () {
|
|
if(destroyed) return
|
|
destroyed = true
|
|
ended = true
|
|
buffer.length = 0
|
|
stream.writable = stream.readable = false
|
|
stream.emit('close')
|
|
return stream
|
|
}
|
|
|
|
stream.pause = function () {
|
|
if(stream.paused) return
|
|
stream.paused = true
|
|
return stream
|
|
}
|
|
|
|
stream.resume = function () {
|
|
if(stream.paused) {
|
|
stream.paused = false
|
|
stream.emit('resume')
|
|
}
|
|
drain()
|
|
//may have become paused again,
|
|
//as drain emits 'data'.
|
|
if(!stream.paused)
|
|
stream.emit('drain')
|
|
return stream
|
|
}
|
|
return stream
|
|
}
|
|
|
|
|
|
}).call(this,require("g5I+bs"))
|
|
},{"g5I+bs":53,"stream":60}],77:[function(require,module,exports){
|
|
if (typeof Object.create === 'function') {
|
|
// implementation from standard node.js 'util' module
|
|
module.exports = function inherits(ctor, 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) {
|
|
ctor.super_ = superCtor
|
|
var TempCtor = function () {}
|
|
TempCtor.prototype = superCtor.prototype
|
|
ctor.prototype = new TempCtor()
|
|
ctor.prototype.constructor = ctor
|
|
}
|
|
}
|
|
|
|
},{}],78:[function(require,module,exports){
|
|
module.exports = function isBuffer(arg) {
|
|
return arg && typeof arg === 'object'
|
|
&& typeof arg.copy === 'function'
|
|
&& typeof arg.fill === 'function'
|
|
&& typeof arg.readUInt8 === 'function';
|
|
}
|
|
},{}],79:[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.
|
|
|
|
var formatRegExp = /%[sdj%]/g;
|
|
exports.format = function(f) {
|
|
if (!isString(f)) {
|
|
var objects = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
objects.push(inspect(arguments[i]));
|
|
}
|
|
return objects.join(' ');
|
|
}
|
|
|
|
var i = 1;
|
|
var args = arguments;
|
|
var len = args.length;
|
|
var str = String(f).replace(formatRegExp, function(x) {
|
|
if (x === '%%') return '%';
|
|
if (i >= len) return x;
|
|
switch (x) {
|
|
case '%s': return String(args[i++]);
|
|
case '%d': return Number(args[i++]);
|
|
case '%j':
|
|
try {
|
|
return JSON.stringify(args[i++]);
|
|
} catch (_) {
|
|
return '[Circular]';
|
|
}
|
|
default:
|
|
return x;
|
|
}
|
|
});
|
|
for (var x = args[i]; i < len; x = args[++i]) {
|
|
if (isNull(x) || !isObject(x)) {
|
|
str += ' ' + x;
|
|
} else {
|
|
str += ' ' + inspect(x);
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
|
|
|
|
// Mark that a method should not be used.
|
|
// Returns a modified function which warns once by default.
|
|
// If --no-deprecation is set, then it is a no-op.
|
|
exports.deprecate = function(fn, msg) {
|
|
// Allow for deprecating things in the process of starting up.
|
|
if (isUndefined(global.process)) {
|
|
return function() {
|
|
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
if (process.noDeprecation === true) {
|
|
return fn;
|
|
}
|
|
|
|
var warned = false;
|
|
function deprecated() {
|
|
if (!warned) {
|
|
if (process.throwDeprecation) {
|
|
throw new Error(msg);
|
|
} else if (process.traceDeprecation) {
|
|
console.trace(msg);
|
|
} else {
|
|
console.error(msg);
|
|
}
|
|
warned = true;
|
|
}
|
|
return fn.apply(this, arguments);
|
|
}
|
|
|
|
return deprecated;
|
|
};
|
|
|
|
|
|
var debugs = {};
|
|
var debugEnviron;
|
|
exports.debuglog = function(set) {
|
|
if (isUndefined(debugEnviron))
|
|
debugEnviron = process.env.NODE_DEBUG || '';
|
|
set = set.toUpperCase();
|
|
if (!debugs[set]) {
|
|
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
|
var pid = process.pid;
|
|
debugs[set] = function() {
|
|
var msg = exports.format.apply(exports, arguments);
|
|
console.error('%s %d: %s', set, pid, msg);
|
|
};
|
|
} else {
|
|
debugs[set] = function() {};
|
|
}
|
|
}
|
|
return debugs[set];
|
|
};
|
|
|
|
|
|
/**
|
|
* Echos the value of a value. Trys to print the value out
|
|
* in the best way possible given the different types.
|
|
*
|
|
* @param {Object} obj The object to print out.
|
|
* @param {Object} opts Optional options object that alters the output.
|
|
*/
|
|
/* legacy: obj, showHidden, depth, colors*/
|
|
function inspect(obj, opts) {
|
|
// default options
|
|
var ctx = {
|
|
seen: [],
|
|
stylize: stylizeNoColor
|
|
};
|
|
// legacy...
|
|
if (arguments.length >= 3) ctx.depth = arguments[2];
|
|
if (arguments.length >= 4) ctx.colors = arguments[3];
|
|
if (isBoolean(opts)) {
|
|
// legacy...
|
|
ctx.showHidden = opts;
|
|
} else if (opts) {
|
|
// got an "options" object
|
|
exports._extend(ctx, opts);
|
|
}
|
|
// set default options
|
|
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
|
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
|
if (isUndefined(ctx.colors)) ctx.colors = false;
|
|
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
|
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
|
return formatValue(ctx, obj, ctx.depth);
|
|
}
|
|
exports.inspect = inspect;
|
|
|
|
|
|
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
|
inspect.colors = {
|
|
'bold' : [1, 22],
|
|
'italic' : [3, 23],
|
|
'underline' : [4, 24],
|
|
'inverse' : [7, 27],
|
|
'white' : [37, 39],
|
|
'grey' : [90, 39],
|
|
'black' : [30, 39],
|
|
'blue' : [34, 39],
|
|
'cyan' : [36, 39],
|
|
'green' : [32, 39],
|
|
'magenta' : [35, 39],
|
|
'red' : [31, 39],
|
|
'yellow' : [33, 39]
|
|
};
|
|
|
|
// Don't use 'blue' not visible on cmd.exe
|
|
inspect.styles = {
|
|
'special': 'cyan',
|
|
'number': 'yellow',
|
|
'boolean': 'yellow',
|
|
'undefined': 'grey',
|
|
'null': 'bold',
|
|
'string': 'green',
|
|
'date': 'magenta',
|
|
// "name": intentionally not styling
|
|
'regexp': 'red'
|
|
};
|
|
|
|
|
|
function stylizeWithColor(str, styleType) {
|
|
var style = inspect.styles[styleType];
|
|
|
|
if (style) {
|
|
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
|
'\u001b[' + inspect.colors[style][1] + 'm';
|
|
} else {
|
|
return str;
|
|
}
|
|
}
|
|
|
|
|
|
function stylizeNoColor(str, styleType) {
|
|
return str;
|
|
}
|
|
|
|
|
|
function arrayToHash(array) {
|
|
var hash = {};
|
|
|
|
array.forEach(function(val, idx) {
|
|
hash[val] = true;
|
|
});
|
|
|
|
return hash;
|
|
}
|
|
|
|
|
|
function formatValue(ctx, value, recurseTimes) {
|
|
// Provide a hook for user-specified inspect functions.
|
|
// Check that value is an object with an inspect function on it
|
|
if (ctx.customInspect &&
|
|
value &&
|
|
isFunction(value.inspect) &&
|
|
// Filter out the util module, it's inspect function is special
|
|
value.inspect !== exports.inspect &&
|
|
// Also filter out any prototype objects using the circular check.
|
|
!(value.constructor && value.constructor.prototype === value)) {
|
|
var ret = value.inspect(recurseTimes, ctx);
|
|
if (!isString(ret)) {
|
|
ret = formatValue(ctx, ret, recurseTimes);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
// Primitive types cannot have properties
|
|
var primitive = formatPrimitive(ctx, value);
|
|
if (primitive) {
|
|
return primitive;
|
|
}
|
|
|
|
// Look up the keys of the object.
|
|
var keys = Object.keys(value);
|
|
var visibleKeys = arrayToHash(keys);
|
|
|
|
if (ctx.showHidden) {
|
|
keys = Object.getOwnPropertyNames(value);
|
|
}
|
|
|
|
// IE doesn't make error fields non-enumerable
|
|
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
|
if (isError(value)
|
|
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
|
return formatError(value);
|
|
}
|
|
|
|
// Some type of object without properties can be shortcutted.
|
|
if (keys.length === 0) {
|
|
if (isFunction(value)) {
|
|
var name = value.name ? ': ' + value.name : '';
|
|
return ctx.stylize('[Function' + name + ']', 'special');
|
|
}
|
|
if (isRegExp(value)) {
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
}
|
|
if (isDate(value)) {
|
|
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
|
}
|
|
if (isError(value)) {
|
|
return formatError(value);
|
|
}
|
|
}
|
|
|
|
var base = '', array = false, braces = ['{', '}'];
|
|
|
|
// Make Array say that they are Array
|
|
if (isArray(value)) {
|
|
array = true;
|
|
braces = ['[', ']'];
|
|
}
|
|
|
|
// Make functions say that they are functions
|
|
if (isFunction(value)) {
|
|
var n = value.name ? ': ' + value.name : '';
|
|
base = ' [Function' + n + ']';
|
|
}
|
|
|
|
// Make RegExps say that they are RegExps
|
|
if (isRegExp(value)) {
|
|
base = ' ' + RegExp.prototype.toString.call(value);
|
|
}
|
|
|
|
// Make dates with properties first say the date
|
|
if (isDate(value)) {
|
|
base = ' ' + Date.prototype.toUTCString.call(value);
|
|
}
|
|
|
|
// Make error with message first say the error
|
|
if (isError(value)) {
|
|
base = ' ' + formatError(value);
|
|
}
|
|
|
|
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
return braces[0] + base + braces[1];
|
|
}
|
|
|
|
if (recurseTimes < 0) {
|
|
if (isRegExp(value)) {
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
} else {
|
|
return ctx.stylize('[Object]', 'special');
|
|
}
|
|
}
|
|
|
|
ctx.seen.push(value);
|
|
|
|
var output;
|
|
if (array) {
|
|
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
} else {
|
|
output = keys.map(function(key) {
|
|
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
});
|
|
}
|
|
|
|
ctx.seen.pop();
|
|
|
|
return reduceToSingleString(output, base, braces);
|
|
}
|
|
|
|
|
|
function formatPrimitive(ctx, value) {
|
|
if (isUndefined(value))
|
|
return ctx.stylize('undefined', 'undefined');
|
|
if (isString(value)) {
|
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
|
.replace(/'/g, "\\'")
|
|
.replace(/\\"/g, '"') + '\'';
|
|
return ctx.stylize(simple, 'string');
|
|
}
|
|
if (isNumber(value))
|
|
return ctx.stylize('' + value, 'number');
|
|
if (isBoolean(value))
|
|
return ctx.stylize('' + value, 'boolean');
|
|
// For some reason typeof null is "object", so special case here.
|
|
if (isNull(value))
|
|
return ctx.stylize('null', 'null');
|
|
}
|
|
|
|
|
|
function formatError(value) {
|
|
return '[' + Error.prototype.toString.call(value) + ']';
|
|
}
|
|
|
|
|
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
var output = [];
|
|
for (var i = 0, l = value.length; i < l; ++i) {
|
|
if (hasOwnProperty(value, String(i))) {
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
String(i), true));
|
|
} else {
|
|
output.push('');
|
|
}
|
|
}
|
|
keys.forEach(function(key) {
|
|
if (!key.match(/^\d+$/)) {
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
key, true));
|
|
}
|
|
});
|
|
return output;
|
|
}
|
|
|
|
|
|
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
var name, str, desc;
|
|
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
if (desc.get) {
|
|
if (desc.set) {
|
|
str = ctx.stylize('[Getter/Setter]', 'special');
|
|
} else {
|
|
str = ctx.stylize('[Getter]', 'special');
|
|
}
|
|
} else {
|
|
if (desc.set) {
|
|
str = ctx.stylize('[Setter]', 'special');
|
|
}
|
|
}
|
|
if (!hasOwnProperty(visibleKeys, key)) {
|
|
name = '[' + key + ']';
|
|
}
|
|
if (!str) {
|
|
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
if (isNull(recurseTimes)) {
|
|
str = formatValue(ctx, desc.value, null);
|
|
} else {
|
|
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
}
|
|
if (str.indexOf('\n') > -1) {
|
|
if (array) {
|
|
str = str.split('\n').map(function(line) {
|
|
return ' ' + line;
|
|
}).join('\n').substr(2);
|
|
} else {
|
|
str = '\n' + str.split('\n').map(function(line) {
|
|
return ' ' + line;
|
|
}).join('\n');
|
|
}
|
|
}
|
|
} else {
|
|
str = ctx.stylize('[Circular]', 'special');
|
|
}
|
|
}
|
|
if (isUndefined(name)) {
|
|
if (array && key.match(/^\d+$/)) {
|
|
return str;
|
|
}
|
|
name = JSON.stringify('' + key);
|
|
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
name = name.substr(1, name.length - 2);
|
|
name = ctx.stylize(name, 'name');
|
|
} else {
|
|
name = name.replace(/'/g, "\\'")
|
|
.replace(/\\"/g, '"')
|
|
.replace(/(^"|"$)/g, "'");
|
|
name = ctx.stylize(name, 'string');
|
|
}
|
|
}
|
|
|
|
return name + ': ' + str;
|
|
}
|
|
|
|
|
|
function reduceToSingleString(output, base, braces) {
|
|
var numLinesEst = 0;
|
|
var length = output.reduce(function(prev, cur) {
|
|
numLinesEst++;
|
|
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
|
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
|
}, 0);
|
|
|
|
if (length > 60) {
|
|
return braces[0] +
|
|
(base === '' ? '' : base + '\n ') +
|
|
' ' +
|
|
output.join(',\n ') +
|
|
' ' +
|
|
braces[1];
|
|
}
|
|
|
|
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
|
}
|
|
|
|
|
|
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
// because it is fragile and can be easily faked with `Object.create()`.
|
|
function isArray(ar) {
|
|
return Array.isArray(ar);
|
|
}
|
|
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 isObject(re) && objectToString(re) === '[object RegExp]';
|
|
}
|
|
exports.isRegExp = isRegExp;
|
|
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
exports.isObject = isObject;
|
|
|
|
function isDate(d) {
|
|
return isObject(d) && objectToString(d) === '[object Date]';
|
|
}
|
|
exports.isDate = isDate;
|
|
|
|
function isError(e) {
|
|
return isObject(e) &&
|
|
(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 = require('./support/isBuffer');
|
|
|
|
function objectToString(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
|
|
|
|
function pad(n) {
|
|
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
|
}
|
|
|
|
|
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
|
'Oct', 'Nov', 'Dec'];
|
|
|
|
// 26 Feb 16:19:34
|
|
function timestamp() {
|
|
var d = new Date();
|
|
var time = [pad(d.getHours()),
|
|
pad(d.getMinutes()),
|
|
pad(d.getSeconds())].join(':');
|
|
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
|
}
|
|
|
|
|
|
// log is just a thin wrapper to console.log that prepends a timestamp
|
|
exports.log = function() {
|
|
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
|
};
|
|
|
|
|
|
/**
|
|
* Inherit the prototype methods from one constructor into another.
|
|
*
|
|
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
* during bootstrapping this function needs to be rewritten using some native
|
|
* functions as prototype setup using normal JavaScript does not work as
|
|
* expected during bootstrapping (see mirror.js in r114903).
|
|
*
|
|
* @param {function} ctor Constructor function which needs to inherit the
|
|
* prototype.
|
|
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
*/
|
|
exports.inherits = require('inherits');
|
|
|
|
exports._extend = function(origin, add) {
|
|
// Don't do anything if add isn't an object
|
|
if (!add || !isObject(add)) return origin;
|
|
|
|
var keys = Object.keys(add);
|
|
var i = keys.length;
|
|
while (i--) {
|
|
origin[keys[i]] = add[keys[i]];
|
|
}
|
|
return origin;
|
|
};
|
|
|
|
function hasOwnProperty(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
|
|
}).call(this,require("g5I+bs"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"./support/isBuffer":78,"g5I+bs":53,"inherits":77}],80:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var implementation = require('./implementation');
|
|
|
|
module.exports = function getPolyfill() {
|
|
return Array.prototype.includes || implementation;
|
|
};
|
|
|
|
},{"./implementation":1}],81:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var define = require('define-properties');
|
|
var getPolyfill = require('./polyfill');
|
|
|
|
module.exports = function shimArrayPrototypeIncludes() {
|
|
var polyfill = getPolyfill();
|
|
define(
|
|
Array.prototype,
|
|
{ includes: polyfill },
|
|
{ includes: function () { return Array.prototype.includes !== polyfill; } }
|
|
);
|
|
return polyfill;
|
|
};
|
|
|
|
},{"./polyfill":80,"define-properties":7}],82:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var includes = require('../');
|
|
var test = require('tape');
|
|
var runTests = require('./tests');
|
|
|
|
test('as a function', function (t) {
|
|
t.test('bad array/this value', function (st) {
|
|
st['throws'](function () { includes(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
|
st['throws'](function () { includes(null, 'a'); }, TypeError, 'null is not an object');
|
|
st.end();
|
|
});
|
|
|
|
runTests(includes, t);
|
|
|
|
t.end();
|
|
});
|
|
|
|
},{"../":2,"./tests":84,"tape":71}],83:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
require('../shim')();
|
|
|
|
var test = require('tape');
|
|
var defineProperties = require('define-properties');
|
|
var bind = require('function-bind');
|
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
var functionsHaveNames = require('functions-have-names')();
|
|
|
|
var runTests = require('./tests');
|
|
|
|
test('shimmed', function (t) {
|
|
t.equal(Array.prototype.includes.length, 1, 'Array#includes has a length of 1');
|
|
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
|
st.equal(Array.prototype.includes.name, 'includes', 'Array#includes has name "includes"');
|
|
st.end();
|
|
});
|
|
|
|
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
|
et.equal(false, isEnumerable.call(Array.prototype, 'includes'), 'Array#includes is not enumerable');
|
|
et.end();
|
|
});
|
|
|
|
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
|
|
|
t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
|
|
st['throws'](function () { return Array.prototype.includes.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
|
st['throws'](function () { return Array.prototype.includes.call(null, 'a'); }, TypeError, 'null is not an object');
|
|
st.end();
|
|
});
|
|
|
|
runTests(bind.call(Function.call, Array.prototype.includes), t);
|
|
|
|
t.end();
|
|
});
|
|
|
|
},{"../shim":81,"./tests":84,"define-properties":7,"function-bind":34,"functions-have-names":35,"tape":71}],84:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = function (includes, t) {
|
|
var sparseish = { length: 5, 0: 'a', 1: 'b' };
|
|
var overfullarrayish = { length: 2, 0: 'a', 1: 'b', 2: 'c' };
|
|
var thrower = { valueOf: function () { throw new RangeError('whoa'); } };
|
|
var numberish = { valueOf: function () { return 2; } };
|
|
|
|
t.test('simple examples', function (st) {
|
|
st.equal(true, includes([1, 2, 3], 1), '[1, 2, 3] includes 1');
|
|
st.equal(false, includes([1, 2, 3], 4), '[1, 2, 3] does not include 4');
|
|
st.equal(true, includes([NaN], NaN), '[NaN] includes NaN');
|
|
st.end();
|
|
});
|
|
|
|
t.test('does not skip holes', function (st) {
|
|
st.equal(true, includes(Array(1)), 'Array(1) includes undefined');
|
|
st.end();
|
|
});
|
|
|
|
t.test('exceptions', function (et) {
|
|
et.test('fromIndex conversion', function (st) {
|
|
st['throws'](function () { includes([0], 0, thrower); }, RangeError, 'fromIndex conversion throws');
|
|
st.end();
|
|
});
|
|
|
|
et.test('ToLength', function (st) {
|
|
st['throws'](function () { includes({ length: thrower, 0: true }, true); }, RangeError, 'ToLength conversion throws');
|
|
st.end();
|
|
});
|
|
|
|
et.end();
|
|
});
|
|
|
|
t.test('arraylike', function (st) {
|
|
st.equal(true, includes(sparseish, 'a'), 'sparse array-like object includes "a"');
|
|
st.equal(false, includes(sparseish, 'c'), 'sparse array-like object does not include "c"');
|
|
|
|
st.equal(true, includes(overfullarrayish, 'b'), 'sparse array-like object includes "b"');
|
|
st.equal(false, includes(overfullarrayish, 'c'), 'sparse array-like object does not include "c"');
|
|
st.end();
|
|
});
|
|
|
|
t.test('fromIndex', function (ft) {
|
|
ft.equal(true, includes([1], 1, NaN), 'NaN fromIndex -> 0 fromIndex');
|
|
|
|
ft.equal(true, includes([0, 1, 2], 1, 0), 'starting from 0 finds index 1');
|
|
ft.equal(true, includes([0, 1, 2], 1, 1), 'starting from 1 finds index 1');
|
|
ft.equal(false, includes([0, 1, 2], 1, 2), 'starting from 2 does not find index 1');
|
|
|
|
ft.test('number coercion', function (st) {
|
|
st.equal(false, includes(['a', 'b', 'c'], 'a', numberish), 'does not find "a" with object fromIndex coercing to 2');
|
|
st.equal(false, includes(['a', 'b', 'c'], 'a', '2'), 'does not find "a" with string fromIndex coercing to 2');
|
|
st.equal(true, includes(['a', 'b', 'c'], 'c', numberish), 'finds "c" with object fromIndex coercing to 2');
|
|
st.equal(true, includes(['a', 'b', 'c'], 'c', '2'), 'finds "c" with string fromIndex coercing to 2');
|
|
st.end();
|
|
});
|
|
|
|
ft.test('fromIndex greater than length', function (st) {
|
|
st.equal(false, includes([1], 1, 2), 'array of length 1 is not searched if fromIndex is > 1');
|
|
st.equal(false, includes([1], 1, 1), 'array of length 1 is not searched if fromIndex is >= 1');
|
|
st.equal(false, includes([1], 1, 1.1), 'array of length 1 is not searched if fromIndex is 1.1');
|
|
st.equal(false, includes([1], 1, Infinity), 'array of length 1 is not searched if fromIndex is Infinity');
|
|
st.end();
|
|
});
|
|
|
|
ft.test('negative fromIndex', function (st) {
|
|
st.equal(true, includes([1, 3], 1, -4), 'computed length would be negative; fromIndex is thus 0');
|
|
st.equal(true, includes([1, 3], 3, -4), 'computed length would be negative; fromIndex is thus 0');
|
|
st.equal(true, includes([1, 3], 1, -Infinity), 'computed length would be negative; fromIndex is thus 0');
|
|
|
|
st.equal(true, includes([12, 13], 13, -1), 'finds -1st item with -1 fromIndex');
|
|
st.equal(false, includes([12, 13], 12, -1), 'does not find -2nd item with -1 fromIndex');
|
|
st.equal(true, includes([12, 13], 13, -2), 'finds -2nd item with -2 fromIndex');
|
|
|
|
st.equal(true, includes(sparseish, 'b', -4), 'finds -4th item with -4 fromIndex');
|
|
st.equal(false, includes(sparseish, 'a', -4), 'does not find -5th item with -4 fromIndex');
|
|
st.equal(true, includes(sparseish, 'a', -5), 'finds -5th item with -5 fromIndex');
|
|
st.end();
|
|
});
|
|
|
|
ft.end();
|
|
});
|
|
|
|
t.test('strings', function (st) {
|
|
st.equal(true, includes('abc', 'c'), 'string includes one of its chars');
|
|
st.equal(false, includes('abc', 'd'), 'string does not include a char it should not');
|
|
|
|
st.equal(true, includes(Object('abc'), 'c'), 'boxed string includes one of its chars');
|
|
st.equal(false, includes(Object('abc'), 'd'), 'boxed string does not include a char it should not');
|
|
|
|
st.end();
|
|
});
|
|
};
|
|
|
|
},{}]},{},[82,83])
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9qb3JkYW5oYXJiYW5kL0Ryb3Bib3ggKE9wZW5kb29yKS9naXQvYXJyYXktaW5jbHVkZXMuZ2l0L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvVXNlcnMvam9yZGFuaGFyYmFuZC9Ecm9wYm94IChPcGVuZG9vcikvZ2l0L2FycmF5LWluY2x1ZGVzLmdpdC9pbXBsZW1lbnRhdGlvbi5qcyIsIi9Vc2Vycy9qb3JkYW5oYXJiYW5kL0Ryb3Bib3ggKE9wZW5kb29yKS9naXQvYXJyYXktaW5j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XG4gICAgfVxufTtcblxudmFyIGZvckVhY2hTdHJpbmcgPSBmdW5jdGlvbiBmb3JFYWNoU3RyaW5nKHN0cmluZywgaXRlcmF0b3IsIHJlY2VpdmVyKSB7XG4gICAgZm9yICh2YXIgaSA9IDAsIGxlbiA9IHN0cmluZy5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAvLyBubyBzdWNoIHRoaW5nIGFzIGEgc3BhcnNlIHN0cmluZy5cbiAgICAgICAgaWYgKHJlY2VpdmVyID09IG51bGwpIHtcbiAgICAgICAgICAgIGl0ZXJhdG9yKHN0cmluZy5jaGFyQXQoaSksIGksIHN0cmluZyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpdGVyYXRvci5jYWxsKHJlY2VpdmVyLCBzdHJpbmcuY2hhckF0KGkpLCBpLCBzdHJpbmcpO1xuICAgICAgICB9XG4gICAgfVxufTtcblxudmFyIGZvckVhY2hPYmplY3QgPSBmdW5jdGlvbiBmb3JFYWNoT2JqZWN0KG9iamVjdCwgaXRlcmF0b3IsIHJlY2VpdmVyKSB7XG4gICAgZm9yICh2YXIgayBpbiBvYmplY3QpIHtcbiAgICAgICAgaWYgKGhhc093blByb3BlcnR5LmNhbGwob2JqZWN0LCBrKSkge1xuICAgICAgICAgICAgaWYgKHJlY2VpdmVyID09IG51bGwpIHtcbiAgICAgICAgICAgICAgICBpdGVyYXRvcihvYmplY3Rba10sIGssIG9iamVjdCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGl0ZXJhdG9yLmNhbGwocmVjZWl2ZXIsIG9iamVjdFtrXSwgaywgb2JqZWN0KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn07XG5cbnZhciBmb3JFYWNoID0gZnVuY3Rpb24gZm9yRWFjaChsaXN0LCBpdGVyYXRvciwgdGhpc0FyZykge1xuICAgIGlmICghaXNDYWxsYWJsZShpdGVyYXRvcikpIHtcbiAgICAgIC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KSAhPT0gZnVuY1R5cGUpIHtcbiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihFUlJPUl9NRVNTQUdFICsgdGFyZ2V0KTtcbiAgICB9XG4gICAgdmFyIGFyZ3MgPSBzbGljZS5jYWxsKGFyZ3VtZW50cywgMSk7XG5cbiAgICB2YXIgYm91bmQ7XG4gICAgdmFyIGJpbmRlciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKHRoaXMgaW5zdGFuY2VvZiBib3VuZCkge1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRhcmdldC5hcHBseShcbiAgICAgICAgICAgICAgICB0aGlzLFxuICAgICAgICAgICAgICAgIGFyZ3MuY29uY2F0KHNsaWNlLmNhbGwoYXJndW1lbnRzKSlcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0KHJlc3VsdCkgPT09IHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0YXJnZXQuYXBwbHkoXG4gICAgICAgICAgICAgICAgdGhhdCxcbiAgICAgICAgICAgICAgICBhcmdzLmNvbmNhdChzbGljZS5jYWxsKGFyZ3VtZW50cykpXG4gICAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHZhciBib3VuZExlbmd0aCA9IE1hdGgubWF4KDAsIHRhcmdldC5sZW5ndGggLSBhcmdzLmxlbmd0aCk7XG4gICAgdmFyIGJvdW5kQXJncyA9IFtdO1xuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYm91bmRMZW5ndGg7IGkrKykge1xuICAgICAgICBib3VuZEFyZ3MucHVzaCgnJCcgKyBpKTtcbiAgICB9XG5cbiAgICBib3VuZCA9IEZ1bmN0aW9uKCdiaW5kZXInLCAncmV0dXJuIGZ1bmN0aW9uICg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ZXRJbW1lZGlhdGUgPSB0eXBlb2Ygd2luZG93ICE9PSAndW5kZWZpbmVkJ1xuICAgICYmIHdpbmRvdy5zZXRJbW1lZGlhdGU7XG4gICAgdmFyIGNhblBvc3QgPSB0eXBlb2Ygd2luZG93ICE9PSAndW5kZWZpbmVkJ1xuICAgICYmIHdpbmRvdy5wb3N0TWVzc2FnZSAmJiB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lclxuICAgIDtcblxuICAgIGlmIChjYW5TZXRJbW1lZGlhdGUpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChmKSB7IHJldHVybiB3aW5kb3cuc2V0SW1tZWRpYXRlKGYpIH07XG4gICAgfVxuXG4gICAgaWYgKGNhblBvc3QpIHtcbiAgICAgICAgdmFyIHF1ZXVlID0gW107XG4gICAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgZnVuY3Rpb24gKGV2KSB7XG4gICAgICAgICAgICB2YXIgc291cmNlID0gZXYuc291cmNlO1xuICAgICAgICAgICAgaWYgKChzb3VyY2UgPT09IHdpbmRvdyB8fCBzb3VyY2UgPT09IG51bGwpICYmIGV2LmRhdGEgPT09ICdwcm9jZXNzLXRpY2snKSB7XG4gICAgICAgICAgICAgICAgZXYuc3RvcFByb3BhZ2F0aW9uKCk7XG4gICAgICAgICAgICAgICAgaWYgKHF1ZXVlLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gcXVldWUuc2hpZnQoKTtcbiAgICAgICAgICAgICAgICAgICAgZm4oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIHRydWUpO1xuXG4gICAgICAgIHJldHVybiBmdW5jdGlvbiBuZXh0VGljayhmbikge1xuICAgICAgICAgICAgcXVldWUucHVzaChmbik7XG4gICAgICAgICAgICB3aW5kb3cucG9zdE1lc3NhZ2UoJ3Byb2Nlc3MtdGljaycsICcqJyk7XG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gW107XG4gICAgdGhpcy5fb25seSA9IG51bGw7XG4gICAgdGhpcy5faXNSdW5uaW5nID0gZmFsc2U7XG59XG5cblJlc3VsdHMucHJvdG90eXBlLmNyZWF0ZVN0cmVhbSA9IGZ1bmN0aW9uIChvcHRzKSB7XG4gICAgaWYgKCFvcHRzKSBvcHRzID0ge307XG4gICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgIHZhciBvdXRwdXQsIHRlc3RJZCA9IDA7XG4gICAgaWYgKG9wdHMub2JqZWN0TW9kZSkge1xuICAgICAgICBvdXRwdXQgPSB0aHJvdWdoKCk7XG4gICAgICAgIHNlbGYub24oJ19wdXNoJywgZnVuY3Rpb24gb250ZXN0KHQsIGV4dHJhKSB7XG4gICAgICAgICAgICBpZiAoIWV4dHJhKSBleHRyYSA9IHt9O1xuICAgICAgICAgICAgdmFyIGlkID0gdGVzdElkKys7XG4gICAgICAgICAgICB0Lm9uY2UoJ3ByZXJ1bicsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcm93ID0ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAndGVzdCcsXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IHQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkLFxuICAgICAgICAgICAgICAgICAgICBza2lwOiB0Ll9za2lwLFxuICAgICAgICAgICAgICAgICAgICB0b2RvOiB0Ll90b2RvXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAoaGFzKGV4dHJhLCAncGFyZW50JykpIHtcbiAgICAgICAgICAgICAgICAgICAgcm93LnBhcmVudCA9IGV4dHJhLnBhcmVudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgb3V0cHV0LnF1ZXVlKHJvdyk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHQub24oJ3Rlc3QnLCBmdW5jdGlvbiAoc3QpIHtcbiAgICAgICAgICAgICAgICBvbnRlc3Qoc3QsIHsgcGFyZW50OiBpZCB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdC5vbigncmVzdWx0JywgZnVuY3Rpb24gKHJlcykge1xuICAgICAgICAgICAgICAgIHJlcy50ZXN0ID0gaWQ7XG4gICAgICAgICAgICAgICAgcmVzLnR5cGUgPSAnYXNzZXJ0JztcbiAgICAgICAgICAgICAgICBvdXRwdXQucXVldWUocmVzKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdC5vbignZW5kJywgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIG91dHB1dC5xdWV1ZSh7IHR5cGU6ICdlbmQnLCB0ZXN0OiBpZCB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICAgICAgc2VsZi5vbignZG9uZScsIGZ1bmN0aW9uICgpIHsgb3V0cHV0LnF1ZXVlKG51bGwpOyB9KTtcbiAgICB9IGVsc2Uge1xuICAgICAgICBvdXRwdXQgPSByZXN1bWVyKCk7XG4gICAgICAgIG91dHB1dC5xdWV1ZSgnVEFQIHZlcnNpb24gMTNcXG4nKTtcbiAgICAgICAgc2VsZi5fc3RyZWFtLnBpcGUob3V0cHV0KTtcbiAgICB9XG5cbiAgICBpZiAoIXRoaXMuX2lzUnVubmluZykge1xuICAgICAgICB0aGlzLl9pc1J1bm5pbmcgPSB0cnVlO1xuICAgICAgICBuZXh0VGljayhmdW5jdGlvbiBuZXh0KCkge1xuICAgICAgICAgICAgdmFyIHQ7XG4gICAgICAgICAgICB3aGlsZSAodCA9IGdldE5leHRUZXN0KHNlbGYpKSB7XG4gICAgICAgICAgICAgICAgdC5ydW4oKTtcbiAgICAgICAgICAgICAgICBpZiAoIXQuZW5kZWQpIHJldHVybiB0Lm9uY2UoJ2VuZCcsIGZ1bmN0aW9uICgpIHsgbmV4dFRpY2sobmV4dCk7IH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5lbWl0KCdkb25lJyk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mludERlcHRoKSB7XG4gICAgICAgIHRoaXMuX29iamVjdFByaW50RGVwdGggPSBhcmdzLm9wdHMub2JqZWN0UHJpbnREZXB0aDtcbiAgICB9IGVsc2UgaWYgKGRlcHRoRW52VmFyKSB7XG4gICAgICAgIGlmICh0b0xvd2VyQ2FzZShkZXB0aEVudlZhcikgPT09ICdpbmZpbml0eScpIHtcbiAgICAgICAgICAgIHRoaXMuX29iamVjdFByaW50RGVwdGggPSBJbmZpbml0eTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX29iamVjdFByaW50RGVwdGggPSBkZXB0aEVudlZhcjtcbiAgICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMuX29iamVjdFByaW50RGVwdGggPSA1O1xuICAgIH1cblxuICAgIGZvciAodmFyIHByb3AgaW4gdGhpcykge1xuICAgICAgICB0aGlzW3Byb3BdID0gKGZ1bmN0aW9uIGJpbmQoc2VsZiwgdmFsKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBib3VuZCgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbC5hcHBseShzZWxmLCBhcmd1bWVudHMpO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdmFsO1xuICAgICAgICB9KSh0aGlzLCB0aGlzW3Byb3BdKTtcbiAgICB9XG59XG5cblRlc3QucHJvdG90eXBlLnJ1biA9IGZ1bmN0aW9uICgpIHtcbiAgICB0aGlzLmVtaXQoJ3ByZXJ1bicpO1xuICAgIGlmICghdGhpcy5fY2IgfHwgdGhpcy5fc2tpcCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZW5kKCk7XG4gICAgfVxuICAgIGlmICh0aGlzLl90aW1lb3V0ICE9IG51bGwpIHtcbiAgICAgICAgdGhpcy50a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cmVzZW50IGEgZnVuY3Rpb24gY2FsbC4gSXQgbWF5IGxvb2tcbiAgICAgICAgICAgICAgICBsaWtlIGA8YW5vbnltb3VzPmAgb3IgJ1Rlc3QuYm91bmQgW2FzIHJ1bl0nLlxuXG4gICAgICAgICAgICAgICAgRm9yIG91ciBwdXJwb3Nlcywgd2UgYXNzdW1lIHRoYXQsIGlmIHRoZXJlIGlzIGEgZnVuY3Rpb25cbiAgICAgICAgICAgICAgICBuYW1lLCBpdCdzIGV2ZXJ5dGhpbmcgbGVhZGluZyB1cCB0byB0aGUgZmlyc3Qgb3BlblxuICAgICAgICAgICAgICAgIHBhcmVudGhlc2VzICh0cmltbWVkKSBiZWZvcmUgb3VyIHBhdGhuYW1lLlxuXG4gICAgICAgICAgICAgICAgICAgIC8oPzooLiopXFxzK1xcKCk/L1xuXG4gICAgICAgICAgICAgICAgTGFzdCBwYXJ0IGNhcHR1cmVzIGZpbGUgcGF0aCBwbHVzIGxpbmUgbm8gKGFuZCBvcHRpb25hbFxuICAgICAgICAgICAgICAgIGNvbHVtbiBubykuXG5cbiAgICAgICAgICAgICAgICAgICAgLygoPzpcXC98W2EtekEtWl06XFxcXClbXjpcXCldKzooXFxkKykoPzo6KFxcZCspKT8pL1xuICAgICAgICAgICAgKi9cbiAgICAgICAgICAgIHZhciByZSA9IC9eKD86W15cXHNdKlxccypcXGJhdFxccyspKD86KC4qKVxccytcXCgpPygoPzpcXC98W2EtekEtWl06XFxcXClbXjpcXCldKzooXFxkKykoPzo6KFxcZCspKT8pLztcbiAgICAgICAgICAgIHZhciBtID0gcmUuZXhlYyhlcnJbaV0pO1xuXG4gICAgICAgICAgICBpZiAoIW0pIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIGNhbGxEZXNjcmlwdGlvbiA9IG1bMV0gfHwgJzxhbm9ueW1vdXM+JztcbiAgICAgICAgICAgIHZhciBmaWxlUGF0aCA9IG1bMl07XG5cbiAgICAgICAgICAgIGlmIChmaWxlUGF0aC5zbGljZSgwLCBkaXIubGVuZ3RoKSA9PT0gZGlyKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEZ1bmN0aW9uIGNhbGwgZGVzY3JpcHRpb24gbWF5IG5vdCAoanVzdCkgYmUgYSBmdW5jdGlvbiBuYW1lLlxuICAgICAgICAgICAgLy8gVHJ5IHRvIGV4dHJhY3QgZnVuY3Rpb24gbmFtZSBieSBsb29raW5nIGF0IGZpcnN0IFwid29yZFwiIG9ubHkuXG4gICAgICAgICAgICByZXMuZnVuY3Rpb25OYW1lID0gY2FsbERlc2NyaXB0aW9uLnNwbGl0KC9cXHMrLylbMF07XG4gICAgICAgICAgICByZXMuZmlsZSA9IGZpbGVQYXRoO1xuICAgICAgICAgICAgcmVzLmxpbmUgPSBOdW1iZXIobVszXSk7XG4gICAgICAgICAgICBpZiAobVs0XSkgcmVzLmNvbHVtbiA9IE51bWJlcihtWzRdKTtcblxuICAgICAgICAgICAgcmVzLmF0ID0gY2FsbERlc2NyaXB0aW9uICsgJyAoJyArIGZpbGVQYXRoICsgJyknO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzZWxmLmVtaXQoJ3Jlc3VsdCcsIHJlcyk7XG5cbiAgICB2YXIgcGVuZGluZ0Fzc2VydHMgPSBzZWxmLl9wZW5kaW5nQXNzZXJ0cygpO1xuICAgIGlmICghcGVuZGluZ0Fzc2VydHMpIHtcbiAgICAgICAgaWYgKGV4dHJhLmV4aXRpbmcpIHtcbiAgICAgICAgICAgIHNlbGYuX2VuZCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbmV4dFRpY2soZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHNlbGYuX2VuZCgpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAg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