define("util",[], function(require, exports, module) {// // // "use strict"; 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; }; function inspect(obj, opts) { var ctx = { seen: [], stylize: stylizeNoColor, }; if (arguments.length >= 3) ctx.depth = arguments[2]; if (arguments.length >= 4) ctx.colors = arguments[3]; if (isBoolean(opts)) { ctx.showHidden = opts; } else if (opts) { exports._extend(ctx, opts); } 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; 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], }; inspect.styles = { special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", 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) { if ( ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== exports.inspect && !(value.constructor && value.constructor.prototype === value) ) { var ret = value.inspect(recurseTimes, ctx); if (!isString(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; } var primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } var keys = Object.keys(value); var visibleKeys = arrayToHash(keys); if (ctx.showHidden) { keys = Object.getOwnPropertyNames(value); } 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 = ["{", "}"]; if (isArray(value)) { array = true; braces = ["[", "]"]; } if (isFunction(value)) { var n = value.name ? ": " + value.name : ""; base = " [Function" + n + "]"; } if (isRegExp(value)) { base = " " + RegExp.prototype.toString.call(value); } if (isDate(value)) { base = " " + Date.prototype.toUTCString.call(value); } 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"); 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]; } 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]"; } 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; function isBuffer(arg) { return false; } exports.isBuffer = 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"]; 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(" "); } exports.log = function() { console.log("%s - %s", timestamp(), exports.format.apply(exports, arguments)); }; exports.inherits = function(ctor, superCtor) { ctor.super_ = superCtor; ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true, }, }); }; exports._extend = function(origin, add) { 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); } exports.callbackify = function callbackify(fn) { if (typeof fn !== "function") return new Error("Missing required function argument"); return function wrapped() { var args = Array.prototype.slice.call(arguments); var callback = args.pop(); fn.apply(this, args) .then(function(payload) { callback(null, payload); }) .catch(function(error) { callback(error); }); }; }; exports.promisify = function promisify(fn) { if (typeof fn !== "function") return new Error("Missing required function argument"); return function wrapped() { var args = Array.prototype.slice.call(arguments); return new Promise(function(resolve, reject) { args.push(function callbackMethod() { var results = Array.prototype.slice.call(arguments); var err = results.shift(); if (err) return reject.call(null, err); return resolve.apply(null, results); }); fn.apply(this, args); }); }; }; class PromiseTimeout extends Error { constructor() { super("TIMEOUT: Promise timed out."); this.code = "TIMEOUT"; } } exports.setPromiseTimeout = function(promise, time) { return new Promise((resolve, reject) => { let resolved = false; setTimeout(() => { if (!resolved) reject(new PromiseTimeout()); }, time); promise .then((result) => { resolved = true; resolve(result); }) .catch(reject); }); }; }); define("assert",[], function(require, exports, module) {// // // // // var util = require("util"); var pSlice = Array.prototype.slice; var assert = (module.exports = ok); assert.AssertionError = function AssertionError(options) { this.name = "AssertionError"; this.actual = options.actual; this.expected = options.expected; this.operator = options.operator; this.message = options.message || getMessage(this); var stackStartFunction = options.stackStartFunction || fail; if (Error.captureStackTrace) { Error.captureStackTrace(this, stackStartFunction); } else { var err = new Error(); this.stack = err.stack; } }; util.inherits(assert.AssertionError, Error); function replacer(key, value) { if (util.isUndefined(value)) { return "" + value; } if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) { return value.toString(); } if (util.isFunction(value) || util.isRegExp(value)) { return value.toString(); } return value; } function truncate(s, n) { if (util.isString(s)) { return s.length < n ? s : s.slice(0, n); } else { return s; } } function getMessage(self) { return ( truncate(JSON.stringify(self.actual, replacer), 128) + " " + self.operator + " " + truncate(JSON.stringify(self.expected, replacer), 128) ); } function fail(actual, expected, message, operator, stackStartFunction) { throw new assert.AssertionError({ message: message, actual: actual, expected: expected, operator: operator, stackStartFunction: stackStartFunction, }); } assert.fail = fail; function ok(value, message) { if (!value) fail(value, true, message, "==", assert.ok); } assert.ok = ok; assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, "==", assert.equal); }; assert.notEqual = function notEqual(actual, expected, message) { if (actual == expected) { fail(actual, expected, message, "!=", assert.notEqual); } }; assert.deepEqual = function deepEqual(actual, expected, message) { if (!_deepEqual(actual, expected)) { fail(actual, expected, message, "deepEqual", assert.deepEqual); } }; function _deepEqual(actual, expected) { if (actual === expected) { return true; } else if (util.isBuffer(actual) && util.isBuffer(expected)) { if (actual.length != expected.length) return false; for (var i = 0; i < actual.length; i++) { if (actual[i] !== expected[i]) return false; } return true; } else if (util.isDate(actual) && util.isDate(expected)) { return actual.getTime() === expected.getTime(); } else if (util.isRegExp(actual) && util.isRegExp(expected)) { return ( actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase ); } else if (!util.isObject(actual) && !util.isObject(expected)) { return actual == expected; } else { return objEquiv(actual, expected); } } function isArguments(object) { return Object.prototype.toString.call(object) == "[object Arguments]"; } function objEquiv(a, b) { if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b)) return false; if (a.prototype !== b.prototype) return false; if (isArguments(a)) { if (!isArguments(b)) { return false; } a = pSlice.call(a); b = pSlice.call(b); return _deepEqual(a, b); } try { var ka = Object.keys(a), kb = Object.keys(b), key, i; } catch (e) { return false; } if (ka.length != kb.length) return false; ka.sort(); kb.sort(); for (i = ka.length - 1; i >= 0; i--) { if (ka[i] != kb[i]) return false; } for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; if (!_deepEqual(a[key], b[key])) return false; } return true; } assert.notDeepEqual = function notDeepEqual(actual, expected, message) { if (_deepEqual(actual, expected)) { fail(actual, expected, message, "notDeepEqual", assert.notDeepEqual); } }; assert.strictEqual = function strictEqual(actual, expected, message) { if (actual !== expected) { fail(actual, expected, message, "===", assert.strictEqual); } }; assert.notStrictEqual = function notStrictEqual(actual, expected, message) { if (actual === expected) { fail(actual, expected, message, "!==", assert.notStrictEqual); } }; function expectedException(actual, expected) { if (!actual || !expected) { return false; } if (Object.prototype.toString.call(expected) == "[object RegExp]") { return expected.test(actual); } else if (actual instanceof expected) { return true; } else if (expected.call({}, actual) === true) { return true; } return false; } function _throws(shouldThrow, block, expected, message) { var actual; if (util.isString(expected)) { message = expected; expected = null; } try { block(); } catch (e) { actual = e; } message = (expected && expected.name ? " (" + expected.name + ")." : ".") + (message ? " " + message : "."); if (shouldThrow && !actual) { fail(actual, expected, "Missing expected exception" + message); } if (!shouldThrow && expectedException(actual, expected)) { fail(actual, expected, "Got unwanted exception" + message); } if ( (shouldThrow && actual && expected && !expectedException(actual, expected)) || (!shouldThrow && actual) ) { throw actual; } } assert.throws = function(block, /*optional*/ error, /*optional*/ message) { _throws.apply(this, [true].concat(pSlice.call(arguments))); }; assert.doesNotThrow = function(block, /*optional*/ message) { _throws.apply(this, [false].concat(pSlice.call(arguments))); }; assert.ifError = function(err) { if (err) { throw err; } }; });