This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14575 lines
447 KiB
14575 lines
447 KiB
(function (global, factory) { |
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : |
|
typeof define === 'function' && define.amd ? define(factory) : |
|
(factory()); |
|
}(this, (function () { 'use strict'; |
|
|
|
function unwrapExports (x) { |
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; |
|
} |
|
|
|
function createCommonjsModule(fn, module) { |
|
return module = { exports: {} }, fn(module, module.exports), module.exports; |
|
} |
|
|
|
var _global = createCommonjsModule(function (module) { |
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 |
|
var global = module.exports = typeof window != 'undefined' && window.Math == Math |
|
? window : typeof self != 'undefined' && self.Math == Math ? self |
|
// eslint-disable-next-line no-new-func |
|
: Function('return this')(); |
|
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef |
|
}); |
|
|
|
var _core = createCommonjsModule(function (module) { |
|
var core = module.exports = { version: '2.5.3' }; |
|
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef |
|
}); |
|
|
|
var _core_1 = _core.version; |
|
|
|
var _aFunction = function (it) { |
|
if (typeof it != 'function') throw TypeError(it + ' is not a function!'); |
|
return it; |
|
}; |
|
|
|
// optional / simple context binding |
|
|
|
var _ctx = function (fn, that, length) { |
|
_aFunction(fn); |
|
if (that === undefined) return fn; |
|
switch (length) { |
|
case 1: return function (a) { |
|
return fn.call(that, a); |
|
}; |
|
case 2: return function (a, b) { |
|
return fn.call(that, a, b); |
|
}; |
|
case 3: return function (a, b, c) { |
|
return fn.call(that, a, b, c); |
|
}; |
|
} |
|
return function (/* ...args */) { |
|
return fn.apply(that, arguments); |
|
}; |
|
}; |
|
|
|
var _isObject = function (it) { |
|
return typeof it === 'object' ? it !== null : typeof it === 'function'; |
|
}; |
|
|
|
var _anObject = function (it) { |
|
if (!_isObject(it)) throw TypeError(it + ' is not an object!'); |
|
return it; |
|
}; |
|
|
|
var _fails = function (exec) { |
|
try { |
|
return !!exec(); |
|
} catch (e) { |
|
return true; |
|
} |
|
}; |
|
|
|
// Thank's IE8 for his funny defineProperty |
|
var _descriptors = !_fails(function () { |
|
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; |
|
}); |
|
|
|
var document$1 = _global.document; |
|
// typeof document.createElement is 'object' in old IE |
|
var is = _isObject(document$1) && _isObject(document$1.createElement); |
|
var _domCreate = function (it) { |
|
return is ? document$1.createElement(it) : {}; |
|
}; |
|
|
|
var _ie8DomDefine = !_descriptors && !_fails(function () { |
|
return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7; |
|
}); |
|
|
|
// 7.1.1 ToPrimitive(input [, PreferredType]) |
|
|
|
// instead of the ES6 spec version, we didn't implement @@toPrimitive case |
|
// and the second argument - flag - preferred type is a string |
|
var _toPrimitive = function (it, S) { |
|
if (!_isObject(it)) return it; |
|
var fn, val; |
|
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; |
|
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val; |
|
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; |
|
throw TypeError("Can't convert object to primitive value"); |
|
}; |
|
|
|
var dP = Object.defineProperty; |
|
|
|
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) { |
|
_anObject(O); |
|
P = _toPrimitive(P, true); |
|
_anObject(Attributes); |
|
if (_ie8DomDefine) try { |
|
return dP(O, P, Attributes); |
|
} catch (e) { /* empty */ } |
|
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); |
|
if ('value' in Attributes) O[P] = Attributes.value; |
|
return O; |
|
}; |
|
|
|
var _objectDp = { |
|
f: f |
|
}; |
|
|
|
var _propertyDesc = function (bitmap, value) { |
|
return { |
|
enumerable: !(bitmap & 1), |
|
configurable: !(bitmap & 2), |
|
writable: !(bitmap & 4), |
|
value: value |
|
}; |
|
}; |
|
|
|
var _hide = _descriptors ? function (object, key, value) { |
|
return _objectDp.f(object, key, _propertyDesc(1, value)); |
|
} : function (object, key, value) { |
|
object[key] = value; |
|
return object; |
|
}; |
|
|
|
var PROTOTYPE = 'prototype'; |
|
|
|
var $export = function (type, name, source) { |
|
var IS_FORCED = type & $export.F; |
|
var IS_GLOBAL = type & $export.G; |
|
var IS_STATIC = type & $export.S; |
|
var IS_PROTO = type & $export.P; |
|
var IS_BIND = type & $export.B; |
|
var IS_WRAP = type & $export.W; |
|
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {}); |
|
var expProto = exports[PROTOTYPE]; |
|
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE]; |
|
var key, own, out; |
|
if (IS_GLOBAL) source = name; |
|
for (key in source) { |
|
// contains in native |
|
own = !IS_FORCED && target && target[key] !== undefined; |
|
if (own && key in exports) continue; |
|
// export native or passed |
|
out = own ? target[key] : source[key]; |
|
// prevent global pollution for namespaces |
|
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] |
|
// bind timers to global for call from export context |
|
: IS_BIND && own ? _ctx(out, _global) |
|
// wrap global constructors for prevent change them in library |
|
: IS_WRAP && target[key] == out ? (function (C) { |
|
var F = function (a, b, c) { |
|
if (this instanceof C) { |
|
switch (arguments.length) { |
|
case 0: return new C(); |
|
case 1: return new C(a); |
|
case 2: return new C(a, b); |
|
} return new C(a, b, c); |
|
} return C.apply(this, arguments); |
|
}; |
|
F[PROTOTYPE] = C[PROTOTYPE]; |
|
return F; |
|
// make static versions for prototype methods |
|
})(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; |
|
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME% |
|
if (IS_PROTO) { |
|
(exports.virtual || (exports.virtual = {}))[key] = out; |
|
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% |
|
if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out); |
|
} |
|
} |
|
}; |
|
// type bitmap |
|
$export.F = 1; // forced |
|
$export.G = 2; // global |
|
$export.S = 4; // static |
|
$export.P = 8; // proto |
|
$export.B = 16; // bind |
|
$export.W = 32; // wrap |
|
$export.U = 64; // safe |
|
$export.R = 128; // real proto method for `library` |
|
var _export = $export; |
|
|
|
var hasOwnProperty = {}.hasOwnProperty; |
|
var _has = function (it, key) { |
|
return hasOwnProperty.call(it, key); |
|
}; |
|
|
|
var toString$1 = {}.toString; |
|
|
|
var _cof = function (it) { |
|
return toString$1.call(it).slice(8, -1); |
|
}; |
|
|
|
// fallback for non-array-like ES3 and non-enumerable old V8 strings |
|
|
|
// eslint-disable-next-line no-prototype-builtins |
|
var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) { |
|
return _cof(it) == 'String' ? it.split('') : Object(it); |
|
}; |
|
|
|
// 7.2.1 RequireObjectCoercible(argument) |
|
var _defined = function (it) { |
|
if (it == undefined) throw TypeError("Can't call method on " + it); |
|
return it; |
|
}; |
|
|
|
// to indexed object, toObject with fallback for non-array-like ES3 strings |
|
|
|
|
|
var _toIobject = function (it) { |
|
return _iobject(_defined(it)); |
|
}; |
|
|
|
// 7.1.4 ToInteger |
|
var ceil = Math.ceil; |
|
var floor = Math.floor; |
|
var _toInteger = function (it) { |
|
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); |
|
}; |
|
|
|
// 7.1.15 ToLength |
|
|
|
var min = Math.min; |
|
var _toLength = function (it) { |
|
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 |
|
}; |
|
|
|
var max = Math.max; |
|
var min$1 = Math.min; |
|
var _toAbsoluteIndex = function (index, length) { |
|
index = _toInteger(index); |
|
return index < 0 ? max(index + length, 0) : min$1(index, length); |
|
}; |
|
|
|
// false -> Array#indexOf |
|
// true -> Array#includes |
|
|
|
|
|
|
|
var _arrayIncludes = function (IS_INCLUDES) { |
|
return function ($this, el, fromIndex) { |
|
var O = _toIobject($this); |
|
var length = _toLength(O.length); |
|
var index = _toAbsoluteIndex(fromIndex, length); |
|
var value; |
|
// Array#includes uses SameValueZero equality algorithm |
|
// eslint-disable-next-line no-self-compare |
|
if (IS_INCLUDES && el != el) while (length > index) { |
|
value = O[index++]; |
|
// eslint-disable-next-line no-self-compare |
|
if (value != value) return true; |
|
// Array#indexOf ignores holes, Array#includes - not |
|
} else for (;length > index; index++) if (IS_INCLUDES || index in O) { |
|
if (O[index] === el) return IS_INCLUDES || index || 0; |
|
} return !IS_INCLUDES && -1; |
|
}; |
|
}; |
|
|
|
var SHARED = '__core-js_shared__'; |
|
var store = _global[SHARED] || (_global[SHARED] = {}); |
|
var _shared = function (key) { |
|
return store[key] || (store[key] = {}); |
|
}; |
|
|
|
var id = 0; |
|
var px = Math.random(); |
|
var _uid = function (key) { |
|
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); |
|
}; |
|
|
|
var shared = _shared('keys'); |
|
|
|
var _sharedKey = function (key) { |
|
return shared[key] || (shared[key] = _uid(key)); |
|
}; |
|
|
|
var arrayIndexOf = _arrayIncludes(false); |
|
var IE_PROTO = _sharedKey('IE_PROTO'); |
|
|
|
var _objectKeysInternal = function (object, names) { |
|
var O = _toIobject(object); |
|
var i = 0; |
|
var result = []; |
|
var key; |
|
for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key); |
|
// Don't enum bug & hidden keys |
|
while (names.length > i) if (_has(O, key = names[i++])) { |
|
~arrayIndexOf(result, key) || result.push(key); |
|
} |
|
return result; |
|
}; |
|
|
|
// IE 8- don't enum bug keys |
|
var _enumBugKeys = ( |
|
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' |
|
).split(','); |
|
|
|
// 19.1.2.14 / 15.2.3.14 Object.keys(O) |
|
|
|
|
|
|
|
var _objectKeys = Object.keys || function keys(O) { |
|
return _objectKeysInternal(O, _enumBugKeys); |
|
}; |
|
|
|
var f$1 = Object.getOwnPropertySymbols; |
|
|
|
var _objectGops = { |
|
f: f$1 |
|
}; |
|
|
|
var f$2 = {}.propertyIsEnumerable; |
|
|
|
var _objectPie = { |
|
f: f$2 |
|
}; |
|
|
|
// 7.1.13 ToObject(argument) |
|
|
|
var _toObject = function (it) { |
|
return Object(_defined(it)); |
|
}; |
|
|
|
// 19.1.2.1 Object.assign(target, source, ...) |
|
|
|
|
|
|
|
|
|
|
|
var $assign = Object.assign; |
|
|
|
// should work with symbols and should have deterministic property order (V8 bug) |
|
var _objectAssign = !$assign || _fails(function () { |
|
var A = {}; |
|
var B = {}; |
|
// eslint-disable-next-line no-undef |
|
var S = Symbol(); |
|
var K = 'abcdefghijklmnopqrst'; |
|
A[S] = 7; |
|
K.split('').forEach(function (k) { B[k] = k; }); |
|
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; |
|
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars |
|
var T = _toObject(target); |
|
var aLen = arguments.length; |
|
var index = 1; |
|
var getSymbols = _objectGops.f; |
|
var isEnum = _objectPie.f; |
|
while (aLen > index) { |
|
var S = _iobject(arguments[index++]); |
|
var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S); |
|
var length = keys.length; |
|
var j = 0; |
|
var key; |
|
while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; |
|
} return T; |
|
} : $assign; |
|
|
|
// 19.1.3.1 Object.assign(target, source) |
|
|
|
|
|
_export(_export.S + _export.F, 'Object', { assign: _objectAssign }); |
|
|
|
var assign$1 = _core.Object.assign; |
|
|
|
var assign = createCommonjsModule(function (module) { |
|
module.exports = { "default": assign$1, __esModule: true }; |
|
}); |
|
|
|
var _Object$assign = unwrapExports(assign); |
|
|
|
// true -> String#at |
|
// false -> String#codePointAt |
|
var _stringAt = function (TO_STRING) { |
|
return function (that, pos) { |
|
var s = String(_defined(that)); |
|
var i = _toInteger(pos); |
|
var l = s.length; |
|
var a, b; |
|
if (i < 0 || i >= l) return TO_STRING ? '' : undefined; |
|
a = s.charCodeAt(i); |
|
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff |
|
? TO_STRING ? s.charAt(i) : a |
|
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; |
|
}; |
|
}; |
|
|
|
var _library = true; |
|
|
|
var _redefine = _hide; |
|
|
|
var _iterators = {}; |
|
|
|
var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) { |
|
_anObject(O); |
|
var keys = _objectKeys(Properties); |
|
var length = keys.length; |
|
var i = 0; |
|
var P; |
|
while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]); |
|
return O; |
|
}; |
|
|
|
var document$2 = _global.document; |
|
var _html = document$2 && document$2.documentElement; |
|
|
|
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) |
|
|
|
|
|
|
|
var IE_PROTO$1 = _sharedKey('IE_PROTO'); |
|
var Empty = function () { /* empty */ }; |
|
var PROTOTYPE$1 = 'prototype'; |
|
|
|
// Create object with fake `null` prototype: use iframe Object with cleared prototype |
|
var createDict = function () { |
|
// Thrash, waste and sodomy: IE GC bug |
|
var iframe = _domCreate('iframe'); |
|
var i = _enumBugKeys.length; |
|
var lt = '<'; |
|
var gt = '>'; |
|
var iframeDocument; |
|
iframe.style.display = 'none'; |
|
_html.appendChild(iframe); |
|
iframe.src = 'javascript:'; // eslint-disable-line no-script-url |
|
// createDict = iframe.contentWindow.Object; |
|
// html.removeChild(iframe); |
|
iframeDocument = iframe.contentWindow.document; |
|
iframeDocument.open(); |
|
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); |
|
iframeDocument.close(); |
|
createDict = iframeDocument.F; |
|
while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]]; |
|
return createDict(); |
|
}; |
|
|
|
var _objectCreate = Object.create || function create(O, Properties) { |
|
var result; |
|
if (O !== null) { |
|
Empty[PROTOTYPE$1] = _anObject(O); |
|
result = new Empty(); |
|
Empty[PROTOTYPE$1] = null; |
|
// add "__proto__" for Object.getPrototypeOf polyfill |
|
result[IE_PROTO$1] = O; |
|
} else result = createDict(); |
|
return Properties === undefined ? result : _objectDps(result, Properties); |
|
}; |
|
|
|
var _wks = createCommonjsModule(function (module) { |
|
var store = _shared('wks'); |
|
|
|
var Symbol = _global.Symbol; |
|
var USE_SYMBOL = typeof Symbol == 'function'; |
|
|
|
var $exports = module.exports = function (name) { |
|
return store[name] || (store[name] = |
|
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name)); |
|
}; |
|
|
|
$exports.store = store; |
|
}); |
|
|
|
var def = _objectDp.f; |
|
|
|
var TAG = _wks('toStringTag'); |
|
|
|
var _setToStringTag = function (it, tag, stat) { |
|
if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); |
|
}; |
|
|
|
var IteratorPrototype = {}; |
|
|
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() |
|
_hide(IteratorPrototype, _wks('iterator'), function () { return this; }); |
|
|
|
var _iterCreate = function (Constructor, NAME, next) { |
|
Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) }); |
|
_setToStringTag(Constructor, NAME + ' Iterator'); |
|
}; |
|
|
|
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) |
|
|
|
|
|
var IE_PROTO$2 = _sharedKey('IE_PROTO'); |
|
var ObjectProto = Object.prototype; |
|
|
|
var _objectGpo = Object.getPrototypeOf || function (O) { |
|
O = _toObject(O); |
|
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2]; |
|
if (typeof O.constructor == 'function' && O instanceof O.constructor) { |
|
return O.constructor.prototype; |
|
} return O instanceof Object ? ObjectProto : null; |
|
}; |
|
|
|
var ITERATOR = _wks('iterator'); |
|
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` |
|
var FF_ITERATOR = '@@iterator'; |
|
var KEYS = 'keys'; |
|
var VALUES = 'values'; |
|
|
|
var returnThis = function () { return this; }; |
|
|
|
var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { |
|
_iterCreate(Constructor, NAME, next); |
|
var getMethod = function (kind) { |
|
if (!BUGGY && kind in proto) return proto[kind]; |
|
switch (kind) { |
|
case KEYS: return function keys() { return new Constructor(this, kind); }; |
|
case VALUES: return function values() { return new Constructor(this, kind); }; |
|
} return function entries() { return new Constructor(this, kind); }; |
|
}; |
|
var TAG = NAME + ' Iterator'; |
|
var DEF_VALUES = DEFAULT == VALUES; |
|
var VALUES_BUG = false; |
|
var proto = Base.prototype; |
|
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; |
|
var $default = (!BUGGY && $native) || getMethod(DEFAULT); |
|
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; |
|
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; |
|
var methods, key, IteratorPrototype; |
|
// Fix native |
|
if ($anyNative) { |
|
IteratorPrototype = _objectGpo($anyNative.call(new Base())); |
|
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { |
|
// Set @@toStringTag to native iterators |
|
_setToStringTag(IteratorPrototype, TAG, true); |
|
// fix for some old engines |
|
if (!_library && !_has(IteratorPrototype, ITERATOR)) _hide(IteratorPrototype, ITERATOR, returnThis); |
|
} |
|
} |
|
// fix Array#{values, @@iterator}.name in V8 / FF |
|
if (DEF_VALUES && $native && $native.name !== VALUES) { |
|
VALUES_BUG = true; |
|
$default = function values() { return $native.call(this); }; |
|
} |
|
// Define iterator |
|
if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { |
|
_hide(proto, ITERATOR, $default); |
|
} |
|
// Plug for library |
|
_iterators[NAME] = $default; |
|
_iterators[TAG] = returnThis; |
|
if (DEFAULT) { |
|
methods = { |
|
values: DEF_VALUES ? $default : getMethod(VALUES), |
|
keys: IS_SET ? $default : getMethod(KEYS), |
|
entries: $entries |
|
}; |
|
if (FORCED) for (key in methods) { |
|
if (!(key in proto)) _redefine(proto, key, methods[key]); |
|
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods); |
|
} |
|
return methods; |
|
}; |
|
|
|
var $at = _stringAt(true); |
|
|
|
// 21.1.3.27 String.prototype[@@iterator]() |
|
_iterDefine(String, 'String', function (iterated) { |
|
this._t = String(iterated); // target |
|
this._i = 0; // next index |
|
// 21.1.5.2.1 %StringIteratorPrototype%.next() |
|
}, function () { |
|
var O = this._t; |
|
var index = this._i; |
|
var point; |
|
if (index >= O.length) return { value: undefined, done: true }; |
|
point = $at(O, index); |
|
this._i += point.length; |
|
return { value: point, done: false }; |
|
}); |
|
|
|
var _iterStep = function (done, value) { |
|
return { value: value, done: !!done }; |
|
}; |
|
|
|
// 22.1.3.4 Array.prototype.entries() |
|
// 22.1.3.13 Array.prototype.keys() |
|
// 22.1.3.29 Array.prototype.values() |
|
// 22.1.3.30 Array.prototype[@@iterator]() |
|
var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) { |
|
this._t = _toIobject(iterated); // target |
|
this._i = 0; // next index |
|
this._k = kind; // kind |
|
// 22.1.5.2.1 %ArrayIteratorPrototype%.next() |
|
}, function () { |
|
var O = this._t; |
|
var kind = this._k; |
|
var index = this._i++; |
|
if (!O || index >= O.length) { |
|
this._t = undefined; |
|
return _iterStep(1); |
|
} |
|
if (kind == 'keys') return _iterStep(0, index); |
|
if (kind == 'values') return _iterStep(0, O[index]); |
|
return _iterStep(0, [index, O[index]]); |
|
}, 'values'); |
|
|
|
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) |
|
_iterators.Arguments = _iterators.Array; |
|
|
|
var TO_STRING_TAG = _wks('toStringTag'); |
|
|
|
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' + |
|
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' + |
|
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' + |
|
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' + |
|
'TextTrackList,TouchList').split(','); |
|
|
|
for (var i = 0; i < DOMIterables.length; i++) { |
|
var NAME = DOMIterables[i]; |
|
var Collection = _global[NAME]; |
|
var proto = Collection && Collection.prototype; |
|
if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME); |
|
_iterators[NAME] = _iterators.Array; |
|
} |
|
|
|
// getting tag from 19.1.3.6 Object.prototype.toString() |
|
|
|
var TAG$1 = _wks('toStringTag'); |
|
// ES3 wrong here |
|
var ARG = _cof(function () { return arguments; }()) == 'Arguments'; |
|
|
|
// fallback for IE11 Script Access Denied error |
|
var tryGet = function (it, key) { |
|
try { |
|
return it[key]; |
|
} catch (e) { /* empty */ } |
|
}; |
|
|
|
var _classof = function (it) { |
|
var O, T, B; |
|
return it === undefined ? 'Undefined' : it === null ? 'Null' |
|
// @@toStringTag case |
|
: typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T |
|
// builtinTag case |
|
: ARG ? _cof(O) |
|
// ES3 arguments fallback |
|
: (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; |
|
}; |
|
|
|
var _anInstance = function (it, Constructor, name, forbiddenField) { |
|
if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { |
|
throw TypeError(name + ': incorrect invocation!'); |
|
} return it; |
|
}; |
|
|
|
// call something on iterator step with safe closing on error |
|
|
|
var _iterCall = function (iterator, fn, value, entries) { |
|
try { |
|
return entries ? fn(_anObject(value)[0], value[1]) : fn(value); |
|
// 7.4.6 IteratorClose(iterator, completion) |
|
} catch (e) { |
|
var ret = iterator['return']; |
|
if (ret !== undefined) _anObject(ret.call(iterator)); |
|
throw e; |
|
} |
|
}; |
|
|
|
// check on default Array iterator |
|
|
|
var ITERATOR$1 = _wks('iterator'); |
|
var ArrayProto = Array.prototype; |
|
|
|
var _isArrayIter = function (it) { |
|
return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it); |
|
}; |
|
|
|
var ITERATOR$2 = _wks('iterator'); |
|
|
|
var core_getIteratorMethod = _core.getIteratorMethod = function (it) { |
|
if (it != undefined) return it[ITERATOR$2] |
|
|| it['@@iterator'] |
|
|| _iterators[_classof(it)]; |
|
}; |
|
|
|
var _forOf = createCommonjsModule(function (module) { |
|
var BREAK = {}; |
|
var RETURN = {}; |
|
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { |
|
var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable); |
|
var f = _ctx(fn, that, entries ? 2 : 1); |
|
var index = 0; |
|
var length, step, iterator, result; |
|
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); |
|
// fast case for arrays with default iterator |
|
if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) { |
|
result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); |
|
if (result === BREAK || result === RETURN) return result; |
|
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { |
|
result = _iterCall(iterator, f, step.value, entries); |
|
if (result === BREAK || result === RETURN) return result; |
|
} |
|
}; |
|
exports.BREAK = BREAK; |
|
exports.RETURN = RETURN; |
|
}); |
|
|
|
// 7.3.20 SpeciesConstructor(O, defaultConstructor) |
|
|
|
|
|
var SPECIES = _wks('species'); |
|
var _speciesConstructor = function (O, D) { |
|
var C = _anObject(O).constructor; |
|
var S; |
|
return C === undefined || (S = _anObject(C)[SPECIES]) == undefined ? D : _aFunction(S); |
|
}; |
|
|
|
// fast apply, http://jsperf.lnkit.com/fast-apply/5 |
|
var _invoke = function (fn, args, that) { |
|
var un = that === undefined; |
|
switch (args.length) { |
|
case 0: return un ? fn() |
|
: fn.call(that); |
|
case 1: return un ? fn(args[0]) |
|
: fn.call(that, args[0]); |
|
case 2: return un ? fn(args[0], args[1]) |
|
: fn.call(that, args[0], args[1]); |
|
case 3: return un ? fn(args[0], args[1], args[2]) |
|
: fn.call(that, args[0], args[1], args[2]); |
|
case 4: return un ? fn(args[0], args[1], args[2], args[3]) |
|
: fn.call(that, args[0], args[1], args[2], args[3]); |
|
} return fn.apply(that, args); |
|
}; |
|
|
|
var process$1 = _global.process; |
|
var setTask = _global.setImmediate; |
|
var clearTask = _global.clearImmediate; |
|
var MessageChannel = _global.MessageChannel; |
|
var Dispatch = _global.Dispatch; |
|
var counter = 0; |
|
var queue = {}; |
|
var ONREADYSTATECHANGE = 'onreadystatechange'; |
|
var defer; |
|
var channel; |
|
var port; |
|
var run = function () { |
|
var id = +this; |
|
// eslint-disable-next-line no-prototype-builtins |
|
if (queue.hasOwnProperty(id)) { |
|
var fn = queue[id]; |
|
delete queue[id]; |
|
fn(); |
|
} |
|
}; |
|
var listener = function (event) { |
|
run.call(event.data); |
|
}; |
|
// Node.js 0.9+ & IE10+ has setImmediate, otherwise: |
|
if (!setTask || !clearTask) { |
|
setTask = function setImmediate(fn) { |
|
var args = []; |
|
var i = 1; |
|
while (arguments.length > i) args.push(arguments[i++]); |
|
queue[++counter] = function () { |
|
// eslint-disable-next-line no-new-func |
|
_invoke(typeof fn == 'function' ? fn : Function(fn), args); |
|
}; |
|
defer(counter); |
|
return counter; |
|
}; |
|
clearTask = function clearImmediate(id) { |
|
delete queue[id]; |
|
}; |
|
// Node.js 0.8- |
|
if (_cof(process$1) == 'process') { |
|
defer = function (id) { |
|
process$1.nextTick(_ctx(run, id, 1)); |
|
}; |
|
// Sphere (JS game engine) Dispatch API |
|
} else if (Dispatch && Dispatch.now) { |
|
defer = function (id) { |
|
Dispatch.now(_ctx(run, id, 1)); |
|
}; |
|
// Browsers with MessageChannel, includes WebWorkers |
|
} else if (MessageChannel) { |
|
channel = new MessageChannel(); |
|
port = channel.port2; |
|
channel.port1.onmessage = listener; |
|
defer = _ctx(port.postMessage, port, 1); |
|
// Browsers with postMessage, skip WebWorkers |
|
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object' |
|
} else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) { |
|
defer = function (id) { |
|
_global.postMessage(id + '', '*'); |
|
}; |
|
_global.addEventListener('message', listener, false); |
|
// IE8- |
|
} else if (ONREADYSTATECHANGE in _domCreate('script')) { |
|
defer = function (id) { |
|
_html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () { |
|
_html.removeChild(this); |
|
run.call(id); |
|
}; |
|
}; |
|
// Rest old browsers |
|
} else { |
|
defer = function (id) { |
|
setTimeout(_ctx(run, id, 1), 0); |
|
}; |
|
} |
|
} |
|
var _task = { |
|
set: setTask, |
|
clear: clearTask |
|
}; |
|
|
|
var macrotask = _task.set; |
|
var Observer = _global.MutationObserver || _global.WebKitMutationObserver; |
|
var process$2 = _global.process; |
|
var Promise = _global.Promise; |
|
var isNode$1 = _cof(process$2) == 'process'; |
|
|
|
var _microtask = function () { |
|
var head, last, notify; |
|
|
|
var flush = function () { |
|
var parent, fn; |
|
if (isNode$1 && (parent = process$2.domain)) parent.exit(); |
|
while (head) { |
|
fn = head.fn; |
|
head = head.next; |
|
try { |
|
fn(); |
|
} catch (e) { |
|
if (head) notify(); |
|
else last = undefined; |
|
throw e; |
|
} |
|
} last = undefined; |
|
if (parent) parent.enter(); |
|
}; |
|
|
|
// Node.js |
|
if (isNode$1) { |
|
notify = function () { |
|
process$2.nextTick(flush); |
|
}; |
|
// browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 |
|
} else if (Observer && !(_global.navigator && _global.navigator.standalone)) { |
|
var toggle = true; |
|
var node = document.createTextNode(''); |
|
new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new |
|
notify = function () { |
|
node.data = toggle = !toggle; |
|
}; |
|
// environments with maybe non-completely correct, but existent Promise |
|
} else if (Promise && Promise.resolve) { |
|
var promise = Promise.resolve(); |
|
notify = function () { |
|
promise.then(flush); |
|
}; |
|
// for other environments - macrotask based on: |
|
// - setImmediate |
|
// - MessageChannel |
|
// - window.postMessag |
|
// - onreadystatechange |
|
// - setTimeout |
|
} else { |
|
notify = function () { |
|
// strange IE + webpack dev server bug - use .call(global) |
|
macrotask.call(_global, flush); |
|
}; |
|
} |
|
|
|
return function (fn) { |
|
var task = { fn: fn, next: undefined }; |
|
if (last) last.next = task; |
|
if (!head) { |
|
head = task; |
|
notify(); |
|
} last = task; |
|
}; |
|
}; |
|
|
|
// 25.4.1.5 NewPromiseCapability(C) |
|
|
|
|
|
function PromiseCapability(C) { |
|
var resolve, reject; |
|
this.promise = new C(function ($$resolve, $$reject) { |
|
if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); |
|
resolve = $$resolve; |
|
reject = $$reject; |
|
}); |
|
this.resolve = _aFunction(resolve); |
|
this.reject = _aFunction(reject); |
|
} |
|
|
|
var f$3 = function (C) { |
|
return new PromiseCapability(C); |
|
}; |
|
|
|
var _newPromiseCapability = { |
|
f: f$3 |
|
}; |
|
|
|
var _perform = function (exec) { |
|
try { |
|
return { e: false, v: exec() }; |
|
} catch (e) { |
|
return { e: true, v: e }; |
|
} |
|
}; |
|
|
|
var _promiseResolve = function (C, x) { |
|
_anObject(C); |
|
if (_isObject(x) && x.constructor === C) return x; |
|
var promiseCapability = _newPromiseCapability.f(C); |
|
var resolve = promiseCapability.resolve; |
|
resolve(x); |
|
return promiseCapability.promise; |
|
}; |
|
|
|
var _redefineAll = function (target, src, safe) { |
|
for (var key in src) { |
|
if (safe && target[key]) target[key] = src[key]; |
|
else _hide(target, key, src[key]); |
|
} return target; |
|
}; |
|
|
|
var SPECIES$1 = _wks('species'); |
|
|
|
var _setSpecies = function (KEY) { |
|
var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY]; |
|
if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, { |
|
configurable: true, |
|
get: function () { return this; } |
|
}); |
|
}; |
|
|
|
var ITERATOR$3 = _wks('iterator'); |
|
var SAFE_CLOSING = false; |
|
|
|
try { |
|
var riter = [7][ITERATOR$3](); |
|
riter['return'] = function () { SAFE_CLOSING = true; }; |
|
// eslint-disable-next-line no-throw-literal |
|
|
|
} catch (e) { /* empty */ } |
|
|
|
var _iterDetect = function (exec, skipClosing) { |
|
if (!skipClosing && !SAFE_CLOSING) return false; |
|
var safe = false; |
|
try { |
|
var arr = [7]; |
|
var iter = arr[ITERATOR$3](); |
|
iter.next = function () { return { done: safe = true }; }; |
|
arr[ITERATOR$3] = function () { return iter; }; |
|
exec(arr); |
|
} catch (e) { /* empty */ } |
|
return safe; |
|
}; |
|
|
|
var task = _task.set; |
|
var microtask = _microtask(); |
|
|
|
|
|
|
|
var PROMISE = 'Promise'; |
|
var TypeError$1 = _global.TypeError; |
|
var process = _global.process; |
|
var $Promise = _global[PROMISE]; |
|
var isNode = _classof(process) == 'process'; |
|
var empty = function () { /* empty */ }; |
|
var Internal; |
|
var newGenericPromiseCapability; |
|
var OwnPromiseCapability; |
|
var Wrapper; |
|
var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f; |
|
|
|
var USE_NATIVE = !!function () { |
|
try { |
|
// correct subclassing with @@species support |
|
var promise = $Promise.resolve(1); |
|
var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) { |
|
exec(empty, empty); |
|
}; |
|
// unhandled rejections tracking support, NodeJS Promise without it fails @@species test |
|
return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise; |
|
} catch (e) { /* empty */ } |
|
}(); |
|
|
|
// helpers |
|
var isThenable = function (it) { |
|
var then; |
|
return _isObject(it) && typeof (then = it.then) == 'function' ? then : false; |
|
}; |
|
var notify = function (promise, isReject) { |
|
if (promise._n) return; |
|
promise._n = true; |
|
var chain = promise._c; |
|
microtask(function () { |
|
var value = promise._v; |
|
var ok = promise._s == 1; |
|
var i = 0; |
|
var run = function (reaction) { |
|
var handler = ok ? reaction.ok : reaction.fail; |
|
var resolve = reaction.resolve; |
|
var reject = reaction.reject; |
|
var domain = reaction.domain; |
|
var result, then; |
|
try { |
|
if (handler) { |
|
if (!ok) { |
|
if (promise._h == 2) onHandleUnhandled(promise); |
|
promise._h = 1; |
|
} |
|
if (handler === true) result = value; |
|
else { |
|
if (domain) domain.enter(); |
|
result = handler(value); |
|
if (domain) domain.exit(); |
|
} |
|
if (result === reaction.promise) { |
|
reject(TypeError$1('Promise-chain cycle')); |
|
} else if (then = isThenable(result)) { |
|
then.call(result, resolve, reject); |
|
} else resolve(result); |
|
} else reject(value); |
|
} catch (e) { |
|
reject(e); |
|
} |
|
}; |
|
while (chain.length > i) run(chain[i++]); // variable length - can't use forEach |
|
promise._c = []; |
|
promise._n = false; |
|
if (isReject && !promise._h) onUnhandled(promise); |
|
}); |
|
}; |
|
var onUnhandled = function (promise) { |
|
task.call(_global, function () { |
|
var value = promise._v; |
|
var unhandled = isUnhandled(promise); |
|
var result, handler, console; |
|
if (unhandled) { |
|
result = _perform(function () { |
|
if (isNode) { |
|
process.emit('unhandledRejection', value, promise); |
|
} else if (handler = _global.onunhandledrejection) { |
|
handler({ promise: promise, reason: value }); |
|
} else if ((console = _global.console) && console.error) { |
|
console.error('Unhandled promise rejection', value); |
|
} |
|
}); |
|
// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should |
|
promise._h = isNode || isUnhandled(promise) ? 2 : 1; |
|
} promise._a = undefined; |
|
if (unhandled && result.e) throw result.v; |
|
}); |
|
}; |
|
var isUnhandled = function (promise) { |
|
return promise._h !== 1 && (promise._a || promise._c).length === 0; |
|
}; |
|
var onHandleUnhandled = function (promise) { |
|
task.call(_global, function () { |
|
var handler; |
|
if (isNode) { |
|
process.emit('rejectionHandled', promise); |
|
} else if (handler = _global.onrejectionhandled) { |
|
handler({ promise: promise, reason: promise._v }); |
|
} |
|
}); |
|
}; |
|
var $reject = function (value) { |
|
var promise = this; |
|
if (promise._d) return; |
|
promise._d = true; |
|
promise = promise._w || promise; // unwrap |
|
promise._v = value; |
|
promise._s = 2; |
|
if (!promise._a) promise._a = promise._c.slice(); |
|
notify(promise, true); |
|
}; |
|
var $resolve = function (value) { |
|
var promise = this; |
|
var then; |
|
if (promise._d) return; |
|
promise._d = true; |
|
promise = promise._w || promise; // unwrap |
|
try { |
|
if (promise === value) throw TypeError$1("Promise can't be resolved itself"); |
|
if (then = isThenable(value)) { |
|
microtask(function () { |
|
var wrapper = { _w: promise, _d: false }; // wrap |
|
try { |
|
then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1)); |
|
} catch (e) { |
|
$reject.call(wrapper, e); |
|
} |
|
}); |
|
} else { |
|
promise._v = value; |
|
promise._s = 1; |
|
notify(promise, false); |
|
} |
|
} catch (e) { |
|
$reject.call({ _w: promise, _d: false }, e); // wrap |
|
} |
|
}; |
|
|
|
// constructor polyfill |
|
if (!USE_NATIVE) { |
|
// 25.4.3.1 Promise(executor) |
|
$Promise = function Promise(executor) { |
|
_anInstance(this, $Promise, PROMISE, '_h'); |
|
_aFunction(executor); |
|
Internal.call(this); |
|
try { |
|
executor(_ctx($resolve, this, 1), _ctx($reject, this, 1)); |
|
} catch (err) { |
|
$reject.call(this, err); |
|
} |
|
}; |
|
// eslint-disable-next-line no-unused-vars |
|
Internal = function Promise(executor) { |
|
this._c = []; // <- awaiting reactions |
|
this._a = undefined; // <- checked in isUnhandled reactions |
|
this._s = 0; // <- state |
|
this._d = false; // <- done |
|
this._v = undefined; // <- value |
|
this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled |
|
this._n = false; // <- notify |
|
}; |
|
Internal.prototype = _redefineAll($Promise.prototype, { |
|
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) |
|
then: function then(onFulfilled, onRejected) { |
|
var reaction = newPromiseCapability(_speciesConstructor(this, $Promise)); |
|
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; |
|
reaction.fail = typeof onRejected == 'function' && onRejected; |
|
reaction.domain = isNode ? process.domain : undefined; |
|
this._c.push(reaction); |
|
if (this._a) this._a.push(reaction); |
|
if (this._s) notify(this, false); |
|
return reaction.promise; |
|
}, |
|
// 25.4.5.1 Promise.prototype.catch(onRejected) |
|
'catch': function (onRejected) { |
|
return this.then(undefined, onRejected); |
|
} |
|
}); |
|
OwnPromiseCapability = function () { |
|
var promise = new Internal(); |
|
this.promise = promise; |
|
this.resolve = _ctx($resolve, promise, 1); |
|
this.reject = _ctx($reject, promise, 1); |
|
}; |
|
_newPromiseCapability.f = newPromiseCapability = function (C) { |
|
return C === $Promise || C === Wrapper |
|
? new OwnPromiseCapability(C) |
|
: newGenericPromiseCapability(C); |
|
}; |
|
} |
|
|
|
_export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise }); |
|
_setToStringTag($Promise, PROMISE); |
|
_setSpecies(PROMISE); |
|
Wrapper = _core[PROMISE]; |
|
|
|
// statics |
|
_export(_export.S + _export.F * !USE_NATIVE, PROMISE, { |
|
// 25.4.4.5 Promise.reject(r) |
|
reject: function reject(r) { |
|
var capability = newPromiseCapability(this); |
|
var $$reject = capability.reject; |
|
$$reject(r); |
|
return capability.promise; |
|
} |
|
}); |
|
_export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, { |
|
// 25.4.4.6 Promise.resolve(x) |
|
resolve: function resolve(x) { |
|
return _promiseResolve(_library && this === Wrapper ? $Promise : this, x); |
|
} |
|
}); |
|
_export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) { |
|
$Promise.all(iter)['catch'](empty); |
|
})), PROMISE, { |
|
// 25.4.4.1 Promise.all(iterable) |
|
all: function all(iterable) { |
|
var C = this; |
|
var capability = newPromiseCapability(C); |
|
var resolve = capability.resolve; |
|
var reject = capability.reject; |
|
var result = _perform(function () { |
|
var values = []; |
|
var index = 0; |
|
var remaining = 1; |
|
_forOf(iterable, false, function (promise) { |
|
var $index = index++; |
|
var alreadyCalled = false; |
|
values.push(undefined); |
|
remaining++; |
|
C.resolve(promise).then(function (value) { |
|
if (alreadyCalled) return; |
|
alreadyCalled = true; |
|
values[$index] = value; |
|
--remaining || resolve(values); |
|
}, reject); |
|
}); |
|
--remaining || resolve(values); |
|
}); |
|
if (result.e) reject(result.v); |
|
return capability.promise; |
|
}, |
|
// 25.4.4.4 Promise.race(iterable) |
|
race: function race(iterable) { |
|
var C = this; |
|
var capability = newPromiseCapability(C); |
|
var reject = capability.reject; |
|
var result = _perform(function () { |
|
_forOf(iterable, false, function (promise) { |
|
C.resolve(promise).then(capability.resolve, reject); |
|
}); |
|
}); |
|
if (result.e) reject(result.v); |
|
return capability.promise; |
|
} |
|
}); |
|
|
|
_export(_export.P + _export.R, 'Promise', { 'finally': function (onFinally) { |
|
var C = _speciesConstructor(this, _core.Promise || _global.Promise); |
|
var isFunction = typeof onFinally == 'function'; |
|
return this.then( |
|
isFunction ? function (x) { |
|
return _promiseResolve(C, onFinally()).then(function () { return x; }); |
|
} : onFinally, |
|
isFunction ? function (e) { |
|
return _promiseResolve(C, onFinally()).then(function () { throw e; }); |
|
} : onFinally |
|
); |
|
} }); |
|
|
|
// https://github.com/tc39/proposal-promise-try |
|
|
|
|
|
|
|
|
|
_export(_export.S, 'Promise', { 'try': function (callbackfn) { |
|
var promiseCapability = _newPromiseCapability.f(this); |
|
var result = _perform(callbackfn); |
|
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); |
|
return promiseCapability.promise; |
|
} }); |
|
|
|
var promise$1 = _core.Promise; |
|
|
|
var promise = createCommonjsModule(function (module) { |
|
module.exports = { "default": promise$1, __esModule: true }; |
|
}); |
|
|
|
var _Promise = unwrapExports(promise); |
|
|
|
// most Object methods by ES6 should accept primitives |
|
|
|
|
|
|
|
var _objectSap = function (KEY, exec) { |
|
var fn = (_core.Object || {})[KEY] || Object[KEY]; |
|
var exp = {}; |
|
exp[KEY] = exec(fn); |
|
_export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp); |
|
}; |
|
|
|
// 19.1.2.14 Object.keys(O) |
|
|
|
|
|
|
|
_objectSap('keys', function () { |
|
return function keys(it) { |
|
return _objectKeys(_toObject(it)); |
|
}; |
|
}); |
|
|
|
var keys$1 = _core.Object.keys; |
|
|
|
var keys = createCommonjsModule(function (module) { |
|
module.exports = { "default": keys$1, __esModule: true }; |
|
}); |
|
|
|
var _Object$keys = unwrapExports(keys); |
|
|
|
var f$4 = _wks; |
|
|
|
var _wksExt = { |
|
f: f$4 |
|
}; |
|
|
|
var iterator$1 = _wksExt.f('iterator'); |
|
|
|
var iterator = createCommonjsModule(function (module) { |
|
module.exports = { "default": iterator$1, __esModule: true }; |
|
}); |
|
|
|
var _Symbol$iterator = unwrapExports(iterator); |
|
|
|
var _meta = createCommonjsModule(function (module) { |
|
var META = _uid('meta'); |
|
|
|
|
|
var setDesc = _objectDp.f; |
|
var id = 0; |
|
var isExtensible = Object.isExtensible || function () { |
|
return true; |
|
}; |
|
var FREEZE = !_fails(function () { |
|
return isExtensible(Object.preventExtensions({})); |
|
}); |
|
var setMeta = function (it) { |
|
setDesc(it, META, { value: { |
|
i: 'O' + ++id, // object ID |
|
w: {} // weak collections IDs |
|
} }); |
|
}; |
|
var fastKey = function (it, create) { |
|
// return primitive with prefix |
|
if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; |
|
if (!_has(it, META)) { |
|
// can't set metadata to uncaught frozen object |
|
if (!isExtensible(it)) return 'F'; |
|
// not necessary to add metadata |
|
if (!create) return 'E'; |
|
// add missing metadata |
|
setMeta(it); |
|
// return object ID |
|
} return it[META].i; |
|
}; |
|
var getWeak = function (it, create) { |
|
if (!_has(it, META)) { |
|
// can't set metadata to uncaught frozen object |
|
if (!isExtensible(it)) return true; |
|
// not necessary to add metadata |
|
if (!create) return false; |
|
// add missing metadata |
|
setMeta(it); |
|
// return hash weak collections IDs |
|
} return it[META].w; |
|
}; |
|
// add metadata on freeze-family methods calling |
|
var onFreeze = function (it) { |
|
if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it); |
|
return it; |
|
}; |
|
var meta = module.exports = { |
|
KEY: META, |
|
NEED: false, |
|
fastKey: fastKey, |
|
getWeak: getWeak, |
|
onFreeze: onFreeze |
|
}; |
|
}); |
|
|
|
var _meta_1 = _meta.KEY; |
|
var _meta_2 = _meta.NEED; |
|
var _meta_3 = _meta.fastKey; |
|
var _meta_4 = _meta.getWeak; |
|
var _meta_5 = _meta.onFreeze; |
|
|
|
var defineProperty = _objectDp.f; |
|
var _wksDefine = function (name) { |
|
var $Symbol = _core.Symbol || (_core.Symbol = _library ? {} : _global.Symbol || {}); |
|
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: _wksExt.f(name) }); |
|
}; |
|
|
|
// all enumerable object keys, includes symbols |
|
|
|
|
|
|
|
var _enumKeys = function (it) { |
|
var result = _objectKeys(it); |
|
var getSymbols = _objectGops.f; |
|
if (getSymbols) { |
|
var symbols = getSymbols(it); |
|
var isEnum = _objectPie.f; |
|
var i = 0; |
|
var key; |
|
while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key); |
|
} return result; |
|
}; |
|
|
|
// 7.2.2 IsArray(argument) |
|
|
|
var _isArray = Array.isArray || function isArray(arg) { |
|
return _cof(arg) == 'Array'; |
|
}; |
|
|
|
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) |
|
|
|
var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); |
|
|
|
var f$6 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { |
|
return _objectKeysInternal(O, hiddenKeys); |
|
}; |
|
|
|
var _objectGopn = { |
|
f: f$6 |
|
}; |
|
|
|
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window |
|
|
|
var gOPN$1 = _objectGopn.f; |
|
var toString$2 = {}.toString; |
|
|
|
var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames |
|
? Object.getOwnPropertyNames(window) : []; |
|
|
|
var getWindowNames = function (it) { |
|
try { |
|
return gOPN$1(it); |
|
} catch (e) { |
|
return windowNames.slice(); |
|
} |
|
}; |
|
|
|
var f$5 = function getOwnPropertyNames(it) { |
|
return windowNames && toString$2.call(it) == '[object Window]' ? getWindowNames(it) : gOPN$1(_toIobject(it)); |
|
}; |
|
|
|
var _objectGopnExt = { |
|
f: f$5 |
|
}; |
|
|
|
var gOPD$1 = Object.getOwnPropertyDescriptor; |
|
|
|
var f$7 = _descriptors ? gOPD$1 : function getOwnPropertyDescriptor(O, P) { |
|
O = _toIobject(O); |
|
P = _toPrimitive(P, true); |
|
if (_ie8DomDefine) try { |
|
return gOPD$1(O, P); |
|
} catch (e) { /* empty */ } |
|
if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); |
|
}; |
|
|
|
var _objectGopd = { |
|
f: f$7 |
|
}; |
|
|
|
// ECMAScript 6 symbols shim |
|
|
|
|
|
|
|
|
|
|
|
var META = _meta.KEY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var gOPD = _objectGopd.f; |
|
var dP$1 = _objectDp.f; |
|
var gOPN = _objectGopnExt.f; |
|
var $Symbol = _global.Symbol; |
|
var $JSON = _global.JSON; |
|
var _stringify = $JSON && $JSON.stringify; |
|
var PROTOTYPE$2 = 'prototype'; |
|
var HIDDEN = _wks('_hidden'); |
|
var TO_PRIMITIVE = _wks('toPrimitive'); |
|
var isEnum = {}.propertyIsEnumerable; |
|
var SymbolRegistry = _shared('symbol-registry'); |
|
var AllSymbols = _shared('symbols'); |
|
var OPSymbols = _shared('op-symbols'); |
|
var ObjectProto$1 = Object[PROTOTYPE$2]; |
|
var USE_NATIVE$1 = typeof $Symbol == 'function'; |
|
var QObject = _global.QObject; |
|
// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 |
|
var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild; |
|
|
|
// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 |
|
var setSymbolDesc = _descriptors && _fails(function () { |
|
return _objectCreate(dP$1({}, 'a', { |
|
get: function () { return dP$1(this, 'a', { value: 7 }).a; } |
|
})).a != 7; |
|
}) ? function (it, key, D) { |
|
var protoDesc = gOPD(ObjectProto$1, key); |
|
if (protoDesc) delete ObjectProto$1[key]; |
|
dP$1(it, key, D); |
|
if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc); |
|
} : dP$1; |
|
|
|
var wrap = function (tag) { |
|
var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]); |
|
sym._k = tag; |
|
return sym; |
|
}; |
|
|
|
var isSymbol = USE_NATIVE$1 && typeof $Symbol.iterator == 'symbol' ? function (it) { |
|
return typeof it == 'symbol'; |
|
} : function (it) { |
|
return it instanceof $Symbol; |
|
}; |
|
|
|
var $defineProperty$1 = function defineProperty(it, key, D) { |
|
if (it === ObjectProto$1) $defineProperty$1(OPSymbols, key, D); |
|
_anObject(it); |
|
key = _toPrimitive(key, true); |
|
_anObject(D); |
|
if (_has(AllSymbols, key)) { |
|
if (!D.enumerable) { |
|
if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {})); |
|
it[HIDDEN][key] = true; |
|
} else { |
|
if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; |
|
D = _objectCreate(D, { enumerable: _propertyDesc(0, false) }); |
|
} return setSymbolDesc(it, key, D); |
|
} return dP$1(it, key, D); |
|
}; |
|
var $defineProperties = function defineProperties(it, P) { |
|
_anObject(it); |
|
var keys = _enumKeys(P = _toIobject(P)); |
|
var i = 0; |
|
var l = keys.length; |
|
var key; |
|
while (l > i) $defineProperty$1(it, key = keys[i++], P[key]); |
|
return it; |
|
}; |
|
var $create = function create(it, P) { |
|
return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P); |
|
}; |
|
var $propertyIsEnumerable = function propertyIsEnumerable(key) { |
|
var E = isEnum.call(this, key = _toPrimitive(key, true)); |
|
if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false; |
|
return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true; |
|
}; |
|
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { |
|
it = _toIobject(it); |
|
key = _toPrimitive(key, true); |
|
if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return; |
|
var D = gOPD(it, key); |
|
if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; |
|
return D; |
|
}; |
|
var $getOwnPropertyNames = function getOwnPropertyNames(it) { |
|
var names = gOPN(_toIobject(it)); |
|
var result = []; |
|
var i = 0; |
|
var key; |
|
while (names.length > i) { |
|
if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); |
|
} return result; |
|
}; |
|
var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { |
|
var IS_OP = it === ObjectProto$1; |
|
var names = gOPN(IS_OP ? OPSymbols : _toIobject(it)); |
|
var result = []; |
|
var i = 0; |
|
var key; |
|
while (names.length > i) { |
|
if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]); |
|
} return result; |
|
}; |
|
|
|
// 19.4.1.1 Symbol([description]) |
|
if (!USE_NATIVE$1) { |
|
$Symbol = function Symbol() { |
|
if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); |
|
var tag = _uid(arguments.length > 0 ? arguments[0] : undefined); |
|
var $set = function (value) { |
|
if (this === ObjectProto$1) $set.call(OPSymbols, value); |
|
if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; |
|
setSymbolDesc(this, tag, _propertyDesc(1, value)); |
|
}; |
|
if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set }); |
|
return wrap(tag); |
|
}; |
|
_redefine($Symbol[PROTOTYPE$2], 'toString', function toString() { |
|
return this._k; |
|
}); |
|
|
|
_objectGopd.f = $getOwnPropertyDescriptor; |
|
_objectDp.f = $defineProperty$1; |
|
_objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames; |
|
_objectPie.f = $propertyIsEnumerable; |
|
_objectGops.f = $getOwnPropertySymbols; |
|
|
|
if (_descriptors && !_library) { |
|
_redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true); |
|
} |
|
|
|
_wksExt.f = function (name) { |
|
return wrap(_wks(name)); |
|
}; |
|
} |
|
|
|
_export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { Symbol: $Symbol }); |
|
|
|
for (var es6Symbols = ( |
|
// 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 |
|
'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' |
|
).split(','), j = 0; es6Symbols.length > j;)_wks(es6Symbols[j++]); |
|
|
|
for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]); |
|
|
|
_export(_export.S + _export.F * !USE_NATIVE$1, 'Symbol', { |
|
// 19.4.2.1 Symbol.for(key) |
|
'for': function (key) { |
|
return _has(SymbolRegistry, key += '') |
|
? SymbolRegistry[key] |
|
: SymbolRegistry[key] = $Symbol(key); |
|
}, |
|
// 19.4.2.5 Symbol.keyFor(sym) |
|
keyFor: function keyFor(sym) { |
|
if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); |
|
for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key; |
|
}, |
|
useSetter: function () { setter = true; }, |
|
useSimple: function () { setter = false; } |
|
}); |
|
|
|
_export(_export.S + _export.F * !USE_NATIVE$1, 'Object', { |
|
// 19.1.2.2 Object.create(O [, Properties]) |
|
create: $create, |
|
// 19.1.2.4 Object.defineProperty(O, P, Attributes) |
|
defineProperty: $defineProperty$1, |
|
// 19.1.2.3 Object.defineProperties(O, Properties) |
|
defineProperties: $defineProperties, |
|
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) |
|
getOwnPropertyDescriptor: $getOwnPropertyDescriptor, |
|
// 19.1.2.7 Object.getOwnPropertyNames(O) |
|
getOwnPropertyNames: $getOwnPropertyNames, |
|
// 19.1.2.8 Object.getOwnPropertySymbols(O) |
|
getOwnPropertySymbols: $getOwnPropertySymbols |
|
}); |
|
|
|
// 24.3.2 JSON.stringify(value [, replacer [, space]]) |
|
$JSON && _export(_export.S + _export.F * (!USE_NATIVE$1 || _fails(function () { |
|
var S = $Symbol(); |
|
// MS Edge converts symbol values to JSON as {} |
|
// WebKit converts symbol values to JSON as null |
|
// V8 throws on boxed symbols |
|
return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; |
|
})), 'JSON', { |
|
stringify: function stringify(it) { |
|
var args = [it]; |
|
var i = 1; |
|
var replacer, $replacer; |
|
while (arguments.length > i) args.push(arguments[i++]); |
|
$replacer = replacer = args[1]; |
|
if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined |
|
if (!_isArray(replacer)) replacer = function (key, value) { |
|
if (typeof $replacer == 'function') value = $replacer.call(this, key, value); |
|
if (!isSymbol(value)) return value; |
|
}; |
|
args[1] = replacer; |
|
return _stringify.apply($JSON, args); |
|
} |
|
}); |
|
|
|
// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) |
|
$Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf); |
|
// 19.4.3.5 Symbol.prototype[@@toStringTag] |
|
_setToStringTag($Symbol, 'Symbol'); |
|
// 20.2.1.9 Math[@@toStringTag] |
|
_setToStringTag(Math, 'Math', true); |
|
// 24.3.3 JSON[@@toStringTag] |
|
_setToStringTag(_global.JSON, 'JSON', true); |
|
|
|
_wksDefine('asyncIterator'); |
|
|
|
_wksDefine('observable'); |
|
|
|
var symbol$1 = _core.Symbol; |
|
|
|
var symbol = createCommonjsModule(function (module) { |
|
module.exports = { "default": symbol$1, __esModule: true }; |
|
}); |
|
|
|
var _Symbol = unwrapExports(symbol); |
|
|
|
var _typeof_1 = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
|
|
|
|
var _iterator2 = _interopRequireDefault(iterator); |
|
|
|
|
|
|
|
var _symbol2 = _interopRequireDefault(symbol); |
|
|
|
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; }; |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) { |
|
return typeof obj === "undefined" ? "undefined" : _typeof(obj); |
|
} : function (obj) { |
|
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); |
|
}; |
|
}); |
|
|
|
var _typeof = unwrapExports(_typeof_1); |
|
|
|
// 19.1.2.9 Object.getPrototypeOf(O) |
|
|
|
|
|
|
|
_objectSap('getPrototypeOf', function () { |
|
return function getPrototypeOf(it) { |
|
return _objectGpo(_toObject(it)); |
|
}; |
|
}); |
|
|
|
var getPrototypeOf$1 = _core.Object.getPrototypeOf; |
|
|
|
var getPrototypeOf = createCommonjsModule(function (module) { |
|
module.exports = { "default": getPrototypeOf$1, __esModule: true }; |
|
}); |
|
|
|
var _Object$getPrototypeOf = unwrapExports(getPrototypeOf); |
|
|
|
var classCallCheck = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
exports.default = function (instance, Constructor) { |
|
if (!(instance instanceof Constructor)) { |
|
throw new TypeError("Cannot call a class as a function"); |
|
} |
|
}; |
|
}); |
|
|
|
var _classCallCheck = unwrapExports(classCallCheck); |
|
|
|
var possibleConstructorReturn = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof_1); |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
exports.default = function (self, call) { |
|
if (!self) { |
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
|
} |
|
|
|
return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; |
|
}; |
|
}); |
|
|
|
var _possibleConstructorReturn = unwrapExports(possibleConstructorReturn); |
|
|
|
// Works with __proto__ only. Old v8 can't work with null proto objects. |
|
/* eslint-disable no-proto */ |
|
|
|
|
|
var check = function (O, proto) { |
|
_anObject(O); |
|
if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); |
|
}; |
|
var _setProto = { |
|
set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line |
|
function (test, buggy, set) { |
|
try { |
|
set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2); |
|
set(test, []); |
|
buggy = !(test instanceof Array); |
|
} catch (e) { buggy = true; } |
|
return function setPrototypeOf(O, proto) { |
|
check(O, proto); |
|
if (buggy) O.__proto__ = proto; |
|
else set(O, proto); |
|
return O; |
|
}; |
|
}({}, false) : undefined), |
|
check: check |
|
}; |
|
|
|
// 19.1.3.19 Object.setPrototypeOf(O, proto) |
|
|
|
_export(_export.S, 'Object', { setPrototypeOf: _setProto.set }); |
|
|
|
var setPrototypeOf$2 = _core.Object.setPrototypeOf; |
|
|
|
var setPrototypeOf = createCommonjsModule(function (module) { |
|
module.exports = { "default": setPrototypeOf$2, __esModule: true }; |
|
}); |
|
|
|
unwrapExports(setPrototypeOf); |
|
|
|
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) |
|
_export(_export.S, 'Object', { create: _objectCreate }); |
|
|
|
var $Object = _core.Object; |
|
var create$2 = function create(P, D) { |
|
return $Object.create(P, D); |
|
}; |
|
|
|
var create$1 = createCommonjsModule(function (module) { |
|
module.exports = { "default": create$2, __esModule: true }; |
|
}); |
|
|
|
var _Object$create = unwrapExports(create$1); |
|
|
|
var inherits = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
|
|
|
|
var _setPrototypeOf2 = _interopRequireDefault(setPrototypeOf); |
|
|
|
|
|
|
|
var _create2 = _interopRequireDefault(create$1); |
|
|
|
|
|
|
|
var _typeof3 = _interopRequireDefault(_typeof_1); |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
exports.default = function (subClass, superClass) { |
|
if (typeof superClass !== "function" && superClass !== null) { |
|
throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); |
|
} |
|
|
|
subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { |
|
constructor: { |
|
value: subClass, |
|
enumerable: false, |
|
writable: true, |
|
configurable: true |
|
} |
|
}); |
|
if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; |
|
}; |
|
}); |
|
|
|
var _inherits = unwrapExports(inherits); |
|
|
|
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) |
|
_export(_export.S + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f }); |
|
|
|
var $Object$1 = _core.Object; |
|
var defineProperty$3 = function defineProperty(it, key, desc) { |
|
return $Object$1.defineProperty(it, key, desc); |
|
}; |
|
|
|
var defineProperty$2 = createCommonjsModule(function (module) { |
|
module.exports = { "default": defineProperty$3, __esModule: true }; |
|
}); |
|
|
|
var _Object$defineProperty = unwrapExports(defineProperty$2); |
|
|
|
var defineProperty$1 = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
|
|
|
|
var _defineProperty2 = _interopRequireDefault(defineProperty$2); |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
exports.default = function (obj, key, value) { |
|
if (key in obj) { |
|
(0, _defineProperty2.default)(obj, key, { |
|
value: value, |
|
enumerable: true, |
|
configurable: true, |
|
writable: true |
|
}); |
|
} else { |
|
obj[key] = value; |
|
} |
|
|
|
return obj; |
|
}; |
|
}); |
|
|
|
var _defineProperty = unwrapExports(defineProperty$1); |
|
|
|
var core_getIterator = _core.getIterator = function (it) { |
|
var iterFn = core_getIteratorMethod(it); |
|
if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!'); |
|
return _anObject(iterFn.call(it)); |
|
}; |
|
|
|
var getIterator$1 = core_getIterator; |
|
|
|
var getIterator = createCommonjsModule(function (module) { |
|
module.exports = { "default": getIterator$1, __esModule: true }; |
|
}); |
|
|
|
var _getIterator = unwrapExports(getIterator); |
|
|
|
var _validateCollection = function (it, TYPE) { |
|
if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); |
|
return it; |
|
}; |
|
|
|
var dP$2 = _objectDp.f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fastKey = _meta.fastKey; |
|
|
|
var SIZE = _descriptors ? '_s' : 'size'; |
|
|
|
var getEntry = function (that, key) { |
|
// fast case |
|
var index = fastKey(key); |
|
var entry; |
|
if (index !== 'F') return that._i[index]; |
|
// frozen object case |
|
for (entry = that._f; entry; entry = entry.n) { |
|
if (entry.k == key) return entry; |
|
} |
|
}; |
|
|
|
var _collectionStrong = { |
|
getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { |
|
var C = wrapper(function (that, iterable) { |
|
_anInstance(that, C, NAME, '_i'); |
|
that._t = NAME; // collection type |
|
that._i = _objectCreate(null); // index |
|
that._f = undefined; // first entry |
|
that._l = undefined; // last entry |
|
that[SIZE] = 0; // size |
|
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); |
|
}); |
|
_redefineAll(C.prototype, { |
|
// 23.1.3.1 Map.prototype.clear() |
|
// 23.2.3.2 Set.prototype.clear() |
|
clear: function clear() { |
|
for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { |
|
entry.r = true; |
|
if (entry.p) entry.p = entry.p.n = undefined; |
|
delete data[entry.i]; |
|
} |
|
that._f = that._l = undefined; |
|
that[SIZE] = 0; |
|
}, |
|
// 23.1.3.3 Map.prototype.delete(key) |
|
// 23.2.3.4 Set.prototype.delete(value) |
|
'delete': function (key) { |
|
var that = _validateCollection(this, NAME); |
|
var entry = getEntry(that, key); |
|
if (entry) { |
|
var next = entry.n; |
|
var prev = entry.p; |
|
delete that._i[entry.i]; |
|
entry.r = true; |
|
if (prev) prev.n = next; |
|
if (next) next.p = prev; |
|
if (that._f == entry) that._f = next; |
|
if (that._l == entry) that._l = prev; |
|
that[SIZE]--; |
|
} return !!entry; |
|
}, |
|
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) |
|
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) |
|
forEach: function forEach(callbackfn /* , that = undefined */) { |
|
_validateCollection(this, NAME); |
|
var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); |
|
var entry; |
|
while (entry = entry ? entry.n : this._f) { |
|
f(entry.v, entry.k, this); |
|
// revert to the last existing entry |
|
while (entry && entry.r) entry = entry.p; |
|
} |
|
}, |
|
// 23.1.3.7 Map.prototype.has(key) |
|
// 23.2.3.7 Set.prototype.has(value) |
|
has: function has(key) { |
|
return !!getEntry(_validateCollection(this, NAME), key); |
|
} |
|
}); |
|
if (_descriptors) dP$2(C.prototype, 'size', { |
|
get: function () { |
|
return _validateCollection(this, NAME)[SIZE]; |
|
} |
|
}); |
|
return C; |
|
}, |
|
def: function (that, key, value) { |
|
var entry = getEntry(that, key); |
|
var prev, index; |
|
// change existing entry |
|
if (entry) { |
|
entry.v = value; |
|
// create new entry |
|
} else { |
|
that._l = entry = { |
|
i: index = fastKey(key, true), // <- index |
|
k: key, // <- key |
|
v: value, // <- value |
|
p: prev = that._l, // <- previous entry |
|
n: undefined, // <- next entry |
|
r: false // <- removed |
|
}; |
|
if (!that._f) that._f = entry; |
|
if (prev) prev.n = entry; |
|
that[SIZE]++; |
|
// add to index |
|
if (index !== 'F') that._i[index] = entry; |
|
} return that; |
|
}, |
|
getEntry: getEntry, |
|
setStrong: function (C, NAME, IS_MAP) { |
|
// add .keys, .values, .entries, [@@iterator] |
|
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 |
|
_iterDefine(C, NAME, function (iterated, kind) { |
|
this._t = _validateCollection(iterated, NAME); // target |
|
this._k = kind; // kind |
|
this._l = undefined; // previous |
|
}, function () { |
|
var that = this; |
|
var kind = that._k; |
|
var entry = that._l; |
|
// revert to the last existing entry |
|
while (entry && entry.r) entry = entry.p; |
|
// get next entry |
|
if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { |
|
// or finish the iteration |
|
that._t = undefined; |
|
return _iterStep(1); |
|
} |
|
// return step by kind |
|
if (kind == 'keys') return _iterStep(0, entry.k); |
|
if (kind == 'values') return _iterStep(0, entry.v); |
|
return _iterStep(0, [entry.k, entry.v]); |
|
}, IS_MAP ? 'entries' : 'values', !IS_MAP, true); |
|
|
|
// add [@@species], 23.1.2.2, 23.2.2.2 |
|
_setSpecies(NAME); |
|
} |
|
}; |
|
|
|
var SPECIES$2 = _wks('species'); |
|
|
|
var _arraySpeciesConstructor = function (original) { |
|
var C; |
|
if (_isArray(original)) { |
|
C = original.constructor; |
|
// cross-realm fallback |
|
if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined; |
|
if (_isObject(C)) { |
|
C = C[SPECIES$2]; |
|
if (C === null) C = undefined; |
|
} |
|
} return C === undefined ? Array : C; |
|
}; |
|
|
|
// 9.4.2.3 ArraySpeciesCreate(originalArray, length) |
|
|
|
|
|
var _arraySpeciesCreate = function (original, length) { |
|
return new (_arraySpeciesConstructor(original))(length); |
|
}; |
|
|
|
// 0 -> Array#forEach |
|
// 1 -> Array#map |
|
// 2 -> Array#filter |
|
// 3 -> Array#some |
|
// 4 -> Array#every |
|
// 5 -> Array#find |
|
// 6 -> Array#findIndex |
|
|
|
|
|
|
|
|
|
|
|
var _arrayMethods = function (TYPE, $create) { |
|
var IS_MAP = TYPE == 1; |
|
var IS_FILTER = TYPE == 2; |
|
var IS_SOME = TYPE == 3; |
|
var IS_EVERY = TYPE == 4; |
|
var IS_FIND_INDEX = TYPE == 6; |
|
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; |
|
var create = $create || _arraySpeciesCreate; |
|
return function ($this, callbackfn, that) { |
|
var O = _toObject($this); |
|
var self = _iobject(O); |
|
var f = _ctx(callbackfn, that, 3); |
|
var length = _toLength(self.length); |
|
var index = 0; |
|
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; |
|
var val, res; |
|
for (;length > index; index++) if (NO_HOLES || index in self) { |
|
val = self[index]; |
|
res = f(val, index, O); |
|
if (TYPE) { |
|
if (IS_MAP) result[index] = res; // map |
|
else if (res) switch (TYPE) { |
|
case 3: return true; // some |
|
case 5: return val; // find |
|
case 6: return index; // findIndex |
|
case 2: result.push(val); // filter |
|
} else if (IS_EVERY) return false; // every |
|
} |
|
} |
|
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; |
|
}; |
|
}; |
|
|
|
var dP$3 = _objectDp.f; |
|
var each = _arrayMethods(0); |
|
|
|
|
|
var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { |
|
var Base = _global[NAME]; |
|
var C = Base; |
|
var ADDER = IS_MAP ? 'set' : 'add'; |
|
var proto = C && C.prototype; |
|
var O = {}; |
|
if (!_descriptors || typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () { |
|
new C().entries().next(); |
|
}))) { |
|
// create collection constructor |
|
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); |
|
_redefineAll(C.prototype, methods); |
|
_meta.NEED = true; |
|
} else { |
|
C = wrapper(function (target, iterable) { |
|
_anInstance(target, C, NAME, '_c'); |
|
target._c = new Base(); |
|
if (iterable != undefined) _forOf(iterable, IS_MAP, target[ADDER], target); |
|
}); |
|
each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) { |
|
var IS_ADDER = KEY == 'add' || KEY == 'set'; |
|
if (KEY in proto && !(IS_WEAK && KEY == 'clear')) _hide(C.prototype, KEY, function (a, b) { |
|
_anInstance(this, C, KEY); |
|
if (!IS_ADDER && IS_WEAK && !_isObject(a)) return KEY == 'get' ? undefined : false; |
|
var result = this._c[KEY](a === 0 ? 0 : a, b); |
|
return IS_ADDER ? this : result; |
|
}); |
|
}); |
|
IS_WEAK || dP$3(C.prototype, 'size', { |
|
get: function () { |
|
return this._c.size; |
|
} |
|
}); |
|
} |
|
|
|
_setToStringTag(C, NAME); |
|
|
|
O[NAME] = C; |
|
_export(_export.G + _export.W + _export.F, O); |
|
|
|
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); |
|
|
|
return C; |
|
}; |
|
|
|
var MAP = 'Map'; |
|
|
|
// 23.1 Map Objects |
|
var es6_map = _collection(MAP, function (get) { |
|
return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; |
|
}, { |
|
// 23.1.3.6 Map.prototype.get(key) |
|
get: function get(key) { |
|
var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key); |
|
return entry && entry.v; |
|
}, |
|
// 23.1.3.9 Map.prototype.set(key, value) |
|
set: function set(key, value) { |
|
return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value); |
|
} |
|
}, _collectionStrong, true); |
|
|
|
var _arrayFromIterable = function (iter, ITERATOR) { |
|
var result = []; |
|
_forOf(iter, false, result.push, result, ITERATOR); |
|
return result; |
|
}; |
|
|
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON |
|
|
|
|
|
var _collectionToJson = function (NAME) { |
|
return function toJSON() { |
|
if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic"); |
|
return _arrayFromIterable(this); |
|
}; |
|
}; |
|
|
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON |
|
|
|
|
|
_export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') }); |
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/ |
|
|
|
|
|
var _setCollectionOf = function (COLLECTION) { |
|
_export(_export.S, COLLECTION, { of: function of() { |
|
var length = arguments.length; |
|
var A = new Array(length); |
|
while (length--) A[length] = arguments[length]; |
|
return new this(A); |
|
} }); |
|
}; |
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of |
|
_setCollectionOf('Map'); |
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/ |
|
|
|
|
|
|
|
|
|
|
|
var _setCollectionFrom = function (COLLECTION) { |
|
_export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) { |
|
var mapFn = arguments[1]; |
|
var mapping, A, n, cb; |
|
_aFunction(this); |
|
mapping = mapFn !== undefined; |
|
if (mapping) _aFunction(mapFn); |
|
if (source == undefined) return new this(); |
|
A = []; |
|
if (mapping) { |
|
n = 0; |
|
cb = _ctx(mapFn, arguments[2], 2); |
|
_forOf(source, false, function (nextItem) { |
|
A.push(cb(nextItem, n++)); |
|
}); |
|
} else { |
|
_forOf(source, false, A.push, A); |
|
} |
|
return new this(A); |
|
} }); |
|
}; |
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from |
|
_setCollectionFrom('Map'); |
|
|
|
var map$1 = _core.Map; |
|
|
|
var map = createCommonjsModule(function (module) { |
|
module.exports = { "default": map$1, __esModule: true }; |
|
}); |
|
|
|
var _Map = unwrapExports(map); |
|
|
|
var colorName = { |
|
"aliceblue": [240, 248, 255], |
|
"antiquewhite": [250, 235, 215], |
|
"aqua": [0, 255, 255], |
|
"aquamarine": [127, 255, 212], |
|
"azure": [240, 255, 255], |
|
"beige": [245, 245, 220], |
|
"bisque": [255, 228, 196], |
|
"black": [0, 0, 0], |
|
"blanchedalmond": [255, 235, 205], |
|
"blue": [0, 0, 255], |
|
"blueviolet": [138, 43, 226], |
|
"brown": [165, 42, 42], |
|
"burlywood": [222, 184, 135], |
|
"cadetblue": [95, 158, 160], |
|
"chartreuse": [127, 255, 0], |
|
"chocolate": [210, 105, 30], |
|
"coral": [255, 127, 80], |
|
"cornflowerblue": [100, 149, 237], |
|
"cornsilk": [255, 248, 220], |
|
"crimson": [220, 20, 60], |
|
"cyan": [0, 255, 255], |
|
"darkblue": [0, 0, 139], |
|
"darkcyan": [0, 139, 139], |
|
"darkgoldenrod": [184, 134, 11], |
|
"darkgray": [169, 169, 169], |
|
"darkgreen": [0, 100, 0], |
|
"darkgrey": [169, 169, 169], |
|
"darkkhaki": [189, 183, 107], |
|
"darkmagenta": [139, 0, 139], |
|
"darkolivegreen": [85, 107, 47], |
|
"darkorange": [255, 140, 0], |
|
"darkorchid": [153, 50, 204], |
|
"darkred": [139, 0, 0], |
|
"darksalmon": [233, 150, 122], |
|
"darkseagreen": [143, 188, 143], |
|
"darkslateblue": [72, 61, 139], |
|
"darkslategray": [47, 79, 79], |
|
"darkslategrey": [47, 79, 79], |
|
"darkturquoise": [0, 206, 209], |
|
"darkviolet": [148, 0, 211], |
|
"deeppink": [255, 20, 147], |
|
"deepskyblue": [0, 191, 255], |
|
"dimgray": [105, 105, 105], |
|
"dimgrey": [105, 105, 105], |
|
"dodgerblue": [30, 144, 255], |
|
"firebrick": [178, 34, 34], |
|
"floralwhite": [255, 250, 240], |
|
"forestgreen": [34, 139, 34], |
|
"fuchsia": [255, 0, 255], |
|
"gainsboro": [220, 220, 220], |
|
"ghostwhite": [248, 248, 255], |
|
"gold": [255, 215, 0], |
|
"goldenrod": [218, 165, 32], |
|
"gray": [128, 128, 128], |
|
"green": [0, 128, 0], |
|
"greenyellow": [173, 255, 47], |
|
"grey": [128, 128, 128], |
|
"honeydew": [240, 255, 240], |
|
"hotpink": [255, 105, 180], |
|
"indianred": [205, 92, 92], |
|
"indigo": [75, 0, 130], |
|
"ivory": [255, 255, 240], |
|
"khaki": [240, 230, 140], |
|
"lavender": [230, 230, 250], |
|
"lavenderblush": [255, 240, 245], |
|
"lawngreen": [124, 252, 0], |
|
"lemonchiffon": [255, 250, 205], |
|
"lightblue": [173, 216, 230], |
|
"lightcoral": [240, 128, 128], |
|
"lightcyan": [224, 255, 255], |
|
"lightgoldenrodyellow": [250, 250, 210], |
|
"lightgray": [211, 211, 211], |
|
"lightgreen": [144, 238, 144], |
|
"lightgrey": [211, 211, 211], |
|
"lightpink": [255, 182, 193], |
|
"lightsalmon": [255, 160, 122], |
|
"lightseagreen": [32, 178, 170], |
|
"lightskyblue": [135, 206, 250], |
|
"lightslategray": [119, 136, 153], |
|
"lightslategrey": [119, 136, 153], |
|
"lightsteelblue": [176, 196, 222], |
|
"lightyellow": [255, 255, 224], |
|
"lime": [0, 255, 0], |
|
"limegreen": [50, 205, 50], |
|
"linen": [250, 240, 230], |
|
"magenta": [255, 0, 255], |
|
"maroon": [128, 0, 0], |
|
"mediumaquamarine": [102, 205, 170], |
|
"mediumblue": [0, 0, 205], |
|
"mediumorchid": [186, 85, 211], |
|
"mediumpurple": [147, 112, 219], |
|
"mediumseagreen": [60, 179, 113], |
|
"mediumslateblue": [123, 104, 238], |
|
"mediumspringgreen": [0, 250, 154], |
|
"mediumturquoise": [72, 209, 204], |
|
"mediumvioletred": [199, 21, 133], |
|
"midnightblue": [25, 25, 112], |
|
"mintcream": [245, 255, 250], |
|
"mistyrose": [255, 228, 225], |
|
"moccasin": [255, 228, 181], |
|
"navajowhite": [255, 222, 173], |
|
"navy": [0, 0, 128], |
|
"oldlace": [253, 245, 230], |
|
"olive": [128, 128, 0], |
|
"olivedrab": [107, 142, 35], |
|
"orange": [255, 165, 0], |
|
"orangered": [255, 69, 0], |
|
"orchid": [218, 112, 214], |
|
"palegoldenrod": [238, 232, 170], |
|
"palegreen": [152, 251, 152], |
|
"paleturquoise": [175, 238, 238], |
|
"palevioletred": [219, 112, 147], |
|
"papayawhip": [255, 239, 213], |
|
"peachpuff": [255, 218, 185], |
|
"peru": [205, 133, 63], |
|
"pink": [255, 192, 203], |
|
"plum": [221, 160, 221], |
|
"powderblue": [176, 224, 230], |
|
"purple": [128, 0, 128], |
|
"rebeccapurple": [102, 51, 153], |
|
"red": [255, 0, 0], |
|
"rosybrown": [188, 143, 143], |
|
"royalblue": [65, 105, 225], |
|
"saddlebrown": [139, 69, 19], |
|
"salmon": [250, 128, 114], |
|
"sandybrown": [244, 164, 96], |
|
"seagreen": [46, 139, 87], |
|
"seashell": [255, 245, 238], |
|
"sienna": [160, 82, 45], |
|
"silver": [192, 192, 192], |
|
"skyblue": [135, 206, 235], |
|
"slateblue": [106, 90, 205], |
|
"slategray": [112, 128, 144], |
|
"slategrey": [112, 128, 144], |
|
"snow": [255, 250, 250], |
|
"springgreen": [0, 255, 127], |
|
"steelblue": [70, 130, 180], |
|
"tan": [210, 180, 140], |
|
"teal": [0, 128, 128], |
|
"thistle": [216, 191, 216], |
|
"tomato": [255, 99, 71], |
|
"turquoise": [64, 224, 208], |
|
"violet": [238, 130, 238], |
|
"wheat": [245, 222, 179], |
|
"white": [255, 255, 255], |
|
"whitesmoke": [245, 245, 245], |
|
"yellow": [255, 255, 0], |
|
"yellowgreen": [154, 205, 50] |
|
}; |
|
|
|
var conversions = createCommonjsModule(function (module) { |
|
/* MIT license */ |
|
|
|
|
|
// NOTE: conversions should only return primitive values (i.e. arrays, or |
|
// values that give correct `typeof` results). |
|
// do not use box values types (i.e. Number(), String(), etc.) |
|
|
|
var reverseKeywords = {}; |
|
for (var key in colorName) { |
|
if (colorName.hasOwnProperty(key)) { |
|
reverseKeywords[colorName[key]] = key; |
|
} |
|
} |
|
|
|
var convert = module.exports = { |
|
rgb: {channels: 3, labels: 'rgb'}, |
|
hsl: {channels: 3, labels: 'hsl'}, |
|
hsv: {channels: 3, labels: 'hsv'}, |
|
hwb: {channels: 3, labels: 'hwb'}, |
|
cmyk: {channels: 4, labels: 'cmyk'}, |
|
xyz: {channels: 3, labels: 'xyz'}, |
|
lab: {channels: 3, labels: 'lab'}, |
|
lch: {channels: 3, labels: 'lch'}, |
|
hex: {channels: 1, labels: ['hex']}, |
|
keyword: {channels: 1, labels: ['keyword']}, |
|
ansi16: {channels: 1, labels: ['ansi16']}, |
|
ansi256: {channels: 1, labels: ['ansi256']}, |
|
hcg: {channels: 3, labels: ['h', 'c', 'g']}, |
|
apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, |
|
gray: {channels: 1, labels: ['gray']} |
|
}; |
|
|
|
// hide .channels and .labels properties |
|
for (var model in convert) { |
|
if (convert.hasOwnProperty(model)) { |
|
if (!('channels' in convert[model])) { |
|
throw new Error('missing channels property: ' + model); |
|
} |
|
|
|
if (!('labels' in convert[model])) { |
|
throw new Error('missing channel labels property: ' + model); |
|
} |
|
|
|
if (convert[model].labels.length !== convert[model].channels) { |
|
throw new Error('channel and label counts mismatch: ' + model); |
|
} |
|
|
|
var channels = convert[model].channels; |
|
var labels = convert[model].labels; |
|
delete convert[model].channels; |
|
delete convert[model].labels; |
|
Object.defineProperty(convert[model], 'channels', {value: channels}); |
|
Object.defineProperty(convert[model], 'labels', {value: labels}); |
|
} |
|
} |
|
|
|
convert.rgb.hsl = function (rgb) { |
|
var r = rgb[0] / 255; |
|
var g = rgb[1] / 255; |
|
var b = rgb[2] / 255; |
|
var min = Math.min(r, g, b); |
|
var max = Math.max(r, g, b); |
|
var delta = max - min; |
|
var h; |
|
var s; |
|
var l; |
|
|
|
if (max === min) { |
|
h = 0; |
|
} else if (r === max) { |
|
h = (g - b) / delta; |
|
} else if (g === max) { |
|
h = 2 + (b - r) / delta; |
|
} else if (b === max) { |
|
h = 4 + (r - g) / delta; |
|
} |
|
|
|
h = Math.min(h * 60, 360); |
|
|
|
if (h < 0) { |
|
h += 360; |
|
} |
|
|
|
l = (min + max) / 2; |
|
|
|
if (max === min) { |
|
s = 0; |
|
} else if (l <= 0.5) { |
|
s = delta / (max + min); |
|
} else { |
|
s = delta / (2 - max - min); |
|
} |
|
|
|
return [h, s * 100, l * 100]; |
|
}; |
|
|
|
convert.rgb.hsv = function (rgb) { |
|
var r = rgb[0]; |
|
var g = rgb[1]; |
|
var b = rgb[2]; |
|
var min = Math.min(r, g, b); |
|
var max = Math.max(r, g, b); |
|
var delta = max - min; |
|
var h; |
|
var s; |
|
var v; |
|
|
|
if (max === 0) { |
|
s = 0; |
|
} else { |
|
s = (delta / max * 1000) / 10; |
|
} |
|
|
|
if (max === min) { |
|
h = 0; |
|
} else if (r === max) { |
|
h = (g - b) / delta; |
|
} else if (g === max) { |
|
h = 2 + (b - r) / delta; |
|
} else if (b === max) { |
|
h = 4 + (r - g) / delta; |
|
} |
|
|
|
h = Math.min(h * 60, 360); |
|
|
|
if (h < 0) { |
|
h += 360; |
|
} |
|
|
|
v = ((max / 255) * 1000) / 10; |
|
|
|
return [h, s, v]; |
|
}; |
|
|
|
convert.rgb.hwb = function (rgb) { |
|
var r = rgb[0]; |
|
var g = rgb[1]; |
|
var b = rgb[2]; |
|
var h = convert.rgb.hsl(rgb)[0]; |
|
var w = 1 / 255 * Math.min(r, Math.min(g, b)); |
|
|
|
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); |
|
|
|
return [h, w * 100, b * 100]; |
|
}; |
|
|
|
convert.rgb.cmyk = function (rgb) { |
|
var r = rgb[0] / 255; |
|
var g = rgb[1] / 255; |
|
var b = rgb[2] / 255; |
|
var c; |
|
var m; |
|
var y; |
|
var k; |
|
|
|
k = Math.min(1 - r, 1 - g, 1 - b); |
|
c = (1 - r - k) / (1 - k) || 0; |
|
m = (1 - g - k) / (1 - k) || 0; |
|
y = (1 - b - k) / (1 - k) || 0; |
|
|
|
return [c * 100, m * 100, y * 100, k * 100]; |
|
}; |
|
|
|
/** |
|
* See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance |
|
* */ |
|
function comparativeDistance(x, y) { |
|
return ( |
|
Math.pow(x[0] - y[0], 2) + |
|
Math.pow(x[1] - y[1], 2) + |
|
Math.pow(x[2] - y[2], 2) |
|
); |
|
} |
|
|
|
convert.rgb.keyword = function (rgb) { |
|
var reversed = reverseKeywords[rgb]; |
|
if (reversed) { |
|
return reversed; |
|
} |
|
|
|
var currentClosestDistance = Infinity; |
|
var currentClosestKeyword; |
|
|
|
for (var keyword in colorName) { |
|
if (colorName.hasOwnProperty(keyword)) { |
|
var value = colorName[keyword]; |
|
|
|
// Compute comparative distance |
|
var distance = comparativeDistance(rgb, value); |
|
|
|
// Check if its less, if so set as closest |
|
if (distance < currentClosestDistance) { |
|
currentClosestDistance = distance; |
|
currentClosestKeyword = keyword; |
|
} |
|
} |
|
} |
|
|
|
return currentClosestKeyword; |
|
}; |
|
|
|
convert.keyword.rgb = function (keyword) { |
|
return colorName[keyword]; |
|
}; |
|
|
|
convert.rgb.xyz = function (rgb) { |
|
var r = rgb[0] / 255; |
|
var g = rgb[1] / 255; |
|
var b = rgb[2] / 255; |
|
|
|
// assume sRGB |
|
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); |
|
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); |
|
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); |
|
|
|
var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); |
|
var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); |
|
var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); |
|
|
|
return [x * 100, y * 100, z * 100]; |
|
}; |
|
|
|
convert.rgb.lab = function (rgb) { |
|
var xyz = convert.rgb.xyz(rgb); |
|
var x = xyz[0]; |
|
var y = xyz[1]; |
|
var z = xyz[2]; |
|
var l; |
|
var a; |
|
var b; |
|
|
|
x /= 95.047; |
|
y /= 100; |
|
z /= 108.883; |
|
|
|
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); |
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); |
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); |
|
|
|
l = (116 * y) - 16; |
|
a = 500 * (x - y); |
|
b = 200 * (y - z); |
|
|
|
return [l, a, b]; |
|
}; |
|
|
|
convert.hsl.rgb = function (hsl) { |
|
var h = hsl[0] / 360; |
|
var s = hsl[1] / 100; |
|
var l = hsl[2] / 100; |
|
var t1; |
|
var t2; |
|
var t3; |
|
var rgb; |
|
var val; |
|
|
|
if (s === 0) { |
|
val = l * 255; |
|
return [val, val, val]; |
|
} |
|
|
|
if (l < 0.5) { |
|
t2 = l * (1 + s); |
|
} else { |
|
t2 = l + s - l * s; |
|
} |
|
|
|
t1 = 2 * l - t2; |
|
|
|
rgb = [0, 0, 0]; |
|
for (var i = 0; i < 3; i++) { |
|
t3 = h + 1 / 3 * -(i - 1); |
|
if (t3 < 0) { |
|
t3++; |
|
} |
|
if (t3 > 1) { |
|
t3--; |
|
} |
|
|
|
if (6 * t3 < 1) { |
|
val = t1 + (t2 - t1) * 6 * t3; |
|
} else if (2 * t3 < 1) { |
|
val = t2; |
|
} else if (3 * t3 < 2) { |
|
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; |
|
} else { |
|
val = t1; |
|
} |
|
|
|
rgb[i] = val * 255; |
|
} |
|
|
|
return rgb; |
|
}; |
|
|
|
convert.hsl.hsv = function (hsl) { |
|
var h = hsl[0]; |
|
var s = hsl[1] / 100; |
|
var l = hsl[2] / 100; |
|
var smin = s; |
|
var lmin = Math.max(l, 0.01); |
|
var sv; |
|
var v; |
|
|
|
l *= 2; |
|
s *= (l <= 1) ? l : 2 - l; |
|
smin *= lmin <= 1 ? lmin : 2 - lmin; |
|
v = (l + s) / 2; |
|
sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); |
|
|
|
return [h, sv * 100, v * 100]; |
|
}; |
|
|
|
convert.hsv.rgb = function (hsv) { |
|
var h = hsv[0] / 60; |
|
var s = hsv[1] / 100; |
|
var v = hsv[2] / 100; |
|
var hi = Math.floor(h) % 6; |
|
|
|
var f = h - Math.floor(h); |
|
var p = 255 * v * (1 - s); |
|
var q = 255 * v * (1 - (s * f)); |
|
var t = 255 * v * (1 - (s * (1 - f))); |
|
v *= 255; |
|
|
|
switch (hi) { |
|
case 0: |
|
return [v, t, p]; |
|
case 1: |
|
return [q, v, p]; |
|
case 2: |
|
return [p, v, t]; |
|
case 3: |
|
return [p, q, v]; |
|
case 4: |
|
return [t, p, v]; |
|
case 5: |
|
return [v, p, q]; |
|
} |
|
}; |
|
|
|
convert.hsv.hsl = function (hsv) { |
|
var h = hsv[0]; |
|
var s = hsv[1] / 100; |
|
var v = hsv[2] / 100; |
|
var vmin = Math.max(v, 0.01); |
|
var lmin; |
|
var sl; |
|
var l; |
|
|
|
l = (2 - s) * v; |
|
lmin = (2 - s) * vmin; |
|
sl = s * vmin; |
|
sl /= (lmin <= 1) ? lmin : 2 - lmin; |
|
sl = sl || 0; |
|
l /= 2; |
|
|
|
return [h, sl * 100, l * 100]; |
|
}; |
|
|
|
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb |
|
convert.hwb.rgb = function (hwb) { |
|
var h = hwb[0] / 360; |
|
var wh = hwb[1] / 100; |
|
var bl = hwb[2] / 100; |
|
var ratio = wh + bl; |
|
var i; |
|
var v; |
|
var f; |
|
var n; |
|
|
|
// wh + bl cant be > 1 |
|
if (ratio > 1) { |
|
wh /= ratio; |
|
bl /= ratio; |
|
} |
|
|
|
i = Math.floor(6 * h); |
|
v = 1 - bl; |
|
f = 6 * h - i; |
|
|
|
if ((i & 0x01) !== 0) { |
|
f = 1 - f; |
|
} |
|
|
|
n = wh + f * (v - wh); // linear interpolation |
|
|
|
var r; |
|
var g; |
|
var b; |
|
switch (i) { |
|
default: |
|
case 6: |
|
case 0: r = v; g = n; b = wh; break; |
|
case 1: r = n; g = v; b = wh; break; |
|
case 2: r = wh; g = v; b = n; break; |
|
case 3: r = wh; g = n; b = v; break; |
|
case 4: r = n; g = wh; b = v; break; |
|
case 5: r = v; g = wh; b = n; break; |
|
} |
|
|
|
return [r * 255, g * 255, b * 255]; |
|
}; |
|
|
|
convert.cmyk.rgb = function (cmyk) { |
|
var c = cmyk[0] / 100; |
|
var m = cmyk[1] / 100; |
|
var y = cmyk[2] / 100; |
|
var k = cmyk[3] / 100; |
|
var r; |
|
var g; |
|
var b; |
|
|
|
r = 1 - Math.min(1, c * (1 - k) + k); |
|
g = 1 - Math.min(1, m * (1 - k) + k); |
|
b = 1 - Math.min(1, y * (1 - k) + k); |
|
|
|
return [r * 255, g * 255, b * 255]; |
|
}; |
|
|
|
convert.xyz.rgb = function (xyz) { |
|
var x = xyz[0] / 100; |
|
var y = xyz[1] / 100; |
|
var z = xyz[2] / 100; |
|
var r; |
|
var g; |
|
var b; |
|
|
|
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); |
|
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); |
|
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); |
|
|
|
// assume sRGB |
|
r = r > 0.0031308 |
|
? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) |
|
: r * 12.92; |
|
|
|
g = g > 0.0031308 |
|
? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) |
|
: g * 12.92; |
|
|
|
b = b > 0.0031308 |
|
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) |
|
: b * 12.92; |
|
|
|
r = Math.min(Math.max(0, r), 1); |
|
g = Math.min(Math.max(0, g), 1); |
|
b = Math.min(Math.max(0, b), 1); |
|
|
|
return [r * 255, g * 255, b * 255]; |
|
}; |
|
|
|
convert.xyz.lab = function (xyz) { |
|
var x = xyz[0]; |
|
var y = xyz[1]; |
|
var z = xyz[2]; |
|
var l; |
|
var a; |
|
var b; |
|
|
|
x /= 95.047; |
|
y /= 100; |
|
z /= 108.883; |
|
|
|
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); |
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); |
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); |
|
|
|
l = (116 * y) - 16; |
|
a = 500 * (x - y); |
|
b = 200 * (y - z); |
|
|
|
return [l, a, b]; |
|
}; |
|
|
|
convert.lab.xyz = function (lab) { |
|
var l = lab[0]; |
|
var a = lab[1]; |
|
var b = lab[2]; |
|
var x; |
|
var y; |
|
var z; |
|
|
|
y = (l + 16) / 116; |
|
x = a / 500 + y; |
|
z = y - b / 200; |
|
|
|
var y2 = Math.pow(y, 3); |
|
var x2 = Math.pow(x, 3); |
|
var z2 = Math.pow(z, 3); |
|
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; |
|
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; |
|
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; |
|
|
|
x *= 95.047; |
|
y *= 100; |
|
z *= 108.883; |
|
|
|
return [x, y, z]; |
|
}; |
|
|
|
convert.lab.lch = function (lab) { |
|
var l = lab[0]; |
|
var a = lab[1]; |
|
var b = lab[2]; |
|
var hr; |
|
var h; |
|
var c; |
|
|
|
hr = Math.atan2(b, a); |
|
h = hr * 360 / 2 / Math.PI; |
|
|
|
if (h < 0) { |
|
h += 360; |
|
} |
|
|
|
c = Math.sqrt(a * a + b * b); |
|
|
|
return [l, c, h]; |
|
}; |
|
|
|
convert.lch.lab = function (lch) { |
|
var l = lch[0]; |
|
var c = lch[1]; |
|
var h = lch[2]; |
|
var a; |
|
var b; |
|
var hr; |
|
|
|
hr = h / 360 * 2 * Math.PI; |
|
a = c * Math.cos(hr); |
|
b = c * Math.sin(hr); |
|
|
|
return [l, a, b]; |
|
}; |
|
|
|
convert.rgb.ansi16 = function (args) { |
|
var r = args[0]; |
|
var g = args[1]; |
|
var b = args[2]; |
|
var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization |
|
|
|
value = Math.round(value / 50); |
|
|
|
if (value === 0) { |
|
return 30; |
|
} |
|
|
|
var ansi = 30 |
|
+ ((Math.round(b / 255) << 2) |
|
| (Math.round(g / 255) << 1) |
|
| Math.round(r / 255)); |
|
|
|
if (value === 2) { |
|
ansi += 60; |
|
} |
|
|
|
return ansi; |
|
}; |
|
|
|
convert.hsv.ansi16 = function (args) { |
|
// optimization here; we already know the value and don't need to get |
|
// it converted for us. |
|
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); |
|
}; |
|
|
|
convert.rgb.ansi256 = function (args) { |
|
var r = args[0]; |
|
var g = args[1]; |
|
var b = args[2]; |
|
|
|
// we use the extended greyscale palette here, with the exception of |
|
// black and white. normal palette only has 4 greyscale shades. |
|
if (r === g && g === b) { |
|
if (r < 8) { |
|
return 16; |
|
} |
|
|
|
if (r > 248) { |
|
return 231; |
|
} |
|
|
|
return Math.round(((r - 8) / 247) * 24) + 232; |
|
} |
|
|
|
var ansi = 16 |
|
+ (36 * Math.round(r / 255 * 5)) |
|
+ (6 * Math.round(g / 255 * 5)) |
|
+ Math.round(b / 255 * 5); |
|
|
|
return ansi; |
|
}; |
|
|
|
convert.ansi16.rgb = function (args) { |
|
var color = args % 10; |
|
|
|
// handle greyscale |
|
if (color === 0 || color === 7) { |
|
if (args > 50) { |
|
color += 3.5; |
|
} |
|
|
|
color = color / 10.5 * 255; |
|
|
|
return [color, color, color]; |
|
} |
|
|
|
var mult = (~~(args > 50) + 1) * 0.5; |
|
var r = ((color & 1) * mult) * 255; |
|
var g = (((color >> 1) & 1) * mult) * 255; |
|
var b = (((color >> 2) & 1) * mult) * 255; |
|
|
|
return [r, g, b]; |
|
}; |
|
|
|
convert.ansi256.rgb = function (args) { |
|
// handle greyscale |
|
if (args >= 232) { |
|
var c = (args - 232) * 10 + 8; |
|
return [c, c, c]; |
|
} |
|
|
|
args -= 16; |
|
|
|
var rem; |
|
var r = Math.floor(args / 36) / 5 * 255; |
|
var g = Math.floor((rem = args % 36) / 6) / 5 * 255; |
|
var b = (rem % 6) / 5 * 255; |
|
|
|
return [r, g, b]; |
|
}; |
|
|
|
convert.rgb.hex = function (args) { |
|
var integer = ((Math.round(args[0]) & 0xFF) << 16) |
|
+ ((Math.round(args[1]) & 0xFF) << 8) |
|
+ (Math.round(args[2]) & 0xFF); |
|
|
|
var string = integer.toString(16).toUpperCase(); |
|
return '000000'.substring(string.length) + string; |
|
}; |
|
|
|
convert.hex.rgb = function (args) { |
|
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); |
|
if (!match) { |
|
return [0, 0, 0]; |
|
} |
|
|
|
var colorString = match[0]; |
|
|
|
if (match[0].length === 3) { |
|
colorString = colorString.split('').map(function (char) { |
|
return char + char; |
|
}).join(''); |
|
} |
|
|
|
var integer = parseInt(colorString, 16); |
|
var r = (integer >> 16) & 0xFF; |
|
var g = (integer >> 8) & 0xFF; |
|
var b = integer & 0xFF; |
|
|
|
return [r, g, b]; |
|
}; |
|
|
|
convert.rgb.hcg = function (rgb) { |
|
var r = rgb[0] / 255; |
|
var g = rgb[1] / 255; |
|
var b = rgb[2] / 255; |
|
var max = Math.max(Math.max(r, g), b); |
|
var min = Math.min(Math.min(r, g), b); |
|
var chroma = (max - min); |
|
var grayscale; |
|
var hue; |
|
|
|
if (chroma < 1) { |
|
grayscale = min / (1 - chroma); |
|
} else { |
|
grayscale = 0; |
|
} |
|
|
|
if (chroma <= 0) { |
|
hue = 0; |
|
} else |
|
if (max === r) { |
|
hue = ((g - b) / chroma) % 6; |
|
} else |
|
if (max === g) { |
|
hue = 2 + (b - r) / chroma; |
|
} else { |
|
hue = 4 + (r - g) / chroma + 4; |
|
} |
|
|
|
hue /= 6; |
|
hue %= 1; |
|
|
|
return [hue * 360, chroma * 100, grayscale * 100]; |
|
}; |
|
|
|
convert.hsl.hcg = function (hsl) { |
|
var s = hsl[1] / 100; |
|
var l = hsl[2] / 100; |
|
var c = 1; |
|
var f = 0; |
|
|
|
if (l < 0.5) { |
|
c = 2.0 * s * l; |
|
} else { |
|
c = 2.0 * s * (1.0 - l); |
|
} |
|
|
|
if (c < 1.0) { |
|
f = (l - 0.5 * c) / (1.0 - c); |
|
} |
|
|
|
return [hsl[0], c * 100, f * 100]; |
|
}; |
|
|
|
convert.hsv.hcg = function (hsv) { |
|
var s = hsv[1] / 100; |
|
var v = hsv[2] / 100; |
|
|
|
var c = s * v; |
|
var f = 0; |
|
|
|
if (c < 1.0) { |
|
f = (v - c) / (1 - c); |
|
} |
|
|
|
return [hsv[0], c * 100, f * 100]; |
|
}; |
|
|
|
convert.hcg.rgb = function (hcg) { |
|
var h = hcg[0] / 360; |
|
var c = hcg[1] / 100; |
|
var g = hcg[2] / 100; |
|
|
|
if (c === 0.0) { |
|
return [g * 255, g * 255, g * 255]; |
|
} |
|
|
|
var pure = [0, 0, 0]; |
|
var hi = (h % 1) * 6; |
|
var v = hi % 1; |
|
var w = 1 - v; |
|
var mg = 0; |
|
|
|
switch (Math.floor(hi)) { |
|
case 0: |
|
pure[0] = 1; pure[1] = v; pure[2] = 0; break; |
|
case 1: |
|
pure[0] = w; pure[1] = 1; pure[2] = 0; break; |
|
case 2: |
|
pure[0] = 0; pure[1] = 1; pure[2] = v; break; |
|
case 3: |
|
pure[0] = 0; pure[1] = w; pure[2] = 1; break; |
|
case 4: |
|
pure[0] = v; pure[1] = 0; pure[2] = 1; break; |
|
default: |
|
pure[0] = 1; pure[1] = 0; pure[2] = w; |
|
} |
|
|
|
mg = (1.0 - c) * g; |
|
|
|
return [ |
|
(c * pure[0] + mg) * 255, |
|
(c * pure[1] + mg) * 255, |
|
(c * pure[2] + mg) * 255 |
|
]; |
|
}; |
|
|
|
convert.hcg.hsv = function (hcg) { |
|
var c = hcg[1] / 100; |
|
var g = hcg[2] / 100; |
|
|
|
var v = c + g * (1.0 - c); |
|
var f = 0; |
|
|
|
if (v > 0.0) { |
|
f = c / v; |
|
} |
|
|
|
return [hcg[0], f * 100, v * 100]; |
|
}; |
|
|
|
convert.hcg.hsl = function (hcg) { |
|
var c = hcg[1] / 100; |
|
var g = hcg[2] / 100; |
|
|
|
var l = g * (1.0 - c) + 0.5 * c; |
|
var s = 0; |
|
|
|
if (l > 0.0 && l < 0.5) { |
|
s = c / (2 * l); |
|
} else |
|
if (l >= 0.5 && l < 1.0) { |
|
s = c / (2 * (1 - l)); |
|
} |
|
|
|
return [hcg[0], s * 100, l * 100]; |
|
}; |
|
|
|
convert.hcg.hwb = function (hcg) { |
|
var c = hcg[1] / 100; |
|
var g = hcg[2] / 100; |
|
var v = c + g * (1.0 - c); |
|
return [hcg[0], (v - c) * 100, (1 - v) * 100]; |
|
}; |
|
|
|
convert.hwb.hcg = function (hwb) { |
|
var w = hwb[1] / 100; |
|
var b = hwb[2] / 100; |
|
var v = 1 - b; |
|
var c = v - w; |
|
var g = 0; |
|
|
|
if (c < 1) { |
|
g = (v - c) / (1 - c); |
|
} |
|
|
|
return [hwb[0], c * 100, g * 100]; |
|
}; |
|
|
|
convert.apple.rgb = function (apple) { |
|
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; |
|
}; |
|
|
|
convert.rgb.apple = function (rgb) { |
|
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; |
|
}; |
|
|
|
convert.gray.rgb = function (args) { |
|
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; |
|
}; |
|
|
|
convert.gray.hsl = convert.gray.hsv = function (args) { |
|
return [0, 0, args[0]]; |
|
}; |
|
|
|
convert.gray.hwb = function (gray) { |
|
return [0, 100, gray[0]]; |
|
}; |
|
|
|
convert.gray.cmyk = function (gray) { |
|
return [0, 0, 0, gray[0]]; |
|
}; |
|
|
|
convert.gray.lab = function (gray) { |
|
return [gray[0], 0, 0]; |
|
}; |
|
|
|
convert.gray.hex = function (gray) { |
|
var val = Math.round(gray[0] / 100 * 255) & 0xFF; |
|
var integer = (val << 16) + (val << 8) + val; |
|
|
|
var string = integer.toString(16).toUpperCase(); |
|
return '000000'.substring(string.length) + string; |
|
}; |
|
|
|
convert.rgb.gray = function (rgb) { |
|
var val = (rgb[0] + rgb[1] + rgb[2]) / 3; |
|
return [val / 255 * 100]; |
|
}; |
|
}); |
|
|
|
var conversions_1 = conversions.rgb; |
|
var conversions_2 = conversions.hsl; |
|
var conversions_3 = conversions.hsv; |
|
var conversions_4 = conversions.hwb; |
|
var conversions_5 = conversions.cmyk; |
|
var conversions_6 = conversions.xyz; |
|
var conversions_7 = conversions.lab; |
|
var conversions_8 = conversions.lch; |
|
var conversions_9 = conversions.hex; |
|
var conversions_10 = conversions.keyword; |
|
var conversions_11 = conversions.ansi16; |
|
var conversions_12 = conversions.ansi256; |
|
var conversions_13 = conversions.hcg; |
|
var conversions_14 = conversions.apple; |
|
var conversions_15 = conversions.gray; |
|
|
|
/* |
|
this function routes a model to all other models. |
|
|
|
all functions that are routed have a property `.conversion` attached |
|
to the returned synthetic function. This property is an array |
|
of strings, each with the steps in between the 'from' and 'to' |
|
color models (inclusive). |
|
|
|
conversions that are not possible simply are not included. |
|
*/ |
|
|
|
function buildGraph() { |
|
var graph = {}; |
|
// https://jsperf.com/object-keys-vs-for-in-with-closure/3 |
|
var models = Object.keys(conversions); |
|
|
|
for (var len = models.length, i = 0; i < len; i++) { |
|
graph[models[i]] = { |
|
// http://jsperf.com/1-vs-infinity |
|
// micro-opt, but this is simple. |
|
distance: -1, |
|
parent: null |
|
}; |
|
} |
|
|
|
return graph; |
|
} |
|
|
|
// https://en.wikipedia.org/wiki/Breadth-first_search |
|
function deriveBFS(fromModel) { |
|
var graph = buildGraph(); |
|
var queue = [fromModel]; // unshift -> queue -> pop |
|
|
|
graph[fromModel].distance = 0; |
|
|
|
while (queue.length) { |
|
var current = queue.pop(); |
|
var adjacents = Object.keys(conversions[current]); |
|
|
|
for (var len = adjacents.length, i = 0; i < len; i++) { |
|
var adjacent = adjacents[i]; |
|
var node = graph[adjacent]; |
|
|
|
if (node.distance === -1) { |
|
node.distance = graph[current].distance + 1; |
|
node.parent = current; |
|
queue.unshift(adjacent); |
|
} |
|
} |
|
} |
|
|
|
return graph; |
|
} |
|
|
|
function link(from, to) { |
|
return function (args) { |
|
return to(from(args)); |
|
}; |
|
} |
|
|
|
function wrapConversion(toModel, graph) { |
|
var path = [graph[toModel].parent, toModel]; |
|
var fn = conversions[graph[toModel].parent][toModel]; |
|
|
|
var cur = graph[toModel].parent; |
|
while (graph[cur].parent) { |
|
path.unshift(graph[cur].parent); |
|
fn = link(conversions[graph[cur].parent][cur], fn); |
|
cur = graph[cur].parent; |
|
} |
|
|
|
fn.conversion = path; |
|
return fn; |
|
} |
|
|
|
var route = function (fromModel) { |
|
var graph = deriveBFS(fromModel); |
|
var conversion = {}; |
|
|
|
var models = Object.keys(graph); |
|
for (var len = models.length, i = 0; i < len; i++) { |
|
var toModel = models[i]; |
|
var node = graph[toModel]; |
|
|
|
if (node.parent === null) { |
|
// no possible conversion, or this node is the source model. |
|
continue; |
|
} |
|
|
|
conversion[toModel] = wrapConversion(toModel, graph); |
|
} |
|
|
|
return conversion; |
|
}; |
|
|
|
var convert = {}; |
|
|
|
var models = Object.keys(conversions); |
|
|
|
function wrapRaw(fn) { |
|
var wrappedFn = function (args) { |
|
if (args === undefined || args === null) { |
|
return args; |
|
} |
|
|
|
if (arguments.length > 1) { |
|
args = Array.prototype.slice.call(arguments); |
|
} |
|
|
|
return fn(args); |
|
}; |
|
|
|
// preserve .conversion property if there is one |
|
if ('conversion' in fn) { |
|
wrappedFn.conversion = fn.conversion; |
|
} |
|
|
|
return wrappedFn; |
|
} |
|
|
|
function wrapRounded(fn) { |
|
var wrappedFn = function (args) { |
|
if (args === undefined || args === null) { |
|
return args; |
|
} |
|
|
|
if (arguments.length > 1) { |
|
args = Array.prototype.slice.call(arguments); |
|
} |
|
|
|
var result = fn(args); |
|
|
|
// we're assuming the result is an array here. |
|
// see notice in conversions.js; don't use box types |
|
// in conversion functions. |
|
if (typeof result === 'object') { |
|
for (var len = result.length, i = 0; i < len; i++) { |
|
result[i] = Math.round(result[i]); |
|
} |
|
} |
|
|
|
return result; |
|
}; |
|
|
|
// preserve .conversion property if there is one |
|
if ('conversion' in fn) { |
|
wrappedFn.conversion = fn.conversion; |
|
} |
|
|
|
return wrappedFn; |
|
} |
|
|
|
models.forEach(function (fromModel) { |
|
convert[fromModel] = {}; |
|
|
|
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); |
|
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); |
|
|
|
var routes = route(fromModel); |
|
var routeModels = Object.keys(routes); |
|
|
|
routeModels.forEach(function (toModel) { |
|
var fn = routes[toModel]; |
|
|
|
convert[fromModel][toModel] = wrapRounded(fn); |
|
convert[fromModel][toModel].raw = wrapRaw(fn); |
|
}); |
|
}); |
|
|
|
var colorConvert = convert; |
|
|
|
var ansiStyles = createCommonjsModule(function (module) { |
|
var wrapAnsi16 = function wrapAnsi16(fn, offset) { |
|
return function () { |
|
var code = fn.apply(colorConvert, arguments); |
|
return '\x1B[' + (code + offset) + 'm'; |
|
}; |
|
}; |
|
|
|
var wrapAnsi256 = function wrapAnsi256(fn, offset) { |
|
return function () { |
|
var code = fn.apply(colorConvert, arguments); |
|
return '\x1B[' + (38 + offset) + ';5;' + code + 'm'; |
|
}; |
|
}; |
|
|
|
var wrapAnsi16m = function wrapAnsi16m(fn, offset) { |
|
return function () { |
|
var rgb = fn.apply(colorConvert, arguments); |
|
return '\x1B[' + (38 + offset) + ';2;' + rgb[0] + ';' + rgb[1] + ';' + rgb[2] + 'm'; |
|
}; |
|
}; |
|
|
|
function assembleStyles() { |
|
var codes = new _Map(); |
|
var styles = { |
|
modifier: { |
|
reset: [0, 0], |
|
// 21 isn't widely supported and 22 does the same thing |
|
bold: [1, 22], |
|
dim: [2, 22], |
|
italic: [3, 23], |
|
underline: [4, 24], |
|
inverse: [7, 27], |
|
hidden: [8, 28], |
|
strikethrough: [9, 29] |
|
}, |
|
color: { |
|
black: [30, 39], |
|
red: [31, 39], |
|
green: [32, 39], |
|
yellow: [33, 39], |
|
blue: [34, 39], |
|
magenta: [35, 39], |
|
cyan: [36, 39], |
|
white: [37, 39], |
|
gray: [90, 39], |
|
|
|
// Bright color |
|
redBright: [91, 39], |
|
greenBright: [92, 39], |
|
yellowBright: [93, 39], |
|
blueBright: [94, 39], |
|
magentaBright: [95, 39], |
|
cyanBright: [96, 39], |
|
whiteBright: [97, 39] |
|
}, |
|
bgColor: { |
|
bgBlack: [40, 49], |
|
bgRed: [41, 49], |
|
bgGreen: [42, 49], |
|
bgYellow: [43, 49], |
|
bgBlue: [44, 49], |
|
bgMagenta: [45, 49], |
|
bgCyan: [46, 49], |
|
bgWhite: [47, 49], |
|
|
|
// Bright color |
|
bgBlackBright: [100, 49], |
|
bgRedBright: [101, 49], |
|
bgGreenBright: [102, 49], |
|
bgYellowBright: [103, 49], |
|
bgBlueBright: [104, 49], |
|
bgMagentaBright: [105, 49], |
|
bgCyanBright: [106, 49], |
|
bgWhiteBright: [107, 49] |
|
} |
|
}; |
|
|
|
// Fix humans |
|
styles.color.grey = styles.color.gray; |
|
|
|
var _iteratorNormalCompletion = true; |
|
var _didIteratorError = false; |
|
var _iteratorError = undefined; |
|
|
|
try { |
|
for (var _iterator = _getIterator(_Object$keys(styles)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
|
var groupName = _step.value; |
|
|
|
var group = styles[groupName]; |
|
|
|
var _iteratorNormalCompletion3 = true; |
|
var _didIteratorError3 = false; |
|
var _iteratorError3 = undefined; |
|
|
|
try { |
|
for (var _iterator3 = _getIterator(_Object$keys(group)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
|
var styleName = _step3.value; |
|
|
|
var style = group[styleName]; |
|
|
|
styles[styleName] = { |
|
open: '\x1B[' + style[0] + 'm', |
|
close: '\x1B[' + style[1] + 'm' |
|
}; |
|
|
|
group[styleName] = styles[styleName]; |
|
|
|
codes.set(style[0], style[1]); |
|
} |
|
} catch (err) { |
|
_didIteratorError3 = true; |
|
_iteratorError3 = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion3 && _iterator3.return) { |
|
_iterator3.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError3) { |
|
throw _iteratorError3; |
|
} |
|
} |
|
} |
|
|
|
_Object$defineProperty(styles, groupName, { |
|
value: group, |
|
enumerable: false |
|
}); |
|
|
|
Object.defineProperty(styles, 'codes', { |
|
value: codes, |
|
enumerable: false |
|
}); |
|
} |
|
} catch (err) { |
|
_didIteratorError = true; |
|
_iteratorError = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion && _iterator.return) { |
|
_iterator.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError) { |
|
throw _iteratorError; |
|
} |
|
} |
|
} |
|
|
|
var rgb2rgb = function rgb2rgb(r, g, b) { |
|
return [r, g, b]; |
|
}; |
|
|
|
styles.color.close = '\x1B[39m'; |
|
styles.bgColor.close = '\x1B[49m'; |
|
|
|
styles.color.ansi = {}; |
|
styles.color.ansi256 = {}; |
|
styles.color.ansi16m = { |
|
rgb: wrapAnsi16m(rgb2rgb, 0) |
|
}; |
|
|
|
styles.bgColor.ansi = {}; |
|
styles.bgColor.ansi256 = {}; |
|
styles.bgColor.ansi16m = { |
|
rgb: wrapAnsi16m(rgb2rgb, 10) |
|
}; |
|
|
|
var _iteratorNormalCompletion2 = true; |
|
var _didIteratorError2 = false; |
|
var _iteratorError2 = undefined; |
|
|
|
try { |
|
for (var _iterator2 = _getIterator(_Object$keys(colorConvert)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
|
var key = _step2.value; |
|
|
|
if (_typeof(colorConvert[key]) !== 'object') { |
|
continue; |
|
} |
|
|
|
var suite = colorConvert[key]; |
|
|
|
if ('ansi16' in suite) { |
|
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); |
|
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); |
|
} |
|
|
|
if ('ansi256' in suite) { |
|
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); |
|
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); |
|
} |
|
|
|
if ('rgb' in suite) { |
|
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); |
|
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); |
|
} |
|
} |
|
} catch (err) { |
|
_didIteratorError2 = true; |
|
_iteratorError2 = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion2 && _iterator2.return) { |
|
_iterator2.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError2) { |
|
throw _iteratorError2; |
|
} |
|
} |
|
} |
|
|
|
return styles; |
|
} |
|
|
|
// Make the export immutable |
|
Object.defineProperty(module, 'exports', { |
|
enumerable: true, |
|
get: assembleStyles |
|
}); |
|
}); |
|
|
|
var fake_chalk = createCommonjsModule(function (module) { |
|
var _ansiStyles2 = _interopRequireDefault(ansiStyles); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
var returnInput = function returnInput(str) { |
|
return str; |
|
}; /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
*/ |
|
|
|
var allColorsAsFunc = _Object$keys(_ansiStyles2.default).map(function (style) { |
|
return _defineProperty({}, style, returnInput); |
|
}).reduce(function (acc, cur) { |
|
return _Object$assign(acc, cur); |
|
}); |
|
|
|
_Object$keys(allColorsAsFunc).map(function (color) { |
|
return allColorsAsFunc[color]; |
|
}).forEach(function (style) { |
|
_Object$assign(style, allColorsAsFunc); |
|
_Object$assign(returnInput, style); |
|
}); |
|
|
|
module.exports = allColorsAsFunc; |
|
}); |
|
|
|
unwrapExports(fake_chalk); |
|
|
|
var SET = 'Set'; |
|
|
|
// 23.2 Set Objects |
|
var es6_set = _collection(SET, function (get) { |
|
return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; |
|
}, { |
|
// 23.2.3.1 Set.prototype.add(value) |
|
add: function add(value) { |
|
return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value); |
|
} |
|
}, _collectionStrong); |
|
|
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON |
|
|
|
|
|
_export(_export.P + _export.R, 'Set', { toJSON: _collectionToJson('Set') }); |
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of |
|
_setCollectionOf('Set'); |
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from |
|
_setCollectionFrom('Set'); |
|
|
|
var set$1 = _core.Set; |
|
|
|
var set = createCommonjsModule(function (module) { |
|
module.exports = { "default": set$1, __esModule: true }; |
|
}); |
|
|
|
var _Set = unwrapExports(set); |
|
|
|
var build$1 = createCommonjsModule(function (module) { |
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var getType = function getType(value) { |
|
if (value === undefined) { |
|
return 'undefined'; |
|
} else if (value === null) { |
|
return 'null'; |
|
} else if (Array.isArray(value)) { |
|
return 'array'; |
|
} else if (typeof value === 'boolean') { |
|
return 'boolean'; |
|
} else if (typeof value === 'function') { |
|
return 'function'; |
|
} else if (typeof value === 'number') { |
|
return 'number'; |
|
} else if (typeof value === 'string') { |
|
return 'string'; |
|
} else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { |
|
if (value.constructor === RegExp) { |
|
return 'regexp'; |
|
} else if (value.constructor === _Map) { |
|
return 'map'; |
|
} else if (value.constructor === _Set) { |
|
return 'set'; |
|
} else if (value.constructor === Date) { |
|
return 'date'; |
|
} |
|
return 'object'; |
|
// $FlowFixMe https://github.com/facebook/flow/issues/1015 |
|
} else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'symbol') { |
|
return 'symbol'; |
|
} |
|
|
|
throw new Error('value of unknown type: ' + value); |
|
}; |
|
|
|
module.exports = getType; |
|
}); |
|
|
|
// 7.2.9 SameValue(x, y) |
|
var _sameValue = Object.is || function is(x, y) { |
|
// eslint-disable-next-line no-self-compare |
|
return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; |
|
}; |
|
|
|
// 19.1.3.10 Object.is(value1, value2) |
|
|
|
_export(_export.S, 'Object', { is: _sameValue }); |
|
|
|
var is$2 = _core.Object.is; |
|
|
|
var is$1 = createCommonjsModule(function (module) { |
|
module.exports = { "default": is$2, __esModule: true }; |
|
}); |
|
|
|
var _Object$is = unwrapExports(is$1); |
|
|
|
var getOwnPropertySymbols$1 = _core.Object.getOwnPropertySymbols; |
|
|
|
var getOwnPropertySymbols = createCommonjsModule(function (module) { |
|
module.exports = { "default": getOwnPropertySymbols$1, __esModule: true }; |
|
}); |
|
|
|
var _Object$getOwnPropertySymbols = unwrapExports(getOwnPropertySymbols); |
|
|
|
var collections = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.printIteratorEntries = printIteratorEntries; |
|
exports.printIteratorValues = printIteratorValues; |
|
exports.printListItems = printListItems; |
|
exports.printObjectProperties = printObjectProperties; |
|
|
|
var getSymbols = _Object$getOwnPropertySymbols || function (obj) { |
|
return []; |
|
}; /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var isSymbol = function isSymbol(key) { |
|
return ( |
|
// $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value |
|
(typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'symbol' || toString.call(key) === '[object Symbol]' |
|
); |
|
}; |
|
|
|
// Return entries (for example, of a map) |
|
// with spacing, indentation, and comma |
|
// without surrounding punctuation (for example, braces) |
|
function printIteratorEntries( |
|
// Flow 0.51.0: property `@@iterator` of $Iterator not found in Object |
|
iterator, config, indentation, depth, refs, printer) { |
|
var separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': '; |
|
|
|
var result = ''; |
|
var current = iterator.next(); |
|
|
|
if (!current.done) { |
|
result += config.spacingOuter; |
|
|
|
var indentationNext = indentation + config.indent; |
|
|
|
while (!current.done) { |
|
var name = printer(current.value[0], config, indentationNext, depth, refs); |
|
var value = printer(current.value[1], config, indentationNext, depth, refs); |
|
|
|
result += indentationNext + name + separator + value; |
|
|
|
current = iterator.next(); |
|
|
|
if (!current.done) { |
|
result += ',' + config.spacingInner; |
|
} else if (!config.min) { |
|
result += ','; |
|
} |
|
} |
|
|
|
result += config.spacingOuter + indentation; |
|
} |
|
|
|
return result; |
|
} |
|
|
|
// Return values (for example, of a set) |
|
// with spacing, indentation, and comma |
|
// without surrounding punctuation (braces or brackets) |
|
function printIteratorValues(iterator, config, indentation, depth, refs, printer) { |
|
var result = ''; |
|
var current = iterator.next(); |
|
|
|
if (!current.done) { |
|
result += config.spacingOuter; |
|
|
|
var indentationNext = indentation + config.indent; |
|
|
|
while (!current.done) { |
|
result += indentationNext + printer(current.value, config, indentationNext, depth, refs); |
|
|
|
current = iterator.next(); |
|
|
|
if (!current.done) { |
|
result += ',' + config.spacingInner; |
|
} else if (!config.min) { |
|
result += ','; |
|
} |
|
} |
|
|
|
result += config.spacingOuter + indentation; |
|
} |
|
|
|
return result; |
|
} |
|
|
|
// Return items (for example, of an array) |
|
// with spacing, indentation, and comma |
|
// without surrounding punctuation (for example, brackets) |
|
function printListItems(list, config, indentation, depth, refs, printer) { |
|
var result = ''; |
|
|
|
if (list.length) { |
|
result += config.spacingOuter; |
|
|
|
var indentationNext = indentation + config.indent; |
|
|
|
for (var i = 0; i < list.length; i++) { |
|
result += indentationNext + printer(list[i], config, indentationNext, depth, refs); |
|
|
|
if (i < list.length - 1) { |
|
result += ',' + config.spacingInner; |
|
} else if (!config.min) { |
|
result += ','; |
|
} |
|
} |
|
|
|
result += config.spacingOuter + indentation; |
|
} |
|
|
|
return result; |
|
} |
|
|
|
// Return properties of an object |
|
// with spacing, indentation, and comma |
|
// without surrounding punctuation (for example, braces) |
|
function printObjectProperties(val, config, indentation, depth, refs, printer) { |
|
var result = ''; |
|
var keys$$1 = _Object$keys(val).sort(); |
|
var symbols = getSymbols(val); |
|
|
|
if (symbols.length) { |
|
keys$$1 = keys$$1.filter(function (key) { |
|
return !isSymbol(key); |
|
}).concat(symbols); |
|
} |
|
|
|
if (keys$$1.length) { |
|
result += config.spacingOuter; |
|
|
|
var indentationNext = indentation + config.indent; |
|
|
|
for (var i = 0; i < keys$$1.length; i++) { |
|
var key = keys$$1[i]; |
|
var name = printer(key, config, indentationNext, depth, refs); |
|
var value = printer(val[key], config, indentationNext, depth, refs); |
|
|
|
result += indentationNext + name + ': ' + value; |
|
|
|
if (i < keys$$1.length - 1) { |
|
result += ',' + config.spacingInner; |
|
} else if (!config.min) { |
|
result += ','; |
|
} |
|
} |
|
|
|
result += config.spacingOuter + indentation; |
|
} |
|
|
|
return result; |
|
} |
|
}); |
|
|
|
unwrapExports(collections); |
|
var collections_1 = collections.printIteratorEntries; |
|
var collections_2 = collections.printIteratorValues; |
|
var collections_3 = collections.printListItems; |
|
var collections_4 = collections.printObjectProperties; |
|
|
|
var _for$1 = _core.Symbol['for']; |
|
|
|
var _for = createCommonjsModule(function (module) { |
|
module.exports = { "default": _for$1, __esModule: true }; |
|
}); |
|
|
|
var _Symbol$for = unwrapExports(_for); |
|
|
|
var asymmetric_matcher = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.test = exports.serialize = undefined; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var asymmetricMatcher = _Symbol$for('jest.asymmetricMatcher'); |
|
var SPACE = ' '; |
|
|
|
var serialize = exports.serialize = function (val, config, indentation, depth, refs, printer) { |
|
var stringedValue = val.toString(); |
|
|
|
if (stringedValue === 'ArrayContaining') { |
|
if (++depth > config.maxDepth) { |
|
return '[' + stringedValue + ']'; |
|
} |
|
return stringedValue + SPACE + '[' + (0, collections.printListItems)(val.sample, config, indentation, depth, refs, printer) + ']'; |
|
} |
|
|
|
if (stringedValue === 'ObjectContaining') { |
|
if (++depth > config.maxDepth) { |
|
return '[' + stringedValue + ']'; |
|
} |
|
return stringedValue + SPACE + '{' + (0, collections.printObjectProperties)(val.sample, config, indentation, depth, refs, printer) + '}'; |
|
} |
|
|
|
if (stringedValue === 'StringMatching') { |
|
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs); |
|
} |
|
|
|
if (stringedValue === 'StringContaining') { |
|
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs); |
|
} |
|
|
|
return val.toAsymmetricMatcher(); |
|
}; |
|
|
|
var test = exports.test = function (val) { |
|
return val && val.$$typeof === asymmetricMatcher; |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(asymmetric_matcher); |
|
var asymmetric_matcher_1 = asymmetric_matcher.test; |
|
var asymmetric_matcher_2 = asymmetric_matcher.serialize; |
|
|
|
var ansiRegex = createCommonjsModule(function (module) { |
|
module.exports = function () { |
|
var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'].join('|'); |
|
|
|
return new RegExp(pattern, 'g'); |
|
}; |
|
}); |
|
|
|
var convert_ansi = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.serialize = exports.test = undefined; |
|
|
|
var _ansiRegex2 = _interopRequireDefault(ansiRegex); |
|
|
|
var _ansiStyles2 = _interopRequireDefault(ansiStyles); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
var toHumanReadableAnsi = function toHumanReadableAnsi(text) { |
|
return text.replace((0, _ansiRegex2.default)(), function (match, offset, string) { |
|
switch (match) { |
|
case _ansiStyles2.default.red.close: |
|
case _ansiStyles2.default.green.close: |
|
case _ansiStyles2.default.cyan.close: |
|
case _ansiStyles2.default.gray.close: |
|
case _ansiStyles2.default.white.close: |
|
case _ansiStyles2.default.yellow.close: |
|
case _ansiStyles2.default.bgRed.close: |
|
case _ansiStyles2.default.bgGreen.close: |
|
case _ansiStyles2.default.bgYellow.close: |
|
case _ansiStyles2.default.inverse.close: |
|
case _ansiStyles2.default.dim.close: |
|
case _ansiStyles2.default.bold.close: |
|
case _ansiStyles2.default.reset.open: |
|
case _ansiStyles2.default.reset.close: |
|
return '</>'; |
|
case _ansiStyles2.default.red.open: |
|
return '<red>'; |
|
case _ansiStyles2.default.green.open: |
|
return '<green>'; |
|
case _ansiStyles2.default.cyan.open: |
|
return '<cyan>'; |
|
case _ansiStyles2.default.gray.open: |
|
return '<gray>'; |
|
case _ansiStyles2.default.white.open: |
|
return '<white>'; |
|
case _ansiStyles2.default.yellow.open: |
|
return '<yellow>'; |
|
case _ansiStyles2.default.bgRed.open: |
|
return '<bgRed>'; |
|
case _ansiStyles2.default.bgGreen.open: |
|
return '<bgGreen>'; |
|
case _ansiStyles2.default.bgYellow.open: |
|
return '<bgYellow>'; |
|
case _ansiStyles2.default.inverse.open: |
|
return '<inverse>'; |
|
case _ansiStyles2.default.dim.open: |
|
return '<dim>'; |
|
case _ansiStyles2.default.bold.open: |
|
return '<bold>'; |
|
default: |
|
return ''; |
|
} |
|
}); |
|
}; /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var test = exports.test = function (val) { |
|
return typeof val === 'string' && val.match((0, _ansiRegex2.default)()); |
|
}; |
|
|
|
var serialize = exports.serialize = function (val, config, indentation, depth, refs, printer) { |
|
return printer(toHumanReadableAnsi(val), config, indentation, depth, refs); |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(convert_ansi); |
|
var convert_ansi_1 = convert_ansi.serialize; |
|
var convert_ansi_2 = convert_ansi.test; |
|
|
|
var dom_collection = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.serialize = exports.test = undefined; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var SPACE = ' '; |
|
|
|
var COLLECTION_NAMES = ['DOMStringMap', 'NamedNodeMap']; |
|
|
|
var test = exports.test = function (val) { |
|
return val && val.constructor && COLLECTION_NAMES.indexOf(val.constructor.name) !== -1; |
|
}; |
|
|
|
var convertCollectionToObject = function convertCollectionToObject(collection) { |
|
var result = {}; |
|
|
|
if (collection.constructor.name === 'NamedNodeMap') { |
|
for (var i = 0; i < collection.length; i++) { |
|
result[collection[i].name] = collection[i].value; |
|
} |
|
} else { |
|
result = _Object$assign({}, collection); |
|
} |
|
|
|
return result; |
|
}; |
|
|
|
var serialize = exports.serialize = function (collection, config, indentation, depth, refs, printer) { |
|
if (++depth > config.maxDepth) { |
|
return '[' + collection.constructor.name + ']'; |
|
} |
|
|
|
return collection.constructor.name + SPACE + '{' + (0, collections.printObjectProperties)(convertCollectionToObject(collection), config, indentation, depth, refs, printer) + '}'; |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(dom_collection); |
|
var dom_collection_1 = dom_collection.serialize; |
|
var dom_collection_2 = dom_collection.test; |
|
|
|
var escape_html = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.default = escapeHTML; |
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
function escapeHTML(str) { |
|
return str.replace(/</g, '<').replace(/>/g, '>'); |
|
} |
|
}); |
|
|
|
unwrapExports(escape_html); |
|
|
|
var markup = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = undefined; |
|
|
|
var _escape_html2 = _interopRequireDefault(escape_html); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
// Return empty string if keys is empty. |
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var printProps = exports.printProps = function (keys, props, config, indentation, depth, refs, printer) { |
|
var indentationNext = indentation + config.indent; |
|
var colors = config.colors; |
|
return keys.map(function (key) { |
|
var value = props[key]; |
|
var printed = printer(value, config, indentationNext, depth, refs); |
|
|
|
if (typeof value !== 'string') { |
|
if (printed.indexOf('\n') !== -1) { |
|
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation; |
|
} |
|
printed = '{' + printed + '}'; |
|
} |
|
|
|
return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close; |
|
}).join(''); |
|
}; |
|
|
|
// Return empty string if children is empty. |
|
var printChildren = exports.printChildren = function (children, config, indentation, depth, refs, printer) { |
|
return children.map(function (child) { |
|
return config.spacingOuter + indentation + (typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs)); |
|
}).join(''); |
|
}; |
|
|
|
var printText = exports.printText = function (text, config) { |
|
var contentColor = config.colors.content; |
|
return contentColor.open + (0, _escape_html2.default)(text) + contentColor.close; |
|
}; |
|
|
|
var printComment = exports.printComment = function (comment, config) { |
|
var commentColor = config.colors.comment; |
|
return commentColor.open + '<!--' + (0, _escape_html2.default)(comment) + '-->' + commentColor.close; |
|
}; |
|
|
|
// Separate the functions to format props, children, and element, |
|
// so a plugin could override a particular function, if needed. |
|
// Too bad, so sad: the traditional (but unnecessary) space |
|
// in a self-closing tagColor requires a second test of printedProps. |
|
var printElement = exports.printElement = function (type, printedProps, printedChildren, config, indentation) { |
|
var tagColor = config.colors.tag; |
|
return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close; |
|
}; |
|
|
|
var printElementAsLeaf = exports.printElementAsLeaf = function (type, config) { |
|
var tagColor = config.colors.tag; |
|
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close; |
|
}; |
|
}); |
|
|
|
unwrapExports(markup); |
|
var markup_1 = markup.printElementAsLeaf; |
|
var markup_2 = markup.printElement; |
|
var markup_3 = markup.printComment; |
|
var markup_4 = markup.printText; |
|
var markup_5 = markup.printChildren; |
|
var markup_6 = markup.printProps; |
|
|
|
var dom_element = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.serialize = exports.test = undefined; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var ELEMENT_NODE = 1; |
|
var TEXT_NODE = 3; |
|
var COMMENT_NODE = 8; |
|
|
|
var ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/; |
|
|
|
var testNode = function testNode(nodeType, name) { |
|
return nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) || nodeType === TEXT_NODE && name === 'Text' || nodeType === COMMENT_NODE && name === 'Comment'; |
|
}; |
|
|
|
var test = exports.test = function (val) { |
|
return val && val.constructor && val.constructor.name && testNode(val.nodeType, val.constructor.name); |
|
}; |
|
|
|
// Convert array of attribute objects to keys array and props object. |
|
var keysMapper = function keysMapper(attribute) { |
|
return attribute.name; |
|
}; |
|
var propsReducer = function propsReducer(props, attribute) { |
|
props[attribute.name] = attribute.value; |
|
return props; |
|
}; |
|
|
|
var serialize = exports.serialize = function (node, config, indentation, depth, refs, printer) { |
|
if (node.nodeType === TEXT_NODE) { |
|
return (0, markup.printText)(node.data, config); |
|
} |
|
|
|
if (node.nodeType === COMMENT_NODE) { |
|
return (0, markup.printComment)(node.data, config); |
|
} |
|
|
|
var type = node.tagName.toLowerCase(); |
|
if (++depth > config.maxDepth) { |
|
return (0, markup.printElementAsLeaf)(type, config); |
|
} |
|
|
|
return (0, markup.printElement)(type, (0, markup.printProps)(Array.prototype.map.call(node.attributes, keysMapper).sort(), Array.prototype.reduce.call(node.attributes, propsReducer, {}), config, indentation + config.indent, depth, refs, printer), (0, markup.printChildren)(Array.prototype.slice.call(node.childNodes), config, indentation + config.indent, depth, refs, printer), config, indentation); |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(dom_element); |
|
var dom_element_1 = dom_element.serialize; |
|
var dom_element_2 = dom_element.test; |
|
|
|
var immutable = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.test = exports.serialize = undefined; |
|
|
|
// SENTINEL constants are from https://github.com/facebook/immutable-js |
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; |
|
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; |
|
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; |
|
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; |
|
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; |
|
var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4 |
|
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; |
|
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; |
|
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; |
|
|
|
var getImmutableName = function getImmutableName(name) { |
|
return 'Immutable.' + name; |
|
}; |
|
var printAsLeaf = function printAsLeaf(name) { |
|
return '[' + name + ']'; |
|
}; |
|
var SPACE = ' '; |
|
var LAZY = '…'; // Seq is lazy if it calls a method like filter |
|
|
|
var printImmutableEntries = function printImmutableEntries(val, config, indentation, depth, refs, printer, type) { |
|
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '{' + (0, collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) + '}'; |
|
}; |
|
|
|
// Record has an entries method because it is a collection in immutable v3. |
|
// Return an iterator for Immutable Record from version v3 or v4. |
|
var getRecordEntries = function getRecordEntries(val) { |
|
var i = 0; |
|
return { |
|
next: function next() { |
|
if (i < val._keys.length) { |
|
var key = val._keys[i++]; |
|
return { done: false, value: [key, val.get(key)] }; |
|
} |
|
return { done: true }; |
|
} |
|
}; |
|
}; |
|
|
|
var printImmutableRecord = function printImmutableRecord(val, config, indentation, depth, refs, printer) { |
|
// _name property is defined only for an Immutable Record instance |
|
// which was constructed with a second optional descriptive name arg |
|
var name = getImmutableName(val._name || 'Record'); |
|
return ++depth > config.maxDepth ? printAsLeaf(name) : name + SPACE + '{' + (0, collections.printIteratorEntries)(getRecordEntries(val), config, indentation, depth, refs, printer) + '}'; |
|
}; |
|
|
|
var printImmutableSeq = function printImmutableSeq(val, config, indentation, depth, refs, printer) { |
|
var name = getImmutableName('Seq'); |
|
|
|
if (++depth > config.maxDepth) { |
|
return printAsLeaf(name); |
|
} |
|
|
|
if (val[IS_KEYED_SENTINEL]) { |
|
return name + SPACE + '{' + ( |
|
// from Immutable collection of entries or from ECMAScript object |
|
val._iter || val._object ? (0, collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) : LAZY) + '}'; |
|
} |
|
|
|
return name + SPACE + '[' + (val._iter || // from Immutable collection of values |
|
val._array || // from ECMAScript array |
|
val._collection || // from ECMAScript collection in immutable v4 |
|
val._iterable // from ECMAScript collection in immutable v3 |
|
? (0, collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) : LAZY) + ']'; |
|
}; |
|
|
|
var printImmutableValues = function printImmutableValues(val, config, indentation, depth, refs, printer, type) { |
|
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '[' + (0, collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + ']'; |
|
}; |
|
|
|
var serialize = exports.serialize = function (val, config, indentation, depth, refs, printer) { |
|
if (val[IS_MAP_SENTINEL]) { |
|
return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'); |
|
} |
|
|
|
if (val[IS_LIST_SENTINEL]) { |
|
return printImmutableValues(val, config, indentation, depth, refs, printer, 'List'); |
|
} |
|
if (val[IS_SET_SENTINEL]) { |
|
return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'); |
|
} |
|
if (val[IS_STACK_SENTINEL]) { |
|
return printImmutableValues(val, config, indentation, depth, refs, printer, 'Stack'); |
|
} |
|
|
|
if (val[IS_SEQ_SENTINEL]) { |
|
return printImmutableSeq(val, config, indentation, depth, refs, printer); |
|
} |
|
|
|
// For compatibility with immutable v3 and v4, let record be the default. |
|
return printImmutableRecord(val, config, indentation, depth, refs, printer); |
|
}; |
|
|
|
// Explicitly comparing sentinel properties to true avoids false positive |
|
// when mock identity-obj-proxy returns the key as the value for any key. |
|
var test = exports.test = function (val) { |
|
return val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true); |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(immutable); |
|
var immutable_1 = immutable.test; |
|
var immutable_2 = immutable.serialize; |
|
|
|
var react_element = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.test = exports.serialize = undefined; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var elementSymbol = _Symbol$for('react.element'); |
|
|
|
// Given element.props.children, or subtree during recursive traversal, |
|
// return flattened array of children. |
|
var getChildren = function getChildren(arg) { |
|
var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
|
|
if (Array.isArray(arg)) { |
|
arg.forEach(function (item) { |
|
getChildren(item, children); |
|
}); |
|
} else if (arg != null && arg !== false) { |
|
children.push(arg); |
|
} |
|
return children; |
|
}; |
|
|
|
var getType = function getType(element) { |
|
if (typeof element.type === 'string') { |
|
return element.type; |
|
} |
|
if (typeof element.type === 'function') { |
|
return element.type.displayName || element.type.name || 'Unknown'; |
|
} |
|
return 'UNDEFINED'; |
|
}; |
|
|
|
var serialize = exports.serialize = function (element, config, indentation, depth, refs, printer) { |
|
return ++depth > config.maxDepth ? (0, markup.printElementAsLeaf)(getType(element), config) : (0, markup.printElement)(getType(element), (0, markup.printProps)(_Object$keys(element.props).filter(function (key) { |
|
return key !== 'children'; |
|
}).sort(), element.props, config, indentation + config.indent, depth, refs, printer), (0, markup.printChildren)(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation); |
|
}; |
|
|
|
var test = exports.test = function (val) { |
|
return val && val.$$typeof === elementSymbol; |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(react_element); |
|
var react_element_1 = react_element.test; |
|
var react_element_2 = react_element.serialize; |
|
|
|
var react_test_component = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.test = exports.serialize = undefined; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var testSymbol = _Symbol$for('react.test.json'); |
|
|
|
var serialize = exports.serialize = function (object, config, indentation, depth, refs, printer) { |
|
return ++depth > config.maxDepth ? (0, markup.printElementAsLeaf)(object.type, config) : (0, markup.printElement)(object.type, object.props ? (0, markup.printProps)(_Object$keys(object.props).sort(), |
|
// Despite ternary expression, Flow 0.51.0 found incorrect error: |
|
// undefined is incompatible with the expected param type of Object |
|
// $FlowFixMe |
|
object.props, config, indentation + config.indent, depth, refs, printer) : '', object.children ? (0, markup.printChildren)(object.children, config, indentation + config.indent, depth, refs, printer) : '', config, indentation); |
|
}; |
|
|
|
var test = exports.test = function (val) { |
|
return val && val.$$typeof === testSymbol; |
|
}; |
|
|
|
exports.default = { serialize: serialize, test: test }; |
|
}); |
|
|
|
unwrapExports(react_test_component); |
|
var react_test_component_1 = react_test_component.test; |
|
var react_test_component_2 = react_test_component.serialize; |
|
|
|
var build$2 = createCommonjsModule(function (module) { |
|
var _ansiStyles2 = _interopRequireDefault(ansiStyles); |
|
|
|
var _asymmetric_matcher2 = _interopRequireDefault(asymmetric_matcher); |
|
|
|
var _convert_ansi2 = _interopRequireDefault(convert_ansi); |
|
|
|
var _dom_collection2 = _interopRequireDefault(dom_collection); |
|
|
|
var _dom_element2 = _interopRequireDefault(dom_element); |
|
|
|
var _immutable2 = _interopRequireDefault(immutable); |
|
|
|
var _react_element2 = _interopRequireDefault(react_element); |
|
|
|
var _react_test_component2 = _interopRequireDefault(react_test_component); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var toString = Object.prototype.toString; |
|
var toISOString = Date.prototype.toISOString; |
|
var errorToString = Error.prototype.toString; |
|
var regExpToString = RegExp.prototype.toString; |
|
var symbolToString = _Symbol.prototype.toString; |
|
|
|
// Explicitly comparing typeof constructor to function avoids undefined as name |
|
// when mock identity-obj-proxy returns the key as the value for any key. |
|
var getConstructorName = function getConstructorName(val) { |
|
return typeof val.constructor === 'function' && val.constructor.name || 'Object'; |
|
}; |
|
|
|
// Is val is equal to global window object? Works even if it does not exist :) |
|
/* global window */ |
|
var isWindow = function isWindow(val) { |
|
return typeof window !== 'undefined' && val === window; |
|
}; |
|
|
|
var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/; |
|
var NEWLINE_REGEXP = /\n/gi; |
|
|
|
var PrettyFormatPluginError = function (_Error) { |
|
_inherits(PrettyFormatPluginError, _Error); |
|
|
|
function PrettyFormatPluginError(message, stack) { |
|
_classCallCheck(this, PrettyFormatPluginError); |
|
|
|
var _this = _possibleConstructorReturn(this, (PrettyFormatPluginError.__proto__ || _Object$getPrototypeOf(PrettyFormatPluginError)).call(this, message)); |
|
|
|
_this.stack = stack; |
|
_this.name = _this.constructor.name; |
|
return _this; |
|
} |
|
|
|
return PrettyFormatPluginError; |
|
}(Error); |
|
|
|
function isToStringedArrayType(toStringed) { |
|
return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]'; |
|
} |
|
|
|
function printNumber(val) { |
|
return _Object$is(val, -0) ? '-0' : String(val); |
|
} |
|
|
|
function printFunction(val, printFunctionName) { |
|
if (!printFunctionName) { |
|
return '[Function]'; |
|
} |
|
return '[Function ' + (val.name || 'anonymous') + ']'; |
|
} |
|
|
|
function printSymbol(val) { |
|
return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)'); |
|
} |
|
|
|
function printError(val) { |
|
return '[' + errorToString.call(val) + ']'; |
|
} |
|
|
|
function printBasicValue(val, printFunctionName, escapeRegex) { |
|
if (val === true || val === false) { |
|
return '' + val; |
|
} |
|
if (val === undefined) { |
|
return 'undefined'; |
|
} |
|
if (val === null) { |
|
return 'null'; |
|
} |
|
|
|
var typeOf = typeof val === 'undefined' ? 'undefined' : _typeof(val); |
|
|
|
if (typeOf === 'number') { |
|
return printNumber(val); |
|
} |
|
if (typeOf === 'string') { |
|
return '"' + val.replace(/"|\\/g, '\\$&') + '"'; |
|
} |
|
if (typeOf === 'function') { |
|
return printFunction(val, printFunctionName); |
|
} |
|
if (typeOf === 'symbol') { |
|
return printSymbol(val); |
|
} |
|
|
|
var toStringed = toString.call(val); |
|
|
|
if (toStringed === '[object WeakMap]') { |
|
return 'WeakMap {}'; |
|
} |
|
if (toStringed === '[object WeakSet]') { |
|
return 'WeakSet {}'; |
|
} |
|
if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') { |
|
return printFunction(val, printFunctionName); |
|
} |
|
if (toStringed === '[object Symbol]') { |
|
return printSymbol(val); |
|
} |
|
if (toStringed === '[object Date]') { |
|
return toISOString.call(val); |
|
} |
|
if (toStringed === '[object Error]') { |
|
return printError(val); |
|
} |
|
if (toStringed === '[object RegExp]') { |
|
if (escapeRegex) { |
|
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js |
|
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); |
|
} |
|
return regExpToString.call(val); |
|
} |
|
|
|
if (val instanceof Error) { |
|
return printError(val); |
|
} |
|
|
|
return null; |
|
} |
|
|
|
function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) { |
|
if (refs.indexOf(val) !== -1) { |
|
return '[Circular]'; |
|
} |
|
refs = refs.slice(); |
|
refs.push(val); |
|
|
|
var hitMaxDepth = ++depth > config.maxDepth; |
|
var min = config.min; |
|
|
|
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function' && !hasCalledToJSON) { |
|
return printer(val.toJSON(), config, indentation, depth, refs, true); |
|
} |
|
|
|
var toStringed = toString.call(val); |
|
if (toStringed === '[object Arguments]') { |
|
return hitMaxDepth ? '[Arguments]' : (min ? '' : 'Arguments ') + '[' + (0, collections.printListItems)(val, config, indentation, depth, refs, printer) + ']'; |
|
} |
|
if (isToStringedArrayType(toStringed)) { |
|
return hitMaxDepth ? '[' + val.constructor.name + ']' : (min ? '' : val.constructor.name + ' ') + '[' + (0, collections.printListItems)(val, config, indentation, depth, refs, printer) + ']'; |
|
} |
|
if (toStringed === '[object Map]') { |
|
return hitMaxDepth ? '[Map]' : 'Map {' + (0, collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer, ' => ') + '}'; |
|
} |
|
if (toStringed === '[object Set]') { |
|
return hitMaxDepth ? '[Set]' : 'Set {' + (0, collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + '}'; |
|
} |
|
|
|
// Avoid failure to serialize global window object in jsdom test environment. |
|
// For example, not even relevant if window is prop of React element. |
|
return hitMaxDepth || isWindow(val) ? '[' + getConstructorName(val) + ']' : (min ? '' : getConstructorName(val) + ' ') + '{' + (0, collections.printObjectProperties)(val, config, indentation, depth, refs, printer) + '}'; |
|
} |
|
|
|
function printPlugin(plugin, val, config, indentation, depth, refs) { |
|
var printed = void 0; |
|
|
|
try { |
|
printed = plugin.serialize ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, function (valChild) { |
|
return printer(valChild, config, indentation, depth, refs); |
|
}, function (str) { |
|
var indentationNext = indentation + config.indent; |
|
return indentationNext + str.replace(NEWLINE_REGEXP, '\n' + indentationNext); |
|
}, { |
|
edgeSpacing: config.spacingOuter, |
|
min: config.min, |
|
spacing: config.spacingInner |
|
}, config.colors); |
|
} catch (error) { |
|
throw new PrettyFormatPluginError(error.message, error.stack); |
|
} |
|
if (typeof printed !== 'string') { |
|
throw new Error('pretty-format: Plugin must return type "string" but instead returned "' + (typeof printed === 'undefined' ? 'undefined' : _typeof(printed)) + '".'); |
|
} |
|
return printed; |
|
} |
|
|
|
function findPlugin(plugins, val) { |
|
for (var p = 0; p < plugins.length; p++) { |
|
try { |
|
if (plugins[p].test(val)) { |
|
return plugins[p]; |
|
} |
|
} catch (error) { |
|
throw new PrettyFormatPluginError(error.message, error.stack); |
|
} |
|
} |
|
|
|
return null; |
|
} |
|
|
|
function printer(val, config, indentation, depth, refs, hasCalledToJSON) { |
|
var plugin = findPlugin(config.plugins, val); |
|
if (plugin !== null) { |
|
return printPlugin(plugin, val, config, indentation, depth, refs); |
|
} |
|
|
|
var basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex); |
|
if (basicResult !== null) { |
|
return basicResult; |
|
} |
|
|
|
return printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON); |
|
} |
|
|
|
var DEFAULT_THEME = { |
|
comment: 'gray', |
|
content: 'reset', |
|
prop: 'yellow', |
|
tag: 'cyan', |
|
value: 'green' |
|
}; |
|
|
|
var DEFAULT_THEME_KEYS = _Object$keys(DEFAULT_THEME); |
|
|
|
var DEFAULT_OPTIONS = { |
|
callToJSON: true, |
|
escapeRegex: false, |
|
highlight: false, |
|
indent: 2, |
|
maxDepth: Infinity, |
|
min: false, |
|
plugins: [], |
|
printFunctionName: true, |
|
theme: DEFAULT_THEME |
|
}; |
|
|
|
function validateOptions(options) { |
|
_Object$keys(options).forEach(function (key) { |
|
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) { |
|
throw new Error('pretty-format: Unknown option "' + key + '".'); |
|
} |
|
}); |
|
|
|
if (options.min && options.indent !== undefined && options.indent !== 0) { |
|
throw new Error('pretty-format: Options "min" and "indent" cannot be used together.'); |
|
} |
|
|
|
if (options.theme !== undefined) { |
|
if (options.theme === null) { |
|
throw new Error('pretty-format: Option "theme" must not be null.'); |
|
} |
|
|
|
if (_typeof(options.theme) !== 'object') { |
|
throw new Error('pretty-format: Option "theme" must be of type "object" but instead received "' + _typeof(options.theme) + '".'); |
|
} |
|
} |
|
} |
|
|
|
var getColorsHighlight = function getColorsHighlight(options |
|
// $FlowFixMe: Flow thinks keys from `Colors` are missing from `DEFAULT_THEME_KEYS` |
|
) { |
|
return DEFAULT_THEME_KEYS.reduce(function (colors, key) { |
|
var value = options.theme && options.theme[key] !== undefined ? options.theme[key] : DEFAULT_THEME[key]; |
|
var color = _ansiStyles2.default[value]; |
|
if (color && typeof color.close === 'string' && typeof color.open === 'string') { |
|
colors[key] = color; |
|
} else { |
|
throw new Error('pretty-format: Option "theme" has a key "' + key + '" whose value "' + value + '" is undefined in ansi-styles.'); |
|
} |
|
return colors; |
|
}, _Object$create(null)); |
|
}; |
|
|
|
var getColorsEmpty = function getColorsEmpty() { |
|
return ( |
|
// $FlowFixMe: Flow thinks keys from `Colors` are missing from `DEFAULT_THEME_KEYS` |
|
DEFAULT_THEME_KEYS.reduce(function (colors, key) { |
|
colors[key] = { close: '', open: '' }; |
|
return colors; |
|
}, _Object$create(null)) |
|
); |
|
}; |
|
|
|
var getPrintFunctionName = function getPrintFunctionName(options) { |
|
return options && options.printFunctionName !== undefined ? options.printFunctionName : DEFAULT_OPTIONS.printFunctionName; |
|
}; |
|
|
|
var getEscapeRegex = function getEscapeRegex(options) { |
|
return options && options.escapeRegex !== undefined ? options.escapeRegex : DEFAULT_OPTIONS.escapeRegex; |
|
}; |
|
|
|
var getConfig = function getConfig(options) { |
|
return { |
|
callToJSON: options && options.callToJSON !== undefined ? options.callToJSON : DEFAULT_OPTIONS.callToJSON, |
|
colors: options && options.highlight ? getColorsHighlight(options) : getColorsEmpty(), |
|
escapeRegex: getEscapeRegex(options), |
|
indent: options && options.min ? '' : createIndent(options && options.indent !== undefined ? options.indent : DEFAULT_OPTIONS.indent), |
|
maxDepth: options && options.maxDepth !== undefined ? options.maxDepth : DEFAULT_OPTIONS.maxDepth, |
|
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min, |
|
plugins: options && options.plugins !== undefined ? options.plugins : DEFAULT_OPTIONS.plugins, |
|
printFunctionName: getPrintFunctionName(options), |
|
spacingInner: options && options.min ? ' ' : '\n', |
|
spacingOuter: options && options.min ? '' : '\n' |
|
}; |
|
}; |
|
|
|
function createIndent(indent) { |
|
return new Array(indent + 1).join(' '); |
|
} |
|
|
|
function prettyFormat(val, options) { |
|
if (options) { |
|
validateOptions(options); |
|
if (options.plugins) { |
|
var plugin = findPlugin(options.plugins, val); |
|
if (plugin !== null) { |
|
return printPlugin(plugin, val, getConfig(options), '', 0, []); |
|
} |
|
} |
|
} |
|
|
|
var basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options)); |
|
if (basicResult !== null) { |
|
return basicResult; |
|
} |
|
|
|
return printComplexValue(val, getConfig(options), '', 0, []); |
|
} |
|
|
|
prettyFormat.plugins = { |
|
AsymmetricMatcher: _asymmetric_matcher2.default, |
|
ConvertAnsi: _convert_ansi2.default, |
|
DOMCollection: _dom_collection2.default, |
|
DOMElement: _dom_element2.default, |
|
Immutable: _immutable2.default, |
|
ReactElement: _react_element2.default, |
|
ReactTestComponent: _react_test_component2.default |
|
}; |
|
|
|
module.exports = prettyFormat; |
|
}); |
|
|
|
unwrapExports(build$2); |
|
|
|
var build = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.matcherHint = exports.pluralize = exports.ensureNumbers = exports.ensureExpectedIsNumber = exports.ensureActualIsNumber = exports.ensureNoExpected = exports.printWithType = exports.printExpected = exports.printReceived = exports.highlightTrailingWhitespace = exports.stringify = exports.SUGGEST_TO_EQUAL = exports.RECEIVED_COLOR = exports.EXPECTED_COLOR = undefined; |
|
|
|
var _chalk2 = _interopRequireDefault(fake_chalk); |
|
|
|
var _jestGetType2 = _interopRequireDefault(build$1); |
|
|
|
var _prettyFormat2 = _interopRequireDefault(build$2); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
var _prettyFormat$plugins = _prettyFormat2.default.plugins; /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var AsymmetricMatcher = _prettyFormat$plugins.AsymmetricMatcher, |
|
DOMCollection = _prettyFormat$plugins.DOMCollection, |
|
DOMElement = _prettyFormat$plugins.DOMElement, |
|
Immutable = _prettyFormat$plugins.Immutable, |
|
ReactElement = _prettyFormat$plugins.ReactElement, |
|
ReactTestComponent = _prettyFormat$plugins.ReactTestComponent; |
|
|
|
var PLUGINS = [ReactTestComponent, ReactElement, DOMElement, DOMCollection, Immutable, AsymmetricMatcher]; |
|
|
|
var EXPECTED_COLOR = exports.EXPECTED_COLOR = _chalk2.default.green; |
|
var RECEIVED_COLOR = exports.RECEIVED_COLOR = _chalk2.default.red; |
|
|
|
var NUMBERS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen']; |
|
|
|
var SUGGEST_TO_EQUAL = exports.SUGGEST_TO_EQUAL = _chalk2.default.dim('Looks like you wanted to test for object/array equality with strict `toBe` matcher. You probably need to use `toEqual` instead.'); |
|
|
|
var stringify = exports.stringify = function (object) { |
|
var maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; |
|
|
|
var MAX_LENGTH = 10000; |
|
var result = void 0; |
|
|
|
try { |
|
result = (0, _prettyFormat2.default)(object, { |
|
maxDepth: maxDepth, |
|
min: true, |
|
plugins: PLUGINS |
|
}); |
|
} catch (e) { |
|
result = (0, _prettyFormat2.default)(object, { |
|
callToJSON: false, |
|
maxDepth: maxDepth, |
|
min: true, |
|
plugins: PLUGINS |
|
}); |
|
} |
|
|
|
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result; |
|
}; |
|
|
|
var highlightTrailingWhitespace = exports.highlightTrailingWhitespace = function (text) { |
|
return text.replace(/\s+$/gm, _chalk2.default.inverse('$&')); |
|
}; |
|
|
|
var printReceived = exports.printReceived = function (object) { |
|
return RECEIVED_COLOR(highlightTrailingWhitespace(stringify(object))); |
|
}; |
|
var printExpected = exports.printExpected = function (value) { |
|
return EXPECTED_COLOR(highlightTrailingWhitespace(stringify(value))); |
|
}; |
|
|
|
var printWithType = exports.printWithType = function (name, received, print) { |
|
var type = (0, _jestGetType2.default)(received); |
|
return name + ':' + (type !== 'null' && type !== 'undefined' ? '\n ' + type + ': ' : ' ') + print(received); |
|
}; |
|
|
|
var ensureNoExpected = exports.ensureNoExpected = function (expected, matcherName) { |
|
matcherName || (matcherName = 'This'); |
|
if (typeof expected !== 'undefined') { |
|
throw new Error(matcherHint('[.not]' + matcherName, undefined, '') + '\n\n' + 'Matcher does not accept any arguments.\n' + printWithType('Got', expected, printExpected)); |
|
} |
|
}; |
|
|
|
var ensureActualIsNumber = exports.ensureActualIsNumber = function (actual, matcherName) { |
|
matcherName || (matcherName = 'This matcher'); |
|
if (typeof actual !== 'number') { |
|
throw new Error(matcherHint('[.not]' + matcherName) + '\n\n' + 'Received value must be a number.\n' + printWithType('Received', actual, printReceived)); |
|
} |
|
}; |
|
|
|
var ensureExpectedIsNumber = exports.ensureExpectedIsNumber = function (expected, matcherName) { |
|
matcherName || (matcherName = 'This matcher'); |
|
if (typeof expected !== 'number') { |
|
throw new Error(matcherHint('[.not]' + matcherName) + '\n\n' + 'Expected value must be a number.\n' + printWithType('Got', expected, printExpected)); |
|
} |
|
}; |
|
|
|
var ensureNumbers = exports.ensureNumbers = function (actual, expected, matcherName) { |
|
ensureActualIsNumber(actual, matcherName); |
|
ensureExpectedIsNumber(expected, matcherName); |
|
}; |
|
|
|
var pluralize = exports.pluralize = function (word, count) { |
|
return (NUMBERS[count] || count) + ' ' + word + (count === 1 ? '' : 's'); |
|
}; |
|
|
|
var matcherHint = exports.matcherHint = function (matcherName) { |
|
var received = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'received'; |
|
var expected = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'expected'; |
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; |
|
var comment = options.comment, |
|
isDirectExpectCall = options.isDirectExpectCall, |
|
secondArgument = options.secondArgument; |
|
|
|
return _chalk2.default.dim('expect' + (isDirectExpectCall ? '' : '(')) + RECEIVED_COLOR(received) + _chalk2.default.dim((isDirectExpectCall ? '' : ')') + matcherName + '(') + EXPECTED_COLOR(expected) + (secondArgument ? '' + _chalk2.default.dim(', ') + EXPECTED_COLOR(secondArgument) : '') + _chalk2.default.dim(')' + (comment ? ' // ' + comment : '')); |
|
}; |
|
}); |
|
|
|
var index = unwrapExports(build); |
|
var build_1 = build.matcherHint; |
|
var build_2 = build.pluralize; |
|
var build_3 = build.ensureNumbers; |
|
var build_4 = build.ensureExpectedIsNumber; |
|
var build_5 = build.ensureActualIsNumber; |
|
var build_6 = build.ensureNoExpected; |
|
var build_7 = build.printWithType; |
|
var build_8 = build.printExpected; |
|
var build_9 = build.printReceived; |
|
var build_10 = build.highlightTrailingWhitespace; |
|
var build_11 = build.stringify; |
|
var build_12 = build.SUGGEST_TO_EQUAL; |
|
var build_13 = build.RECEIVED_COLOR; |
|
var build_14 = build.EXPECTED_COLOR; |
|
|
|
|
|
var utils = Object.freeze({ |
|
default: index, |
|
__moduleExports: build, |
|
matcherHint: build_1, |
|
pluralize: build_2, |
|
ensureNumbers: build_3, |
|
ensureExpectedIsNumber: build_4, |
|
ensureActualIsNumber: build_5, |
|
ensureNoExpected: build_6, |
|
printWithType: build_7, |
|
printExpected: build_8, |
|
printReceived: build_9, |
|
highlightTrailingWhitespace: build_10, |
|
stringify: build_11, |
|
SUGGEST_TO_EQUAL: build_12, |
|
RECEIVED_COLOR: build_13, |
|
EXPECTED_COLOR: build_14 |
|
}); |
|
|
|
var _createProperty = function (object, index, value) { |
|
if (index in object) _objectDp.f(object, index, _propertyDesc(0, value)); |
|
else object[index] = value; |
|
}; |
|
|
|
_export(_export.S + _export.F * !_iterDetect(function (iter) { }), 'Array', { |
|
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) |
|
from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { |
|
var O = _toObject(arrayLike); |
|
var C = typeof this == 'function' ? this : Array; |
|
var aLen = arguments.length; |
|
var mapfn = aLen > 1 ? arguments[1] : undefined; |
|
var mapping = mapfn !== undefined; |
|
var index = 0; |
|
var iterFn = core_getIteratorMethod(O); |
|
var length, result, step, iterator; |
|
if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); |
|
// if object isn't iterable or it's array with default iterator - use simple case |
|
if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) { |
|
for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { |
|
_createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value); |
|
} |
|
} else { |
|
length = _toLength(O.length); |
|
for (result = new C(length); length > index; index++) { |
|
_createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); |
|
} |
|
} |
|
result.length = index; |
|
return result; |
|
} |
|
}); |
|
|
|
var from$2 = _core.Array.from; |
|
|
|
var from$1 = createCommonjsModule(function (module) { |
|
module.exports = { "default": from$2, __esModule: true }; |
|
}); |
|
|
|
var _Array$from = unwrapExports(from$1); |
|
|
|
// 20.1.2.4 Number.isNaN(number) |
|
|
|
|
|
_export(_export.S, 'Number', { |
|
isNaN: function isNaN(number) { |
|
// eslint-disable-next-line no-self-compare |
|
return number != number; |
|
} |
|
}); |
|
|
|
var isNan$1 = _core.Number.isNaN; |
|
|
|
var isNan = createCommonjsModule(function (module) { |
|
module.exports = { "default": isNan$1, __esModule: true }; |
|
}); |
|
|
|
var _Number$isNaN = unwrapExports(isNan); |
|
|
|
var base = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports['default'] = /*istanbul ignore end*/Diff; |
|
function Diff() {} |
|
|
|
Diff.prototype = { |
|
/*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) { |
|
/*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
|
|
var callback = options.callback; |
|
if (typeof options === 'function') { |
|
callback = options; |
|
options = {}; |
|
} |
|
this.options = options; |
|
|
|
var self = this; |
|
|
|
function done(value) { |
|
if (callback) { |
|
setTimeout(function () { |
|
callback(undefined, value); |
|
}, 0); |
|
return true; |
|
} else { |
|
return value; |
|
} |
|
} |
|
|
|
// Allow subclasses to massage the input prior to running |
|
oldString = this.castInput(oldString); |
|
newString = this.castInput(newString); |
|
|
|
oldString = this.removeEmpty(this.tokenize(oldString)); |
|
newString = this.removeEmpty(this.tokenize(newString)); |
|
|
|
var newLen = newString.length, |
|
oldLen = oldString.length; |
|
var editLength = 1; |
|
var maxEditLength = newLen + oldLen; |
|
var bestPath = [{ newPos: -1, components: [] }]; |
|
|
|
// Seed editLength = 0, i.e. the content starts with the same values |
|
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); |
|
if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { |
|
// Identity per the equality and tokenizer |
|
return done([{ value: this.join(newString), count: newString.length }]); |
|
} |
|
|
|
// Main worker method. checks all permutations of a given edit length for acceptance. |
|
function execEditLength() { |
|
for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { |
|
var basePath = /*istanbul ignore start*/void 0; |
|
var addPath = bestPath[diagonalPath - 1], |
|
removePath = bestPath[diagonalPath + 1], |
|
_oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; |
|
if (addPath) { |
|
// No one else is going to attempt to use this value, clear it |
|
bestPath[diagonalPath - 1] = undefined; |
|
} |
|
|
|
var canAdd = addPath && addPath.newPos + 1 < newLen, |
|
canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; |
|
if (!canAdd && !canRemove) { |
|
// If this path is a terminal then prune |
|
bestPath[diagonalPath] = undefined; |
|
continue; |
|
} |
|
|
|
// Select the diagonal that we want to branch from. We select the prior |
|
// path whose position in the new string is the farthest from the origin |
|
// and does not pass the bounds of the diff graph |
|
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { |
|
basePath = clonePath(removePath); |
|
self.pushComponent(basePath.components, undefined, true); |
|
} else { |
|
basePath = addPath; // No need to clone, we've pulled it from the list |
|
basePath.newPos++; |
|
self.pushComponent(basePath.components, true, undefined); |
|
} |
|
|
|
_oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); |
|
|
|
// If we have hit the end of both strings, then we are done |
|
if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { |
|
return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); |
|
} else { |
|
// Otherwise track this path as a potential candidate and continue. |
|
bestPath[diagonalPath] = basePath; |
|
} |
|
} |
|
|
|
editLength++; |
|
} |
|
|
|
// Performs the length of edit iteration. Is a bit fugly as this has to support the |
|
// sync and async mode which is never fun. Loops over execEditLength until a value |
|
// is produced. |
|
if (callback) { |
|
(function exec() { |
|
setTimeout(function () { |
|
// This should not happen, but we want to be safe. |
|
/* istanbul ignore next */ |
|
if (editLength > maxEditLength) { |
|
return callback(); |
|
} |
|
|
|
if (!execEditLength()) { |
|
exec(); |
|
} |
|
}, 0); |
|
})(); |
|
} else { |
|
while (editLength <= maxEditLength) { |
|
var ret = execEditLength(); |
|
if (ret) { |
|
return ret; |
|
} |
|
} |
|
} |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) { |
|
var last = components[components.length - 1]; |
|
if (last && last.added === added && last.removed === removed) { |
|
// We need to clone here as the component clone operation is just |
|
// as shallow array clone |
|
components[components.length - 1] = { count: last.count + 1, added: added, removed: removed }; |
|
} else { |
|
components.push({ count: 1, added: added, removed: removed }); |
|
} |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { |
|
var newLen = newString.length, |
|
oldLen = oldString.length, |
|
newPos = basePath.newPos, |
|
oldPos = newPos - diagonalPath, |
|
commonCount = 0; |
|
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { |
|
newPos++; |
|
oldPos++; |
|
commonCount++; |
|
} |
|
|
|
if (commonCount) { |
|
basePath.components.push({ count: commonCount }); |
|
} |
|
|
|
basePath.newPos = newPos; |
|
return oldPos; |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) { |
|
if (this.options.comparator) { |
|
return this.options.comparator(left, right); |
|
} else { |
|
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); |
|
} |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) { |
|
var ret = []; |
|
for (var i = 0; i < array.length; i++) { |
|
if (array[i]) { |
|
ret.push(array[i]); |
|
} |
|
} |
|
return ret; |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) { |
|
return value; |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) { |
|
return value.split(''); |
|
}, |
|
/*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) { |
|
return chars.join(''); |
|
} |
|
}; |
|
|
|
function buildValues(diff, components, newString, oldString, useLongestToken) { |
|
var componentPos = 0, |
|
componentLen = components.length, |
|
newPos = 0, |
|
oldPos = 0; |
|
|
|
for (; componentPos < componentLen; componentPos++) { |
|
var component = components[componentPos]; |
|
if (!component.removed) { |
|
if (!component.added && useLongestToken) { |
|
var value = newString.slice(newPos, newPos + component.count); |
|
value = value.map(function (value, i) { |
|
var oldValue = oldString[oldPos + i]; |
|
return oldValue.length > value.length ? oldValue : value; |
|
}); |
|
|
|
component.value = diff.join(value); |
|
} else { |
|
component.value = diff.join(newString.slice(newPos, newPos + component.count)); |
|
} |
|
newPos += component.count; |
|
|
|
// Common case |
|
if (!component.added) { |
|
oldPos += component.count; |
|
} |
|
} else { |
|
component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); |
|
oldPos += component.count; |
|
|
|
// Reverse add and remove so removes are output first to match common convention |
|
// The diffing algorithm is tied to add then remove output and this is the simplest |
|
// route to get the desired output with minimal overhead. |
|
if (componentPos && components[componentPos - 1].added) { |
|
var tmp = components[componentPos - 1]; |
|
components[componentPos - 1] = components[componentPos]; |
|
components[componentPos] = tmp; |
|
} |
|
} |
|
} |
|
|
|
// Special case handle for when one terminal is ignored (i.e. whitespace). |
|
// For this case we merge the terminal into the prior string and drop the change. |
|
// This is only available for string mode. |
|
var lastComponent = components[componentLen - 1]; |
|
if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { |
|
components[componentLen - 2].value += lastComponent.value; |
|
components.pop(); |
|
} |
|
|
|
return components; |
|
} |
|
|
|
function clonePath(path) { |
|
return { newPos: path.newPos, components: path.components.slice(0) }; |
|
} |
|
}); |
|
|
|
unwrapExports(base); |
|
|
|
var character = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.characterDiff = undefined; |
|
exports. /*istanbul ignore end*/diffChars = diffChars; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
function diffChars(oldStr, newStr, options) { |
|
return characterDiff.diff(oldStr, newStr, options); |
|
} |
|
}); |
|
|
|
unwrapExports(character); |
|
var character_1 = character.characterDiff; |
|
var character_2 = character.diffChars; |
|
|
|
var params = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/generateOptions = generateOptions; |
|
function generateOptions(options, defaults) { |
|
if (typeof options === 'function') { |
|
defaults.callback = options; |
|
} else if (options) { |
|
for (var name in options) { |
|
/* istanbul ignore else */ |
|
if (options.hasOwnProperty(name)) { |
|
defaults[name] = options[name]; |
|
} |
|
} |
|
} |
|
return defaults; |
|
} |
|
}); |
|
|
|
unwrapExports(params); |
|
var params_1 = params.generateOptions; |
|
|
|
var word = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.wordDiff = undefined; |
|
exports. /*istanbul ignore end*/diffWords = diffWords; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
/*istanbul ignore end*/ |
|
|
|
/*istanbul ignore start*/function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode |
|
// |
|
// Ranges and exceptions: |
|
// Latin-1 Supplement, 0080–00FF |
|
// - U+00D7 × Multiplication sign |
|
// - U+00F7 ÷ Division sign |
|
// Latin Extended-A, 0100–017F |
|
// Latin Extended-B, 0180–024F |
|
// IPA Extensions, 0250–02AF |
|
// Spacing Modifier Letters, 02B0–02FF |
|
// - U+02C7 ˇ ˇ Caron |
|
// - U+02D8 ˘ ˘ Breve |
|
// - U+02D9 ˙ ˙ Dot Above |
|
// - U+02DA ˚ ˚ Ring Above |
|
// - U+02DB ˛ ˛ Ogonek |
|
// - U+02DC ˜ ˜ Small Tilde |
|
// - U+02DD ˝ ˝ Double Acute Accent |
|
// Latin Extended Additional, 1E00–1EFF |
|
var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; |
|
|
|
var reWhitespace = /\S/; |
|
|
|
var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
wordDiff.equals = function (left, right) { |
|
if (this.options.ignoreCase) { |
|
left = left.toLowerCase(); |
|
right = right.toLowerCase(); |
|
} |
|
return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); |
|
}; |
|
wordDiff.tokenize = function (value) { |
|
var tokens = value.split(/(\s+|\b)/); |
|
|
|
// Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. |
|
for (var i = 0; i < tokens.length - 1; i++) { |
|
// If we have an empty string in the next field and we have only word chars before and after, merge |
|
if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { |
|
tokens[i] += tokens[i + 2]; |
|
tokens.splice(i + 1, 2); |
|
i--; |
|
} |
|
} |
|
|
|
return tokens; |
|
}; |
|
|
|
function diffWords(oldStr, newStr, options) { |
|
options = /*istanbul ignore start*/(0, params.generateOptions)(options, { ignoreWhitespace: true }); |
|
return wordDiff.diff(oldStr, newStr, options); |
|
} |
|
|
|
function diffWordsWithSpace(oldStr, newStr, options) { |
|
return wordDiff.diff(oldStr, newStr, options); |
|
} |
|
}); |
|
|
|
unwrapExports(word); |
|
var word_1 = word.wordDiff; |
|
var word_2 = word.diffWords; |
|
var word_3 = word.diffWordsWithSpace; |
|
|
|
var line = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.lineDiff = undefined; |
|
exports. /*istanbul ignore end*/diffLines = diffLines; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
/*istanbul ignore end*/ |
|
|
|
/*istanbul ignore start*/function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
lineDiff.tokenize = function (value) { |
|
var retLines = [], |
|
linesAndNewlines = value.split(/(\n|\r\n)/); |
|
|
|
// Ignore the final empty token that occurs if the string ends with a new line |
|
if (!linesAndNewlines[linesAndNewlines.length - 1]) { |
|
linesAndNewlines.pop(); |
|
} |
|
|
|
// Merge the content and line separators into single tokens |
|
for (var i = 0; i < linesAndNewlines.length; i++) { |
|
var line = linesAndNewlines[i]; |
|
|
|
if (i % 2 && !this.options.newlineIsToken) { |
|
retLines[retLines.length - 1] += line; |
|
} else { |
|
if (this.options.ignoreWhitespace) { |
|
line = line.trim(); |
|
} |
|
retLines.push(line); |
|
} |
|
} |
|
|
|
return retLines; |
|
}; |
|
|
|
function diffLines(oldStr, newStr, callback) { |
|
return lineDiff.diff(oldStr, newStr, callback); |
|
} |
|
function diffTrimmedLines(oldStr, newStr, callback) { |
|
var options = /*istanbul ignore start*/(0, params.generateOptions)(callback, { ignoreWhitespace: true }); |
|
return lineDiff.diff(oldStr, newStr, options); |
|
} |
|
}); |
|
|
|
unwrapExports(line); |
|
var line_1 = line.lineDiff; |
|
var line_2 = line.diffLines; |
|
var line_3 = line.diffTrimmedLines; |
|
|
|
var sentence = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.sentenceDiff = undefined; |
|
exports. /*istanbul ignore end*/diffSentences = diffSentences; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
sentenceDiff.tokenize = function (value) { |
|
return value.split(/(\S.+?[.!?])(?=\s+|$)/); |
|
}; |
|
|
|
function diffSentences(oldStr, newStr, callback) { |
|
return sentenceDiff.diff(oldStr, newStr, callback); |
|
} |
|
}); |
|
|
|
unwrapExports(sentence); |
|
var sentence_1 = sentence.sentenceDiff; |
|
var sentence_2 = sentence.diffSentences; |
|
|
|
var css = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.cssDiff = undefined; |
|
exports. /*istanbul ignore end*/diffCss = diffCss; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
cssDiff.tokenize = function (value) { |
|
return value.split(/([{}:;,]|\s+)/); |
|
}; |
|
|
|
function diffCss(oldStr, newStr, callback) { |
|
return cssDiff.diff(oldStr, newStr, callback); |
|
} |
|
}); |
|
|
|
unwrapExports(css); |
|
var css_1 = css.cssDiff; |
|
var css_2 = css.diffCss; |
|
|
|
var $JSON$1 = _core.JSON || (_core.JSON = { stringify: JSON.stringify }); |
|
var stringify$1 = function stringify(it) { // eslint-disable-line no-unused-vars |
|
return $JSON$1.stringify.apply($JSON$1, arguments); |
|
}; |
|
|
|
var stringify = createCommonjsModule(function (module) { |
|
module.exports = { "default": stringify$1, __esModule: true }; |
|
}); |
|
|
|
var _JSON$stringify = unwrapExports(stringify); |
|
|
|
var json = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.jsonDiff = undefined; |
|
|
|
var _typeof$$1 = typeof _Symbol === "function" && _typeof(_Symbol$iterator) === "symbol" ? function (obj) { |
|
return typeof obj === 'undefined' ? 'undefined' : _typeof(obj); |
|
} : function (obj) { |
|
return obj && typeof _Symbol === "function" && obj.constructor === _Symbol && obj !== _Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof(obj); |
|
}; |
|
|
|
exports. /*istanbul ignore end*/diffJson = diffJson; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
/*istanbul ignore end*/ |
|
|
|
/*istanbul ignore start*/function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString; |
|
|
|
var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a |
|
// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: |
|
jsonDiff.useLongestToken = true; |
|
|
|
jsonDiff.tokenize = /*istanbul ignore start*/line.lineDiff /*istanbul ignore end*/.tokenize; |
|
jsonDiff.castInput = function (value) { |
|
/*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement; |
|
|
|
return typeof value === 'string' ? value : _JSON$stringify(canonicalize(value), function (k, v) { |
|
if (typeof v === 'undefined') { |
|
return undefinedReplacement; |
|
} |
|
|
|
return v; |
|
}, ' '); |
|
}; |
|
jsonDiff.equals = function (left, right) { |
|
return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')) |
|
); |
|
}; |
|
|
|
function diffJson(oldObj, newObj, options) { |
|
return jsonDiff.diff(oldObj, newObj, options); |
|
} |
|
|
|
// This function handles the presence of circular references by bailing out when encountering an |
|
// object that is already on the "stack" of items being processed. |
|
function canonicalize(obj, stack, replacementStack) { |
|
stack = stack || []; |
|
replacementStack = replacementStack || []; |
|
|
|
var i = /*istanbul ignore start*/void 0; |
|
|
|
for (i = 0; i < stack.length; i += 1) { |
|
if (stack[i] === obj) { |
|
return replacementStack[i]; |
|
} |
|
} |
|
|
|
var canonicalizedObj = /*istanbul ignore start*/void 0; |
|
|
|
if ('[object Array]' === objectPrototypeToString.call(obj)) { |
|
stack.push(obj); |
|
canonicalizedObj = new Array(obj.length); |
|
replacementStack.push(canonicalizedObj); |
|
for (i = 0; i < obj.length; i += 1) { |
|
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack); |
|
} |
|
stack.pop(); |
|
replacementStack.pop(); |
|
return canonicalizedObj; |
|
} |
|
|
|
if (obj && obj.toJSON) { |
|
obj = obj.toJSON(); |
|
} |
|
|
|
if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof$$1(obj)) === 'object' && obj !== null) { |
|
stack.push(obj); |
|
canonicalizedObj = {}; |
|
replacementStack.push(canonicalizedObj); |
|
var sortedKeys = [], |
|
key = /*istanbul ignore start*/void 0; |
|
for (key in obj) { |
|
/* istanbul ignore else */ |
|
if (obj.hasOwnProperty(key)) { |
|
sortedKeys.push(key); |
|
} |
|
} |
|
sortedKeys.sort(); |
|
for (i = 0; i < sortedKeys.length; i += 1) { |
|
key = sortedKeys[i]; |
|
canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack); |
|
} |
|
stack.pop(); |
|
replacementStack.pop(); |
|
} else { |
|
canonicalizedObj = obj; |
|
} |
|
return canonicalizedObj; |
|
} |
|
}); |
|
|
|
unwrapExports(json); |
|
var json_1 = json.jsonDiff; |
|
var json_2 = json.diffJson; |
|
var json_3 = json.canonicalize; |
|
|
|
var array = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.arrayDiff = undefined; |
|
exports. /*istanbul ignore end*/diffArrays = diffArrays; |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
arrayDiff.tokenize = arrayDiff.join = function (value) { |
|
return value.slice(); |
|
}; |
|
arrayDiff.removeEmpty = function (value) { |
|
return value; |
|
}; |
|
|
|
function diffArrays(oldArr, newArr, callback) { |
|
return arrayDiff.diff(oldArr, newArr, callback); |
|
} |
|
}); |
|
|
|
unwrapExports(array); |
|
var array_1 = array.arrayDiff; |
|
var array_2 = array.diffArrays; |
|
|
|
var parse = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/parsePatch = parsePatch; |
|
function parsePatch(uniDiff) { |
|
/*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
|
|
var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), |
|
delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
|
list = [], |
|
i = 0; |
|
|
|
function parseIndex() { |
|
var index = {}; |
|
list.push(index); |
|
|
|
// Parse diff metadata |
|
while (i < diffstr.length) { |
|
var line = diffstr[i]; |
|
|
|
// File header found, end parsing diff metadata |
|
if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { |
|
break; |
|
} |
|
|
|
// Diff index |
|
var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); |
|
if (header) { |
|
index.index = header[1]; |
|
} |
|
|
|
i++; |
|
} |
|
|
|
// Parse file headers if they are defined. Unified diff requires them, but |
|
// there's no technical issues to have an isolated hunk without file header |
|
parseFileHeader(index); |
|
parseFileHeader(index); |
|
|
|
// Parse hunks |
|
index.hunks = []; |
|
|
|
while (i < diffstr.length) { |
|
var _line = diffstr[i]; |
|
|
|
if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { |
|
break; |
|
} else if (/^@@/.test(_line)) { |
|
index.hunks.push(parseHunk()); |
|
} else if (_line && options.strict) { |
|
// Ignore unexpected content unless in strict mode |
|
throw new Error('Unknown line ' + (i + 1) + ' ' + _JSON$stringify(_line)); |
|
} else { |
|
i++; |
|
} |
|
} |
|
} |
|
|
|
// Parses the --- and +++ headers, if none are found, no lines |
|
// are consumed. |
|
function parseFileHeader(index) { |
|
var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/; |
|
var fileHeader = headerPattern.exec(diffstr[i]); |
|
if (fileHeader) { |
|
var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; |
|
var fileName = fileHeader[2].replace(/\\\\/g, '\\'); |
|
if (/^".*"$/.test(fileName)) { |
|
fileName = fileName.substr(1, fileName.length - 2); |
|
} |
|
index[keyPrefix + 'FileName'] = fileName; |
|
index[keyPrefix + 'Header'] = fileHeader[3]; |
|
|
|
i++; |
|
} |
|
} |
|
|
|
// Parses a hunk |
|
// This assumes that we are at the start of a hunk. |
|
function parseHunk() { |
|
var chunkHeaderIndex = i, |
|
chunkHeaderLine = diffstr[i++], |
|
chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); |
|
|
|
var hunk = { |
|
oldStart: +chunkHeader[1], |
|
oldLines: +chunkHeader[2] || 1, |
|
newStart: +chunkHeader[3], |
|
newLines: +chunkHeader[4] || 1, |
|
lines: [], |
|
linedelimiters: [] |
|
}; |
|
|
|
var addCount = 0, |
|
removeCount = 0; |
|
for (; i < diffstr.length; i++) { |
|
// Lines starting with '---' could be mistaken for the "remove line" operation |
|
// But they could be the header for the next file. Therefore prune such cases out. |
|
if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { |
|
break; |
|
} |
|
var operation = diffstr[i][0]; |
|
|
|
if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { |
|
hunk.lines.push(diffstr[i]); |
|
hunk.linedelimiters.push(delimiters[i] || '\n'); |
|
|
|
if (operation === '+') { |
|
addCount++; |
|
} else if (operation === '-') { |
|
removeCount++; |
|
} else if (operation === ' ') { |
|
addCount++; |
|
removeCount++; |
|
} |
|
} else { |
|
break; |
|
} |
|
} |
|
|
|
// Handle the empty block count case |
|
if (!addCount && hunk.newLines === 1) { |
|
hunk.newLines = 0; |
|
} |
|
if (!removeCount && hunk.oldLines === 1) { |
|
hunk.oldLines = 0; |
|
} |
|
|
|
// Perform optional sanity checking |
|
if (options.strict) { |
|
if (addCount !== hunk.newLines) { |
|
throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
|
} |
|
if (removeCount !== hunk.oldLines) { |
|
throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
|
} |
|
} |
|
|
|
return hunk; |
|
} |
|
|
|
while (i < diffstr.length) { |
|
parseIndex(); |
|
} |
|
|
|
return list; |
|
} |
|
}); |
|
|
|
unwrapExports(parse); |
|
var parse_1 = parse.parsePatch; |
|
|
|
var distanceIterator = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
|
|
exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) { |
|
var wantForward = true, |
|
backwardExhausted = false, |
|
forwardExhausted = false, |
|
localOffset = 1; |
|
|
|
return function iterator() { |
|
if (wantForward && !forwardExhausted) { |
|
if (backwardExhausted) { |
|
localOffset++; |
|
} else { |
|
wantForward = false; |
|
} |
|
|
|
// Check if trying to fit beyond text length, and if not, check it fits |
|
// after offset location (or desired location on first iteration) |
|
if (start + localOffset <= maxLine) { |
|
return localOffset; |
|
} |
|
|
|
forwardExhausted = true; |
|
} |
|
|
|
if (!backwardExhausted) { |
|
if (!forwardExhausted) { |
|
wantForward = true; |
|
} |
|
|
|
// Check if trying to fit before text beginning, and if not, check it fits |
|
// before offset location |
|
if (minLine <= start - localOffset) { |
|
return -localOffset++; |
|
} |
|
|
|
backwardExhausted = true; |
|
return iterator(); |
|
} |
|
|
|
// We tried to fit hunk before text beginning and beyond text length, then |
|
// hunk can't fit on the text. Return undefined |
|
}; |
|
}; |
|
}); |
|
|
|
unwrapExports(distanceIterator); |
|
|
|
var apply = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/applyPatch = applyPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches; |
|
|
|
/*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(distanceIterator); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/*istanbul ignore end*/function applyPatch(source, uniDiff) { |
|
/*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
|
|
if (typeof uniDiff === 'string') { |
|
uniDiff = /*istanbul ignore start*/(0, parse.parsePatch)(uniDiff); |
|
} |
|
|
|
if (Array.isArray(uniDiff)) { |
|
if (uniDiff.length > 1) { |
|
throw new Error('applyPatch only works with a single input.'); |
|
} |
|
|
|
uniDiff = uniDiff[0]; |
|
} |
|
|
|
// Apply the diff to the input |
|
var lines = source.split(/\r\n|[\n\v\f\r\x85]/), |
|
delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
|
hunks = uniDiff.hunks, |
|
compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{ |
|
return (/*istanbul ignore end*/line === patchContent |
|
); |
|
}, |
|
errorCount = 0, |
|
fuzzFactor = options.fuzzFactor || 0, |
|
minLine = 0, |
|
offset = 0, |
|
removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/ |
|
, |
|
addEOFNL = /*istanbul ignore start*/void 0; |
|
|
|
/** |
|
* Checks if the hunk exactly fits on the provided location |
|
*/ |
|
function hunkFits(hunk, toPos) { |
|
for (var j = 0; j < hunk.lines.length; j++) { |
|
var line = hunk.lines[j], |
|
operation = line[0], |
|
content = line.substr(1); |
|
|
|
if (operation === ' ' || operation === '-') { |
|
// Context sanity check |
|
if (!compareLine(toPos + 1, lines[toPos], operation, content)) { |
|
errorCount++; |
|
|
|
if (errorCount > fuzzFactor) { |
|
return false; |
|
} |
|
} |
|
toPos++; |
|
} |
|
} |
|
|
|
return true; |
|
} |
|
|
|
// Search best fit offsets for each hunk based on the previous ones |
|
for (var i = 0; i < hunks.length; i++) { |
|
var hunk = hunks[i], |
|
maxLine = lines.length - hunk.oldLines, |
|
localOffset = 0, |
|
toPos = offset + hunk.oldStart - 1; |
|
|
|
var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default'])(toPos, minLine, maxLine); |
|
|
|
for (; localOffset !== undefined; localOffset = iterator()) { |
|
if (hunkFits(hunk, toPos + localOffset)) { |
|
hunk.offset = offset += localOffset; |
|
break; |
|
} |
|
} |
|
|
|
if (localOffset === undefined) { |
|
return false; |
|
} |
|
|
|
// Set lower text limit to end of the current hunk, so next ones don't try |
|
// to fit over already patched text |
|
minLine = hunk.offset + hunk.oldStart + hunk.oldLines; |
|
} |
|
|
|
// Apply patch hunks |
|
var diffOffset = 0; |
|
for (var _i = 0; _i < hunks.length; _i++) { |
|
var _hunk = hunks[_i], |
|
_toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; |
|
diffOffset += _hunk.newLines - _hunk.oldLines; |
|
|
|
if (_toPos < 0) { |
|
// Creating a new file |
|
_toPos = 0; |
|
} |
|
|
|
for (var j = 0; j < _hunk.lines.length; j++) { |
|
var line = _hunk.lines[j], |
|
operation = line[0], |
|
content = line.substr(1), |
|
delimiter = _hunk.linedelimiters[j]; |
|
|
|
if (operation === ' ') { |
|
_toPos++; |
|
} else if (operation === '-') { |
|
lines.splice(_toPos, 1); |
|
delimiters.splice(_toPos, 1); |
|
/* istanbul ignore else */ |
|
} else if (operation === '+') { |
|
lines.splice(_toPos, 0, content); |
|
delimiters.splice(_toPos, 0, delimiter); |
|
_toPos++; |
|
} else if (operation === '\\') { |
|
var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; |
|
if (previousOperation === '+') { |
|
removeEOFNL = true; |
|
} else if (previousOperation === '-') { |
|
addEOFNL = true; |
|
} |
|
} |
|
} |
|
} |
|
|
|
// Handle EOFNL insertion/removal |
|
if (removeEOFNL) { |
|
while (!lines[lines.length - 1]) { |
|
lines.pop(); |
|
delimiters.pop(); |
|
} |
|
} else if (addEOFNL) { |
|
lines.push(''); |
|
delimiters.push('\n'); |
|
} |
|
for (var _k = 0; _k < lines.length - 1; _k++) { |
|
lines[_k] = lines[_k] + delimiters[_k]; |
|
} |
|
return lines.join(''); |
|
} |
|
|
|
// Wrapper that supports multiple file patches via callbacks. |
|
function applyPatches(uniDiff, options) { |
|
if (typeof uniDiff === 'string') { |
|
uniDiff = /*istanbul ignore start*/(0, parse.parsePatch)(uniDiff); |
|
} |
|
|
|
var currentIndex = 0; |
|
function processIndex() { |
|
var index = uniDiff[currentIndex++]; |
|
if (!index) { |
|
return options.complete(); |
|
} |
|
|
|
options.loadFile(index, function (err, data) { |
|
if (err) { |
|
return options.complete(err); |
|
} |
|
|
|
var updatedContent = applyPatch(data, index, options); |
|
options.patched(index, updatedContent, function (err) { |
|
if (err) { |
|
return options.complete(err); |
|
} |
|
|
|
processIndex(); |
|
}); |
|
}); |
|
} |
|
processIndex(); |
|
} |
|
}); |
|
|
|
unwrapExports(apply); |
|
var apply_1 = apply.applyPatch; |
|
var apply_2 = apply.applyPatches; |
|
|
|
var create$4 = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/structuredPatch = structuredPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch; |
|
|
|
/*istanbul ignore start*/function _toConsumableArray(arr) { |
|
if (Array.isArray(arr)) { |
|
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { |
|
arr2[i] = arr[i]; |
|
}return arr2; |
|
} else { |
|
return _Array$from(arr); |
|
} |
|
} |
|
|
|
/*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
|
if (!options) { |
|
options = {}; |
|
} |
|
if (typeof options.context === 'undefined') { |
|
options.context = 4; |
|
} |
|
|
|
var diff = /*istanbul ignore start*/(0, line.diffLines)(oldStr, newStr, options); |
|
diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier |
|
|
|
function contextLines(lines) { |
|
return lines.map(function (entry) { |
|
return ' ' + entry; |
|
}); |
|
} |
|
|
|
var hunks = []; |
|
var oldRangeStart = 0, |
|
newRangeStart = 0, |
|
curRange = [], |
|
oldLine = 1, |
|
newLine = 1; |
|
|
|
/*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) { |
|
var current = diff[i], |
|
lines = current.lines || current.value.replace(/\n$/, '').split('\n'); |
|
current.lines = lines; |
|
|
|
if (current.added || current.removed) { |
|
/*istanbul ignore start*/var _curRange; |
|
|
|
/*istanbul ignore end*/ // If we have previous context, start with that |
|
if (!oldRangeStart) { |
|
var prev = diff[i - 1]; |
|
oldRangeStart = oldLine; |
|
newRangeStart = newLine; |
|
|
|
if (prev) { |
|
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; |
|
oldRangeStart -= curRange.length; |
|
newRangeStart -= curRange.length; |
|
} |
|
} |
|
|
|
// Output our changes |
|
/*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) { |
|
return (current.added ? '+' : '-') + entry; |
|
}))); |
|
|
|
// Track the updated file position |
|
if (current.added) { |
|
newLine += lines.length; |
|
} else { |
|
oldLine += lines.length; |
|
} |
|
} else { |
|
// Identical context lines. Track line changes |
|
if (oldRangeStart) { |
|
// Close out any changes that have been output (or join overlapping) |
|
if (lines.length <= options.context * 2 && i < diff.length - 2) { |
|
/*istanbul ignore start*/var _curRange2; |
|
|
|
/*istanbul ignore end*/ // Overlapping |
|
/*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines))); |
|
} else { |
|
/*istanbul ignore start*/var _curRange3; |
|
|
|
/*istanbul ignore end*/ // end the range and output |
|
var contextSize = Math.min(lines.length, options.context); |
|
/*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize)))); |
|
|
|
var hunk = { |
|
oldStart: oldRangeStart, |
|
oldLines: oldLine - oldRangeStart + contextSize, |
|
newStart: newRangeStart, |
|
newLines: newLine - newRangeStart + contextSize, |
|
lines: curRange |
|
}; |
|
if (i >= diff.length - 2 && lines.length <= options.context) { |
|
// EOF is inside this hunk |
|
var oldEOFNewline = /\n$/.test(oldStr); |
|
var newEOFNewline = /\n$/.test(newStr); |
|
if (lines.length == 0 && !oldEOFNewline) { |
|
// special case: old has no eol and no trailing context; no-nl can end up before adds |
|
curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); |
|
} else if (!oldEOFNewline || !newEOFNewline) { |
|
curRange.push('\\ No newline at end of file'); |
|
} |
|
} |
|
hunks.push(hunk); |
|
|
|
oldRangeStart = 0; |
|
newRangeStart = 0; |
|
curRange = []; |
|
} |
|
} |
|
oldLine += lines.length; |
|
newLine += lines.length; |
|
} |
|
}; |
|
|
|
for (var i = 0; i < diff.length; i++) { |
|
/*istanbul ignore start*/_loop( /*istanbul ignore end*/i); |
|
} |
|
|
|
return { |
|
oldFileName: oldFileName, newFileName: newFileName, |
|
oldHeader: oldHeader, newHeader: newHeader, |
|
hunks: hunks |
|
}; |
|
} |
|
|
|
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
|
var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); |
|
|
|
var ret = []; |
|
if (oldFileName == newFileName) { |
|
ret.push('Index: ' + oldFileName); |
|
} |
|
ret.push('==================================================================='); |
|
ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); |
|
ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); |
|
|
|
for (var i = 0; i < diff.hunks.length; i++) { |
|
var hunk = diff.hunks[i]; |
|
ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); |
|
ret.push.apply(ret, hunk.lines); |
|
} |
|
|
|
return ret.join('\n') + '\n'; |
|
} |
|
|
|
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { |
|
return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); |
|
} |
|
}); |
|
|
|
unwrapExports(create$4); |
|
var create_1 = create$4.structuredPatch; |
|
var create_2 = create$4.createTwoFilesPatch; |
|
var create_3 = create$4.createPatch; |
|
|
|
var array$2 = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/arrayEqual = arrayEqual; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith; |
|
function arrayEqual(a, b) { |
|
if (a.length !== b.length) { |
|
return false; |
|
} |
|
|
|
return arrayStartsWith(a, b); |
|
} |
|
|
|
function arrayStartsWith(array, start) { |
|
if (start.length > array.length) { |
|
return false; |
|
} |
|
|
|
for (var i = 0; i < start.length; i++) { |
|
if (start[i] !== array[i]) { |
|
return false; |
|
} |
|
} |
|
|
|
return true; |
|
} |
|
}); |
|
|
|
unwrapExports(array$2); |
|
var array_1$1 = array$2.arrayEqual; |
|
var array_2$1 = array$2.arrayStartsWith; |
|
|
|
var merge_1 = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/calcLineCount = calcLineCount; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge; |
|
|
|
/*istanbul ignore start*/function _toConsumableArray(arr) { |
|
if (Array.isArray(arr)) { |
|
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { |
|
arr2[i] = arr[i]; |
|
}return arr2; |
|
} else { |
|
return _Array$from(arr); |
|
} |
|
} |
|
|
|
/*istanbul ignore end*/function calcLineCount(hunk) { |
|
/*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines), |
|
oldLines = _calcOldNewLineCount.oldLines, |
|
newLines = _calcOldNewLineCount.newLines; |
|
|
|
if (oldLines !== undefined) { |
|
hunk.oldLines = oldLines; |
|
} else { |
|
delete hunk.oldLines; |
|
} |
|
|
|
if (newLines !== undefined) { |
|
hunk.newLines = newLines; |
|
} else { |
|
delete hunk.newLines; |
|
} |
|
} |
|
|
|
function merge(mine, theirs, base) { |
|
mine = loadPatch(mine, base); |
|
theirs = loadPatch(theirs, base); |
|
|
|
var ret = {}; |
|
|
|
// For index we just let it pass through as it doesn't have any necessary meaning. |
|
// Leaving sanity checks on this to the API consumer that may know more about the |
|
// meaning in their own context. |
|
if (mine.index || theirs.index) { |
|
ret.index = mine.index || theirs.index; |
|
} |
|
|
|
if (mine.newFileName || theirs.newFileName) { |
|
if (!fileNameChanged(mine)) { |
|
// No header or no change in ours, use theirs (and ours if theirs does not exist) |
|
ret.oldFileName = theirs.oldFileName || mine.oldFileName; |
|
ret.newFileName = theirs.newFileName || mine.newFileName; |
|
ret.oldHeader = theirs.oldHeader || mine.oldHeader; |
|
ret.newHeader = theirs.newHeader || mine.newHeader; |
|
} else if (!fileNameChanged(theirs)) { |
|
// No header or no change in theirs, use ours |
|
ret.oldFileName = mine.oldFileName; |
|
ret.newFileName = mine.newFileName; |
|
ret.oldHeader = mine.oldHeader; |
|
ret.newHeader = mine.newHeader; |
|
} else { |
|
// Both changed... figure it out |
|
ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); |
|
ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); |
|
ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); |
|
ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); |
|
} |
|
} |
|
|
|
ret.hunks = []; |
|
|
|
var mineIndex = 0, |
|
theirsIndex = 0, |
|
mineOffset = 0, |
|
theirsOffset = 0; |
|
|
|
while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { |
|
var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity }, |
|
theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity }; |
|
|
|
if (hunkBefore(mineCurrent, theirsCurrent)) { |
|
// This patch does not overlap with any of the others, yay. |
|
ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); |
|
mineIndex++; |
|
theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; |
|
} else if (hunkBefore(theirsCurrent, mineCurrent)) { |
|
// This patch does not overlap with any of the others, yay. |
|
ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); |
|
theirsIndex++; |
|
mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; |
|
} else { |
|
// Overlap, merge as best we can |
|
var mergedHunk = { |
|
oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), |
|
oldLines: 0, |
|
newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), |
|
newLines: 0, |
|
lines: [] |
|
}; |
|
mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); |
|
theirsIndex++; |
|
mineIndex++; |
|
|
|
ret.hunks.push(mergedHunk); |
|
} |
|
} |
|
|
|
return ret; |
|
} |
|
|
|
function loadPatch(param, base) { |
|
if (typeof param === 'string') { |
|
if (/^@@/m.test(param) || /^Index:/m.test(param)) { |
|
return (/*istanbul ignore start*/(0, parse.parsePatch)(param)[0] |
|
); |
|
} |
|
|
|
if (!base) { |
|
throw new Error('Must provide a base reference or pass in a patch'); |
|
} |
|
return (/*istanbul ignore start*/(0, create$4.structuredPatch)(undefined, undefined, base, param) |
|
); |
|
} |
|
|
|
return param; |
|
} |
|
|
|
function fileNameChanged(patch) { |
|
return patch.newFileName && patch.newFileName !== patch.oldFileName; |
|
} |
|
|
|
function selectField(index, mine, theirs) { |
|
if (mine === theirs) { |
|
return mine; |
|
} else { |
|
index.conflict = true; |
|
return { mine: mine, theirs: theirs }; |
|
} |
|
} |
|
|
|
function hunkBefore(test, check) { |
|
return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; |
|
} |
|
|
|
function cloneHunk(hunk, offset) { |
|
return { |
|
oldStart: hunk.oldStart, oldLines: hunk.oldLines, |
|
newStart: hunk.newStart + offset, newLines: hunk.newLines, |
|
lines: hunk.lines |
|
}; |
|
} |
|
|
|
function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { |
|
// This will generally result in a conflicted hunk, but there are cases where the context |
|
// is the only overlap where we can successfully merge the content here. |
|
var mine = { offset: mineOffset, lines: mineLines, index: 0 }, |
|
their = { offset: theirOffset, lines: theirLines, index: 0 }; |
|
|
|
// Handle any leading content |
|
insertLeading(hunk, mine, their); |
|
insertLeading(hunk, their, mine); |
|
|
|
// Now in the overlap content. Scan through and select the best changes from each. |
|
while (mine.index < mine.lines.length && their.index < their.lines.length) { |
|
var mineCurrent = mine.lines[mine.index], |
|
theirCurrent = their.lines[their.index]; |
|
|
|
if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { |
|
// Both modified ... |
|
mutualChange(hunk, mine, their); |
|
} else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { |
|
/*istanbul ignore start*/var _hunk$lines; |
|
|
|
/*istanbul ignore end*/ // Mine inserted |
|
/*istanbul ignore start*/(_hunk$lines = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(mine))); |
|
} else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { |
|
/*istanbul ignore start*/var _hunk$lines2; |
|
|
|
/*istanbul ignore end*/ // Theirs inserted |
|
/*istanbul ignore start*/(_hunk$lines2 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(their))); |
|
} else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { |
|
// Mine removed or edited |
|
removal(hunk, mine, their); |
|
} else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { |
|
// Their removed or edited |
|
removal(hunk, their, mine, true); |
|
} else if (mineCurrent === theirCurrent) { |
|
// Context identity |
|
hunk.lines.push(mineCurrent); |
|
mine.index++; |
|
their.index++; |
|
} else { |
|
// Context mismatch |
|
conflict(hunk, collectChange(mine), collectChange(their)); |
|
} |
|
} |
|
|
|
// Now push anything that may be remaining |
|
insertTrailing(hunk, mine); |
|
insertTrailing(hunk, their); |
|
|
|
calcLineCount(hunk); |
|
} |
|
|
|
function mutualChange(hunk, mine, their) { |
|
var myChanges = collectChange(mine), |
|
theirChanges = collectChange(their); |
|
|
|
if (allRemoves(myChanges) && allRemoves(theirChanges)) { |
|
// Special case for remove changes that are supersets of one another |
|
if ( /*istanbul ignore start*/(0, array$2.arrayStartsWith)(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { |
|
/*istanbul ignore start*/var _hunk$lines3; |
|
|
|
/*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines3 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges)); |
|
return; |
|
} else if ( /*istanbul ignore start*/(0, array$2.arrayStartsWith)(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { |
|
/*istanbul ignore start*/var _hunk$lines4; |
|
|
|
/*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines4 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines4 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges)); |
|
return; |
|
} |
|
} else if ( /*istanbul ignore start*/(0, array$2.arrayEqual)(myChanges, theirChanges)) { |
|
/*istanbul ignore start*/var _hunk$lines5; |
|
|
|
/*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines5 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines5 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges)); |
|
return; |
|
} |
|
|
|
conflict(hunk, myChanges, theirChanges); |
|
} |
|
|
|
function removal(hunk, mine, their, swap) { |
|
var myChanges = collectChange(mine), |
|
theirChanges = collectContext(their, myChanges); |
|
if (theirChanges.merged) { |
|
/*istanbul ignore start*/var _hunk$lines6; |
|
|
|
/*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines6 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines6 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges.merged)); |
|
} else { |
|
conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); |
|
} |
|
} |
|
|
|
function conflict(hunk, mine, their) { |
|
hunk.conflict = true; |
|
hunk.lines.push({ |
|
conflict: true, |
|
mine: mine, |
|
theirs: their |
|
}); |
|
} |
|
|
|
function insertLeading(hunk, insert, their) { |
|
while (insert.offset < their.offset && insert.index < insert.lines.length) { |
|
var line = insert.lines[insert.index++]; |
|
hunk.lines.push(line); |
|
insert.offset++; |
|
} |
|
} |
|
function insertTrailing(hunk, insert) { |
|
while (insert.index < insert.lines.length) { |
|
var line = insert.lines[insert.index++]; |
|
hunk.lines.push(line); |
|
} |
|
} |
|
|
|
function collectChange(state) { |
|
var ret = [], |
|
operation = state.lines[state.index][0]; |
|
while (state.index < state.lines.length) { |
|
var line = state.lines[state.index]; |
|
|
|
// Group additions that are immediately after subtractions and treat them as one "atomic" modify change. |
|
if (operation === '-' && line[0] === '+') { |
|
operation = '+'; |
|
} |
|
|
|
if (operation === line[0]) { |
|
ret.push(line); |
|
state.index++; |
|
} else { |
|
break; |
|
} |
|
} |
|
|
|
return ret; |
|
} |
|
function collectContext(state, matchChanges) { |
|
var changes = [], |
|
merged = [], |
|
matchIndex = 0, |
|
contextChanges = false, |
|
conflicted = false; |
|
while (matchIndex < matchChanges.length && state.index < state.lines.length) { |
|
var change = state.lines[state.index], |
|
match = matchChanges[matchIndex]; |
|
|
|
// Once we've hit our add, then we are done |
|
if (match[0] === '+') { |
|
break; |
|
} |
|
|
|
contextChanges = contextChanges || change[0] !== ' '; |
|
|
|
merged.push(match); |
|
matchIndex++; |
|
|
|
// Consume any additions in the other block as a conflict to attempt |
|
// to pull in the remaining context after this |
|
if (change[0] === '+') { |
|
conflicted = true; |
|
|
|
while (change[0] === '+') { |
|
changes.push(change); |
|
change = state.lines[++state.index]; |
|
} |
|
} |
|
|
|
if (match.substr(1) === change.substr(1)) { |
|
changes.push(change); |
|
state.index++; |
|
} else { |
|
conflicted = true; |
|
} |
|
} |
|
|
|
if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { |
|
conflicted = true; |
|
} |
|
|
|
if (conflicted) { |
|
return changes; |
|
} |
|
|
|
while (matchIndex < matchChanges.length) { |
|
merged.push(matchChanges[matchIndex++]); |
|
} |
|
|
|
return { |
|
merged: merged, |
|
changes: changes |
|
}; |
|
} |
|
|
|
function allRemoves(changes) { |
|
return changes.reduce(function (prev, change) { |
|
return prev && change[0] === '-'; |
|
}, true); |
|
} |
|
function skipRemoveSuperset(state, removeChanges, delta) { |
|
for (var i = 0; i < delta; i++) { |
|
var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); |
|
if (state.lines[state.index + i] !== ' ' + changeContent) { |
|
return false; |
|
} |
|
} |
|
|
|
state.index += delta; |
|
return true; |
|
} |
|
|
|
function calcOldNewLineCount(lines) { |
|
var oldLines = 0; |
|
var newLines = 0; |
|
|
|
lines.forEach(function (line) { |
|
if (typeof line !== 'string') { |
|
var myCount = calcOldNewLineCount(line.mine); |
|
var theirCount = calcOldNewLineCount(line.theirs); |
|
|
|
if (oldLines !== undefined) { |
|
if (myCount.oldLines === theirCount.oldLines) { |
|
oldLines += myCount.oldLines; |
|
} else { |
|
oldLines = undefined; |
|
} |
|
} |
|
|
|
if (newLines !== undefined) { |
|
if (myCount.newLines === theirCount.newLines) { |
|
newLines += myCount.newLines; |
|
} else { |
|
newLines = undefined; |
|
} |
|
} |
|
} else { |
|
if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { |
|
newLines++; |
|
} |
|
if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { |
|
oldLines++; |
|
} |
|
} |
|
}); |
|
|
|
return { oldLines: oldLines, newLines: newLines }; |
|
} |
|
}); |
|
|
|
unwrapExports(merge_1); |
|
var merge_2 = merge_1.calcLineCount; |
|
var merge_3 = merge_1.merge; |
|
|
|
var dmp = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP; |
|
// See: http://code.google.com/p/google-diff-match-patch/wiki/API |
|
function convertChangesToDMP(changes) { |
|
var ret = [], |
|
change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/ |
|
, |
|
operation = /*istanbul ignore start*/void 0; |
|
for (var i = 0; i < changes.length; i++) { |
|
change = changes[i]; |
|
if (change.added) { |
|
operation = 1; |
|
} else if (change.removed) { |
|
operation = -1; |
|
} else { |
|
operation = 0; |
|
} |
|
|
|
ret.push([operation, change.value]); |
|
} |
|
return ret; |
|
} |
|
}); |
|
|
|
unwrapExports(dmp); |
|
var dmp_1 = dmp.convertChangesToDMP; |
|
|
|
var xml = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML; |
|
function convertChangesToXML(changes) { |
|
var ret = []; |
|
for (var i = 0; i < changes.length; i++) { |
|
var change = changes[i]; |
|
if (change.added) { |
|
ret.push('<ins>'); |
|
} else if (change.removed) { |
|
ret.push('<del>'); |
|
} |
|
|
|
ret.push(escapeHTML(change.value)); |
|
|
|
if (change.added) { |
|
ret.push('</ins>'); |
|
} else if (change.removed) { |
|
ret.push('</del>'); |
|
} |
|
} |
|
return ret.join(''); |
|
} |
|
|
|
function escapeHTML(s) { |
|
var n = s; |
|
n = n.replace(/&/g, '&'); |
|
n = n.replace(/</g, '<'); |
|
n = n.replace(/>/g, '>'); |
|
n = n.replace(/"/g, '"'); |
|
|
|
return n; |
|
} |
|
}); |
|
|
|
unwrapExports(xml); |
|
var xml_1 = xml.convertChangesToXML; |
|
|
|
var lib = createCommonjsModule(function (module, exports) { |
|
/*istanbul ignore start*/exports.__esModule = true; |
|
exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.merge = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined; |
|
|
|
/*istanbul ignore end*/ |
|
|
|
/*istanbul ignore start*/var _base2 = _interopRequireDefault(base); |
|
|
|
/*istanbul ignore end*/ |
|
|
|
/*istanbul ignore start*/function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { 'default': obj }; |
|
} |
|
|
|
/* See LICENSE file for terms of use */ |
|
|
|
/* |
|
* Text diff implementation. |
|
* |
|
* This library supports the following APIS: |
|
* JsDiff.diffChars: Character by character diff |
|
* JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace |
|
* JsDiff.diffLines: Line based diff |
|
* |
|
* JsDiff.diffCss: Diff targeted at CSS content |
|
* |
|
* These methods are based on the implementation proposed in |
|
* "An O(ND) Difference Algorithm and its Variations" (Myers, 1986). |
|
* http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927 |
|
*/ |
|
exports. /*istanbul ignore end*/Diff = _base2['default']; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = character.diffChars; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = word.diffWords; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = word.diffWordsWithSpace; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = line.diffLines; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = line.diffTrimmedLines; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = sentence.diffSentences; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = css.diffCss; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = json.diffJson; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = array.diffArrays; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = create$4.structuredPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = create$4.createTwoFilesPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = create$4.createPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = apply.applyPatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = apply.applyPatches; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = parse.parsePatch; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge_1.merge; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = dmp.convertChangesToDMP; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = xml.convertChangesToXML; |
|
/*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = json.canonicalize; |
|
}); |
|
|
|
unwrapExports(lib); |
|
var lib_1 = lib.canonicalize; |
|
var lib_2 = lib.convertChangesToXML; |
|
var lib_3 = lib.convertChangesToDMP; |
|
var lib_4 = lib.merge; |
|
var lib_5 = lib.parsePatch; |
|
var lib_6 = lib.applyPatches; |
|
var lib_7 = lib.applyPatch; |
|
var lib_8 = lib.createPatch; |
|
var lib_9 = lib.createTwoFilesPatch; |
|
var lib_10 = lib.structuredPatch; |
|
var lib_11 = lib.diffArrays; |
|
var lib_12 = lib.diffJson; |
|
var lib_13 = lib.diffCss; |
|
var lib_14 = lib.diffSentences; |
|
var lib_15 = lib.diffTrimmedLines; |
|
var lib_16 = lib.diffLines; |
|
var lib_17 = lib.diffWordsWithSpace; |
|
var lib_18 = lib.diffWords; |
|
var lib_19 = lib.diffChars; |
|
var lib_20 = lib.Diff; |
|
|
|
var constants = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.SIMILAR_MESSAGE = exports.NO_DIFF_MESSAGE = undefined; |
|
|
|
var _chalk2 = _interopRequireDefault(fake_chalk); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
var NO_DIFF_MESSAGE = exports.NO_DIFF_MESSAGE = _chalk2.default.dim('Compared values have no visual difference.'); /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var SIMILAR_MESSAGE = exports.SIMILAR_MESSAGE = _chalk2.default.dim('Compared values serialize to the same structure.\n' + 'Printing internal object structure without calling `toJSON` instead.'); |
|
}); |
|
|
|
unwrapExports(constants); |
|
var constants_1 = constants.SIMILAR_MESSAGE; |
|
var constants_2 = constants.NO_DIFF_MESSAGE; |
|
|
|
var diff_strings = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.default = diffStrings; |
|
|
|
var _chalk2 = _interopRequireDefault(fake_chalk); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
var DIFF_CONTEXT_DEFAULT = 5; // removed | added | equal |
|
|
|
// Given diff digit, return array which consists of: |
|
// if compared line is removed or added: corresponding original line |
|
// if compared line is equal: original received and expected lines |
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
// Given chunk, return diff character. |
|
var getDiffChar = function getDiffChar(chunk) { |
|
return chunk.removed ? '-' : chunk.added ? '+' : ' '; |
|
}; |
|
|
|
// Given diff character in line of hunk or computed from properties of chunk. |
|
var getDiffDigit = function getDiffDigit(char) { |
|
return char === '-' ? -1 : char === '+' ? 1 : 0; |
|
}; |
|
|
|
// Color for text of line. |
|
var getColor = function getColor(digit, onlyIndentationChanged) { |
|
if (digit === -1) { |
|
return _chalk2.default.green; // removed |
|
} |
|
if (digit === 1) { |
|
return _chalk2.default.red; // added |
|
} |
|
return onlyIndentationChanged ? _chalk2.default.cyan : _chalk2.default.dim; |
|
}; |
|
|
|
// Do NOT color leading or trailing spaces if original lines are equal: |
|
|
|
// Background color for leading or trailing spaces. |
|
var getBgColor = function getBgColor(digit, onlyIndentationChanged) { |
|
return digit === 0 && !onlyIndentationChanged ? _chalk2.default.bgYellow : _chalk2.default.inverse; |
|
}; |
|
|
|
// ONLY trailing if expected value is snapshot or multiline string. |
|
var highlightTrailingSpaces = function highlightTrailingSpaces(line, bgColor) { |
|
return line.replace(/\s+$/, bgColor('$&')); |
|
}; |
|
|
|
// BOTH leading AND trailing if expected value is data structure. |
|
var highlightLeadingTrailingSpaces = function highlightLeadingTrailingSpaces(line, bgColor |
|
// If line consists of ALL spaces: highlight all of them. |
|
) { |
|
return highlightTrailingSpaces(line, bgColor).replace( |
|
// If line has an ODD length of leading spaces: highlight only the LAST. |
|
/^(\s\s)*(\s)(?=[^\s])/, '$1' + bgColor('$2')); |
|
}; |
|
|
|
var getAnnotation = function getAnnotation(options) { |
|
return _chalk2.default.green('- ' + (options && options.aAnnotation || 'Expected')) + '\n' + _chalk2.default.red('+ ' + (options && options.bAnnotation || 'Received')) + '\n\n'; |
|
}; |
|
|
|
// Given string, return array of its lines. |
|
var splitIntoLines = function splitIntoLines(string) { |
|
var lines = string.split('\n'); |
|
|
|
if (lines.length !== 0 && lines[lines.length - 1] === '') { |
|
lines.pop(); |
|
} |
|
|
|
return lines; |
|
}; |
|
|
|
// Given diff character and compared line, return original line with colors. |
|
var formatLine = function formatLine(char, lineCompared, getOriginal) { |
|
var digit = getDiffDigit(char); |
|
|
|
if (getOriginal) { |
|
// Compared without indentation if expected value is data structure. |
|
var lineArray = getOriginal(digit); |
|
var lineOriginal = lineArray[0]; |
|
var onlyIndentationChanged = digit === 0 && lineOriginal.length !== lineArray[1].length; |
|
|
|
return getColor(digit, onlyIndentationChanged)(char + ' ' + |
|
// Prepend indentation spaces from original to compared line. |
|
lineOriginal.slice(0, lineOriginal.length - lineCompared.length) + highlightLeadingTrailingSpaces(lineCompared, getBgColor(digit, onlyIndentationChanged))); |
|
} |
|
|
|
// Format compared line when expected is snapshot or multiline string. |
|
return getColor(digit)(char + ' ' + highlightTrailingSpaces(lineCompared, getBgColor(digit))); |
|
}; |
|
|
|
// Given original lines, return callback function |
|
// which given diff digit, returns array. |
|
var getterForChunks = function getterForChunks(original) { |
|
var linesExpected = splitIntoLines(original.a); |
|
var linesReceived = splitIntoLines(original.b); |
|
|
|
var iExpected = 0; |
|
var iReceived = 0; |
|
|
|
return function (digit) { |
|
if (digit === -1) { |
|
return [linesExpected[iExpected++]]; |
|
} |
|
if (digit === 1) { |
|
return [linesReceived[iReceived++]]; |
|
} |
|
// Because compared line is equal: original received and expected lines. |
|
return [linesReceived[iReceived++], linesExpected[iExpected++]]; |
|
}; |
|
}; |
|
|
|
// jest --expand |
|
var formatChunks = function formatChunks(a, b, original) { |
|
var chunks = (0, lib.diffLines)(a, b); |
|
if (chunks.every(function (chunk) { |
|
return !chunk.removed && !chunk.added; |
|
})) { |
|
return null; |
|
} |
|
|
|
var getOriginal = original && getterForChunks(original); |
|
return chunks.reduce(function (lines, chunk) { |
|
var char = getDiffChar(chunk); |
|
|
|
splitIntoLines(chunk.value).forEach(function (line) { |
|
lines.push(formatLine(char, line, getOriginal)); |
|
}); |
|
|
|
return lines; |
|
}, []).join('\n'); |
|
}; |
|
|
|
// Only show patch marks ("@@ ... @@") if the diff is big. |
|
// To determine this, we need to compare either the original string (a) to |
|
// `hunk.oldLines` or a new string to `hunk.newLines`. |
|
// If the `oldLinesCount` is greater than `hunk.oldLines` |
|
// we can be sure that at least 1 line has been "hidden". |
|
var shouldShowPatchMarks = function shouldShowPatchMarks(hunk, oldLinesCount) { |
|
return oldLinesCount > hunk.oldLines; |
|
}; |
|
|
|
var createPatchMark = function createPatchMark(hunk) { |
|
var markOld = '-' + hunk.oldStart + ',' + hunk.oldLines; |
|
var markNew = '+' + hunk.newStart + ',' + hunk.newLines; |
|
return _chalk2.default.yellow('@@ ' + markOld + ' ' + markNew + ' @@'); |
|
}; |
|
|
|
// Given original lines, return callback function which given indexes for hunk, |
|
// returns another callback function which given diff digit, returns array. |
|
var getterForHunks = function getterForHunks(original) { |
|
var linesExpected = splitIntoLines(original.a); |
|
var linesReceived = splitIntoLines(original.b); |
|
|
|
return function (iExpected, iReceived) { |
|
return function (digit) { |
|
if (digit === -1) { |
|
return [linesExpected[iExpected++]]; |
|
} |
|
if (digit === 1) { |
|
return [linesReceived[iReceived++]]; |
|
} |
|
// Because compared line is equal: original received and expected lines. |
|
return [linesReceived[iReceived++], linesExpected[iExpected++]]; |
|
}; |
|
}; |
|
}; |
|
|
|
// jest --no-expand |
|
var formatHunks = function formatHunks(a, b, contextLines, original) { |
|
var options = { |
|
context: typeof contextLines === 'number' && contextLines >= 0 ? contextLines : DIFF_CONTEXT_DEFAULT |
|
}; |
|
|
|
var _structuredPatch = (0, lib.structuredPatch)('', '', a, b, '', '', options); |
|
|
|
var hunks = _structuredPatch.hunks; |
|
|
|
if (hunks.length === 0) { |
|
return null; |
|
} |
|
|
|
var getter = original && getterForHunks(original); |
|
var oldLinesCount = (a.match(/\n/g) || []).length; |
|
return hunks.reduce(function (lines, hunk) { |
|
if (shouldShowPatchMarks(hunk, oldLinesCount)) { |
|
lines.push(createPatchMark(hunk)); |
|
} |
|
|
|
// Hunk properties are one-based but index args are zero-based. |
|
var getOriginal = getter && getter(hunk.oldStart - 1, hunk.newStart - 1); |
|
hunk.lines.forEach(function (line) { |
|
lines.push(formatLine(line[0], line.slice(1), getOriginal)); |
|
}); |
|
|
|
return lines; |
|
}, []).join('\n'); |
|
}; |
|
|
|
function diffStrings(a, b, options, original) { |
|
// Because `formatHunks` and `formatChunks` ignore one trailing newline, |
|
// always append newline to strings: |
|
a += '\n'; |
|
b += '\n'; |
|
|
|
// `diff` uses the Myers LCS diff algorithm which runs in O(n+d^2) time |
|
// (where "d" is the edit distance) and can get very slow for large edit |
|
// distances. Mitigate the cost by switching to a lower-resolution diff |
|
// whenever linebreaks are involved. |
|
var result = options && options.expand === false ? formatHunks(a, b, options && options.contextLines, original) : formatChunks(a, b, original); |
|
|
|
return result === null ? constants.NO_DIFF_MESSAGE : getAnnotation(options) + result; |
|
} |
|
}); |
|
|
|
unwrapExports(diff_strings); |
|
|
|
var build$3 = createCommonjsModule(function (module) { |
|
var _prettyFormat2 = _interopRequireDefault(build$2); |
|
|
|
var _chalk2 = _interopRequireDefault(fake_chalk); |
|
|
|
var _jestGetType2 = _interopRequireDefault(build$1); |
|
|
|
var _diff_strings2 = _interopRequireDefault(diff_strings); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var _prettyFormat$plugins = _prettyFormat2.default.plugins; |
|
var AsymmetricMatcher = _prettyFormat$plugins.AsymmetricMatcher, |
|
DOMCollection = _prettyFormat$plugins.DOMCollection, |
|
DOMElement = _prettyFormat$plugins.DOMElement, |
|
Immutable = _prettyFormat$plugins.Immutable, |
|
ReactElement = _prettyFormat$plugins.ReactElement, |
|
ReactTestComponent = _prettyFormat$plugins.ReactTestComponent; |
|
|
|
var PLUGINS = [ReactTestComponent, ReactElement, DOMElement, DOMCollection, Immutable, AsymmetricMatcher]; |
|
var FORMAT_OPTIONS = { |
|
plugins: PLUGINS |
|
}; |
|
var FORMAT_OPTIONS_0 = _Object$assign({}, FORMAT_OPTIONS, { |
|
indent: 0 |
|
}); |
|
var FALLBACK_FORMAT_OPTIONS = { |
|
callToJSON: false, |
|
maxDepth: 10, |
|
plugins: PLUGINS |
|
}; |
|
var FALLBACK_FORMAT_OPTIONS_0 = _Object$assign({}, FALLBACK_FORMAT_OPTIONS, { |
|
indent: 0 |
|
}); |
|
|
|
var MULTILINE_REGEXP = /[\r\n]/; |
|
|
|
// Generate a string that will highlight the difference between two values |
|
// with green and red. (similar to how github does code diffing) |
|
function diff(a, b, options) { |
|
if (a === b) { |
|
return constants.NO_DIFF_MESSAGE; |
|
} |
|
|
|
var aType = (0, _jestGetType2.default)(a); |
|
var expectedType = aType; |
|
var omitDifference = false; |
|
if (aType === 'object' && typeof a.asymmetricMatch === 'function') { |
|
if (a.$$typeof !== _Symbol$for('jest.asymmetricMatcher')) { |
|
// Do not know expected type of user-defined asymmetric matcher. |
|
return null; |
|
} |
|
if (typeof a.getExpectedType !== 'function') { |
|
// For example, expect.anything() matches either null or undefined |
|
return null; |
|
} |
|
expectedType = a.getExpectedType(); |
|
// Primitive types boolean and number omit difference below. |
|
// For example, omit difference for expect.stringMatching(regexp) |
|
omitDifference = expectedType === 'string'; |
|
} |
|
|
|
if (expectedType !== (0, _jestGetType2.default)(b)) { |
|
return ' Comparing two different types of values.' + (' Expected ' + _chalk2.default.green(expectedType) + ' but ') + ('received ' + _chalk2.default.red((0, _jestGetType2.default)(b)) + '.'); |
|
} |
|
|
|
if (omitDifference) { |
|
return null; |
|
} |
|
|
|
switch (aType) { |
|
case 'string': |
|
var multiline = MULTILINE_REGEXP.test(a) && b.indexOf('\n') !== -1; |
|
if (multiline) { |
|
return (0, _diff_strings2.default)(a, b, options); |
|
} |
|
return null; |
|
case 'number': |
|
case 'boolean': |
|
return null; |
|
case 'map': |
|
return compareObjects(sortMap(a), sortMap(b), options); |
|
case 'set': |
|
return compareObjects(sortSet(a), sortSet(b), options); |
|
default: |
|
return compareObjects(a, b, options); |
|
} |
|
} |
|
|
|
function sortMap(map$$1) { |
|
return new _Map(_Array$from(map$$1.entries()).sort()); |
|
} |
|
|
|
function sortSet(set$$1) { |
|
return new _Set(_Array$from(set$$1.values()).sort()); |
|
} |
|
|
|
function compareObjects(a, b, options) { |
|
var diffMessage = void 0; |
|
var hasThrown = false; |
|
|
|
try { |
|
diffMessage = (0, _diff_strings2.default)((0, _prettyFormat2.default)(a, FORMAT_OPTIONS_0), (0, _prettyFormat2.default)(b, FORMAT_OPTIONS_0), options, { |
|
a: (0, _prettyFormat2.default)(a, FORMAT_OPTIONS), |
|
b: (0, _prettyFormat2.default)(b, FORMAT_OPTIONS) |
|
}); |
|
} catch (e) { |
|
hasThrown = true; |
|
} |
|
|
|
// If the comparison yields no results, compare again but this time |
|
// without calling `toJSON`. It's also possible that toJSON might throw. |
|
if (!diffMessage || diffMessage === constants.NO_DIFF_MESSAGE) { |
|
diffMessage = (0, _diff_strings2.default)((0, _prettyFormat2.default)(a, FALLBACK_FORMAT_OPTIONS_0), (0, _prettyFormat2.default)(b, FALLBACK_FORMAT_OPTIONS_0), options, { |
|
a: (0, _prettyFormat2.default)(a, FALLBACK_FORMAT_OPTIONS), |
|
b: (0, _prettyFormat2.default)(b, FALLBACK_FORMAT_OPTIONS) |
|
}); |
|
if (diffMessage !== constants.NO_DIFF_MESSAGE && !hasThrown) { |
|
diffMessage = constants.SIMILAR_MESSAGE + '\n\n' + diffMessage; |
|
} |
|
} |
|
|
|
return diffMessage; |
|
} |
|
|
|
module.exports = diff; |
|
}); |
|
|
|
var diff = unwrapExports(build$3); |
|
|
|
// 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; |
|
} |
|
|
|
// Split a filename into [root, dir, basename, ext], unix version |
|
// 'root' is just a slash, or nothing. |
|
var splitPathRe = |
|
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; |
|
var splitPath = function(filename) { |
|
return splitPathRe.exec(filename).slice(1); |
|
}; |
|
|
|
// path.resolve([from ...], to) |
|
// posix version |
|
function resolve() { |
|
var resolvedPath = '', |
|
resolvedAbsolute = false; |
|
|
|
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { |
|
var path = (i >= 0) ? arguments[i] : '/'; |
|
|
|
// 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 |
|
function normalize(path) { |
|
var isPathAbsolute = isAbsolute(path), |
|
trailingSlash = substr(path, -1) === '/'; |
|
|
|
// Normalize the path |
|
path = normalizeArray(filter(path.split('/'), function(p) { |
|
return !!p; |
|
}), !isPathAbsolute).join('/'); |
|
|
|
if (!path && !isPathAbsolute) { |
|
path = '.'; |
|
} |
|
if (path && trailingSlash) { |
|
path += '/'; |
|
} |
|
|
|
return (isPathAbsolute ? '/' : '') + path; |
|
} |
|
|
|
// posix version |
|
function isAbsolute(path) { |
|
return path.charAt(0) === '/'; |
|
} |
|
|
|
// posix version |
|
function join() { |
|
var paths = Array.prototype.slice.call(arguments, 0); |
|
return 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 |
|
function relative(from, to) { |
|
from = resolve(from).substr(1); |
|
to = 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('/'); |
|
} |
|
|
|
var sep = '/'; |
|
var delimiter = ':'; |
|
|
|
function dirname(path) { |
|
var result = splitPath(path), |
|
root = result[0], |
|
dir = result[1]; |
|
|
|
if (!root && !dir) { |
|
// No dirname whatsoever |
|
return '.'; |
|
} |
|
|
|
if (dir) { |
|
// It has a dirname, strip trailing slash |
|
dir = dir.substr(0, dir.length - 1); |
|
} |
|
|
|
return root + dir; |
|
} |
|
|
|
function basename(path, ext) { |
|
var f = splitPath(path)[2]; |
|
// TODO: make this comparison case-insensitive on windows? |
|
if (ext && f.substr(-1 * ext.length) === ext) { |
|
f = f.substr(0, f.length - ext.length); |
|
} |
|
return f; |
|
} |
|
|
|
|
|
function extname(path) { |
|
return splitPath(path)[3]; |
|
} |
|
var path = { |
|
extname: extname, |
|
basename: basename, |
|
dirname: dirname, |
|
sep: sep, |
|
delimiter: delimiter, |
|
relative: relative, |
|
join: join, |
|
isAbsolute: isAbsolute, |
|
normalize: normalize, |
|
resolve: resolve |
|
}; |
|
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); |
|
}; |
|
|
|
|
|
var path$1 = Object.freeze({ |
|
resolve: resolve, |
|
normalize: normalize, |
|
isAbsolute: isAbsolute, |
|
join: join, |
|
relative: relative, |
|
sep: sep, |
|
delimiter: delimiter, |
|
dirname: dirname, |
|
basename: basename, |
|
extname: extname, |
|
default: path |
|
}); |
|
|
|
var path$2 = ( path$1 && path ) || path$1; |
|
|
|
var build$4 = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.replacePathSepForRegex = exports.escapeStrForRegex = exports.escapePathForRegex = undefined; |
|
|
|
var _path2 = _interopRequireDefault(path$2); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
var escapePathForRegex = exports.escapePathForRegex = function (dir) { |
|
if (_path2.default.sep === '\\') { |
|
// Replace "\" with "/" so it's not escaped by escapeStrForRegex. |
|
// replacePathSepForRegex will convert it back. |
|
dir = dir.replace(/\\/g, '/'); |
|
} |
|
return replacePathSepForRegex(escapeStrForRegex(dir)); |
|
}; /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var escapeStrForRegex = exports.escapeStrForRegex = function (string) { |
|
return string.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&'); |
|
}; |
|
|
|
var replacePathSepForRegex = exports.replacePathSepForRegex = function (string) { |
|
if (_path2.default.sep === '\\') { |
|
return string.replace(/(\/|\\(?!\.))/g, '\\\\'); |
|
} |
|
return string; |
|
}; |
|
}); |
|
|
|
unwrapExports(build$4); |
|
var build_1$1 = build$4.replacePathSepForRegex; |
|
var build_2$1 = build$4.escapeStrForRegex; |
|
var build_3$1 = build$4.escapePathForRegex; |
|
|
|
/* |
|
Copyright (c) 2008-2016 Pivotal Labs |
|
|
|
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. |
|
|
|
|
|
*/ |
|
|
|
/* eslint-disable */ |
|
|
|
// Extracted out of jasmine 2.5.2 |
|
function equals(a, b, customTesters) { |
|
customTesters = customTesters || []; |
|
return eq(a, b, [], [], customTesters); |
|
} |
|
|
|
function isAsymmetric(obj) { |
|
return obj && isA('Function', obj.asymmetricMatch); |
|
} |
|
|
|
function asymmetricMatch(a, b) { |
|
var asymmetricA = isAsymmetric(a), |
|
asymmetricB = isAsymmetric(b); |
|
|
|
if (asymmetricA && asymmetricB) { |
|
return undefined; |
|
} |
|
|
|
if (asymmetricA) { |
|
return a.asymmetricMatch(b); |
|
} |
|
|
|
if (asymmetricB) { |
|
return b.asymmetricMatch(a); |
|
} |
|
} |
|
|
|
// Equality function lovingly adapted from isEqual in |
|
// [Underscore](http://underscorejs.org) |
|
function eq(a, b, aStack, bStack, customTesters) { |
|
var result = true; |
|
|
|
var asymmetricResult = asymmetricMatch(a, b); |
|
if (asymmetricResult !== undefined) { |
|
return asymmetricResult; |
|
} |
|
|
|
for (var i = 0; i < customTesters.length; i++) { |
|
var customTesterResult = customTesters[i](a, b); |
|
if (customTesterResult !== undefined) { |
|
return customTesterResult; |
|
} |
|
} |
|
|
|
if (a instanceof Error && b instanceof Error) { |
|
return a.message == b.message; |
|
} |
|
|
|
if (_Object$is(a, b)) { |
|
return true; |
|
} |
|
// A strict comparison is necessary because `null == undefined`. |
|
if (a === null || b === null) { |
|
return a === b; |
|
} |
|
var className = Object.prototype.toString.call(a); |
|
if (className != Object.prototype.toString.call(b)) { |
|
return false; |
|
} |
|
switch (className) { |
|
// Strings, numbers, dates, and booleans are compared by value. |
|
case '[object String]': |
|
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is |
|
// equivalent to `new String("5")`. |
|
return a == String(b); |
|
case '[object Number]': |
|
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for |
|
// other numeric values. |
|
return a != +a ? b != +b : a === 0 ? 1 / a == 1 / b : a == +b; |
|
case '[object Date]': |
|
case '[object Boolean]': |
|
// Coerce dates and booleans to numeric primitive values. Dates are compared by their |
|
// millisecond representations. Note that invalid dates with millisecond representations |
|
// of `NaN` are not equivalent. |
|
return +a == +b; |
|
// RegExps are compared by their source patterns and flags. |
|
case '[object RegExp]': |
|
return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; |
|
} |
|
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) != 'object' || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) != 'object') { |
|
return false; |
|
} |
|
|
|
var aIsDomNode = isDomNode(a); |
|
var bIsDomNode = isDomNode(b); |
|
if (aIsDomNode && bIsDomNode) { |
|
// At first try to use DOM3 method isEqualNode |
|
if (a.isEqualNode) { |
|
return a.isEqualNode(b); |
|
} |
|
// IE8 doesn't support isEqualNode, try to use outerHTML && innerText |
|
var aIsElement = a instanceof Element; |
|
var bIsElement = b instanceof Element; |
|
if (aIsElement && bIsElement) { |
|
return a.outerHTML == b.outerHTML; |
|
} |
|
if (aIsElement || bIsElement) { |
|
return false; |
|
} |
|
return a.innerText == b.innerText && a.textContent == b.textContent; |
|
} |
|
if (aIsDomNode || bIsDomNode) { |
|
return false; |
|
} |
|
|
|
// Assume equality for cyclic structures. The algorithm for detecting cyclic |
|
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. |
|
var length = aStack.length; |
|
while (length--) { |
|
// Linear search. Performance is inversely proportional to the number of |
|
// unique nested structures. |
|
if (aStack[length] == a) { |
|
return bStack[length] == b; |
|
} |
|
} |
|
// Add the first object to the stack of traversed objects. |
|
aStack.push(a); |
|
bStack.push(b); |
|
var size = 0; |
|
// Recursively compare objects and arrays. |
|
// Compare array lengths to determine if a deep comparison is necessary. |
|
if (className == '[object Array]') { |
|
size = a.length; |
|
if (size !== b.length) { |
|
return false; |
|
} |
|
|
|
while (size--) { |
|
result = eq(a[size], b[size], aStack, bStack, customTesters); |
|
if (!result) { |
|
return false; |
|
} |
|
} |
|
} |
|
|
|
// Deep compare objects. |
|
var aKeys = keys$3(a, className == '[object Array]'), |
|
key; |
|
size = aKeys.length; |
|
|
|
// Ensure that both objects contain the same number of properties before comparing deep equality. |
|
if (keys$3(b, className == '[object Array]').length !== size) { |
|
return false; |
|
} |
|
|
|
while (size--) { |
|
key = aKeys[size]; |
|
|
|
// Deep compare each member |
|
result = has$1(b, key) && eq(a[key], b[key], aStack, bStack, customTesters); |
|
|
|
if (!result) { |
|
return false; |
|
} |
|
} |
|
// Remove the first object from the stack of traversed objects. |
|
aStack.pop(); |
|
bStack.pop(); |
|
|
|
return result; |
|
} |
|
|
|
function keys$3(obj, isArray) { |
|
var allKeys = function (o) { |
|
var keys = []; |
|
for (var key in o) { |
|
if (has$1(o, key)) { |
|
keys.push(key); |
|
} |
|
} |
|
return keys.concat(_Object$getOwnPropertySymbols(o)); |
|
}(obj); |
|
|
|
if (!isArray) { |
|
return allKeys; |
|
} |
|
|
|
var extraKeys = []; |
|
if (allKeys.length === 0) { |
|
return allKeys; |
|
} |
|
|
|
for (var x = 0; x < allKeys.length; x++) { |
|
if (!allKeys[x].match(/^[0-9]+$/)) { |
|
extraKeys.push(allKeys[x]); |
|
} |
|
} |
|
|
|
return extraKeys; |
|
} |
|
|
|
function has$1(obj, key) { |
|
return Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined; |
|
} |
|
|
|
function isA(typeName, value) { |
|
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; |
|
} |
|
|
|
function isDomNode(obj) { |
|
return obj.nodeType > 0; |
|
} |
|
|
|
function fnNameFor(func) { |
|
if (func.name) { |
|
return func.name; |
|
} |
|
|
|
var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/); |
|
return matches ? matches[1] : '<anonymous>'; |
|
} |
|
|
|
function isUndefined(obj) { |
|
return obj === void 0; |
|
} |
|
|
|
function getPrototype(obj) { |
|
if (_Object$getPrototypeOf) { |
|
return _Object$getPrototypeOf(obj); |
|
} |
|
|
|
if (obj.constructor.prototype == obj) { |
|
return null; |
|
} |
|
|
|
return obj.constructor.prototype; |
|
} |
|
|
|
function hasProperty(obj, property) { |
|
if (!obj) { |
|
return false; |
|
} |
|
|
|
if (Object.prototype.hasOwnProperty.call(obj, property)) { |
|
return true; |
|
} |
|
|
|
return hasProperty(getPrototype(obj), property); |
|
} |
|
|
|
// SENTINEL constants are from https://github.com/facebook/immutable-js |
|
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; |
|
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; |
|
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; |
|
|
|
function isImmutableUnorderedKeyed(maybeKeyed) { |
|
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL] && !maybeKeyed[IS_ORDERED_SENTINEL]); |
|
} |
|
|
|
function isImmutableUnorderedSet(maybeSet) { |
|
return !!(maybeSet && maybeSet[IS_SET_SENTINEL] && !maybeSet[IS_ORDERED_SENTINEL]); |
|
} |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var hasOwnProperty$1 = function hasOwnProperty(object, value) { |
|
return Object.prototype.hasOwnProperty.call(object, value) || Object.prototype.hasOwnProperty.call(object.constructor.prototype, value); |
|
}; |
|
|
|
var getPath = function getPath(object, propertyPath) { |
|
if (!Array.isArray(propertyPath)) { |
|
propertyPath = propertyPath.split('.'); |
|
} |
|
|
|
if (propertyPath.length) { |
|
var lastProp = propertyPath.length === 1; |
|
var prop = propertyPath[0]; |
|
var newObject = object[prop]; |
|
|
|
if (!lastProp && (newObject === null || newObject === undefined)) { |
|
// This is not the last prop in the chain. If we keep recursing it will |
|
// hit a `can't access property X of undefined | null`. At this point we |
|
// know that the chain has broken and we can return right away. |
|
return { |
|
hasEndProp: false, |
|
lastTraversedObject: object, |
|
traversedPath: [] |
|
}; |
|
} |
|
|
|
var result = getPath(newObject, propertyPath.slice(1)); |
|
|
|
if (result.lastTraversedObject === null) { |
|
result.lastTraversedObject = object; |
|
} |
|
|
|
result.traversedPath.unshift(prop); |
|
|
|
if (lastProp) { |
|
result.hasEndProp = hasOwnProperty$1(object, prop); |
|
if (!result.hasEndProp) { |
|
result.traversedPath.shift(); |
|
} |
|
} |
|
|
|
return result; |
|
} |
|
|
|
return { |
|
lastTraversedObject: null, |
|
traversedPath: [], |
|
value: object |
|
}; |
|
}; |
|
|
|
// Strip properties from object that are not present in the subset. Useful for |
|
// printing the diff for toMatchObject() without adding unrelated noise. |
|
var getObjectSubset = function getObjectSubset(object, subset) { |
|
if (Array.isArray(object)) { |
|
if (Array.isArray(subset) && subset.length === object.length) { |
|
return subset.map(function (sub, i) { |
|
return getObjectSubset(object[i], sub); |
|
}); |
|
} |
|
} else if (object instanceof Date) { |
|
return object; |
|
} else if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object !== null && (typeof subset === 'undefined' ? 'undefined' : _typeof(subset)) === 'object' && subset !== null) { |
|
var trimmed = {}; |
|
_Object$keys(subset).filter(function (key) { |
|
return hasOwnProperty$1(object, key); |
|
}).forEach(function (key) { |
|
return trimmed[key] = getObjectSubset(object[key], subset[key]); |
|
}); |
|
|
|
if (_Object$keys(trimmed).length > 0) { |
|
return trimmed; |
|
} |
|
} |
|
return object; |
|
}; |
|
|
|
var IteratorSymbol = _Symbol$iterator; |
|
|
|
var hasIterator = function hasIterator(object) { |
|
return !!(object != null && object[IteratorSymbol]); |
|
}; |
|
var iterableEquality = function iterableEquality(a, b) { |
|
if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) { |
|
return undefined; |
|
} |
|
if (a.constructor !== b.constructor) { |
|
return false; |
|
} |
|
|
|
if (a.size !== undefined) { |
|
if (a.size !== b.size) { |
|
return false; |
|
} else if (isA('Set', a) || isImmutableUnorderedSet(a)) { |
|
var allFound = true; |
|
var _iteratorNormalCompletion = true; |
|
var _didIteratorError = false; |
|
var _iteratorError = undefined; |
|
|
|
try { |
|
for (var _iterator = _getIterator(a), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
|
var aValue = _step.value; |
|
|
|
if (!b.has(aValue)) { |
|
allFound = false; |
|
break; |
|
} |
|
} |
|
} catch (err) { |
|
_didIteratorError = true; |
|
_iteratorError = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion && _iterator.return) { |
|
_iterator.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError) { |
|
throw _iteratorError; |
|
} |
|
} |
|
} |
|
|
|
if (allFound) { |
|
return true; |
|
} |
|
} else if (isA('Map', a) || isImmutableUnorderedKeyed(a)) { |
|
var _allFound = true; |
|
var _iteratorNormalCompletion2 = true; |
|
var _didIteratorError2 = false; |
|
var _iteratorError2 = undefined; |
|
|
|
try { |
|
for (var _iterator2 = _getIterator(a), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
|
var aEntry = _step2.value; |
|
|
|
if (!b.has(aEntry[0]) || !equals(aEntry[1], b.get(aEntry[0]), [iterableEquality])) { |
|
_allFound = false; |
|
break; |
|
} |
|
} |
|
} catch (err) { |
|
_didIteratorError2 = true; |
|
_iteratorError2 = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion2 && _iterator2.return) { |
|
_iterator2.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError2) { |
|
throw _iteratorError2; |
|
} |
|
} |
|
} |
|
|
|
if (_allFound) { |
|
return true; |
|
} |
|
} |
|
} |
|
|
|
var bIterator = b[IteratorSymbol](); |
|
|
|
var _iteratorNormalCompletion3 = true; |
|
var _didIteratorError3 = false; |
|
var _iteratorError3 = undefined; |
|
|
|
try { |
|
for (var _iterator3 = _getIterator(a), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
|
var _aValue = _step3.value; |
|
|
|
var nextB = bIterator.next(); |
|
if (nextB.done || !equals(_aValue, nextB.value, [iterableEquality])) { |
|
return false; |
|
} |
|
} |
|
} catch (err) { |
|
_didIteratorError3 = true; |
|
_iteratorError3 = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion3 && _iterator3.return) { |
|
_iterator3.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError3) { |
|
throw _iteratorError3; |
|
} |
|
} |
|
} |
|
|
|
if (!bIterator.next().done) { |
|
return false; |
|
} |
|
return true; |
|
}; |
|
|
|
var isObjectWithKeys = function isObjectWithKeys(a) { |
|
return a !== null && (typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object' && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date); |
|
}; |
|
|
|
var subsetEquality = function subsetEquality(object, subset) { |
|
if (!isObjectWithKeys(subset)) { |
|
return undefined; |
|
} |
|
|
|
return _Object$keys(subset).every(function (key) { |
|
return hasOwnProperty$1(object, key) && equals(object[key], subset[key], [iterableEquality, subsetEquality]); |
|
}); |
|
}; |
|
|
|
var partition = function partition(items, predicate) { |
|
var result = [[], []]; |
|
|
|
items.forEach(function (item) { |
|
return result[predicate(item) ? 0 : 1].push(item); |
|
}); |
|
|
|
return result; |
|
}; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var matchers = { |
|
toBe: function toBe(received, expected) { |
|
var _this = this; |
|
|
|
var comment = 'Object.is equality'; |
|
var pass = _Object$is(received, expected); |
|
|
|
var message = pass ? function () { |
|
return build_1('.not.toBe', undefined, undefined, { |
|
comment: comment |
|
}) + '\n\n' + 'Expected value to not be:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received)); |
|
} : function () { |
|
var suggestToEqual = build$1(received) === build$1(expected) && (build$1(received) === 'object' || build$1(expected) === 'array') && equals(received, expected, [iterableEquality]); |
|
|
|
var diffString = diff(expected, received, { |
|
expand: _this.expand |
|
}); |
|
|
|
return build_1('.toBe', undefined, undefined, { |
|
comment: comment |
|
}) + '\n\n' + 'Expected value to be:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received)) + (diffString ? '\n\nDifference:\n\n' + diffString : '') + (suggestToEqual ? ' ' + build_12 : ''); |
|
}; |
|
|
|
// Passing the the actual and expected objects so that a custom reporter |
|
// could access them, for example in order to display a custom visual diff, |
|
// or create a different error message |
|
return { actual: received, expected: expected, message: message, name: 'toBe', pass: pass }; |
|
}, |
|
toBeCloseTo: function toBeCloseTo(actual, expected) { |
|
var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; |
|
|
|
var secondArgument = arguments.length === 3 ? 'precision' : null; |
|
build_3(actual, expected, '.toBeCloseTo'); |
|
var pass = Math.abs(expected - actual) < Math.pow(10, -precision) / 2; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeCloseTo', undefined, undefined, { |
|
secondArgument: secondArgument |
|
}) + '\n\n' + ('Expected value not to be close to (with ' + build_8(precision) + '-digit precision):\n') + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeCloseTo', undefined, undefined, { |
|
secondArgument: secondArgument |
|
}) + '\n\n' + ('Expected value to be close to (with ' + build_8(precision) + '-digit precision):\n') + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toBeDefined: function toBeDefined(actual, expected) { |
|
build_6(expected, '.toBeDefined'); |
|
var pass = actual !== void 0; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeDefined', 'received', '') + '\n\n' + 'Expected value not to be defined, instead received\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeDefined', 'received', '') + '\n\n' + 'Expected value to be defined, instead received\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeFalsy: function toBeFalsy(actual, expected) { |
|
build_6(expected, '.toBeFalsy'); |
|
var pass = !actual; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeFalsy', 'received', '') + '\n\n' + 'Expected value not to be falsy, instead received\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeFalsy', 'received', '') + '\n\n' + 'Expected value to be falsy, instead received\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeGreaterThan: function toBeGreaterThan(actual, expected) { |
|
build_3(actual, expected, '.toBeGreaterThan'); |
|
var pass = actual > expected; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeGreaterThan') + '\n\n' + 'Expected value not to be greater than:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeGreaterThan') + '\n\n' + 'Expected value to be greater than:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeGreaterThanOrEqual: function toBeGreaterThanOrEqual(actual, expected) { |
|
build_3(actual, expected, '.toBeGreaterThanOrEqual'); |
|
var pass = actual >= expected; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeGreaterThanOrEqual') + '\n\n' + 'Expected value not to be greater than or equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeGreaterThanOrEqual') + '\n\n' + 'Expected value to be greater than or equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeInstanceOf: function toBeInstanceOf(received, constructor) { |
|
var constType = build$1(constructor); |
|
|
|
if (constType !== 'function') { |
|
throw new Error(build_1('[.not].toBeInstanceOf', 'value', 'constructor') + '\n\n' + 'Expected constructor to be a function. Instead got:\n' + (' ' + build_8(constType))); |
|
} |
|
var pass = received instanceof constructor; |
|
|
|
var message = pass ? function () { |
|
return build_1('.not.toBeInstanceOf', 'value', 'constructor') + '\n\n' + 'Expected value not to be an instance of:\n' + (' ' + build_8(constructor.name || constructor) + '\n') + 'Received:\n' + (' ' + build_9(received) + '\n'); |
|
} : function () { |
|
return build_1('.toBeInstanceOf', 'value', 'constructor') + '\n\n' + 'Expected value to be an instance of:\n' + (' ' + build_8(constructor.name || constructor) + '\n') + 'Received:\n' + (' ' + build_9(received) + '\n') + 'Constructor:\n' + (' ' + build_9(received.constructor && received.constructor.name)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toBeLessThan: function toBeLessThan(actual, expected) { |
|
build_3(actual, expected, '.toBeLessThan'); |
|
var pass = actual < expected; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeLessThan') + '\n\n' + 'Expected value not to be less than:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeLessThan') + '\n\n' + 'Expected value to be less than:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeLessThanOrEqual: function toBeLessThanOrEqual(actual, expected) { |
|
build_3(actual, expected, '.toBeLessThanOrEqual'); |
|
var pass = actual <= expected; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeLessThanOrEqual') + '\n\n' + 'Expected value not to be less than or equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeLessThanOrEqual') + '\n\n' + 'Expected value to be less than or equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeNaN: function toBeNaN(actual, expected) { |
|
build_6(expected, '.toBeNaN'); |
|
var pass = _Number$isNaN(actual); |
|
var message = pass ? function () { |
|
return build_1('.not.toBeNaN', 'received', '') + '\n\n' + 'Expected value not to be NaN, instead received\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeNaN', 'received', '') + '\n\n' + 'Expected value to be NaN, instead received\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeNull: function toBeNull(actual, expected) { |
|
build_6(expected, '.toBeNull'); |
|
var pass = actual === null; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeNull', 'received', '') + '\n\n' + 'Expected value not to be null, instead received\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeNull', 'received', '') + '\n\n' + 'Expected value to be null, instead received\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeTruthy: function toBeTruthy(actual, expected) { |
|
build_6(expected, '.toBeTruthy'); |
|
var pass = !!actual; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeTruthy', 'received', '') + '\n\n' + 'Expected value not to be truthy, instead received\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeTruthy', 'received', '') + '\n\n' + 'Expected value to be truthy, instead received\n' + (' ' + build_9(actual)); |
|
}; |
|
return { message: message, pass: pass }; |
|
}, |
|
toBeUndefined: function toBeUndefined(actual, expected) { |
|
build_6(expected, '.toBeUndefined'); |
|
var pass = actual === void 0; |
|
var message = pass ? function () { |
|
return build_1('.not.toBeUndefined', 'received', '') + '\n\n' + 'Expected value not to be undefined, instead received\n' + (' ' + build_9(actual)); |
|
} : function () { |
|
return build_1('.toBeUndefined', 'received', '') + '\n\n' + 'Expected value to be undefined, instead received\n' + (' ' + build_9(actual)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toContain: function toContain(collection, value) { |
|
var collectionType = build$1(collection); |
|
|
|
var converted = null; |
|
if (Array.isArray(collection) || typeof collection === 'string') { |
|
// strings have `indexOf` so we don't need to convert |
|
// arrays have `indexOf` and we don't want to make a copy |
|
converted = collection; |
|
} else { |
|
try { |
|
converted = _Array$from(collection); |
|
} catch (e) { |
|
throw new Error(build_1('[.not].toContainEqual', 'collection', 'value') + '\n\n' + ('Expected ' + build_13('collection') + ' to be an array-like structure.\n') + build_7('Received', collection, build_9)); |
|
} |
|
} |
|
// At this point, we're either a string or an Array, |
|
// which was converted from an array-like structure. |
|
var pass = converted.indexOf(value) != -1; |
|
var message = pass ? function () { |
|
return build_1('.not.toContain', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'Not to contain value:\n' + (' ' + build_8(value) + '\n'); |
|
} : function () { |
|
return build_1('.toContain', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'To contain value:\n' + (' ' + build_8(value)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toContainEqual: function toContainEqual(collection, value) { |
|
var collectionType = build$1(collection); |
|
var converted = null; |
|
if (Array.isArray(collection)) { |
|
converted = collection; |
|
} else { |
|
try { |
|
converted = _Array$from(collection); |
|
} catch (e) { |
|
throw new Error(build_1('[.not].toContainEqual', 'collection', 'value') + '\n\n' + ('Expected ' + build_13('collection') + ' to be an array-like structure.\n') + build_7('Received', collection, build_9)); |
|
} |
|
} |
|
|
|
var pass = converted.findIndex(function (item) { |
|
return equals(item, value, [iterableEquality]); |
|
}) !== -1; |
|
var message = pass ? function () { |
|
return build_1('.not.toContainEqual', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'Not to contain a value equal to:\n' + (' ' + build_8(value) + '\n'); |
|
} : function () { |
|
return build_1('.toContainEqual', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'To contain a value equal to:\n' + (' ' + build_8(value)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toEqual: function toEqual(received, expected) { |
|
var _this2 = this; |
|
|
|
var pass = equals(received, expected, [iterableEquality]); |
|
|
|
var message = pass ? function () { |
|
return build_1('.not.toEqual') + '\n\n' + 'Expected value to not equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received)); |
|
} : function () { |
|
var diffString = diff(expected, received, { |
|
expand: _this2.expand |
|
}); |
|
return build_1('.toEqual') + '\n\n' + 'Expected value to equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received)) + (diffString ? '\n\nDifference:\n\n' + diffString : ''); |
|
}; |
|
|
|
// Passing the the actual and expected objects so that a custom reporter |
|
// could access them, for example in order to display a custom visual diff, |
|
// or create a different error message |
|
return { actual: received, expected: expected, message: message, name: 'toEqual', pass: pass }; |
|
}, |
|
toHaveLength: function toHaveLength(received, length) { |
|
if (typeof received !== 'string' && (!received || typeof received.length !== 'number')) { |
|
throw new Error(build_1('[.not].toHaveLength', 'received', 'length') + '\n\n' + 'Expected value to have a \'length\' property that is a number. ' + 'Received:\n' + (' ' + build_9(received) + '\n') + (received ? 'received.length:\n ' + build_9(received.length) : '')); |
|
} |
|
|
|
var pass = received.length === length; |
|
var message = pass ? function () { |
|
return build_1('.not.toHaveLength', 'received', 'length') + '\n\n' + 'Expected value to not have length:\n' + (' ' + build_8(length) + '\n') + 'Received:\n' + (' ' + build_9(received) + '\n') + 'received.length:\n' + (' ' + build_9(received.length)); |
|
} : function () { |
|
return build_1('.toHaveLength', 'received', 'length') + '\n\n' + 'Expected value to have length:\n' + (' ' + build_8(length) + '\n') + 'Received:\n' + (' ' + build_9(received) + '\n') + 'received.length:\n' + (' ' + build_9(received.length)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toHaveProperty: function toHaveProperty(object, keyPath, value) { |
|
var _this3 = this; |
|
|
|
var valuePassed = arguments.length === 3; |
|
var secondArgument = valuePassed ? 'value' : null; |
|
|
|
if (!object && typeof object !== 'string' && typeof object !== 'number') { |
|
throw new Error(build_1('[.not].toHaveProperty', 'object', 'path', { |
|
secondArgument: secondArgument |
|
}) + '\n\n' + ('Expected ' + build_13('object') + ' to be an object. Received:\n') + (' ' + build$1(object) + ': ' + build_9(object))); |
|
} |
|
|
|
var keyPathType = build$1(keyPath); |
|
|
|
if (keyPathType !== 'string' && keyPathType !== 'array') { |
|
throw new Error(build_1('[.not].toHaveProperty', 'object', 'path', { |
|
secondArgument: secondArgument |
|
}) + '\n\n' + ('Expected ' + build_14('path') + ' to be a string or an array. Received:\n') + (' ' + build$1(keyPath) + ': ' + build_9(keyPath))); |
|
} |
|
|
|
var result = getPath(object, keyPath); |
|
var lastTraversedObject = result.lastTraversedObject, |
|
hasEndProp = result.hasEndProp; |
|
|
|
|
|
var pass = valuePassed ? equals(result.value, value, [iterableEquality]) : hasEndProp; |
|
|
|
var traversedPath = result.traversedPath.join('.'); |
|
|
|
var message = pass ? function () { |
|
return build_1('.not.toHaveProperty', 'object', 'path', { |
|
secondArgument: secondArgument |
|
}) + '\n\n' + 'Expected the object:\n' + (' ' + build_9(object) + '\n') + 'Not to have a nested property:\n' + (' ' + build_8(keyPath) + '\n') + (valuePassed ? 'With a value of:\n ' + build_8(value) + '\n' : ''); |
|
} : function () { |
|
var diffString = valuePassed && hasEndProp ? diff(value, result.value, { expand: _this3.expand }) : ''; |
|
return build_1('.toHaveProperty', 'object', 'path', { |
|
secondArgument: secondArgument |
|
}) + '\n\n' + 'Expected the object:\n' + (' ' + build_9(object) + '\n') + 'To have a nested property:\n' + (' ' + build_8(keyPath) + '\n') + (valuePassed ? 'With a value of:\n ' + build_8(value) + '\n' : '') + (hasEndProp ? 'Received:\n' + (' ' + build_9(result.value)) + (diffString ? '\n\nDifference:\n\n' + diffString : '') : traversedPath ? 'Received:\n ' + build_13('object') + '.' + traversedPath + ': ' + build_9(lastTraversedObject) : ''); |
|
}; |
|
if (pass === undefined) { |
|
throw new Error('pass must be initialized'); |
|
} |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toMatch: function toMatch(received, expected) { |
|
if (typeof received !== 'string') { |
|
throw new Error(build_1('[.not].toMatch', 'string', 'expected') + '\n\n' + (build_13('string') + ' value must be a string.\n') + build_7('Received', received, build_9)); |
|
} |
|
|
|
if (!(expected instanceof RegExp) && !(typeof expected === 'string')) { |
|
throw new Error(build_1('[.not].toMatch', 'string', 'expected') + '\n\n' + (build_14('expected') + ' value must be a string or a regular expression.\n') + build_7('Expected', expected, build_8)); |
|
} |
|
|
|
var pass = new RegExp(typeof expected === 'string' ? build_2$1(expected) : expected).test(received); |
|
var message = pass ? function () { |
|
return build_1('.not.toMatch') + '\n\nExpected value not to match:\n' + (' ' + build_8(expected)) + '\nReceived:\n' + (' ' + build_9(received)); |
|
} : function () { |
|
return build_1('.toMatch') + '\n\nExpected value to match:\n' + (' ' + build_8(expected)) + '\nReceived:\n' + (' ' + build_9(received)); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
toMatchObject: function toMatchObject(receivedObject, expectedObject) { |
|
var _this4 = this; |
|
|
|
if ((typeof receivedObject === 'undefined' ? 'undefined' : _typeof(receivedObject)) !== 'object' || receivedObject === null) { |
|
throw new Error(build_1('[.not].toMatchObject', 'object', 'expected') + '\n\n' + (build_13('received') + ' value must be an object.\n') + build_7('Received', receivedObject, build_9)); |
|
} |
|
|
|
if ((typeof expectedObject === 'undefined' ? 'undefined' : _typeof(expectedObject)) !== 'object' || expectedObject === null) { |
|
throw new Error(build_1('[.not].toMatchObject', 'object', 'expected') + '\n\n' + (build_14('expected') + ' value must be an object.\n') + build_7('Expected', expectedObject, build_8)); |
|
} |
|
|
|
var pass = equals(receivedObject, expectedObject, [iterableEquality, subsetEquality]); |
|
|
|
var message = pass ? function () { |
|
return build_1('.not.toMatchObject') + '\n\nExpected value not to match object:\n' + (' ' + build_8(expectedObject)) + '\nReceived:\n' + (' ' + build_9(receivedObject)); |
|
} : function () { |
|
var diffString = diff(expectedObject, getObjectSubset(receivedObject, expectedObject), { |
|
expand: _this4.expand |
|
}); |
|
return build_1('.toMatchObject') + '\n\nExpected value to match object:\n' + (' ' + build_8(expectedObject)) + '\nReceived:\n' + (' ' + build_9(receivedObject)) + (diffString ? '\nDifference:\n' + diffString : ''); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
} |
|
}; |
|
|
|
var ITERATOR$4 = _wks('iterator'); |
|
|
|
var core_isIterable = _core.isIterable = function (it) { |
|
var O = Object(it); |
|
return O[ITERATOR$4] !== undefined |
|
|| '@@iterator' in O |
|
// eslint-disable-next-line no-prototype-builtins |
|
|| _iterators.hasOwnProperty(_classof(O)); |
|
}; |
|
|
|
var isIterable$2 = core_isIterable; |
|
|
|
var isIterable = createCommonjsModule(function (module) { |
|
module.exports = { "default": isIterable$2, __esModule: true }; |
|
}); |
|
|
|
unwrapExports(isIterable); |
|
|
|
var slicedToArray = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
|
|
|
|
var _isIterable3 = _interopRequireDefault(isIterable); |
|
|
|
|
|
|
|
var _getIterator3 = _interopRequireDefault(getIterator); |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
exports.default = function () { |
|
function sliceIterator(arr, i) { |
|
var _arr = []; |
|
var _n = true; |
|
var _d = false; |
|
var _e = undefined; |
|
|
|
try { |
|
for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { |
|
_arr.push(_s.value); |
|
|
|
if (i && _arr.length === i) break; |
|
} |
|
} catch (err) { |
|
_d = true; |
|
_e = err; |
|
} finally { |
|
try { |
|
if (!_n && _i["return"]) _i["return"](); |
|
} finally { |
|
if (_d) throw _e; |
|
} |
|
} |
|
|
|
return _arr; |
|
} |
|
|
|
return function (arr, i) { |
|
if (Array.isArray(arr)) { |
|
return arr; |
|
} else if ((0, _isIterable3.default)(Object(arr))) { |
|
return sliceIterator(arr, i); |
|
} else { |
|
throw new TypeError("Invalid attempt to destructure non-iterable instance"); |
|
} |
|
}; |
|
}(); |
|
}); |
|
|
|
var _slicedToArray = unwrapExports(slicedToArray); |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var CALL_PRINT_LIMIT = 3; |
|
var LAST_CALL_PRINT_LIMIT = 1; |
|
var createToBeCalledMatcher = function createToBeCalledMatcher(matcherName) { |
|
return function (received, expected) { |
|
build_6(expected, matcherName); |
|
ensureMock(received, matcherName); |
|
|
|
var receivedIsSpy = isSpy(received); |
|
var type = receivedIsSpy ? 'spy' : 'mock function'; |
|
var receivedName = receivedIsSpy ? 'spy' : received.getMockName(); |
|
var count = receivedIsSpy ? received.calls.count() : received.mock.calls.length; |
|
var calls = receivedIsSpy ? received.calls.all().map(function (x) { |
|
return x.args; |
|
}) : received.mock.calls; |
|
var pass = count > 0; |
|
var message = pass ? function () { |
|
return build_1('.not' + matcherName, receivedName, '') + '\n\n' + ('Expected ' + type + ' not to be called ') + formatReceivedCalls(calls, CALL_PRINT_LIMIT, { sameSentence: true }); |
|
} : function () { |
|
return build_1(matcherName, receivedName, '') + '\n\n' + ('Expected ' + type + ' to have been called.'); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}; |
|
}; |
|
|
|
var createToBeCalledWithMatcher = function createToBeCalledWithMatcher(matcherName) { |
|
return function (received) { |
|
for (var _len = arguments.length, expected = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
expected[_key - 1] = arguments[_key]; |
|
} |
|
|
|
ensureMock(received, matcherName); |
|
|
|
var receivedIsSpy = isSpy(received); |
|
var type = receivedIsSpy ? 'spy' : 'mock function'; |
|
var receivedName = receivedIsSpy ? 'spy' : received.getMockName(); |
|
var calls = receivedIsSpy ? received.calls.all().map(function (x) { |
|
return x.args; |
|
}) : received.mock.calls; |
|
|
|
var _partition = partition(calls, function (call) { |
|
return equals(call, expected, [iterableEquality]); |
|
}), |
|
_partition2 = _slicedToArray(_partition, 2), |
|
match = _partition2[0], |
|
fail = _partition2[1]; |
|
|
|
var pass = match.length > 0; |
|
|
|
var message = pass ? function () { |
|
return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + type + ' not to have been called with:\n') + (' ' + build_8(expected)); |
|
} : function () { |
|
return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + type + ' to have been called with:\n') + formatMismatchedCalls(fail, expected, CALL_PRINT_LIMIT); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}; |
|
}; |
|
|
|
var createLastCalledWithMatcher = function createLastCalledWithMatcher(matcherName) { |
|
return function (received) { |
|
for (var _len2 = arguments.length, expected = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
|
expected[_key2 - 1] = arguments[_key2]; |
|
} |
|
|
|
ensureMock(received, matcherName); |
|
|
|
var receivedIsSpy = isSpy(received); |
|
var type = receivedIsSpy ? 'spy' : 'mock function'; |
|
var receivedName = receivedIsSpy ? 'spy' : received.getMockName(); |
|
var calls = receivedIsSpy ? received.calls.all().map(function (x) { |
|
return x.args; |
|
}) : received.mock.calls; |
|
var pass = equals(calls[calls.length - 1], expected, [iterableEquality]); |
|
|
|
var message = pass ? function () { |
|
return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + type + ' to not have been last called with:\n') + (' ' + build_8(expected)); |
|
} : function () { |
|
return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + type + ' to have been last called with:\n') + formatMismatchedCalls(calls, expected, LAST_CALL_PRINT_LIMIT); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}; |
|
}; |
|
|
|
var spyMatchers = { |
|
lastCalledWith: createLastCalledWithMatcher('.lastCalledWith'), |
|
toBeCalled: createToBeCalledMatcher('.toBeCalled'), |
|
toBeCalledWith: createToBeCalledWithMatcher('.toBeCalledWith'), |
|
toHaveBeenCalled: createToBeCalledMatcher('.toHaveBeenCalled'), |
|
toHaveBeenCalledTimes: function toHaveBeenCalledTimes(received, expected) { |
|
var matcherName = '.toHaveBeenCalledTimes'; |
|
build_4(expected, matcherName); |
|
ensureMock(received, matcherName); |
|
|
|
var receivedIsSpy = isSpy(received); |
|
var type = receivedIsSpy ? 'spy' : 'mock function'; |
|
var receivedName = receivedIsSpy ? 'spy' : received.getMockName(); |
|
var count = receivedIsSpy ? received.calls.count() : received.mock.calls.length; |
|
var pass = count === expected; |
|
var message = pass ? function () { |
|
return build_1('.not' + matcherName, receivedName, String(expected)) + '\n\n' + ('Expected ' + type + ' not to be called ') + (build_14(build_2('time', expected)) + ', but it was') + (' called exactly ' + build_13(build_2('time', count)) + '.'); |
|
} : function () { |
|
return build_1(matcherName, receivedName, String(expected)) + '\n\n' + ('Expected ' + type + ' to have been called ') + (build_14(build_2('time', expected)) + ',') + (' but it was called ' + build_13(build_2('time', count)) + '.'); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}, |
|
|
|
toHaveBeenCalledWith: createToBeCalledWithMatcher('.toHaveBeenCalledWith'), |
|
toHaveBeenLastCalledWith: createLastCalledWithMatcher('.toHaveBeenLastCalledWith') |
|
}; |
|
|
|
var isSpy = function isSpy(spy) { |
|
return spy.calls && typeof spy.calls.count === 'function'; |
|
}; |
|
|
|
var ensureMock = function ensureMock(mockOrSpy, matcherName) { |
|
if (!mockOrSpy || (mockOrSpy.calls === undefined || mockOrSpy.calls.all === undefined) && mockOrSpy._isMockFunction !== true) { |
|
throw new Error(build_1('[.not]' + matcherName, 'jest.fn()', '') + '\n\n' + (build_13('jest.fn()') + ' value must be a mock function ') + 'or spy.\n' + build_7('Received', mockOrSpy, build_9)); |
|
} |
|
}; |
|
|
|
var getPrintedCalls = function getPrintedCalls(calls, limit, sep, fn) { |
|
var result = []; |
|
var i = calls.length; |
|
|
|
while (--i >= 0 && --limit >= 0) { |
|
result.push(fn(calls[i])); |
|
} |
|
|
|
return result.join(sep); |
|
}; |
|
|
|
var formatReceivedCalls = function formatReceivedCalls(calls, limit, options) { |
|
if (calls.length) { |
|
var but = options && options.sameSentence ? 'but' : 'But'; |
|
var count = calls.length - limit; |
|
var printedCalls = getPrintedCalls(calls, limit, ', ', build_9); |
|
return but + ' it was ' + (options && options.isLast ? 'last ' : '') + 'called ' + 'with:\n ' + printedCalls + (count > 0 ? '\nand ' + build_13(build_2('more call', count)) + '.' : ''); |
|
} else { |
|
return 'But it was ' + build_13('not called') + '.'; |
|
} |
|
}; |
|
|
|
var formatMismatchedCalls = function formatMismatchedCalls(calls, expected, limit) { |
|
if (calls.length) { |
|
return getPrintedCalls(calls, limit, '\n\n', formatMismatchedArgs.bind(null, expected)); |
|
} else { |
|
return ' ' + build_8(expected) + '\n' + ('But it was ' + build_13('not called') + '.'); |
|
} |
|
}; |
|
|
|
var formatMismatchedArgs = function formatMismatchedArgs(expected, received) { |
|
var length = Math.max(expected.length, received.length); |
|
|
|
var printedArgs = []; |
|
for (var i = 0; i < length; i++) { |
|
if (!equals(expected[i], received[i], [iterableEquality])) { |
|
printedArgs.push(' ' + build_8(expected[i]) + ' as argument ' + (i + 1) + ', ' + ('but it was called with ' + build_9(received[i]) + '.')); |
|
} else if (i >= expected.length) { |
|
printedArgs.push(' Did not expect argument ' + (i + 1) + ' ' + ('but it was called with ' + build_9(received[i]) + '.')); |
|
} |
|
} |
|
|
|
return printedArgs.join('\n'); |
|
}; |
|
|
|
var global$2 = typeof global !== "undefined" ? global : |
|
typeof self !== "undefined" ? self : |
|
typeof window !== "undefined" ? window : {} |
|
|
|
// shim for using process in browser |
|
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js |
|
|
|
function defaultSetTimout() { |
|
throw new Error('setTimeout has not been defined'); |
|
} |
|
function defaultClearTimeout () { |
|
throw new Error('clearTimeout has not been defined'); |
|
} |
|
var cachedSetTimeout = defaultSetTimout; |
|
var cachedClearTimeout = defaultClearTimeout; |
|
if (typeof global$2.setTimeout === 'function') { |
|
cachedSetTimeout = setTimeout; |
|
} |
|
if (typeof global$2.clearTimeout === 'function') { |
|
cachedClearTimeout = clearTimeout; |
|
} |
|
|
|
function runTimeout(fun) { |
|
if (cachedSetTimeout === setTimeout) { |
|
//normal enviroments in sane situations |
|
return setTimeout(fun, 0); |
|
} |
|
// if setTimeout wasn't available but was latter defined |
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { |
|
cachedSetTimeout = setTimeout; |
|
return setTimeout(fun, 0); |
|
} |
|
try { |
|
// when when somebody has screwed with setTimeout but no I.E. maddness |
|
return cachedSetTimeout(fun, 0); |
|
} catch(e){ |
|
try { |
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
|
return cachedSetTimeout.call(null, fun, 0); |
|
} catch(e){ |
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error |
|
return cachedSetTimeout.call(this, fun, 0); |
|
} |
|
} |
|
|
|
|
|
} |
|
function runClearTimeout(marker) { |
|
if (cachedClearTimeout === clearTimeout) { |
|
//normal enviroments in sane situations |
|
return clearTimeout(marker); |
|
} |
|
// if clearTimeout wasn't available but was latter defined |
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { |
|
cachedClearTimeout = clearTimeout; |
|
return clearTimeout(marker); |
|
} |
|
try { |
|
// when when somebody has screwed with setTimeout but no I.E. maddness |
|
return cachedClearTimeout(marker); |
|
} catch (e){ |
|
try { |
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
|
return cachedClearTimeout.call(null, marker); |
|
} catch (e){ |
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. |
|
// Some versions of I.E. have different rules for clearTimeout vs setTimeout |
|
return cachedClearTimeout.call(this, marker); |
|
} |
|
} |
|
|
|
|
|
|
|
} |
|
var queue$1 = []; |
|
var draining = false; |
|
var currentQueue; |
|
var queueIndex = -1; |
|
|
|
function cleanUpNextTick() { |
|
if (!draining || !currentQueue) { |
|
return; |
|
} |
|
draining = false; |
|
if (currentQueue.length) { |
|
queue$1 = currentQueue.concat(queue$1); |
|
} else { |
|
queueIndex = -1; |
|
} |
|
if (queue$1.length) { |
|
drainQueue(); |
|
} |
|
} |
|
|
|
function drainQueue() { |
|
if (draining) { |
|
return; |
|
} |
|
var timeout = runTimeout(cleanUpNextTick); |
|
draining = true; |
|
|
|
var len = queue$1.length; |
|
while(len) { |
|
currentQueue = queue$1; |
|
queue$1 = []; |
|
while (++queueIndex < len) { |
|
if (currentQueue) { |
|
currentQueue[queueIndex].run(); |
|
} |
|
} |
|
queueIndex = -1; |
|
len = queue$1.length; |
|
} |
|
currentQueue = null; |
|
draining = false; |
|
runClearTimeout(timeout); |
|
} |
|
function nextTick(fun) { |
|
var args = new Array(arguments.length - 1); |
|
if (arguments.length > 1) { |
|
for (var i = 1; i < arguments.length; i++) { |
|
args[i - 1] = arguments[i]; |
|
} |
|
} |
|
queue$1.push(new Item(fun, args)); |
|
if (queue$1.length === 1 && !draining) { |
|
runTimeout(drainQueue); |
|
} |
|
} |
|
// v8 likes predictible objects |
|
function Item(fun, array) { |
|
this.fun = fun; |
|
this.array = array; |
|
} |
|
Item.prototype.run = function () { |
|
this.fun.apply(null, this.array); |
|
}; |
|
var title = 'browser'; |
|
var platform = 'browser'; |
|
var browser = true; |
|
var env = {}; |
|
var argv = []; |
|
var version = ''; // empty string to avoid regexp issues |
|
var versions = {}; |
|
var release = {}; |
|
var config = {}; |
|
|
|
function noop() {} |
|
|
|
var on = noop; |
|
var addListener = noop; |
|
var once = noop; |
|
var off = noop; |
|
var removeListener = noop; |
|
var removeAllListeners = noop; |
|
var emit = noop; |
|
|
|
function binding(name) { |
|
throw new Error('process.binding is not supported'); |
|
} |
|
|
|
function cwd () { return '/' } |
|
function chdir (dir) { |
|
throw new Error('process.chdir is not supported'); |
|
} |
|
function umask() { return 0; } |
|
|
|
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js |
|
var performance = global$2.performance || {}; |
|
var performanceNow = |
|
performance.now || |
|
performance.mozNow || |
|
performance.msNow || |
|
performance.oNow || |
|
performance.webkitNow || |
|
function(){ return (new Date()).getTime() }; |
|
|
|
// generate timestamp or delta |
|
// see http://nodejs.org/api/process.html#process_process_hrtime |
|
function hrtime(previousTimestamp){ |
|
var clocktime = performanceNow.call(performance)*1e-3; |
|
var seconds = Math.floor(clocktime); |
|
var nanoseconds = Math.floor((clocktime%1)*1e9); |
|
if (previousTimestamp) { |
|
seconds = seconds - previousTimestamp[0]; |
|
nanoseconds = nanoseconds - previousTimestamp[1]; |
|
if (nanoseconds<0) { |
|
seconds--; |
|
nanoseconds += 1e9; |
|
} |
|
} |
|
return [seconds,nanoseconds] |
|
} |
|
|
|
var startTime = new Date(); |
|
function uptime() { |
|
var currentTime = new Date(); |
|
var dif = currentTime - startTime; |
|
return dif / 1000; |
|
} |
|
|
|
var process$3 = { |
|
nextTick: nextTick, |
|
title: title, |
|
browser: browser, |
|
env: env, |
|
argv: argv, |
|
version: version, |
|
versions: versions, |
|
on: on, |
|
addListener: addListener, |
|
once: once, |
|
off: off, |
|
removeListener: removeListener, |
|
removeAllListeners: removeAllListeners, |
|
emit: emit, |
|
binding: binding, |
|
cwd: cwd, |
|
chdir: chdir, |
|
umask: umask, |
|
hrtime: hrtime, |
|
platform: platform, |
|
release: release, |
|
config: config, |
|
uptime: uptime |
|
}; |
|
|
|
var empty$1 = {}; |
|
|
|
|
|
var empty$2 = Object.freeze({ |
|
default: empty$1 |
|
}); |
|
|
|
/*! |
|
* filename-regex <https://github.com/regexps/filename-regex> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert |
|
* Licensed under the MIT license. |
|
*/ |
|
|
|
var filenameRegex = function filenameRegex() { |
|
return /([^\\\/]+)$/; |
|
}; |
|
|
|
/*! |
|
* arr-flatten <https://github.com/jonschlinkert/arr-flatten> |
|
* |
|
* Copyright (c) 2014-2017, Jon Schlinkert. |
|
* Released under the MIT License. |
|
*/ |
|
|
|
var arrFlatten = function (arr) { |
|
return flat(arr, []); |
|
}; |
|
|
|
function flat(arr, res) { |
|
var i = 0, cur; |
|
var len = arr.length; |
|
for (; i < len; i++) { |
|
cur = arr[i]; |
|
Array.isArray(cur) ? flat(cur, res) : res.push(cur); |
|
} |
|
return res; |
|
} |
|
|
|
var slice = [].slice; |
|
|
|
/** |
|
* Return the difference between the first array and |
|
* additional arrays. |
|
* |
|
* ```js |
|
* var diff = require('{%= name %}'); |
|
* |
|
* var a = ['a', 'b', 'c', 'd']; |
|
* var b = ['b', 'c']; |
|
* |
|
* console.log(diff(a, b)) |
|
* //=> ['a', 'd'] |
|
* ``` |
|
* |
|
* @param {Array} `a` |
|
* @param {Array} `b` |
|
* @return {Array} |
|
* @api public |
|
*/ |
|
|
|
function diff$1(arr, arrays) { |
|
var argsLen = arguments.length; |
|
var len = arr.length, i = -1; |
|
var res = [], arrays; |
|
|
|
if (argsLen === 1) { |
|
return arr; |
|
} |
|
|
|
if (argsLen > 2) { |
|
arrays = arrFlatten(slice.call(arguments, 1)); |
|
} |
|
|
|
while (++i < len) { |
|
if (!~arrays.indexOf(arr[i])) { |
|
res.push(arr[i]); |
|
} |
|
} |
|
return res; |
|
} |
|
|
|
/** |
|
* Expose `diff` |
|
*/ |
|
|
|
var arrDiff = diff$1; |
|
|
|
/*! |
|
* array-unique <https://github.com/jonschlinkert/array-unique> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
var arrayUnique = function unique(arr) { |
|
if (!Array.isArray(arr)) { |
|
throw new TypeError('array-unique expects an array.'); |
|
} |
|
|
|
var len = arr.length; |
|
var i = -1; |
|
|
|
while (i++ < len) { |
|
var j = i + 1; |
|
|
|
for (; j < arr.length; ++j) { |
|
if (arr[i] === arr[j]) { |
|
arr.splice(j--, 1); |
|
} |
|
} |
|
} |
|
return arr; |
|
}; |
|
|
|
var toString$3 = {}.toString; |
|
|
|
var isarray = Array.isArray || function (arr) { |
|
return toString$3.call(arr) == '[object Array]'; |
|
}; |
|
|
|
var isobject = function isObject(val) { |
|
return val != null && typeof val === 'object' && isarray(val) === false; |
|
}; |
|
|
|
/*! |
|
* Determine if an object is a Buffer |
|
* |
|
* @author Feross Aboukhadijeh <https://feross.org> |
|
* @license MIT |
|
*/ |
|
|
|
// The _isBuffer check is for Safari 5-7 support, because it's missing |
|
// Object.prototype.constructor. Remove this eventually |
|
var isBuffer_1 = function (obj) { |
|
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) |
|
}; |
|
|
|
function isBuffer (obj) { |
|
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) |
|
} |
|
|
|
// For Node v0.10 support. Remove this eventually. |
|
function isSlowBuffer (obj) { |
|
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) |
|
} |
|
|
|
var toString$4 = Object.prototype.toString; |
|
|
|
/** |
|
* Get the native `typeof` a value. |
|
* |
|
* @param {*} `val` |
|
* @return {*} Native javascript type |
|
*/ |
|
|
|
var kindOf = function kindOf(val) { |
|
// primitivies |
|
if (typeof val === 'undefined') { |
|
return 'undefined'; |
|
} |
|
if (val === null) { |
|
return 'null'; |
|
} |
|
if (val === true || val === false || val instanceof Boolean) { |
|
return 'boolean'; |
|
} |
|
if (typeof val === 'string' || val instanceof String) { |
|
return 'string'; |
|
} |
|
if (typeof val === 'number' || val instanceof Number) { |
|
return 'number'; |
|
} |
|
|
|
// functions |
|
if (typeof val === 'function' || val instanceof Function) { |
|
return 'function'; |
|
} |
|
|
|
// array |
|
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) { |
|
return 'array'; |
|
} |
|
|
|
// check for instances of RegExp and Date before calling `toString` |
|
if (val instanceof RegExp) { |
|
return 'regexp'; |
|
} |
|
if (val instanceof Date) { |
|
return 'date'; |
|
} |
|
|
|
// other objects |
|
var type = toString$4.call(val); |
|
|
|
if (type === '[object RegExp]') { |
|
return 'regexp'; |
|
} |
|
if (type === '[object Date]') { |
|
return 'date'; |
|
} |
|
if (type === '[object Arguments]') { |
|
return 'arguments'; |
|
} |
|
if (type === '[object Error]') { |
|
return 'error'; |
|
} |
|
|
|
// buffer |
|
if (isBuffer_1(val)) { |
|
return 'buffer'; |
|
} |
|
|
|
// es6: Map, WeakMap, Set, WeakSet |
|
if (type === '[object Set]') { |
|
return 'set'; |
|
} |
|
if (type === '[object WeakSet]') { |
|
return 'weakset'; |
|
} |
|
if (type === '[object Map]') { |
|
return 'map'; |
|
} |
|
if (type === '[object WeakMap]') { |
|
return 'weakmap'; |
|
} |
|
if (type === '[object Symbol]') { |
|
return 'symbol'; |
|
} |
|
|
|
// typed arrays |
|
if (type === '[object Int8Array]') { |
|
return 'int8array'; |
|
} |
|
if (type === '[object Uint8Array]') { |
|
return 'uint8array'; |
|
} |
|
if (type === '[object Uint8ClampedArray]') { |
|
return 'uint8clampedarray'; |
|
} |
|
if (type === '[object Int16Array]') { |
|
return 'int16array'; |
|
} |
|
if (type === '[object Uint16Array]') { |
|
return 'uint16array'; |
|
} |
|
if (type === '[object Int32Array]') { |
|
return 'int32array'; |
|
} |
|
if (type === '[object Uint32Array]') { |
|
return 'uint32array'; |
|
} |
|
if (type === '[object Float32Array]') { |
|
return 'float32array'; |
|
} |
|
if (type === '[object Float64Array]') { |
|
return 'float64array'; |
|
} |
|
|
|
// must be a plain object |
|
return 'object'; |
|
}; |
|
|
|
var isNumber = function isNumber(num) { |
|
var type = kindOf(num); |
|
if (type !== 'number' && type !== 'string') { |
|
return false; |
|
} |
|
var n = +num; |
|
return (n - n + 1) >= 0 && num !== ''; |
|
}; |
|
|
|
var toString$5 = Object.prototype.toString; |
|
|
|
/** |
|
* Get the native `typeof` a value. |
|
* |
|
* @param {*} `val` |
|
* @return {*} Native javascript type |
|
*/ |
|
|
|
var kindOf$2 = function kindOf(val) { |
|
// primitivies |
|
if (typeof val === 'undefined') { |
|
return 'undefined'; |
|
} |
|
if (val === null) { |
|
return 'null'; |
|
} |
|
if (val === true || val === false || val instanceof Boolean) { |
|
return 'boolean'; |
|
} |
|
if (typeof val === 'string' || val instanceof String) { |
|
return 'string'; |
|
} |
|
if (typeof val === 'number' || val instanceof Number) { |
|
return 'number'; |
|
} |
|
|
|
// functions |
|
if (typeof val === 'function' || val instanceof Function) { |
|
return 'function'; |
|
} |
|
|
|
// array |
|
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) { |
|
return 'array'; |
|
} |
|
|
|
// check for instances of RegExp and Date before calling `toString` |
|
if (val instanceof RegExp) { |
|
return 'regexp'; |
|
} |
|
if (val instanceof Date) { |
|
return 'date'; |
|
} |
|
|
|
// other objects |
|
var type = toString$5.call(val); |
|
|
|
if (type === '[object RegExp]') { |
|
return 'regexp'; |
|
} |
|
if (type === '[object Date]') { |
|
return 'date'; |
|
} |
|
if (type === '[object Arguments]') { |
|
return 'arguments'; |
|
} |
|
if (type === '[object Error]') { |
|
return 'error'; |
|
} |
|
|
|
// buffer |
|
if (isBuffer_1(val)) { |
|
return 'buffer'; |
|
} |
|
|
|
// es6: Map, WeakMap, Set, WeakSet |
|
if (type === '[object Set]') { |
|
return 'set'; |
|
} |
|
if (type === '[object WeakSet]') { |
|
return 'weakset'; |
|
} |
|
if (type === '[object Map]') { |
|
return 'map'; |
|
} |
|
if (type === '[object WeakMap]') { |
|
return 'weakmap'; |
|
} |
|
if (type === '[object Symbol]') { |
|
return 'symbol'; |
|
} |
|
|
|
// typed arrays |
|
if (type === '[object Int8Array]') { |
|
return 'int8array'; |
|
} |
|
if (type === '[object Uint8Array]') { |
|
return 'uint8array'; |
|
} |
|
if (type === '[object Uint8ClampedArray]') { |
|
return 'uint8clampedarray'; |
|
} |
|
if (type === '[object Int16Array]') { |
|
return 'int16array'; |
|
} |
|
if (type === '[object Uint16Array]') { |
|
return 'uint16array'; |
|
} |
|
if (type === '[object Int32Array]') { |
|
return 'int32array'; |
|
} |
|
if (type === '[object Uint32Array]') { |
|
return 'uint32array'; |
|
} |
|
if (type === '[object Float32Array]') { |
|
return 'float32array'; |
|
} |
|
if (type === '[object Float64Array]') { |
|
return 'float64array'; |
|
} |
|
|
|
// must be a plain object |
|
return 'object'; |
|
}; |
|
|
|
var isNumber$2 = function isNumber(num) { |
|
var type = kindOf$2(num); |
|
|
|
if (type === 'string') { |
|
if (!num.trim()) return false; |
|
} else if (type !== 'number') { |
|
return false; |
|
} |
|
|
|
return (num - num + 1) >= 0; |
|
}; |
|
|
|
var toString$6 = Object.prototype.toString; |
|
|
|
/** |
|
* Get the native `typeof` a value. |
|
* |
|
* @param {*} `val` |
|
* @return {*} Native javascript type |
|
*/ |
|
|
|
var kindOf$4 = function kindOf(val) { |
|
// primitivies |
|
if (typeof val === 'undefined') { |
|
return 'undefined'; |
|
} |
|
if (val === null) { |
|
return 'null'; |
|
} |
|
if (val === true || val === false || val instanceof Boolean) { |
|
return 'boolean'; |
|
} |
|
if (typeof val === 'string' || val instanceof String) { |
|
return 'string'; |
|
} |
|
if (typeof val === 'number' || val instanceof Number) { |
|
return 'number'; |
|
} |
|
|
|
// functions |
|
if (typeof val === 'function' || val instanceof Function) { |
|
return 'function'; |
|
} |
|
|
|
// array |
|
if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) { |
|
return 'array'; |
|
} |
|
|
|
// check for instances of RegExp and Date before calling `toString` |
|
if (val instanceof RegExp) { |
|
return 'regexp'; |
|
} |
|
if (val instanceof Date) { |
|
return 'date'; |
|
} |
|
|
|
// other objects |
|
var type = toString$6.call(val); |
|
|
|
if (type === '[object RegExp]') { |
|
return 'regexp'; |
|
} |
|
if (type === '[object Date]') { |
|
return 'date'; |
|
} |
|
if (type === '[object Arguments]') { |
|
return 'arguments'; |
|
} |
|
if (type === '[object Error]') { |
|
return 'error'; |
|
} |
|
if (type === '[object Promise]') { |
|
return 'promise'; |
|
} |
|
|
|
// buffer |
|
if (isBuffer_1(val)) { |
|
return 'buffer'; |
|
} |
|
|
|
// es6: Map, WeakMap, Set, WeakSet |
|
if (type === '[object Set]') { |
|
return 'set'; |
|
} |
|
if (type === '[object WeakSet]') { |
|
return 'weakset'; |
|
} |
|
if (type === '[object Map]') { |
|
return 'map'; |
|
} |
|
if (type === '[object WeakMap]') { |
|
return 'weakmap'; |
|
} |
|
if (type === '[object Symbol]') { |
|
return 'symbol'; |
|
} |
|
|
|
// typed arrays |
|
if (type === '[object Int8Array]') { |
|
return 'int8array'; |
|
} |
|
if (type === '[object Uint8Array]') { |
|
return 'uint8array'; |
|
} |
|
if (type === '[object Uint8ClampedArray]') { |
|
return 'uint8clampedarray'; |
|
} |
|
if (type === '[object Int16Array]') { |
|
return 'int16array'; |
|
} |
|
if (type === '[object Uint16Array]') { |
|
return 'uint16array'; |
|
} |
|
if (type === '[object Int32Array]') { |
|
return 'int32array'; |
|
} |
|
if (type === '[object Uint32Array]') { |
|
return 'uint32array'; |
|
} |
|
if (type === '[object Float32Array]') { |
|
return 'float32array'; |
|
} |
|
if (type === '[object Float64Array]') { |
|
return 'float64array'; |
|
} |
|
|
|
// must be a plain object |
|
return 'object'; |
|
}; |
|
|
|
/** |
|
* Expose `randomatic` |
|
*/ |
|
|
|
var randomatic_1 = randomatic; |
|
|
|
/** |
|
* Available mask characters |
|
*/ |
|
|
|
var type = { |
|
lower: 'abcdefghijklmnopqrstuvwxyz', |
|
upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', |
|
number: '0123456789', |
|
special: '~!@#$%^&()_+-={}[];\',.' |
|
}; |
|
|
|
type.all = type.lower + type.upper + type.number + type.special; |
|
|
|
/** |
|
* Generate random character sequences of a specified `length`, |
|
* based on the given `pattern`. |
|
* |
|
* @param {String} `pattern` The pattern to use for generating the random string. |
|
* @param {String} `length` The length of the string to generate. |
|
* @param {String} `options` |
|
* @return {String} |
|
* @api public |
|
*/ |
|
|
|
function randomatic(pattern, length, options) { |
|
if (typeof pattern === 'undefined') { |
|
throw new Error('randomatic expects a string or number.'); |
|
} |
|
|
|
var custom = false; |
|
if (arguments.length === 1) { |
|
if (typeof pattern === 'string') { |
|
length = pattern.length; |
|
|
|
} else if (isNumber$2(pattern)) { |
|
options = {}; length = pattern; pattern = '*'; |
|
} |
|
} |
|
|
|
if (kindOf$4(length) === 'object' && length.hasOwnProperty('chars')) { |
|
options = length; |
|
pattern = options.chars; |
|
length = pattern.length; |
|
custom = true; |
|
} |
|
|
|
var opts = options || {}; |
|
var mask = ''; |
|
var res = ''; |
|
|
|
// Characters to be used |
|
if (pattern.indexOf('?') !== -1) mask += opts.chars; |
|
if (pattern.indexOf('a') !== -1) mask += type.lower; |
|
if (pattern.indexOf('A') !== -1) mask += type.upper; |
|
if (pattern.indexOf('0') !== -1) mask += type.number; |
|
if (pattern.indexOf('!') !== -1) mask += type.special; |
|
if (pattern.indexOf('*') !== -1) mask += type.all; |
|
if (custom) mask += pattern; |
|
|
|
while (length--) { |
|
res += mask.charAt(parseInt(Math.random() * mask.length, 10)); |
|
} |
|
return res; |
|
} |
|
|
|
/*! |
|
* repeat-string <https://github.com/jonschlinkert/repeat-string> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
/** |
|
* Results cache |
|
*/ |
|
|
|
var res = ''; |
|
var cache; |
|
|
|
/** |
|
* Expose `repeat` |
|
*/ |
|
|
|
var repeatString = repeat; |
|
|
|
/** |
|
* Repeat the given `string` the specified `number` |
|
* of times. |
|
* |
|
* **Example:** |
|
* |
|
* ```js |
|
* var repeat = require('repeat-string'); |
|
* repeat('A', 5); |
|
* //=> AAAAA |
|
* ``` |
|
* |
|
* @param {String} `string` The string to repeat |
|
* @param {Number} `number` The number of times to repeat the string |
|
* @return {String} Repeated string |
|
* @api public |
|
*/ |
|
|
|
function repeat(str, num) { |
|
if (typeof str !== 'string') { |
|
throw new TypeError('expected a string'); |
|
} |
|
|
|
// cover common, quick use cases |
|
if (num === 1) return str; |
|
if (num === 2) return str + str; |
|
|
|
var max = str.length * num; |
|
if (cache !== str || typeof cache === 'undefined') { |
|
cache = str; |
|
res = ''; |
|
} else if (res.length >= max) { |
|
return res.substr(0, max); |
|
} |
|
|
|
while (max > res.length && num > 1) { |
|
if (num & 1) { |
|
res += str; |
|
} |
|
|
|
num >>= 1; |
|
str += str; |
|
} |
|
|
|
res += str; |
|
res = res.substr(0, max); |
|
return res; |
|
} |
|
|
|
/*! |
|
* repeat-element <https://github.com/jonschlinkert/repeat-element> |
|
* |
|
* Copyright (c) 2015 Jon Schlinkert. |
|
* Licensed under the MIT license. |
|
*/ |
|
|
|
var repeatElement = function repeat(ele, num) { |
|
var arr = new Array(num); |
|
|
|
for (var i = 0; i < num; i++) { |
|
arr[i] = ele; |
|
} |
|
|
|
return arr; |
|
}; |
|
|
|
/** |
|
* Expose `fillRange` |
|
*/ |
|
|
|
var fillRange_1 = fillRange; |
|
|
|
/** |
|
* Return a range of numbers or letters. |
|
* |
|
* @param {String} `a` Start of the range |
|
* @param {String} `b` End of the range |
|
* @param {String} `step` Increment or decrement to use. |
|
* @param {Function} `fn` Custom function to modify each element in the range. |
|
* @return {Array} |
|
*/ |
|
|
|
function fillRange(a, b, step, options, fn) { |
|
if (a == null || b == null) { |
|
throw new Error('fill-range expects the first and second args to be strings.'); |
|
} |
|
|
|
if (typeof step === 'function') { |
|
fn = step; options = {}; step = null; |
|
} |
|
|
|
if (typeof options === 'function') { |
|
fn = options; options = {}; |
|
} |
|
|
|
if (isobject(step)) { |
|
options = step; step = ''; |
|
} |
|
|
|
var expand, regex = false, sep = ''; |
|
var opts = options || {}; |
|
|
|
if (typeof opts.silent === 'undefined') { |
|
opts.silent = true; |
|
} |
|
|
|
step = step || opts.step; |
|
|
|
// store a ref to unmodified arg |
|
var origA = a, origB = b; |
|
|
|
b = (b.toString() === '-0') ? 0 : b; |
|
|
|
if (opts.optimize || opts.makeRe) { |
|
step = step ? (step += '~') : step; |
|
expand = true; |
|
regex = true; |
|
sep = '~'; |
|
} |
|
|
|
// handle special step characters |
|
if (typeof step === 'string') { |
|
var match = stepRe().exec(step); |
|
|
|
if (match) { |
|
var i = match.index; |
|
var m = match[0]; |
|
|
|
// repeat string |
|
if (m === '+') { |
|
return repeatElement(a, b); |
|
|
|
// randomize a, `b` times |
|
} else if (m === '?') { |
|
return [randomatic_1(a, b)]; |
|
|
|
// expand right, no regex reduction |
|
} else if (m === '>') { |
|
step = step.substr(0, i) + step.substr(i + 1); |
|
expand = true; |
|
|
|
// expand to an array, or if valid create a reduced |
|
// string for a regex logic `or` |
|
} else if (m === '|') { |
|
step = step.substr(0, i) + step.substr(i + 1); |
|
expand = true; |
|
regex = true; |
|
sep = m; |
|
|
|
// expand to an array, or if valid create a reduced |
|
// string for a regex range |
|
} else if (m === '~') { |
|
step = step.substr(0, i) + step.substr(i + 1); |
|
expand = true; |
|
regex = true; |
|
sep = m; |
|
} |
|
} else if (!isNumber(step)) { |
|
if (!opts.silent) { |
|
throw new TypeError('fill-range: invalid step.'); |
|
} |
|
return null; |
|
} |
|
} |
|
|
|
if (/[.&*()[\]^%$#@!]/.test(a) || /[.&*()[\]^%$#@!]/.test(b)) { |
|
if (!opts.silent) { |
|
throw new RangeError('fill-range: invalid range arguments.'); |
|
} |
|
return null; |
|
} |
|
|
|
// has neither a letter nor number, or has both letters and numbers |
|
// this needs to be after the step logic |
|
if (!noAlphaNum(a) || !noAlphaNum(b) || hasBoth(a) || hasBoth(b)) { |
|
if (!opts.silent) { |
|
throw new RangeError('fill-range: invalid range arguments.'); |
|
} |
|
return null; |
|
} |
|
|
|
// validate arguments |
|
var isNumA = isNumber(zeros(a)); |
|
var isNumB = isNumber(zeros(b)); |
|
|
|
if ((!isNumA && isNumB) || (isNumA && !isNumB)) { |
|
if (!opts.silent) { |
|
throw new TypeError('fill-range: first range argument is incompatible with second.'); |
|
} |
|
return null; |
|
} |
|
|
|
// by this point both are the same, so we |
|
// can use A to check going forward. |
|
var isNum = isNumA; |
|
var num = formatStep(step); |
|
|
|
// is the range alphabetical? or numeric? |
|
if (isNum) { |
|
// if numeric, coerce to an integer |
|
a = +a; b = +b; |
|
} else { |
|
// otherwise, get the charCode to expand alpha ranges |
|
a = a.charCodeAt(0); |
|
b = b.charCodeAt(0); |
|
} |
|
|
|
// is the pattern descending? |
|
var isDescending = a > b; |
|
|
|
// don't create a character class if the args are < 0 |
|
if (a < 0 || b < 0) { |
|
expand = false; |
|
regex = false; |
|
} |
|
|
|
// detect padding |
|
var padding = isPadded(origA, origB); |
|
var res, pad, arr = []; |
|
var ii = 0; |
|
|
|
// character classes, ranges and logical `or` |
|
if (regex) { |
|
if (shouldExpand(a, b, num, isNum, padding, opts)) { |
|
// make sure the correct separator is used |
|
if (sep === '|' || sep === '~') { |
|
sep = detectSeparator(a, b, num, isNum, isDescending); |
|
} |
|
return wrap$2([origA, origB], sep, opts); |
|
} |
|
} |
|
|
|
while (isDescending ? (a >= b) : (a <= b)) { |
|
if (padding && isNum) { |
|
pad = padding(a); |
|
} |
|
|
|
// custom function |
|
if (typeof fn === 'function') { |
|
res = fn(a, isNum, pad, ii++); |
|
|
|
// letters |
|
} else if (!isNum) { |
|
if (regex && isInvalidChar(a)) { |
|
res = null; |
|
} else { |
|
res = String.fromCharCode(a); |
|
} |
|
|
|
// numbers |
|
} else { |
|
res = formatPadding(a, pad); |
|
} |
|
|
|
// add result to the array, filtering any nulled values |
|
if (res !== null) arr.push(res); |
|
|
|
// increment or decrement |
|
if (isDescending) { |
|
a -= num; |
|
} else { |
|
a += num; |
|
} |
|
} |
|
|
|
// now that the array is expanded, we need to handle regex |
|
// character classes, ranges or logical `or` that wasn't |
|
// already handled before the loop |
|
if ((regex || expand) && !opts.noexpand) { |
|
// make sure the correct separator is used |
|
if (sep === '|' || sep === '~') { |
|
sep = detectSeparator(a, b, num, isNum, isDescending); |
|
} |
|
if (arr.length === 1 || a < 0 || b < 0) { return arr; } |
|
return wrap$2(arr, sep, opts); |
|
} |
|
|
|
return arr; |
|
} |
|
|
|
/** |
|
* Wrap the string with the correct regex |
|
* syntax. |
|
*/ |
|
|
|
function wrap$2(arr, sep, opts) { |
|
if (sep === '~') { sep = '-'; } |
|
var str = arr.join(sep); |
|
var pre = opts && opts.regexPrefix; |
|
|
|
// regex logical `or` |
|
if (sep === '|') { |
|
str = pre ? pre + str : str; |
|
str = '(' + str + ')'; |
|
} |
|
|
|
// regex character class |
|
if (sep === '-') { |
|
str = (pre && pre === '^') |
|
? pre + str |
|
: str; |
|
str = '[' + str + ']'; |
|
} |
|
return [str]; |
|
} |
|
|
|
/** |
|
* Check for invalid characters |
|
*/ |
|
|
|
function isCharClass(a, b, step, isNum, isDescending) { |
|
if (isDescending) { return false; } |
|
if (isNum) { return a <= 9 && b <= 9; } |
|
if (a < b) { return step === 1; } |
|
return false; |
|
} |
|
|
|
/** |
|
* Detect the correct separator to use |
|
*/ |
|
|
|
function shouldExpand(a, b, num, isNum, padding, opts) { |
|
if (isNum && (a > 9 || b > 9)) { return false; } |
|
return !padding && num === 1 && a < b; |
|
} |
|
|
|
/** |
|
* Detect the correct separator to use |
|
*/ |
|
|
|
function detectSeparator(a, b, step, isNum, isDescending) { |
|
var isChar = isCharClass(a, b, step, isNum, isDescending); |
|
if (!isChar) { |
|
return '|'; |
|
} |
|
return '~'; |
|
} |
|
|
|
/** |
|
* Correctly format the step based on type |
|
*/ |
|
|
|
function formatStep(step) { |
|
return Math.abs(step >> 0) || 1; |
|
} |
|
|
|
/** |
|
* Format padding, taking leading `-` into account |
|
*/ |
|
|
|
function formatPadding(ch, pad) { |
|
var res = pad ? pad + ch : ch; |
|
if (pad && ch.toString().charAt(0) === '-') { |
|
res = '-' + pad + ch.toString().substr(1); |
|
} |
|
return res.toString(); |
|
} |
|
|
|
/** |
|
* Check for invalid characters |
|
*/ |
|
|
|
function isInvalidChar(str) { |
|
var ch = toStr(str); |
|
return ch === '\\' |
|
|| ch === '[' |
|
|| ch === ']' |
|
|| ch === '^' |
|
|| ch === '(' |
|
|| ch === ')' |
|
|| ch === '`'; |
|
} |
|
|
|
/** |
|
* Convert to a string from a charCode |
|
*/ |
|
|
|
function toStr(ch) { |
|
return String.fromCharCode(ch); |
|
} |
|
|
|
|
|
/** |
|
* Step regex |
|
*/ |
|
|
|
function stepRe() { |
|
return /\?|>|\||\+|\~/g; |
|
} |
|
|
|
/** |
|
* Return true if `val` has either a letter |
|
* or a number |
|
*/ |
|
|
|
function noAlphaNum(val) { |
|
return /[a-z0-9]/i.test(val); |
|
} |
|
|
|
/** |
|
* Return true if `val` has both a letter and |
|
* a number (invalid) |
|
*/ |
|
|
|
function hasBoth(val) { |
|
return /[a-z][0-9]|[0-9][a-z]/i.test(val); |
|
} |
|
|
|
/** |
|
* Normalize zeros for checks |
|
*/ |
|
|
|
function zeros(val) { |
|
if (/^-*0+$/.test(val.toString())) { |
|
return '0'; |
|
} |
|
return val; |
|
} |
|
|
|
/** |
|
* Return true if `val` has leading zeros, |
|
* or a similar valid pattern. |
|
*/ |
|
|
|
function hasZeros(val) { |
|
return /[^.]\.|^-*0+[0-9]/.test(val); |
|
} |
|
|
|
/** |
|
* If the string is padded, returns a curried function with |
|
* the a cached padding string, or `false` if no padding. |
|
* |
|
* @param {*} `origA` String or number. |
|
* @return {String|Boolean} |
|
*/ |
|
|
|
function isPadded(origA, origB) { |
|
if (hasZeros(origA) || hasZeros(origB)) { |
|
var alen = length(origA); |
|
var blen = length(origB); |
|
|
|
var len = alen >= blen |
|
? alen |
|
: blen; |
|
|
|
return function (a) { |
|
return repeatString('0', len - length(a)); |
|
}; |
|
} |
|
return false; |
|
} |
|
|
|
/** |
|
* Get the string length of `val` |
|
*/ |
|
|
|
function length(val) { |
|
return val.toString().length; |
|
} |
|
|
|
var expandRange = function expandRange(str, options, fn) { |
|
if (typeof str !== 'string') { |
|
throw new TypeError('expand-range expects a string.'); |
|
} |
|
|
|
if (typeof options === 'function') { |
|
fn = options; |
|
options = {}; |
|
} |
|
|
|
if (typeof options === 'boolean') { |
|
options = {}; |
|
options.makeRe = true; |
|
} |
|
|
|
// create arguments to pass to fill-range |
|
var opts = options || {}; |
|
var args = str.split('..'); |
|
var len = args.length; |
|
if (len > 3) { return str; } |
|
|
|
// if only one argument, it can't expand so return it |
|
if (len === 1) { return args; } |
|
|
|
// if `true`, tell fill-range to regexify the string |
|
if (typeof fn === 'boolean' && fn === true) { |
|
opts.makeRe = true; |
|
} |
|
|
|
args.push(opts); |
|
return fillRange_1.apply(null, args.concat(fn)); |
|
}; |
|
|
|
/*! |
|
* preserve <https://github.com/jonschlinkert/preserve> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert. |
|
* Licensed under the MIT license. |
|
*/ |
|
|
|
/** |
|
* Replace tokens in `str` with a temporary, heuristic placeholder. |
|
* |
|
* ```js |
|
* tokens.before('{a\\,b}'); |
|
* //=> '{__ID1__}' |
|
* ``` |
|
* |
|
* @param {String} `str` |
|
* @return {String} String with placeholders. |
|
* @api public |
|
*/ |
|
|
|
var before = function before(str, re) { |
|
return str.replace(re, function (match) { |
|
var id = randomize$1(); |
|
cache$1[id] = match; |
|
return '__ID' + id + '__'; |
|
}); |
|
}; |
|
|
|
/** |
|
* Replace placeholders in `str` with original tokens. |
|
* |
|
* ```js |
|
* tokens.after('{__ID1__}'); |
|
* //=> '{a\\,b}' |
|
* ``` |
|
* |
|
* @param {String} `str` String with placeholders |
|
* @return {String} `str` String with original tokens. |
|
* @api public |
|
*/ |
|
|
|
var after = function after(str) { |
|
return str.replace(/__ID(.{5})__/g, function (_, id) { |
|
return cache$1[id]; |
|
}); |
|
}; |
|
|
|
function randomize$1() { |
|
return Math.random().toString().slice(2, 7); |
|
} |
|
|
|
var cache$1 = {}; |
|
|
|
var preserve = { |
|
before: before, |
|
after: after |
|
}; |
|
|
|
/** |
|
* Module dependencies |
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
* Expose `braces` |
|
*/ |
|
|
|
var braces_1 = function(str, options) { |
|
if (typeof str !== 'string') { |
|
throw new Error('braces expects a string'); |
|
} |
|
return braces(str, options); |
|
}; |
|
|
|
/** |
|
* Expand `{foo,bar}` or `{1..5}` braces in the |
|
* given `string`. |
|
* |
|
* @param {String} `str` |
|
* @param {Array} `arr` |
|
* @param {Object} `options` |
|
* @return {Array} |
|
*/ |
|
|
|
function braces(str, arr, options) { |
|
if (str === '') { |
|
return []; |
|
} |
|
|
|
if (!Array.isArray(arr)) { |
|
options = arr; |
|
arr = []; |
|
} |
|
|
|
var opts = options || {}; |
|
arr = arr || []; |
|
|
|
if (typeof opts.nodupes === 'undefined') { |
|
opts.nodupes = true; |
|
} |
|
|
|
var fn = opts.fn; |
|
var es6; |
|
|
|
if (typeof opts === 'function') { |
|
fn = opts; |
|
opts = {}; |
|
} |
|
|
|
if (!(patternRe instanceof RegExp)) { |
|
patternRe = patternRegex(); |
|
} |
|
|
|
var matches = str.match(patternRe) || []; |
|
var m = matches[0]; |
|
|
|
switch(m) { |
|
case '\\,': |
|
return escapeCommas(str, arr, opts); |
|
case '\\.': |
|
return escapeDots(str, arr, opts); |
|
case '\/.': |
|
return escapePaths(str, arr, opts); |
|
case ' ': |
|
return splitWhitespace(str); |
|
case '{,}': |
|
return exponential(str, opts, braces); |
|
case '{}': |
|
return emptyBraces(str, arr, opts); |
|
case '\\{': |
|
case '\\}': |
|
return escapeBraces(str, arr, opts); |
|
case '${': |
|
if (!/\{[^{]+\{/.test(str)) { |
|
return arr.concat(str); |
|
} else { |
|
es6 = true; |
|
str = preserve.before(str, es6Regex()); |
|
} |
|
} |
|
|
|
if (!(braceRe instanceof RegExp)) { |
|
braceRe = braceRegex(); |
|
} |
|
|
|
var match = braceRe.exec(str); |
|
if (match == null) { |
|
return [str]; |
|
} |
|
|
|
var outter = match[1]; |
|
var inner = match[2]; |
|
if (inner === '') { return [str]; } |
|
|
|
var segs, segsLength; |
|
|
|
if (inner.indexOf('..') !== -1) { |
|
segs = expandRange(inner, opts, fn) || inner.split(','); |
|
segsLength = segs.length; |
|
|
|
} else if (inner[0] === '"' || inner[0] === '\'') { |
|
return arr.concat(str.split(/['"]/).join('')); |
|
|
|
} else { |
|
segs = inner.split(','); |
|
if (opts.makeRe) { |
|
return braces(str.replace(outter, wrap$1(segs, '|')), opts); |
|
} |
|
|
|
segsLength = segs.length; |
|
if (segsLength === 1 && opts.bash) { |
|
segs[0] = wrap$1(segs[0], '\\'); |
|
} |
|
} |
|
|
|
var len = segs.length; |
|
var i = 0, val; |
|
|
|
while (len--) { |
|
var path = segs[i++]; |
|
|
|
if (/(\.[^.\/])/.test(path)) { |
|
if (segsLength > 1) { |
|
return segs; |
|
} else { |
|
return [str]; |
|
} |
|
} |
|
|
|
val = splice(str, outter, path); |
|
|
|
if (/\{[^{}]+?\}/.test(val)) { |
|
arr = braces(val, arr, opts); |
|
} else if (val !== '') { |
|
if (opts.nodupes && arr.indexOf(val) !== -1) { continue; } |
|
arr.push(es6 ? preserve.after(val) : val); |
|
} |
|
} |
|
|
|
if (opts.strict) { return filter$2(arr, filterEmpty); } |
|
return arr; |
|
} |
|
|
|
/** |
|
* Expand exponential ranges |
|
* |
|
* `a{,}{,}` => ['a', 'a', 'a', 'a'] |
|
*/ |
|
|
|
function exponential(str, options, fn) { |
|
if (typeof options === 'function') { |
|
fn = options; |
|
options = null; |
|
} |
|
|
|
var opts = options || {}; |
|
var esc = '__ESC_EXP__'; |
|
var exp = 0; |
|
var res; |
|
|
|
var parts = str.split('{,}'); |
|
if (opts.nodupes) { |
|
return fn(parts.join(''), opts); |
|
} |
|
|
|
exp = parts.length - 1; |
|
res = fn(parts.join(esc), opts); |
|
var len = res.length; |
|
var arr = []; |
|
var i = 0; |
|
|
|
while (len--) { |
|
var ele = res[i++]; |
|
var idx = ele.indexOf(esc); |
|
|
|
if (idx === -1) { |
|
arr.push(ele); |
|
|
|
} else { |
|
ele = ele.split('__ESC_EXP__').join(''); |
|
if (!!ele && opts.nodupes !== false) { |
|
arr.push(ele); |
|
|
|
} else { |
|
var num = Math.pow(2, exp); |
|
arr.push.apply(arr, repeatElement(ele, num)); |
|
} |
|
} |
|
} |
|
return arr; |
|
} |
|
|
|
/** |
|
* Wrap a value with parens, brackets or braces, |
|
* based on the given character/separator. |
|
* |
|
* @param {String|Array} `val` |
|
* @param {String} `ch` |
|
* @return {String} |
|
*/ |
|
|
|
function wrap$1(val, ch) { |
|
if (ch === '|') { |
|
return '(' + val.join(ch) + ')'; |
|
} |
|
if (ch === ',') { |
|
return '{' + val.join(ch) + '}'; |
|
} |
|
if (ch === '-') { |
|
return '[' + val.join(ch) + ']'; |
|
} |
|
if (ch === '\\') { |
|
return '\\{' + val + '\\}'; |
|
} |
|
} |
|
|
|
/** |
|
* Handle empty braces: `{}` |
|
*/ |
|
|
|
function emptyBraces(str, arr, opts) { |
|
return braces(str.split('{}').join('\\{\\}'), arr, opts); |
|
} |
|
|
|
/** |
|
* Filter out empty-ish values |
|
*/ |
|
|
|
function filterEmpty(ele) { |
|
return !!ele && ele !== '\\'; |
|
} |
|
|
|
/** |
|
* Handle patterns with whitespace |
|
*/ |
|
|
|
function splitWhitespace(str) { |
|
var segs = str.split(' '); |
|
var len = segs.length; |
|
var res = []; |
|
var i = 0; |
|
|
|
while (len--) { |
|
res.push.apply(res, braces(segs[i++])); |
|
} |
|
return res; |
|
} |
|
|
|
/** |
|
* Handle escaped braces: `\\{foo,bar}` |
|
*/ |
|
|
|
function escapeBraces(str, arr, opts) { |
|
if (!/\{[^{]+\{/.test(str)) { |
|
return arr.concat(str.split('\\').join('')); |
|
} else { |
|
str = str.split('\\{').join('__LT_BRACE__'); |
|
str = str.split('\\}').join('__RT_BRACE__'); |
|
return map$3(braces(str, arr, opts), function(ele) { |
|
ele = ele.split('__LT_BRACE__').join('{'); |
|
return ele.split('__RT_BRACE__').join('}'); |
|
}); |
|
} |
|
} |
|
|
|
/** |
|
* Handle escaped dots: `{1\\.2}` |
|
*/ |
|
|
|
function escapeDots(str, arr, opts) { |
|
if (!/[^\\]\..+\\\./.test(str)) { |
|
return arr.concat(str.split('\\').join('')); |
|
} else { |
|
str = str.split('\\.').join('__ESC_DOT__'); |
|
return map$3(braces(str, arr, opts), function(ele) { |
|
return ele.split('__ESC_DOT__').join('.'); |
|
}); |
|
} |
|
} |
|
|
|
/** |
|
* Handle escaped dots: `{1\\.2}` |
|
*/ |
|
|
|
function escapePaths(str, arr, opts) { |
|
str = str.split('\/.').join('__ESC_PATH__'); |
|
return map$3(braces(str, arr, opts), function(ele) { |
|
return ele.split('__ESC_PATH__').join('\/.'); |
|
}); |
|
} |
|
|
|
/** |
|
* Handle escaped commas: `{a\\,b}` |
|
*/ |
|
|
|
function escapeCommas(str, arr, opts) { |
|
if (!/\w,/.test(str)) { |
|
return arr.concat(str.split('\\').join('')); |
|
} else { |
|
str = str.split('\\,').join('__ESC_COMMA__'); |
|
return map$3(braces(str, arr, opts), function(ele) { |
|
return ele.split('__ESC_COMMA__').join(','); |
|
}); |
|
} |
|
} |
|
|
|
/** |
|
* Regex for common patterns |
|
*/ |
|
|
|
function patternRegex() { |
|
return /\${|( (?=[{,}])|(?=[{,}]) )|{}|{,}|\\,(?=.*[{}])|\/\.(?=.*[{}])|\\\.(?={)|\\{|\\}/; |
|
} |
|
|
|
/** |
|
* Braces regex. |
|
*/ |
|
|
|
function braceRegex() { |
|
return /.*(\\?\{([^}]+)\})/; |
|
} |
|
|
|
/** |
|
* es6 delimiter regex. |
|
*/ |
|
|
|
function es6Regex() { |
|
return /\$\{([^}]+)\}/; |
|
} |
|
|
|
var braceRe; |
|
var patternRe; |
|
|
|
/** |
|
* Faster alternative to `String.replace()` when the |
|
* index of the token to be replaces can't be supplied |
|
*/ |
|
|
|
function splice(str, token, replacement) { |
|
var i = str.indexOf(token); |
|
return str.substr(0, i) + replacement |
|
+ str.substr(i + token.length); |
|
} |
|
|
|
/** |
|
* Fast array map |
|
*/ |
|
|
|
function map$3(arr, fn) { |
|
if (arr == null) { |
|
return []; |
|
} |
|
|
|
var len = arr.length; |
|
var res = new Array(len); |
|
var i = -1; |
|
|
|
while (++i < len) { |
|
res[i] = fn(arr[i], i, arr); |
|
} |
|
|
|
return res; |
|
} |
|
|
|
/** |
|
* Fast array filter |
|
*/ |
|
|
|
function filter$2(arr, cb) { |
|
if (arr == null) return []; |
|
if (typeof cb !== 'function') { |
|
throw new TypeError('braces: filter expects a callback function.'); |
|
} |
|
|
|
var len = arr.length; |
|
var res = arr.slice(); |
|
var i = 0; |
|
|
|
while (len--) { |
|
if (!cb(arr[len], i++)) { |
|
res.splice(len, 1); |
|
} |
|
} |
|
return res; |
|
} |
|
|
|
/*! |
|
* is-posix-bracket <https://github.com/jonschlinkert/is-posix-bracket> |
|
* |
|
* Copyright (c) 2015-2016, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
var isPosixBracket = function isPosixBracket(str) { |
|
return typeof str === 'string' && /\[([:.=+])(?:[^\[\]]|)+\1\]/.test(str); |
|
}; |
|
|
|
/** |
|
* POSIX character classes |
|
*/ |
|
|
|
var POSIX = { |
|
alnum: 'a-zA-Z0-9', |
|
alpha: 'a-zA-Z', |
|
blank: ' \\t', |
|
cntrl: '\\x00-\\x1F\\x7F', |
|
digit: '0-9', |
|
graph: '\\x21-\\x7E', |
|
lower: 'a-z', |
|
print: '\\x20-\\x7E', |
|
punct: '-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~', |
|
space: ' \\t\\r\\n\\v\\f', |
|
upper: 'A-Z', |
|
word: 'A-Za-z0-9_', |
|
xdigit: 'A-Fa-f0-9', |
|
}; |
|
|
|
/** |
|
* Expose `brackets` |
|
*/ |
|
|
|
var expandBrackets = brackets; |
|
|
|
function brackets(str) { |
|
if (!isPosixBracket(str)) { |
|
return str; |
|
} |
|
|
|
var negated = false; |
|
if (str.indexOf('[^') !== -1) { |
|
negated = true; |
|
str = str.split('[^').join('['); |
|
} |
|
if (str.indexOf('[!') !== -1) { |
|
negated = true; |
|
str = str.split('[!').join('['); |
|
} |
|
|
|
var a = str.split('['); |
|
var b = str.split(']'); |
|
var imbalanced = a.length !== b.length; |
|
|
|
var parts = str.split(/(?::\]\[:|\[?\[:|:\]\]?)/); |
|
var len = parts.length, i = 0; |
|
var end = '', beg = ''; |
|
var res = []; |
|
|
|
// start at the end (innermost) first |
|
while (len--) { |
|
var inner = parts[i++]; |
|
if (inner === '^[!' || inner === '[!') { |
|
inner = ''; |
|
negated = true; |
|
} |
|
|
|
var prefix = negated ? '^' : ''; |
|
var ch = POSIX[inner]; |
|
|
|
if (ch) { |
|
res.push('[' + prefix + ch + ']'); |
|
} else if (inner) { |
|
if (/^\[?\w-\w\]?$/.test(inner)) { |
|
if (i === parts.length) { |
|
res.push('[' + prefix + inner); |
|
} else if (i === 1) { |
|
res.push(prefix + inner + ']'); |
|
} else { |
|
res.push(prefix + inner); |
|
} |
|
} else { |
|
if (i === 1) { |
|
beg += inner; |
|
} else if (i === parts.length) { |
|
end += inner; |
|
} else { |
|
res.push('[' + prefix + inner + ']'); |
|
} |
|
} |
|
} |
|
} |
|
|
|
var result = res.join('|'); |
|
var rlen = res.length || 1; |
|
if (rlen > 1) { |
|
result = '(?:' + result + ')'; |
|
rlen = 1; |
|
} |
|
if (beg) { |
|
rlen++; |
|
if (beg.charAt(0) === '[') { |
|
if (imbalanced) { |
|
beg = '\\[' + beg.slice(1); |
|
} else { |
|
beg += ']'; |
|
} |
|
} |
|
result = beg + result; |
|
} |
|
if (end) { |
|
rlen++; |
|
if (end.slice(-1) === ']') { |
|
if (imbalanced) { |
|
end = end.slice(0, end.length - 1) + '\\]'; |
|
} else { |
|
end = '[' + end; |
|
} |
|
} |
|
result += end; |
|
} |
|
|
|
if (rlen > 1) { |
|
result = result.split('][').join(']|['); |
|
if (result.indexOf('|') !== -1 && !/\(\?/.test(result)) { |
|
result = '(?:' + result + ')'; |
|
} |
|
} |
|
|
|
result = result.replace(/\[+=|=\]+/g, '\\b'); |
|
return result; |
|
} |
|
|
|
brackets.makeRe = function(pattern) { |
|
try { |
|
return new RegExp(brackets(pattern)); |
|
} catch (err) {} |
|
}; |
|
|
|
brackets.isMatch = function(str, pattern) { |
|
try { |
|
return brackets.makeRe(pattern).test(str); |
|
} catch (err) { |
|
return false; |
|
} |
|
}; |
|
|
|
brackets.match = function(arr, pattern) { |
|
var len = arr.length, i = 0; |
|
var res = arr.slice(); |
|
|
|
var re = brackets.makeRe(pattern); |
|
while (i < len) { |
|
var ele = arr[i++]; |
|
if (!re.test(ele)) { |
|
continue; |
|
} |
|
res.splice(i, 1); |
|
} |
|
return res; |
|
}; |
|
|
|
/*! |
|
* is-extglob <https://github.com/jonschlinkert/is-extglob> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
var isExtglob = function isExtglob(str) { |
|
return typeof str === 'string' |
|
&& /[@?!+*]\(/.test(str); |
|
}; |
|
|
|
/** |
|
* Module dependencies |
|
*/ |
|
|
|
|
|
var re; |
|
var cache$2 = {}; |
|
|
|
/** |
|
* Expose `extglob` |
|
*/ |
|
|
|
var extglob_1 = extglob; |
|
|
|
/** |
|
* Convert the given extglob `string` to a regex-compatible |
|
* string. |
|
* |
|
* ```js |
|
* var extglob = require('extglob'); |
|
* extglob('!(a?(b))'); |
|
* //=> '(?!a(?:b)?)[^/]*?' |
|
* ``` |
|
* |
|
* @param {String} `str` The string to convert. |
|
* @param {Object} `options` |
|
* @option {Boolean} [options] `esc` If `false` special characters will not be escaped. Defaults to `true`. |
|
* @option {Boolean} [options] `regex` If `true` a regular expression is returned instead of a string. |
|
* @return {String} |
|
* @api public |
|
*/ |
|
|
|
|
|
function extglob(str, opts) { |
|
opts = opts || {}; |
|
var o = {}, i = 0; |
|
|
|
// fix common character reversals |
|
// '*!(.js)' => '*.!(js)' |
|
str = str.replace(/!\(([^\w*()])/g, '$1!('); |
|
|
|
// support file extension negation |
|
str = str.replace(/([*\/])\.!\([*]\)/g, function (m, ch) { |
|
if (ch === '/') { |
|
return escape('\\/[^.]+'); |
|
} |
|
return escape('[^.]+'); |
|
}); |
|
|
|
// create a unique key for caching by |
|
// combining the string and options |
|
var key = str |
|
+ String(!!opts.regex) |
|
+ String(!!opts.contains) |
|
+ String(!!opts.escape); |
|
|
|
if (cache$2.hasOwnProperty(key)) { |
|
return cache$2[key]; |
|
} |
|
|
|
if (!(re instanceof RegExp)) { |
|
re = regex(); |
|
} |
|
|
|
opts.negate = false; |
|
var m; |
|
|
|
while (m = re.exec(str)) { |
|
var prefix = m[1]; |
|
var inner = m[3]; |
|
if (prefix === '!') { |
|
opts.negate = true; |
|
} |
|
|
|
var id = '__EXTGLOB_' + (i++) + '__'; |
|
// use the prefix of the _last_ (outtermost) pattern |
|
o[id] = wrap$3(inner, prefix, opts.escape); |
|
str = str.split(m[0]).join(id); |
|
} |
|
|
|
var keys = Object.keys(o); |
|
var len = keys.length; |
|
|
|
// we have to loop again to allow us to convert |
|
// patterns in reverse order (starting with the |
|
// innermost/last pattern first) |
|
while (len--) { |
|
var prop = keys[len]; |
|
str = str.split(prop).join(o[prop]); |
|
} |
|
|
|
var result = opts.regex |
|
? toRegex$1(str, opts.contains, opts.negate) |
|
: str; |
|
|
|
result = result.split('.').join('\\.'); |
|
|
|
// cache the result and return it |
|
return (cache$2[key] = result); |
|
} |
|
|
|
/** |
|
* Convert `string` to a regex string. |
|
* |
|
* @param {String} `str` |
|
* @param {String} `prefix` Character that determines how to wrap the string. |
|
* @param {Boolean} `esc` If `false` special characters will not be escaped. Defaults to `true`. |
|
* @return {String} |
|
*/ |
|
|
|
function wrap$3(inner, prefix, esc) { |
|
if (esc) inner = escape(inner); |
|
|
|
switch (prefix) { |
|
case '!': |
|
return '(?!' + inner + ')[^/]' + (esc ? '%%%~' : '*?'); |
|
case '@': |
|
return '(?:' + inner + ')'; |
|
case '+': |
|
return '(?:' + inner + ')+'; |
|
case '*': |
|
return '(?:' + inner + ')' + (esc ? '%%' : '*') |
|
case '?': |
|
return '(?:' + inner + '|)'; |
|
default: |
|
return inner; |
|
} |
|
} |
|
|
|
function escape(str) { |
|
str = str.split('*').join('[^/]%%%~'); |
|
str = str.split('.').join('\\.'); |
|
return str; |
|
} |
|
|
|
/** |
|
* extglob regex. |
|
*/ |
|
|
|
function regex() { |
|
return /(\\?[@?!+*$]\\?)(\(([^()]*?)\))/; |
|
} |
|
|
|
/** |
|
* Negation regex |
|
*/ |
|
|
|
function negate(str) { |
|
return '(?!^' + str + ').*$'; |
|
} |
|
|
|
/** |
|
* Create the regex to do the matching. If |
|
* the leading character in the `pattern` is `!` |
|
* a negation regex is returned. |
|
* |
|
* @param {String} `pattern` |
|
* @param {Boolean} `contains` Allow loose matching. |
|
* @param {Boolean} `isNegated` True if the pattern is a negation pattern. |
|
*/ |
|
|
|
function toRegex$1(pattern, contains, isNegated) { |
|
var prefix = contains ? '^' : ''; |
|
var after = contains ? '$' : ''; |
|
pattern = ('(?:' + pattern + ')' + after); |
|
if (isNegated) { |
|
pattern = prefix + negate(pattern); |
|
} |
|
return new RegExp(prefix + pattern); |
|
} |
|
|
|
/*! |
|
* is-glob <https://github.com/jonschlinkert/is-glob> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
|
|
|
|
var isGlob = function isGlob(str) { |
|
return typeof str === 'string' |
|
&& (/[*!?{}(|)[\]]/.test(str) |
|
|| isExtglob(str)); |
|
}; |
|
|
|
var isWin = process$3.platform === 'win32'; |
|
|
|
var removeTrailingSeparator = function (str) { |
|
var i = str.length - 1; |
|
if (i < 2) { |
|
return str; |
|
} |
|
while (isSeparator(str, i)) { |
|
i--; |
|
} |
|
return str.substr(0, i + 1); |
|
}; |
|
|
|
function isSeparator(str, i) { |
|
var char = str[i]; |
|
return i > 0 && (char === '/' || (isWin && char === '\\')); |
|
} |
|
|
|
/*! |
|
* normalize-path <https://github.com/jonschlinkert/normalize-path> |
|
* |
|
* Copyright (c) 2014-2017, Jon Schlinkert. |
|
* Released under the MIT License. |
|
*/ |
|
|
|
|
|
|
|
var normalizePath = function normalizePath(str, stripTrailing) { |
|
if (typeof str !== 'string') { |
|
throw new TypeError('expected a string'); |
|
} |
|
str = str.replace(/[\\\/]+/g, '/'); |
|
if (stripTrailing !== false) { |
|
str = removeTrailingSeparator(str); |
|
} |
|
return str; |
|
}; |
|
|
|
/*! |
|
* is-extendable <https://github.com/jonschlinkert/is-extendable> |
|
* |
|
* Copyright (c) 2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
var isExtendable = function isExtendable(val) { |
|
return typeof val !== 'undefined' && val !== null |
|
&& (typeof val === 'object' || typeof val === 'function'); |
|
}; |
|
|
|
/*! |
|
* for-in <https://github.com/jonschlinkert/for-in> |
|
* |
|
* Copyright (c) 2014-2017, Jon Schlinkert. |
|
* Released under the MIT License. |
|
*/ |
|
|
|
var forIn = function forIn(obj, fn, thisArg) { |
|
for (var key in obj) { |
|
if (fn.call(thisArg, obj[key], key, obj) === false) { |
|
break; |
|
} |
|
} |
|
}; |
|
|
|
var hasOwn = Object.prototype.hasOwnProperty; |
|
|
|
var forOwn = function forOwn(obj, fn, thisArg) { |
|
forIn(obj, function(val, key) { |
|
if (hasOwn.call(obj, key)) { |
|
return fn.call(thisArg, obj[key], key, obj); |
|
} |
|
}); |
|
}; |
|
|
|
var object_omit = function omit(obj, keys) { |
|
if (!isExtendable(obj)) return {}; |
|
|
|
keys = [].concat.apply([], [].slice.call(arguments, 1)); |
|
var last = keys[keys.length - 1]; |
|
var res = {}, fn; |
|
|
|
if (typeof last === 'function') { |
|
fn = keys.pop(); |
|
} |
|
|
|
var isFunction = typeof fn === 'function'; |
|
if (!keys.length && !isFunction) { |
|
return obj; |
|
} |
|
|
|
forOwn(obj, function(value, key) { |
|
if (keys.indexOf(key) === -1) { |
|
|
|
if (!isFunction) { |
|
res[key] = value; |
|
} else if (fn(value, key, obj)) { |
|
res[key] = value; |
|
} |
|
} |
|
}); |
|
return res; |
|
}; |
|
|
|
var globParent = function globParent(str) { |
|
str += 'a'; // preserves full path in case of trailing path separator |
|
do {str = path$2.dirname(str);} while (isGlob(str)); |
|
return str; |
|
}; |
|
|
|
var globBase = function globBase(pattern) { |
|
if (typeof pattern !== 'string') { |
|
throw new TypeError('glob-base expects a string.'); |
|
} |
|
|
|
var res = {}; |
|
res.base = globParent(pattern); |
|
res.isGlob = isGlob(pattern); |
|
|
|
if (res.base !== '.') { |
|
res.glob = pattern.substr(res.base.length); |
|
if (res.glob.charAt(0) === '/') { |
|
res.glob = res.glob.substr(1); |
|
} |
|
} else { |
|
res.glob = pattern; |
|
} |
|
|
|
if (!res.isGlob) { |
|
res.base = dirname$1(pattern); |
|
res.glob = res.base !== '.' |
|
? pattern.substr(res.base.length) |
|
: pattern; |
|
} |
|
|
|
if (res.glob.substr(0, 2) === './') { |
|
res.glob = res.glob.substr(2); |
|
} |
|
if (res.glob.charAt(0) === '/') { |
|
res.glob = res.glob.substr(1); |
|
} |
|
return res; |
|
}; |
|
|
|
function dirname$1(glob) { |
|
if (glob.slice(-1) === '/') return glob; |
|
return path$2.dirname(glob); |
|
} |
|
|
|
/*! |
|
* is-dotfile <https://github.com/jonschlinkert/is-dotfile> |
|
* |
|
* Copyright (c) 2015-2017, Jon Schlinkert. |
|
* Released under the MIT License. |
|
*/ |
|
|
|
var isDotfile = function(str) { |
|
if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) { |
|
return true; |
|
} |
|
var slash = str.lastIndexOf('/'); |
|
return slash !== -1 ? str.charCodeAt(slash + 1) === 46 /* . */ : false; |
|
}; |
|
|
|
var parseGlob = createCommonjsModule(function (module) { |
|
/*! |
|
* parse-glob <https://github.com/jonschlinkert/parse-glob> |
|
* |
|
* Copyright (c) 2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
var cache = module.exports.cache = {}; |
|
|
|
/** |
|
* Parse a glob pattern into tokens. |
|
* |
|
* When no paths or '**' are in the glob, we use a |
|
* different strategy for parsing the filename, since |
|
* file names can contain braces and other difficult |
|
* patterns. such as: |
|
* |
|
* - `*.{a,b}` |
|
* - `(**|*.js)` |
|
*/ |
|
|
|
module.exports = function parseGlob(glob) { |
|
if (cache.hasOwnProperty(glob)) { |
|
return cache[glob]; |
|
} |
|
|
|
var tok = {}; |
|
tok.orig = glob; |
|
tok.is = {}; |
|
|
|
// unescape dots and slashes in braces/brackets |
|
glob = escape(glob); |
|
|
|
var parsed = globBase(glob); |
|
tok.is.glob = parsed.isGlob; |
|
|
|
tok.glob = parsed.glob; |
|
tok.base = parsed.base; |
|
var segs = /([^\/]*)$/.exec(glob); |
|
|
|
tok.path = {}; |
|
tok.path.dirname = ''; |
|
tok.path.basename = segs[1] || ''; |
|
tok.path.dirname = glob.split(tok.path.basename).join('') || ''; |
|
var basename = (tok.path.basename || '').split('.') || ''; |
|
tok.path.filename = basename[0] || ''; |
|
tok.path.extname = basename.slice(1).join('.') || ''; |
|
tok.path.ext = ''; |
|
|
|
if (isGlob(tok.path.dirname) && !tok.path.basename) { |
|
if (!/\/$/.test(tok.glob)) { |
|
tok.path.basename = tok.glob; |
|
} |
|
tok.path.dirname = tok.base; |
|
} |
|
|
|
if (glob.indexOf('/') === -1 && !tok.is.globstar) { |
|
tok.path.dirname = ''; |
|
tok.path.basename = tok.orig; |
|
} |
|
|
|
var dot = tok.path.basename.indexOf('.'); |
|
if (dot !== -1) { |
|
tok.path.filename = tok.path.basename.slice(0, dot); |
|
tok.path.extname = tok.path.basename.slice(dot); |
|
} |
|
|
|
if (tok.path.extname.charAt(0) === '.') { |
|
var exts = tok.path.extname.split('.'); |
|
tok.path.ext = exts[exts.length - 1]; |
|
} |
|
|
|
// unescape dots and slashes in braces/brackets |
|
tok.glob = unescape(tok.glob); |
|
tok.path.dirname = unescape(tok.path.dirname); |
|
tok.path.basename = unescape(tok.path.basename); |
|
tok.path.filename = unescape(tok.path.filename); |
|
tok.path.extname = unescape(tok.path.extname); |
|
|
|
// Booleans |
|
var is = (glob && tok.is.glob); |
|
tok.is.negated = glob && glob.charAt(0) === '!'; |
|
tok.is.extglob = glob && isExtglob(glob); |
|
tok.is.braces = has(is, glob, '{'); |
|
tok.is.brackets = has(is, glob, '[:'); |
|
tok.is.globstar = has(is, glob, '**'); |
|
tok.is.dotfile = isDotfile(tok.path.basename) || isDotfile(tok.path.filename); |
|
tok.is.dotdir = dotdir(tok.path.dirname); |
|
return (cache[glob] = tok); |
|
}; |
|
|
|
/** |
|
* Returns true if the glob matches dot-directories. |
|
* |
|
* @param {Object} `tok` The tokens object |
|
* @param {Object} `path` The path object |
|
* @return {Object} |
|
*/ |
|
|
|
function dotdir(base) { |
|
if (base.indexOf('/.') !== -1) { |
|
return true; |
|
} |
|
if (base.charAt(0) === '.' && base.charAt(1) !== '/') { |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
/** |
|
* Returns true if the pattern has the given `ch`aracter(s) |
|
* |
|
* @param {Object} `glob` The glob pattern. |
|
* @param {Object} `ch` The character to test for |
|
* @return {Object} |
|
*/ |
|
|
|
function has(is, glob, ch) { |
|
return is && glob.indexOf(ch) !== -1; |
|
} |
|
|
|
/** |
|
* Escape/unescape utils |
|
*/ |
|
|
|
function escape(str) { |
|
var re = /\{([^{}]*?)}|\(([^()]*?)\)|\[([^\[\]]*?)\]/g; |
|
return str.replace(re, function (outter, braces, parens, brackets) { |
|
var inner = braces || parens || brackets; |
|
if (!inner) { return outter; } |
|
return outter.split(inner).join(esc(inner)); |
|
}); |
|
} |
|
|
|
function esc(str) { |
|
str = str.split('/').join('__SLASH__'); |
|
str = str.split('.').join('__DOT__'); |
|
return str; |
|
} |
|
|
|
function unescape(str) { |
|
str = str.split('__SLASH__').join('/'); |
|
str = str.split('__DOT__').join('.'); |
|
return str; |
|
} |
|
}); |
|
|
|
var parseGlob_1 = parseGlob.cache; |
|
|
|
/*! |
|
* is-primitive <https://github.com/jonschlinkert/is-primitive> |
|
* |
|
* Copyright (c) 2014-2015, Jon Schlinkert. |
|
* Licensed under the MIT License. |
|
*/ |
|
|
|
// see http://jsperf.com/testing-value-is-primitive/7 |
|
var isPrimitive = function isPrimitive(value) { |
|
return value == null || (typeof value !== 'function' && typeof value !== 'object'); |
|
}; |
|
|
|
var isEqualShallow = function isEqual(a, b) { |
|
if (!a && !b) { return true; } |
|
if (!a && b || a && !b) { return false; } |
|
|
|
var numKeysA = 0, numKeysB = 0, key; |
|
for (key in b) { |
|
numKeysB++; |
|
if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) { |
|
return false; |
|
} |
|
} |
|
for (key in a) { |
|
numKeysA++; |
|
} |
|
return numKeysA === numKeysB; |
|
}; |
|
|
|
var basic = {}; |
|
var cache$3 = {}; |
|
|
|
/** |
|
* Expose `regexCache` |
|
*/ |
|
|
|
var regexCache_1 = regexCache; |
|
|
|
/** |
|
* Memoize the results of a call to the new RegExp constructor. |
|
* |
|
* @param {Function} fn [description] |
|
* @param {String} str [description] |
|
* @param {Options} options [description] |
|
* @param {Boolean} nocompare [description] |
|
* @return {RegExp} |
|
*/ |
|
|
|
function regexCache(fn, str, opts) { |
|
var key = '_default_', regex, cached; |
|
|
|
if (!str && !opts) { |
|
if (typeof fn !== 'function') { |
|
return fn; |
|
} |
|
return basic[key] || (basic[key] = fn(str)); |
|
} |
|
|
|
var isString = typeof str === 'string'; |
|
if (isString) { |
|
if (!opts) { |
|
return basic[str] || (basic[str] = fn(str)); |
|
} |
|
key = str; |
|
} else { |
|
opts = str; |
|
} |
|
|
|
cached = cache$3[key]; |
|
if (cached && isEqualShallow(cached.opts, opts)) { |
|
return cached.regex; |
|
} |
|
|
|
memo(key, opts, (regex = fn(str, opts))); |
|
return regex; |
|
} |
|
|
|
function memo(key, opts, regex) { |
|
cache$3[key] = {regex: regex, opts: opts}; |
|
} |
|
|
|
/** |
|
* Expose `cache` |
|
*/ |
|
|
|
var cache_1 = cache$3; |
|
var basic_1 = basic; |
|
|
|
regexCache_1.cache = cache_1; |
|
regexCache_1.basic = basic_1; |
|
|
|
var utils_1 = createCommonjsModule(function (module) { |
|
var win32 = process$3 && process$3.platform === 'win32'; |
|
|
|
|
|
var utils = module.exports; |
|
|
|
/** |
|
* Module dependencies |
|
*/ |
|
|
|
utils.diff = arrDiff; |
|
utils.unique = arrayUnique; |
|
utils.braces = braces_1; |
|
utils.brackets = expandBrackets; |
|
utils.extglob = extglob_1; |
|
utils.isExtglob = isExtglob; |
|
utils.isGlob = isGlob; |
|
utils.typeOf = kindOf; |
|
utils.normalize = normalizePath; |
|
utils.omit = object_omit; |
|
utils.parseGlob = parseGlob; |
|
utils.cache = regexCache_1; |
|
|
|
/** |
|
* Get the filename of a filepath |
|
* |
|
* @param {String} `string` |
|
* @return {String} |
|
*/ |
|
|
|
utils.filename = function filename(fp) { |
|
var seg = fp.match(filenameRegex()); |
|
return seg && seg[0]; |
|
}; |
|
|
|
/** |
|
* Returns a function that returns true if the given |
|
* pattern is the same as a given `filepath` |
|
* |
|
* @param {String} `pattern` |
|
* @return {Function} |
|
*/ |
|
|
|
utils.isPath = function isPath(pattern, opts) { |
|
opts = opts || {}; |
|
return function(fp) { |
|
var unixified = utils.unixify(fp, opts); |
|
if(opts.nocase){ |
|
return pattern.toLowerCase() === unixified.toLowerCase(); |
|
} |
|
return pattern === unixified; |
|
}; |
|
}; |
|
|
|
/** |
|
* Returns a function that returns true if the given |
|
* pattern contains a `filepath` |
|
* |
|
* @param {String} `pattern` |
|
* @return {Function} |
|
*/ |
|
|
|
utils.hasPath = function hasPath(pattern, opts) { |
|
return function(fp) { |
|
return utils.unixify(pattern, opts).indexOf(fp) !== -1; |
|
}; |
|
}; |
|
|
|
/** |
|
* Returns a function that returns true if the given |
|
* pattern matches or contains a `filepath` |
|
* |
|
* @param {String} `pattern` |
|
* @return {Function} |
|
*/ |
|
|
|
utils.matchPath = function matchPath(pattern, opts) { |
|
var fn = (opts && opts.contains) |
|
? utils.hasPath(pattern, opts) |
|
: utils.isPath(pattern, opts); |
|
return fn; |
|
}; |
|
|
|
/** |
|
* Returns a function that returns true if the given |
|
* regex matches the `filename` of a file path. |
|
* |
|
* @param {RegExp} `re` |
|
* @return {Boolean} |
|
*/ |
|
|
|
utils.hasFilename = function hasFilename(re) { |
|
return function(fp) { |
|
var name = utils.filename(fp); |
|
return name && re.test(name); |
|
}; |
|
}; |
|
|
|
/** |
|
* Coerce `val` to an array |
|
* |
|
* @param {*} val |
|
* @return {Array} |
|
*/ |
|
|
|
utils.arrayify = function arrayify(val) { |
|
return !Array.isArray(val) |
|
? [val] |
|
: val; |
|
}; |
|
|
|
/** |
|
* Normalize all slashes in a file path or glob pattern to |
|
* forward slashes. |
|
*/ |
|
|
|
utils.unixify = function unixify(fp, opts) { |
|
if (opts && opts.unixify === false) return fp; |
|
if (opts && opts.unixify === true || win32 || path$2.sep === '\\') { |
|
return utils.normalize(fp, false); |
|
} |
|
if (opts && opts.unescape === true) { |
|
return fp ? fp.toString().replace(/\\(\w)/g, '$1') : ''; |
|
} |
|
return fp; |
|
}; |
|
|
|
/** |
|
* Escape/unescape utils |
|
*/ |
|
|
|
utils.escapePath = function escapePath(fp) { |
|
return fp.replace(/[\\.]/g, '\\$&'); |
|
}; |
|
|
|
utils.unescapeGlob = function unescapeGlob(fp) { |
|
return fp.replace(/[\\"']/g, ''); |
|
}; |
|
|
|
utils.escapeRe = function escapeRe(str) { |
|
return str.replace(/[-[\\$*+?.#^\s{}(|)\]]/g, '\\$&'); |
|
}; |
|
|
|
/** |
|
* Expose `utils` |
|
*/ |
|
|
|
module.exports = utils; |
|
}); |
|
|
|
var chars = {}; |
|
var unesc; |
|
var temp; |
|
|
|
function reverse(object, prepender) { |
|
return Object.keys(object).reduce(function(reversed, key) { |
|
var newKey = prepender ? prepender + key : key; // Optionally prepend a string to key. |
|
reversed[object[key]] = newKey; // Swap key and value. |
|
return reversed; // Return the result. |
|
}, {}); |
|
} |
|
|
|
/** |
|
* Regex for common characters |
|
*/ |
|
|
|
chars.escapeRegex = { |
|
'?': /\?/g, |
|
'@': /\@/g, |
|
'!': /\!/g, |
|
'+': /\+/g, |
|
'*': /\*/g, |
|
'(': /\(/g, |
|
')': /\)/g, |
|
'[': /\[/g, |
|
']': /\]/g |
|
}; |
|
|
|
/** |
|
* Escape characters |
|
*/ |
|
|
|
chars.ESC = { |
|
'?': '__UNESC_QMRK__', |
|
'@': '__UNESC_AMPE__', |
|
'!': '__UNESC_EXCL__', |
|
'+': '__UNESC_PLUS__', |
|
'*': '__UNESC_STAR__', |
|
',': '__UNESC_COMMA__', |
|
'(': '__UNESC_LTPAREN__', |
|
')': '__UNESC_RTPAREN__', |
|
'[': '__UNESC_LTBRACK__', |
|
']': '__UNESC_RTBRACK__' |
|
}; |
|
|
|
/** |
|
* Unescape characters |
|
*/ |
|
|
|
chars.UNESC = unesc || (unesc = reverse(chars.ESC, '\\')); |
|
|
|
chars.ESC_TEMP = { |
|
'?': '__TEMP_QMRK__', |
|
'@': '__TEMP_AMPE__', |
|
'!': '__TEMP_EXCL__', |
|
'*': '__TEMP_STAR__', |
|
'+': '__TEMP_PLUS__', |
|
',': '__TEMP_COMMA__', |
|
'(': '__TEMP_LTPAREN__', |
|
')': '__TEMP_RTPAREN__', |
|
'[': '__TEMP_LTBRACK__', |
|
']': '__TEMP_RTBRACK__' |
|
}; |
|
|
|
chars.TEMP = temp || (temp = reverse(chars.ESC_TEMP)); |
|
|
|
var chars_1 = chars; |
|
|
|
var glob = createCommonjsModule(function (module) { |
|
var Glob = module.exports = function Glob(pattern, options) { |
|
if (!(this instanceof Glob)) { |
|
return new Glob(pattern, options); |
|
} |
|
this.options = options || {}; |
|
this.pattern = pattern; |
|
this.history = []; |
|
this.tokens = {}; |
|
this.init(pattern); |
|
}; |
|
|
|
/** |
|
* Initialize defaults |
|
*/ |
|
|
|
Glob.prototype.init = function(pattern) { |
|
this.orig = pattern; |
|
this.negated = this.isNegated(); |
|
this.options.track = this.options.track || false; |
|
this.options.makeRe = true; |
|
}; |
|
|
|
/** |
|
* Push a change into `glob.history`. Useful |
|
* for debugging. |
|
*/ |
|
|
|
Glob.prototype.track = function(msg) { |
|
if (this.options.track) { |
|
this.history.push({msg: msg, pattern: this.pattern}); |
|
} |
|
}; |
|
|
|
/** |
|
* Return true if `glob.pattern` was negated |
|
* with `!`, also remove the `!` from the pattern. |
|
* |
|
* @return {Boolean} |
|
*/ |
|
|
|
Glob.prototype.isNegated = function() { |
|
if (this.pattern.charCodeAt(0) === 33 /* '!' */) { |
|
this.pattern = this.pattern.slice(1); |
|
return true; |
|
} |
|
return false; |
|
}; |
|
|
|
/** |
|
* Expand braces in the given glob pattern. |
|
* |
|
* We only need to use the [braces] lib when |
|
* patterns are nested. |
|
*/ |
|
|
|
Glob.prototype.braces = function() { |
|
if (this.options.nobraces !== true && this.options.nobrace !== true) { |
|
// naive/fast check for imbalanced characters |
|
var a = this.pattern.match(/[\{\(\[]/g); |
|
var b = this.pattern.match(/[\}\)\]]/g); |
|
|
|
// if imbalanced, don't optimize the pattern |
|
if (a && b && (a.length !== b.length)) { |
|
this.options.makeRe = false; |
|
} |
|
|
|
// expand brace patterns and join the resulting array |
|
var expanded = utils_1.braces(this.pattern, this.options); |
|
this.pattern = expanded.join('|'); |
|
} |
|
}; |
|
|
|
/** |
|
* Expand bracket expressions in `glob.pattern` |
|
*/ |
|
|
|
Glob.prototype.brackets = function() { |
|
if (this.options.nobrackets !== true) { |
|
this.pattern = utils_1.brackets(this.pattern); |
|
} |
|
}; |
|
|
|
/** |
|
* Expand bracket expressions in `glob.pattern` |
|
*/ |
|
|
|
Glob.prototype.extglob = function() { |
|
if (this.options.noextglob === true) return; |
|
|
|
if (utils_1.isExtglob(this.pattern)) { |
|
this.pattern = utils_1.extglob(this.pattern, {escape: true}); |
|
} |
|
}; |
|
|
|
/** |
|
* Parse the given pattern |
|
*/ |
|
|
|
Glob.prototype.parse = function(pattern) { |
|
this.tokens = utils_1.parseGlob(pattern || this.pattern, true); |
|
return this.tokens; |
|
}; |
|
|
|
/** |
|
* Replace `a` with `b`. Also tracks the change before and |
|
* after each replacement. This is disabled by default, but |
|
* can be enabled by setting `options.track` to true. |
|
* |
|
* Also, when the pattern is a string, `.split()` is used, |
|
* because it's much faster than replace. |
|
* |
|
* @param {RegExp|String} `a` |
|
* @param {String} `b` |
|
* @param {Boolean} `escape` When `true`, escapes `*` and `?` in the replacement. |
|
* @return {String} |
|
*/ |
|
|
|
Glob.prototype._replace = function(a, b, escape) { |
|
this.track('before (find): "' + a + '" (replace with): "' + b + '"'); |
|
if (escape) b = esc(b); |
|
if (a && b && typeof a === 'string') { |
|
this.pattern = this.pattern.split(a).join(b); |
|
} else { |
|
this.pattern = this.pattern.replace(a, b); |
|
} |
|
this.track('after'); |
|
}; |
|
|
|
/** |
|
* Escape special characters in the given string. |
|
* |
|
* @param {String} `str` Glob pattern |
|
* @return {String} |
|
*/ |
|
|
|
Glob.prototype.escape = function(str) { |
|
this.track('before escape: '); |
|
var re = /["\\](['"]?[^"'\\]['"]?)/g; |
|
|
|
this.pattern = str.replace(re, function($0, $1) { |
|
var o = chars_1.ESC; |
|
var ch = o && o[$1]; |
|
if (ch) { |
|
return ch; |
|
} |
|
if (/[a-z]/i.test($0)) { |
|
return $0.split('\\').join(''); |
|
} |
|
return $0; |
|
}); |
|
|
|
this.track('after escape: '); |
|
}; |
|
|
|
/** |
|
* Unescape special characters in the given string. |
|
* |
|
* @param {String} `str` |
|
* @return {String} |
|
*/ |
|
|
|
Glob.prototype.unescape = function(str) { |
|
var re = /__([A-Z]+)_([A-Z]+)__/g; |
|
this.pattern = str.replace(re, function($0, $1) { |
|
return chars_1[$1][$0]; |
|
}); |
|
this.pattern = unesc(this.pattern); |
|
}; |
|
|
|
/** |
|
* Escape/unescape utils |
|
*/ |
|
|
|
function esc(str) { |
|
str = str.split('?').join('%~'); |
|
str = str.split('*').join('%%'); |
|
return str; |
|
} |
|
|
|
function unesc(str) { |
|
str = str.split('%~').join('?'); |
|
str = str.split('%%').join('*'); |
|
return str; |
|
} |
|
}); |
|
|
|
/** |
|
* Expose `expand` |
|
*/ |
|
|
|
var expand_1 = expand; |
|
|
|
/** |
|
* Expand a glob pattern to resolve braces and |
|
* similar patterns before converting to regex. |
|
* |
|
* @param {String|Array} `pattern` |
|
* @param {Array} `files` |
|
* @param {Options} `opts` |
|
* @return {Array} |
|
*/ |
|
|
|
function expand(pattern, options) { |
|
if (typeof pattern !== 'string') { |
|
throw new TypeError('micromatch.expand(): argument should be a string.'); |
|
} |
|
|
|
var glob$$1 = new glob(pattern, options || {}); |
|
var opts = glob$$1.options; |
|
|
|
if (!utils_1.isGlob(pattern)) { |
|
glob$$1.pattern = glob$$1.pattern.replace(/([\/.])/g, '\\$1'); |
|
return glob$$1; |
|
} |
|
|
|
glob$$1.pattern = glob$$1.pattern.replace(/(\+)(?!\()/g, '\\$1'); |
|
glob$$1.pattern = glob$$1.pattern.split('$').join('\\$'); |
|
|
|
if (typeof opts.braces !== 'boolean' && typeof opts.nobraces !== 'boolean') { |
|
opts.braces = true; |
|
} |
|
|
|
if (glob$$1.pattern === '.*') { |
|
return { |
|
pattern: '\\.' + star, |
|
tokens: tok, |
|
options: opts |
|
}; |
|
} |
|
|
|
if (glob$$1.pattern === '*') { |
|
return { |
|
pattern: oneStar(opts.dot), |
|
tokens: tok, |
|
options: opts |
|
}; |
|
} |
|
|
|
// parse the glob pattern into tokens |
|
glob$$1.parse(); |
|
var tok = glob$$1.tokens; |
|
tok.is.negated = opts.negated; |
|
|
|
// dotfile handling |
|
if ((opts.dotfiles === true || tok.is.dotfile) && opts.dot !== false) { |
|
opts.dotfiles = true; |
|
opts.dot = true; |
|
} |
|
|
|
if ((opts.dotdirs === true || tok.is.dotdir) && opts.dot !== false) { |
|
opts.dotdirs = true; |
|
opts.dot = true; |
|
} |
|
|
|
// check for braces with a dotfile pattern |
|
if (/[{,]\./.test(glob$$1.pattern)) { |
|
opts.makeRe = false; |
|
opts.dot = true; |
|
} |
|
|
|
if (opts.nonegate !== true) { |
|
opts.negated = glob$$1.negated; |
|
} |
|
|
|
// if the leading character is a dot or a slash, escape it |
|
if (glob$$1.pattern.charAt(0) === '.' && glob$$1.pattern.charAt(1) !== '/') { |
|
glob$$1.pattern = '\\' + glob$$1.pattern; |
|
} |
|
|
|
/** |
|
* Extended globs |
|
*/ |
|
|
|
// expand braces, e.g `{1..5}` |
|
glob$$1.track('before braces'); |
|
if (tok.is.braces) { |
|
glob$$1.braces(); |
|
} |
|
glob$$1.track('after braces'); |
|
|
|
// expand extglobs, e.g `foo/!(a|b)` |
|
glob$$1.track('before extglob'); |
|
if (tok.is.extglob) { |
|
glob$$1.extglob(); |
|
} |
|
glob$$1.track('after extglob'); |
|
|
|
// expand brackets, e.g `[[:alpha:]]` |
|
glob$$1.track('before brackets'); |
|
if (tok.is.brackets) { |
|
glob$$1.brackets(); |
|
} |
|
glob$$1.track('after brackets'); |
|
|
|
// special patterns |
|
glob$$1._replace('[!', '[^'); |
|
glob$$1._replace('(?', '(%~'); |
|
glob$$1._replace(/\[\]/, '\\[\\]'); |
|
glob$$1._replace('/[', '/' + (opts.dot ? dotfiles : nodot) + '[', true); |
|
glob$$1._replace('/?', '/' + (opts.dot ? dotfiles : nodot) + '[^/]', true); |
|
glob$$1._replace('/.', '/(?=.)\\.', true); |
|
|
|
// windows drives |
|
glob$$1._replace(/^(\w):([\\\/]+?)/gi, '(?=.)$1:$2', true); |
|
|
|
// negate slashes in exclusion ranges |
|
if (glob$$1.pattern.indexOf('[^') !== -1) { |
|
glob$$1.pattern = negateSlash(glob$$1.pattern); |
|
} |
|
|
|
if (opts.globstar !== false && glob$$1.pattern === '**') { |
|
glob$$1.pattern = globstar(opts.dot); |
|
|
|
} else { |
|
glob$$1.pattern = balance(glob$$1.pattern, '[', ']'); |
|
glob$$1.escape(glob$$1.pattern); |
|
|
|
// if the pattern has `**` |
|
if (tok.is.globstar) { |
|
glob$$1.pattern = collapse(glob$$1.pattern, '/**'); |
|
glob$$1.pattern = collapse(glob$$1.pattern, '**/'); |
|
glob$$1._replace('/**/', '(?:/' + globstar(opts.dot) + '/|/)', true); |
|
glob$$1._replace(/\*{2,}/g, '**'); |
|
|
|
// 'foo/*' |
|
glob$$1._replace(/(\w+)\*(?!\/)/g, '$1[^/]*?', true); |
|
glob$$1._replace(/\*\*\/\*(\w)/g, globstar(opts.dot) + '\\/' + (opts.dot ? dotfiles : nodot) + '[^/]*?$1', true); |
|
|
|
if (opts.dot !== true) { |
|
glob$$1._replace(/\*\*\/(.)/g, '(?:**\\/|)$1'); |
|
} |
|
|
|
// 'foo/**' or '{**,*}', but not 'foo**' |
|
if (tok.path.dirname !== '' || /,\*\*|\*\*,/.test(glob$$1.orig)) { |
|
glob$$1._replace('**', globstar(opts.dot), true); |
|
} |
|
} |
|
|
|
// ends with /* |
|
glob$$1._replace(/\/\*$/, '\\/' + oneStar(opts.dot), true); |
|
// ends with *, no slashes |
|
glob$$1._replace(/(?!\/)\*$/, star, true); |
|
// has 'n*.' (partial wildcard w/ file extension) |
|
glob$$1._replace(/([^\/]+)\*/, '$1' + oneStar(true), true); |
|
// has '*' |
|
glob$$1._replace('*', oneStar(opts.dot), true); |
|
glob$$1._replace('?.', '?\\.', true); |
|
glob$$1._replace('?:', '?:', true); |
|
|
|
glob$$1._replace(/\?+/g, function(match) { |
|
var len = match.length; |
|
if (len === 1) { |
|
return qmark; |
|
} |
|
return qmark + '{' + len + '}'; |
|
}); |
|
|
|
// escape '.abc' => '\\.abc' |
|
glob$$1._replace(/\.([*\w]+)/g, '\\.$1'); |
|
// fix '[^\\\\/]' |
|
glob$$1._replace(/\[\^[\\\/]+\]/g, qmark); |
|
// '///' => '\/' |
|
glob$$1._replace(/\/+/g, '\\/'); |
|
// '\\\\\\' => '\\' |
|
glob$$1._replace(/\\{2,}/g, '\\'); |
|
} |
|
|
|
// unescape previously escaped patterns |
|
glob$$1.unescape(glob$$1.pattern); |
|
glob$$1._replace('__UNESC_STAR__', '*'); |
|
|
|
// escape dots that follow qmarks |
|
glob$$1._replace('?.', '?\\.'); |
|
|
|
// remove unnecessary slashes in character classes |
|
glob$$1._replace('[^\\/]', qmark); |
|
|
|
if (glob$$1.pattern.length > 1) { |
|
if (/^[\[?*]/.test(glob$$1.pattern)) { |
|
// only prepend the string if we don't want to match dotfiles |
|
glob$$1.pattern = (opts.dot ? dotfiles : nodot) + glob$$1.pattern; |
|
} |
|
} |
|
|
|
return glob$$1; |
|
} |
|
|
|
/** |
|
* Collapse repeated character sequences. |
|
* |
|
* ```js |
|
* collapse('a/../../../b', '../'); |
|
* //=> 'a/../b' |
|
* ``` |
|
* |
|
* @param {String} `str` |
|
* @param {String} `ch` Character sequence to collapse |
|
* @return {String} |
|
*/ |
|
|
|
function collapse(str, ch) { |
|
var res = str.split(ch); |
|
var isFirst = res[0] === ''; |
|
var isLast = res[res.length - 1] === ''; |
|
res = res.filter(Boolean); |
|
if (isFirst) res.unshift(''); |
|
if (isLast) res.push(''); |
|
return res.join(ch); |
|
} |
|
|
|
/** |
|
* Negate slashes in exclusion ranges, per glob spec: |
|
* |
|
* ```js |
|
* negateSlash('[^foo]'); |
|
* //=> '[^\\/foo]' |
|
* ``` |
|
* |
|
* @param {String} `str` glob pattern |
|
* @return {String} |
|
*/ |
|
|
|
function negateSlash(str) { |
|
return str.replace(/\[\^([^\]]*?)\]/g, function(match, inner) { |
|
if (inner.indexOf('/') === -1) { |
|
inner = '\\/' + inner; |
|
} |
|
return '[^' + inner + ']'; |
|
}); |
|
} |
|
|
|
/** |
|
* Escape imbalanced braces/bracket. This is a very |
|
* basic, naive implementation that only does enough |
|
* to serve the purpose. |
|
*/ |
|
|
|
function balance(str, a, b) { |
|
var aarr = str.split(a); |
|
var alen = aarr.join('').length; |
|
var blen = str.split(b).join('').length; |
|
|
|
if (alen !== blen) { |
|
str = aarr.join('\\' + a); |
|
return str.split(b).join('\\' + b); |
|
} |
|
return str; |
|
} |
|
|
|
/** |
|
* Special patterns to be converted to regex. |
|
* Heuristics are used to simplify patterns |
|
* and speed up processing. |
|
*/ |
|
|
|
/* eslint no-multi-spaces: 0 */ |
|
var qmark = '[^/]'; |
|
var star = qmark + '*?'; |
|
var nodot = '(?!\\.)(?=.)'; |
|
var dotfileGlob = '(?:\\/|^)\\.{1,2}($|\\/)'; |
|
var dotfiles = '(?!' + dotfileGlob + ')(?=.)'; |
|
var twoStarDot = '(?:(?!' + dotfileGlob + ').)*?'; |
|
|
|
/** |
|
* Create a regex for `*`. |
|
* |
|
* If `dot` is true, or the pattern does not begin with |
|
* a leading star, then return the simpler regex. |
|
*/ |
|
|
|
function oneStar(dotfile) { |
|
return dotfile ? '(?!' + dotfileGlob + ')(?=.)' + star : (nodot + star); |
|
} |
|
|
|
function globstar(dotfile) { |
|
if (dotfile) { return twoStarDot; } |
|
return '(?:(?!(?:\\/|^)\\.).)*?'; |
|
} |
|
|
|
/** |
|
* The main function. Pass an array of filepaths, |
|
* and a string or array of glob patterns |
|
* |
|
* @param {Array|String} `files` |
|
* @param {Array|String} `patterns` |
|
* @param {Object} `opts` |
|
* @return {Array} Array of matches |
|
*/ |
|
|
|
function micromatch(files, patterns, opts) { |
|
if (!files || !patterns) return []; |
|
opts = opts || {}; |
|
|
|
if (typeof opts.cache === 'undefined') { |
|
opts.cache = true; |
|
} |
|
|
|
if (!Array.isArray(patterns)) { |
|
return match(files, patterns, opts); |
|
} |
|
|
|
var len = patterns.length, i = 0; |
|
var omit = [], keep = []; |
|
|
|
while (len--) { |
|
var glob = patterns[i++]; |
|
if (typeof glob === 'string' && glob.charCodeAt(0) === 33 /* ! */) { |
|
omit.push.apply(omit, match(files, glob.slice(1), opts)); |
|
} else { |
|
keep.push.apply(keep, match(files, glob, opts)); |
|
} |
|
} |
|
return utils_1.diff(keep, omit); |
|
} |
|
|
|
/** |
|
* Return an array of files that match the given glob pattern. |
|
* |
|
* This function is called by the main `micromatch` function If you only |
|
* need to pass a single pattern you might get very minor speed improvements |
|
* using this function. |
|
* |
|
* @param {Array} `files` |
|
* @param {String} `pattern` |
|
* @param {Object} `options` |
|
* @return {Array} |
|
*/ |
|
|
|
function match(files, pattern, opts) { |
|
if (utils_1.typeOf(files) !== 'string' && !Array.isArray(files)) { |
|
throw new Error(msg('match', 'files', 'a string or array')); |
|
} |
|
|
|
files = utils_1.arrayify(files); |
|
opts = opts || {}; |
|
|
|
var negate = opts.negate || false; |
|
var orig = pattern; |
|
|
|
if (typeof pattern === 'string') { |
|
negate = pattern.charAt(0) === '!'; |
|
if (negate) { |
|
pattern = pattern.slice(1); |
|
} |
|
|
|
// we need to remove the character regardless, |
|
// so the above logic is still needed |
|
if (opts.nonegate === true) { |
|
negate = false; |
|
} |
|
} |
|
|
|
var _isMatch = matcher(pattern, opts); |
|
var len = files.length, i = 0; |
|
var res = []; |
|
|
|
while (i < len) { |
|
var file = files[i++]; |
|
var fp = utils_1.unixify(file, opts); |
|
|
|
if (!_isMatch(fp)) { continue; } |
|
res.push(fp); |
|
} |
|
|
|
if (res.length === 0) { |
|
if (opts.failglob === true) { |
|
throw new Error('micromatch.match() found no matches for: "' + orig + '".'); |
|
} |
|
|
|
if (opts.nonull || opts.nullglob) { |
|
res.push(utils_1.unescapeGlob(orig)); |
|
} |
|
} |
|
|
|
// if `negate` was defined, diff negated files |
|
if (negate) { res = utils_1.diff(files, res); } |
|
|
|
// if `ignore` was defined, diff ignored filed |
|
if (opts.ignore && opts.ignore.length) { |
|
pattern = opts.ignore; |
|
opts = utils_1.omit(opts, ['ignore']); |
|
res = utils_1.diff(res, micromatch(res, pattern, opts)); |
|
} |
|
|
|
if (opts.nodupes) { |
|
return utils_1.unique(res); |
|
} |
|
return res; |
|
} |
|
|
|
/** |
|
* Returns a function that takes a glob pattern or array of glob patterns |
|
* to be used with `Array#filter()`. (Internally this function generates |
|
* the matching function using the [matcher] method). |
|
* |
|
* ```js |
|
* var fn = mm.filter('[a-c]'); |
|
* ['a', 'b', 'c', 'd', 'e'].filter(fn); |
|
* //=> ['a', 'b', 'c'] |
|
* ``` |
|
* @param {String|Array} `patterns` Can be a glob or array of globs. |
|
* @param {Options} `opts` Options to pass to the [matcher] method. |
|
* @return {Function} Filter function to be passed to `Array#filter()`. |
|
*/ |
|
|
|
function filter$1(patterns, opts) { |
|
if (!Array.isArray(patterns) && typeof patterns !== 'string') { |
|
throw new TypeError(msg('filter', 'patterns', 'a string or array')); |
|
} |
|
|
|
patterns = utils_1.arrayify(patterns); |
|
var len = patterns.length, i = 0; |
|
var patternMatchers = Array(len); |
|
while (i < len) { |
|
patternMatchers[i] = matcher(patterns[i++], opts); |
|
} |
|
|
|
return function(fp) { |
|
if (fp == null) return []; |
|
var len = patternMatchers.length, i = 0; |
|
var res = true; |
|
|
|
fp = utils_1.unixify(fp, opts); |
|
while (i < len) { |
|
var fn = patternMatchers[i++]; |
|
if (!fn(fp)) { |
|
res = false; |
|
break; |
|
} |
|
} |
|
return res; |
|
}; |
|
} |
|
|
|
/** |
|
* Returns true if the filepath contains the given |
|
* pattern. Can also return a function for matching. |
|
* |
|
* ```js |
|
* isMatch('foo.md', '*.md', {}); |
|
* //=> true |
|
* |
|
* isMatch('*.md', {})('foo.md') |
|
* //=> true |
|
* ``` |
|
* @param {String} `fp` |
|
* @param {String} `pattern` |
|
* @param {Object} `opts` |
|
* @return {Boolean} |
|
*/ |
|
|
|
function isMatch(fp, pattern, opts) { |
|
if (typeof fp !== 'string') { |
|
throw new TypeError(msg('isMatch', 'filepath', 'a string')); |
|
} |
|
|
|
fp = utils_1.unixify(fp, opts); |
|
if (utils_1.typeOf(pattern) === 'object') { |
|
return matcher(fp, pattern); |
|
} |
|
return matcher(pattern, opts)(fp); |
|
} |
|
|
|
/** |
|
* Returns true if the filepath matches the |
|
* given pattern. |
|
*/ |
|
|
|
function contains(fp, pattern, opts) { |
|
if (typeof fp !== 'string') { |
|
throw new TypeError(msg('contains', 'pattern', 'a string')); |
|
} |
|
|
|
opts = opts || {}; |
|
opts.contains = (pattern !== ''); |
|
fp = utils_1.unixify(fp, opts); |
|
|
|
if (opts.contains && !utils_1.isGlob(pattern)) { |
|
return fp.indexOf(pattern) !== -1; |
|
} |
|
return matcher(pattern, opts)(fp); |
|
} |
|
|
|
/** |
|
* Returns true if a file path matches any of the |
|
* given patterns. |
|
* |
|
* @param {String} `fp` The filepath to test. |
|
* @param {String|Array} `patterns` Glob patterns to use. |
|
* @param {Object} `opts` Options to pass to the `matcher()` function. |
|
* @return {String} |
|
*/ |
|
|
|
function any(fp, patterns, opts) { |
|
if (!Array.isArray(patterns) && typeof patterns !== 'string') { |
|
throw new TypeError(msg('any', 'patterns', 'a string or array')); |
|
} |
|
|
|
patterns = utils_1.arrayify(patterns); |
|
var len = patterns.length; |
|
|
|
fp = utils_1.unixify(fp, opts); |
|
while (len--) { |
|
var isMatch = matcher(patterns[len], opts); |
|
if (isMatch(fp)) { |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
/** |
|
* Filter the keys of an object with the given `glob` pattern |
|
* and `options` |
|
* |
|
* @param {Object} `object` |
|
* @param {Pattern} `object` |
|
* @return {Array} |
|
*/ |
|
|
|
function matchKeys(obj, glob, options) { |
|
if (utils_1.typeOf(obj) !== 'object') { |
|
throw new TypeError(msg('matchKeys', 'first argument', 'an object')); |
|
} |
|
|
|
var fn = matcher(glob, options); |
|
var res = {}; |
|
|
|
for (var key in obj) { |
|
if (obj.hasOwnProperty(key) && fn(key)) { |
|
res[key] = obj[key]; |
|
} |
|
} |
|
return res; |
|
} |
|
|
|
/** |
|
* Return a function for matching based on the |
|
* given `pattern` and `options`. |
|
* |
|
* @param {String} `pattern` |
|
* @param {Object} `options` |
|
* @return {Function} |
|
*/ |
|
|
|
function matcher(pattern, opts) { |
|
// pattern is a function |
|
if (typeof pattern === 'function') { |
|
return pattern; |
|
} |
|
// pattern is a regex |
|
if (pattern instanceof RegExp) { |
|
return function(fp) { |
|
return pattern.test(fp); |
|
}; |
|
} |
|
|
|
if (typeof pattern !== 'string') { |
|
throw new TypeError(msg('matcher', 'pattern', 'a string, regex, or function')); |
|
} |
|
|
|
// strings, all the way down... |
|
pattern = utils_1.unixify(pattern, opts); |
|
|
|
// pattern is a non-glob string |
|
if (!utils_1.isGlob(pattern)) { |
|
return utils_1.matchPath(pattern, opts); |
|
} |
|
// pattern is a glob string |
|
var re = makeRe(pattern, opts); |
|
|
|
// `matchBase` is defined |
|
if (opts && opts.matchBase) { |
|
return utils_1.hasFilename(re, opts); |
|
} |
|
// `matchBase` is not defined |
|
return function(fp) { |
|
fp = utils_1.unixify(fp, opts); |
|
return re.test(fp); |
|
}; |
|
} |
|
|
|
/** |
|
* Create and cache a regular expression for matching |
|
* file paths. |
|
* |
|
* If the leading character in the `glob` is `!`, a negation |
|
* regex is returned. |
|
* |
|
* @param {String} `glob` |
|
* @param {Object} `options` |
|
* @return {RegExp} |
|
*/ |
|
|
|
function toRegex(glob, options) { |
|
// clone options to prevent mutating the original object |
|
var opts = Object.create(options || {}); |
|
var flags = opts.flags || ''; |
|
if (opts.nocase && flags.indexOf('i') === -1) { |
|
flags += 'i'; |
|
} |
|
|
|
var parsed = expand_1(glob, opts); |
|
|
|
// pass in tokens to avoid parsing more than once |
|
opts.negated = opts.negated || parsed.negated; |
|
opts.negate = opts.negated; |
|
glob = wrapGlob(parsed.pattern, opts); |
|
var re; |
|
|
|
try { |
|
re = new RegExp(glob, flags); |
|
return re; |
|
} catch (err) { |
|
err.reason = 'micromatch invalid regex: (' + re + ')'; |
|
if (opts.strict) throw new SyntaxError(err); |
|
} |
|
|
|
// we're only here if a bad pattern was used and the user |
|
// passed `options.silent`, so match nothing |
|
return /$^/; |
|
} |
|
|
|
/** |
|
* Create the regex to do the matching. If the leading |
|
* character in the `glob` is `!` a negation regex is returned. |
|
* |
|
* @param {String} `glob` |
|
* @param {Boolean} `negate` |
|
*/ |
|
|
|
function wrapGlob(glob, opts) { |
|
var prefix = (opts && !opts.contains) ? '^' : ''; |
|
var after = (opts && !opts.contains) ? '$' : ''; |
|
glob = ('(?:' + glob + ')' + after); |
|
if (opts && opts.negate) { |
|
return prefix + ('(?!^' + glob + ').*$'); |
|
} |
|
return prefix + glob; |
|
} |
|
|
|
/** |
|
* Create and cache a regular expression for matching file paths. |
|
* If the leading character in the `glob` is `!`, a negation |
|
* regex is returned. |
|
* |
|
* @param {String} `glob` |
|
* @param {Object} `options` |
|
* @return {RegExp} |
|
*/ |
|
|
|
function makeRe(glob, opts) { |
|
if (utils_1.typeOf(glob) !== 'string') { |
|
throw new Error(msg('makeRe', 'glob', 'a string')); |
|
} |
|
return utils_1.cache(toRegex, glob, opts); |
|
} |
|
|
|
/** |
|
* Make error messages consistent. Follows this format: |
|
* |
|
* ```js |
|
* msg(methodName, argNumber, nativeType); |
|
* // example: |
|
* msg('matchKeys', 'first', 'an object'); |
|
* ``` |
|
* |
|
* @param {String} `method` |
|
* @param {String} `num` |
|
* @param {String} `type` |
|
* @return {String} |
|
*/ |
|
|
|
function msg(method, what, type) { |
|
return 'micromatch.' + method + '(): ' + what + ' should be ' + type + '.'; |
|
} |
|
|
|
/** |
|
* Public methods |
|
*/ |
|
|
|
/* eslint no-multi-spaces: 0 */ |
|
micromatch.any = any; |
|
micromatch.braces = micromatch.braceExpand = utils_1.braces; |
|
micromatch.contains = contains; |
|
micromatch.expand = expand_1; |
|
micromatch.filter = filter$1; |
|
micromatch.isMatch = isMatch; |
|
micromatch.makeRe = makeRe; |
|
micromatch.match = match; |
|
micromatch.matcher = matcher; |
|
micromatch.matchKeys = matchKeys; |
|
|
|
/** |
|
* Expose `micromatch` |
|
*/ |
|
|
|
var micromatch_1 = micromatch; |
|
|
|
var slash = function (str) { |
|
var isExtendedLengthPath = /^\\\\\?\\/.test(str); |
|
var hasNonAscii = /[^\x00-\x80]+/.test(str); |
|
|
|
if (isExtendedLengthPath || hasNonAscii) { |
|
return str; |
|
} |
|
|
|
return str.replace(/\\/g, '/'); |
|
}; |
|
|
|
var jsTokens = createCommonjsModule(function (module, exports) { |
|
// Copyright 2014, 2015, 2016, 2017 Simon Lydell |
|
// License: MIT. (See LICENSE.) |
|
|
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
|
|
// This regex comes from regex.coffee, and is inserted here by generate-index.js |
|
// (run `npm run build`). |
|
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g; |
|
|
|
exports.matchToToken = function(match) { |
|
var token = {type: "invalid", value: match[0]}; |
|
if (match[ 1]) token.type = "string", token.closed = !!(match[3] || match[4]); |
|
else if (match[ 5]) token.type = "comment"; |
|
else if (match[ 6]) token.type = "comment", token.closed = !!match[7]; |
|
else if (match[ 8]) token.type = "regex"; |
|
else if (match[ 9]) token.type = "number"; |
|
else if (match[10]) token.type = "name"; |
|
else if (match[11]) token.type = "punctuator"; |
|
else if (match[12]) token.type = "whitespace"; |
|
return token |
|
}; |
|
}); |
|
|
|
unwrapExports(jsTokens); |
|
var jsTokens_1 = jsTokens.matchToToken; |
|
|
|
var ast = createCommonjsModule(function (module) { |
|
/* |
|
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> |
|
|
|
Redistribution and use in source and binary forms, with or without |
|
modification, are permitted provided that the following conditions are met: |
|
|
|
* Redistributions of source code must retain the above copyright |
|
notice, this list of conditions and the following disclaimer. |
|
* Redistributions in binary form must reproduce the above copyright |
|
notice, this list of conditions and the following disclaimer in the |
|
documentation and/or other materials provided with the distribution. |
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' |
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
|
|
|
(function () { |
|
function isExpression(node) { |
|
if (node == null) { return false; } |
|
switch (node.type) { |
|
case 'ArrayExpression': |
|
case 'AssignmentExpression': |
|
case 'BinaryExpression': |
|
case 'CallExpression': |
|
case 'ConditionalExpression': |
|
case 'FunctionExpression': |
|
case 'Identifier': |
|
case 'Literal': |
|
case 'LogicalExpression': |
|
case 'MemberExpression': |
|
case 'NewExpression': |
|
case 'ObjectExpression': |
|
case 'SequenceExpression': |
|
case 'ThisExpression': |
|
case 'UnaryExpression': |
|
case 'UpdateExpression': |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
function isIterationStatement(node) { |
|
if (node == null) { return false; } |
|
switch (node.type) { |
|
case 'DoWhileStatement': |
|
case 'ForInStatement': |
|
case 'ForStatement': |
|
case 'WhileStatement': |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
function isStatement(node) { |
|
if (node == null) { return false; } |
|
switch (node.type) { |
|
case 'BlockStatement': |
|
case 'BreakStatement': |
|
case 'ContinueStatement': |
|
case 'DebuggerStatement': |
|
case 'DoWhileStatement': |
|
case 'EmptyStatement': |
|
case 'ExpressionStatement': |
|
case 'ForInStatement': |
|
case 'ForStatement': |
|
case 'IfStatement': |
|
case 'LabeledStatement': |
|
case 'ReturnStatement': |
|
case 'SwitchStatement': |
|
case 'ThrowStatement': |
|
case 'TryStatement': |
|
case 'VariableDeclaration': |
|
case 'WhileStatement': |
|
case 'WithStatement': |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
function isSourceElement(node) { |
|
return isStatement(node) || node != null && node.type === 'FunctionDeclaration'; |
|
} |
|
|
|
function trailingStatement(node) { |
|
switch (node.type) { |
|
case 'IfStatement': |
|
if (node.alternate != null) { |
|
return node.alternate; |
|
} |
|
return node.consequent; |
|
|
|
case 'LabeledStatement': |
|
case 'ForStatement': |
|
case 'ForInStatement': |
|
case 'WhileStatement': |
|
case 'WithStatement': |
|
return node.body; |
|
} |
|
return null; |
|
} |
|
|
|
function isProblematicIfStatement(node) { |
|
var current; |
|
|
|
if (node.type !== 'IfStatement') { |
|
return false; |
|
} |
|
if (node.alternate == null) { |
|
return false; |
|
} |
|
current = node.consequent; |
|
do { |
|
if (current.type === 'IfStatement') { |
|
if (current.alternate == null) { |
|
return true; |
|
} |
|
} |
|
current = trailingStatement(current); |
|
} while (current); |
|
|
|
return false; |
|
} |
|
|
|
module.exports = { |
|
isExpression: isExpression, |
|
isStatement: isStatement, |
|
isIterationStatement: isIterationStatement, |
|
isSourceElement: isSourceElement, |
|
isProblematicIfStatement: isProblematicIfStatement, |
|
|
|
trailingStatement: trailingStatement |
|
}; |
|
}()); |
|
/* vim: set sw=4 ts=4 et tw=80 : */ |
|
}); |
|
|
|
var ast_1 = ast.isExpression; |
|
var ast_2 = ast.isStatement; |
|
var ast_3 = ast.isIterationStatement; |
|
var ast_4 = ast.isSourceElement; |
|
var ast_5 = ast.isProblematicIfStatement; |
|
var ast_6 = ast.trailingStatement; |
|
|
|
var code = createCommonjsModule(function (module) { |
|
/* |
|
Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com> |
|
Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com> |
|
|
|
Redistribution and use in source and binary forms, with or without |
|
modification, are permitted provided that the following conditions are met: |
|
|
|
* Redistributions of source code must retain the above copyright |
|
notice, this list of conditions and the following disclaimer. |
|
* Redistributions in binary form must reproduce the above copyright |
|
notice, this list of conditions and the following disclaimer in the |
|
documentation and/or other materials provided with the distribution. |
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
|
|
|
(function () { |
|
var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; |
|
|
|
// See `tools/generate-identifier-regex.js`. |
|
ES5Regex = { |
|
// ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart: |
|
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/, |
|
// ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart: |
|
NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/ |
|
}; |
|
|
|
ES6Regex = { |
|
// ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart: |
|
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/, |
|
// ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart: |
|
NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ |
|
}; |
|
|
|
function isDecimalDigit(ch) { |
|
return 0x30 <= ch && ch <= 0x39; // 0..9 |
|
} |
|
|
|
function isHexDigit(ch) { |
|
return 0x30 <= ch && ch <= 0x39 || // 0..9 |
|
0x61 <= ch && ch <= 0x66 || // a..f |
|
0x41 <= ch && ch <= 0x46; // A..F |
|
} |
|
|
|
function isOctalDigit(ch) { |
|
return ch >= 0x30 && ch <= 0x37; // 0..7 |
|
} |
|
|
|
// 7.2 White Space |
|
|
|
NON_ASCII_WHITESPACES = [ |
|
0x1680, 0x180E, |
|
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, |
|
0x202F, 0x205F, |
|
0x3000, |
|
0xFEFF |
|
]; |
|
|
|
function isWhiteSpace(ch) { |
|
return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || |
|
ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0; |
|
} |
|
|
|
// 7.3 Line Terminators |
|
|
|
function isLineTerminator(ch) { |
|
return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029; |
|
} |
|
|
|
// 7.6 Identifier Names and Identifiers |
|
|
|
function fromCodePoint(cp) { |
|
if (cp <= 0xFFFF) { return String.fromCharCode(cp); } |
|
var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800); |
|
var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00); |
|
return cu1 + cu2; |
|
} |
|
|
|
IDENTIFIER_START = new Array(0x80); |
|
for(ch = 0; ch < 0x80; ++ch) { |
|
IDENTIFIER_START[ch] = |
|
ch >= 0x61 && ch <= 0x7A || // a..z |
|
ch >= 0x41 && ch <= 0x5A || // A..Z |
|
ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) |
|
} |
|
|
|
IDENTIFIER_PART = new Array(0x80); |
|
for(ch = 0; ch < 0x80; ++ch) { |
|
IDENTIFIER_PART[ch] = |
|
ch >= 0x61 && ch <= 0x7A || // a..z |
|
ch >= 0x41 && ch <= 0x5A || // A..Z |
|
ch >= 0x30 && ch <= 0x39 || // 0..9 |
|
ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore) |
|
} |
|
|
|
function isIdentifierStartES5(ch) { |
|
return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); |
|
} |
|
|
|
function isIdentifierPartES5(ch) { |
|
return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); |
|
} |
|
|
|
function isIdentifierStartES6(ch) { |
|
return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)); |
|
} |
|
|
|
function isIdentifierPartES6(ch) { |
|
return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)); |
|
} |
|
|
|
module.exports = { |
|
isDecimalDigit: isDecimalDigit, |
|
isHexDigit: isHexDigit, |
|
isOctalDigit: isOctalDigit, |
|
isWhiteSpace: isWhiteSpace, |
|
isLineTerminator: isLineTerminator, |
|
isIdentifierStartES5: isIdentifierStartES5, |
|
isIdentifierPartES5: isIdentifierPartES5, |
|
isIdentifierStartES6: isIdentifierStartES6, |
|
isIdentifierPartES6: isIdentifierPartES6 |
|
}; |
|
}()); |
|
/* vim: set sw=4 ts=4 et tw=80 : */ |
|
}); |
|
|
|
var code_1 = code.isDecimalDigit; |
|
var code_2 = code.isHexDigit; |
|
var code_3 = code.isOctalDigit; |
|
var code_4 = code.isWhiteSpace; |
|
var code_5 = code.isLineTerminator; |
|
var code_6 = code.isIdentifierStartES5; |
|
var code_7 = code.isIdentifierPartES5; |
|
var code_8 = code.isIdentifierStartES6; |
|
var code_9 = code.isIdentifierPartES6; |
|
|
|
var keyword = createCommonjsModule(function (module) { |
|
/* |
|
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> |
|
|
|
Redistribution and use in source and binary forms, with or without |
|
modification, are permitted provided that the following conditions are met: |
|
|
|
* Redistributions of source code must retain the above copyright |
|
notice, this list of conditions and the following disclaimer. |
|
* Redistributions in binary form must reproduce the above copyright |
|
notice, this list of conditions and the following disclaimer in the |
|
documentation and/or other materials provided with the distribution. |
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
|
|
|
(function () { |
|
var code$$1 = code; |
|
|
|
function isStrictModeReservedWordES6(id) { |
|
switch (id) { |
|
case 'implements': |
|
case 'interface': |
|
case 'package': |
|
case 'private': |
|
case 'protected': |
|
case 'public': |
|
case 'static': |
|
case 'let': |
|
return true; |
|
default: |
|
return false; |
|
} |
|
} |
|
|
|
function isKeywordES5(id, strict) { |
|
// yield should not be treated as keyword under non-strict mode. |
|
if (!strict && id === 'yield') { |
|
return false; |
|
} |
|
return isKeywordES6(id, strict); |
|
} |
|
|
|
function isKeywordES6(id, strict) { |
|
if (strict && isStrictModeReservedWordES6(id)) { |
|
return true; |
|
} |
|
|
|
switch (id.length) { |
|
case 2: |
|
return (id === 'if') || (id === 'in') || (id === 'do'); |
|
case 3: |
|
return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try'); |
|
case 4: |
|
return (id === 'this') || (id === 'else') || (id === 'case') || |
|
(id === 'void') || (id === 'with') || (id === 'enum'); |
|
case 5: |
|
return (id === 'while') || (id === 'break') || (id === 'catch') || |
|
(id === 'throw') || (id === 'const') || (id === 'yield') || |
|
(id === 'class') || (id === 'super'); |
|
case 6: |
|
return (id === 'return') || (id === 'typeof') || (id === 'delete') || |
|
(id === 'switch') || (id === 'export') || (id === 'import'); |
|
case 7: |
|
return (id === 'default') || (id === 'finally') || (id === 'extends'); |
|
case 8: |
|
return (id === 'function') || (id === 'continue') || (id === 'debugger'); |
|
case 10: |
|
return (id === 'instanceof'); |
|
default: |
|
return false; |
|
} |
|
} |
|
|
|
function isReservedWordES5(id, strict) { |
|
return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict); |
|
} |
|
|
|
function isReservedWordES6(id, strict) { |
|
return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict); |
|
} |
|
|
|
function isRestrictedWord(id) { |
|
return id === 'eval' || id === 'arguments'; |
|
} |
|
|
|
function isIdentifierNameES5(id) { |
|
var i, iz, ch; |
|
|
|
if (id.length === 0) { return false; } |
|
|
|
ch = id.charCodeAt(0); |
|
if (!code$$1.isIdentifierStartES5(ch)) { |
|
return false; |
|
} |
|
|
|
for (i = 1, iz = id.length; i < iz; ++i) { |
|
ch = id.charCodeAt(i); |
|
if (!code$$1.isIdentifierPartES5(ch)) { |
|
return false; |
|
} |
|
} |
|
return true; |
|
} |
|
|
|
function decodeUtf16(lead, trail) { |
|
return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; |
|
} |
|
|
|
function isIdentifierNameES6(id) { |
|
var i, iz, ch, lowCh, check; |
|
|
|
if (id.length === 0) { return false; } |
|
|
|
check = code$$1.isIdentifierStartES6; |
|
for (i = 0, iz = id.length; i < iz; ++i) { |
|
ch = id.charCodeAt(i); |
|
if (0xD800 <= ch && ch <= 0xDBFF) { |
|
++i; |
|
if (i >= iz) { return false; } |
|
lowCh = id.charCodeAt(i); |
|
if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) { |
|
return false; |
|
} |
|
ch = decodeUtf16(ch, lowCh); |
|
} |
|
if (!check(ch)) { |
|
return false; |
|
} |
|
check = code$$1.isIdentifierPartES6; |
|
} |
|
return true; |
|
} |
|
|
|
function isIdentifierES5(id, strict) { |
|
return isIdentifierNameES5(id) && !isReservedWordES5(id, strict); |
|
} |
|
|
|
function isIdentifierES6(id, strict) { |
|
return isIdentifierNameES6(id) && !isReservedWordES6(id, strict); |
|
} |
|
|
|
module.exports = { |
|
isKeywordES5: isKeywordES5, |
|
isKeywordES6: isKeywordES6, |
|
isReservedWordES5: isReservedWordES5, |
|
isReservedWordES6: isReservedWordES6, |
|
isRestrictedWord: isRestrictedWord, |
|
isIdentifierNameES5: isIdentifierNameES5, |
|
isIdentifierNameES6: isIdentifierNameES6, |
|
isIdentifierES5: isIdentifierES5, |
|
isIdentifierES6: isIdentifierES6 |
|
}; |
|
}()); |
|
/* vim: set sw=4 ts=4 et tw=80 : */ |
|
}); |
|
|
|
var keyword_1 = keyword.isKeywordES5; |
|
var keyword_2 = keyword.isKeywordES6; |
|
var keyword_3 = keyword.isReservedWordES5; |
|
var keyword_4 = keyword.isReservedWordES6; |
|
var keyword_5 = keyword.isRestrictedWord; |
|
var keyword_6 = keyword.isIdentifierNameES5; |
|
var keyword_7 = keyword.isIdentifierNameES6; |
|
var keyword_8 = keyword.isIdentifierES5; |
|
var keyword_9 = keyword.isIdentifierES6; |
|
|
|
var utils$2 = createCommonjsModule(function (module, exports) { |
|
/* |
|
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com> |
|
|
|
Redistribution and use in source and binary forms, with or without |
|
modification, are permitted provided that the following conditions are met: |
|
|
|
* Redistributions of source code must retain the above copyright |
|
notice, this list of conditions and the following disclaimer. |
|
* Redistributions in binary form must reproduce the above copyright |
|
notice, this list of conditions and the following disclaimer in the |
|
documentation and/or other materials provided with the distribution. |
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY |
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
*/ |
|
|
|
|
|
(function () { |
|
exports.ast = ast; |
|
exports.code = code; |
|
exports.keyword = keyword; |
|
}()); |
|
/* vim: set sw=4 ts=4 et tw=80 : */ |
|
}); |
|
|
|
var utils_1$2 = utils$2.ast; |
|
var utils_2 = utils$2.code; |
|
var utils_3 = utils$2.keyword; |
|
|
|
var lib$1 = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
exports.codeFrameColumns = codeFrameColumns; |
|
exports.default = _default; |
|
|
|
var _jsTokens = _interopRequireWildcard(jsTokens); |
|
|
|
var _esutils = _interopRequireDefault(utils$2); |
|
|
|
var _chalk = _interopRequireDefault(fake_chalk); |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } |
|
|
|
var deprecationWarningShown = false; |
|
|
|
function getDefs(chalk) { |
|
return { |
|
keyword: chalk.cyan, |
|
capitalized: chalk.yellow, |
|
jsx_tag: chalk.yellow, |
|
punctuator: chalk.yellow, |
|
number: chalk.magenta, |
|
string: chalk.green, |
|
regex: chalk.magenta, |
|
comment: chalk.grey, |
|
invalid: chalk.white.bgRed.bold, |
|
gutter: chalk.grey, |
|
marker: chalk.red.bold |
|
}; |
|
} |
|
|
|
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; |
|
var JSX_TAG = /^[a-z][\w-]*$/i; |
|
var BRACKET = /^[()[\]{}]$/; |
|
|
|
function getTokenType(match) { |
|
var _match$slice = match.slice(-2), |
|
offset = _match$slice[0], |
|
text = _match$slice[1]; |
|
|
|
var token = (0, _jsTokens.matchToToken)(match); |
|
|
|
if (token.type === "name") { |
|
if (_esutils.default.keyword.isReservedWordES6(token.value)) { |
|
return "keyword"; |
|
} |
|
|
|
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { |
|
return "jsx_tag"; |
|
} |
|
|
|
if (token.value[0] !== token.value[0].toLowerCase()) { |
|
return "capitalized"; |
|
} |
|
} |
|
|
|
if (token.type === "punctuator" && BRACKET.test(token.value)) { |
|
return "bracket"; |
|
} |
|
|
|
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) { |
|
return "punctuator"; |
|
} |
|
|
|
return token.type; |
|
} |
|
|
|
function highlight(defs, text) { |
|
return text.replace(_jsTokens.default, function () { |
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
|
args[_key] = arguments[_key]; |
|
} |
|
|
|
var type = getTokenType(args); |
|
var colorize = defs[type]; |
|
|
|
if (colorize) { |
|
return args[0].split(NEWLINE).map(function (str) { |
|
return colorize(str); |
|
}).join("\n"); |
|
} else { |
|
return args[0]; |
|
} |
|
}); |
|
} |
|
|
|
function getMarkerLines(loc, source, opts) { |
|
var startLoc = Object.assign({}, { |
|
column: 0, |
|
line: -1 |
|
}, loc.start); |
|
var endLoc = Object.assign({}, startLoc, loc.end); |
|
var linesAbove = opts.linesAbove || 2; |
|
var linesBelow = opts.linesBelow || 3; |
|
var startLine = startLoc.line; |
|
var startColumn = startLoc.column; |
|
var endLine = endLoc.line; |
|
var endColumn = endLoc.column; |
|
var start = Math.max(startLine - (linesAbove + 1), 0); |
|
var end = Math.min(source.length, endLine + linesBelow); |
|
|
|
if (startLine === -1) { |
|
start = 0; |
|
} |
|
|
|
if (endLine === -1) { |
|
end = source.length; |
|
} |
|
|
|
var lineDiff = endLine - startLine; |
|
var markerLines = {}; |
|
|
|
if (lineDiff) { |
|
for (var i = 0; i <= lineDiff; i++) { |
|
var lineNumber = i + startLine; |
|
|
|
if (!startColumn) { |
|
markerLines[lineNumber] = true; |
|
} else if (i === 0) { |
|
var sourceLength = source[lineNumber - 1].length; |
|
markerLines[lineNumber] = [startColumn, sourceLength - startColumn]; |
|
} else if (i === lineDiff) { |
|
markerLines[lineNumber] = [0, endColumn]; |
|
} else { |
|
var _sourceLength = source[lineNumber - i].length; |
|
markerLines[lineNumber] = [0, _sourceLength]; |
|
} |
|
} |
|
} else { |
|
if (startColumn === endColumn) { |
|
if (startColumn) { |
|
markerLines[startLine] = [startColumn, 0]; |
|
} else { |
|
markerLines[startLine] = true; |
|
} |
|
} else { |
|
markerLines[startLine] = [startColumn, endColumn - startColumn]; |
|
} |
|
} |
|
|
|
return { |
|
start: start, |
|
end: end, |
|
markerLines: markerLines |
|
}; |
|
} |
|
|
|
function codeFrameColumns(rawLines, loc, opts) { |
|
if (opts === void 0) { |
|
opts = {}; |
|
} |
|
|
|
var highlighted = opts.highlightCode && _chalk.default.supportsColor || opts.forceColor; |
|
var chalk = _chalk.default; |
|
|
|
if (opts.forceColor) { |
|
chalk = new _chalk.default.constructor({ |
|
enabled: true |
|
}); |
|
} |
|
|
|
var maybeHighlight = function maybeHighlight(chalkFn, string) { |
|
return highlighted ? chalkFn(string) : string; |
|
}; |
|
|
|
var defs = getDefs(chalk); |
|
if (highlighted) rawLines = highlight(defs, rawLines); |
|
var lines = rawLines.split(NEWLINE); |
|
|
|
var _getMarkerLines = getMarkerLines(loc, lines, opts), |
|
start = _getMarkerLines.start, |
|
end = _getMarkerLines.end, |
|
markerLines = _getMarkerLines.markerLines; |
|
|
|
var numberMaxWidth = String(end).length; |
|
var frame = lines.slice(start, end).map(function (line, index) { |
|
var number = start + 1 + index; |
|
var paddedNumber = (" " + number).slice(-numberMaxWidth); |
|
var gutter = " " + paddedNumber + " | "; |
|
var hasMarker = markerLines[number]; |
|
|
|
if (hasMarker) { |
|
var markerLine = ""; |
|
|
|
if (Array.isArray(hasMarker)) { |
|
var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); |
|
var numberOfMarkers = hasMarker[1] || 1; |
|
markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); |
|
} |
|
|
|
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join(""); |
|
} else { |
|
return " " + maybeHighlight(defs.gutter, gutter) + line; |
|
} |
|
}).join("\n"); |
|
|
|
if (highlighted) { |
|
return chalk.reset(frame); |
|
} else { |
|
return frame; |
|
} |
|
} |
|
|
|
function _default(rawLines, lineNumber, colNumber, opts) { |
|
if (opts === void 0) { |
|
opts = {}; |
|
} |
|
|
|
if (!deprecationWarningShown) { |
|
deprecationWarningShown = true; |
|
var deprecationError = new Error("Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."); |
|
deprecationError.name = "DeprecationWarning"; |
|
|
|
if (process$3.emitWarning) { |
|
process$3.emitWarning(deprecationError); |
|
} else { |
|
console.warn(deprecationError); |
|
} |
|
} |
|
|
|
colNumber = Math.max(colNumber, 0); |
|
var location = { |
|
start: { |
|
column: colNumber, |
|
line: lineNumber |
|
} |
|
}; |
|
return codeFrameColumns(rawLines, location, opts); |
|
} |
|
}); |
|
|
|
unwrapExports(lib$1); |
|
var lib_1$1 = lib$1.codeFrameColumns; |
|
|
|
var stackUtils = createCommonjsModule(function (module) { |
|
module.exports = StackUtils; |
|
|
|
function StackUtils(opts) { |
|
if (!(this instanceof StackUtils)) { |
|
throw new Error('StackUtils constructor must be called with new'); |
|
} |
|
opts = opts || {}; |
|
this._cwd = (opts.cwd || process$3.cwd()).replace(/\\/g, '/'); |
|
this._internals = opts.internals || []; |
|
this._wrapCallSite = opts.wrapCallSite || false; |
|
} |
|
|
|
module.exports.nodeInternals = nodeInternals; |
|
|
|
function nodeInternals() { |
|
if (!module.exports.natives) { |
|
module.exports.natives = Object.keys(process$3.binding('natives')); |
|
module.exports.natives.push('bootstrap_node', 'node'); |
|
} |
|
|
|
return module.exports.natives.map(function (n) { |
|
return new RegExp('\\(' + n + '\\.js:\\d+:\\d+\\)$'); |
|
}).concat([ |
|
/\s*at (bootstrap_)?node\.js:\d+:\d+?$/, |
|
/\/\.node-spawn-wrap-\w+-\w+\/node:\d+:\d+\)?$/ |
|
]); |
|
} |
|
|
|
StackUtils.prototype.clean = function (stack) { |
|
if (!Array.isArray(stack)) { |
|
stack = stack.split('\n'); |
|
} |
|
|
|
if (!(/^\s*at /.test(stack[0])) && |
|
(/^\s*at /.test(stack[1]))) { |
|
stack = stack.slice(1); |
|
} |
|
|
|
var outdent = false; |
|
var lastNonAtLine = null; |
|
var result = []; |
|
|
|
stack.forEach(function (st) { |
|
st = st.replace(/\\/g, '/'); |
|
var isInternal = this._internals.some(function (internal) { |
|
return internal.test(st); |
|
}); |
|
|
|
if (isInternal) { |
|
return null; |
|
} |
|
|
|
var isAtLine = /^\s*at /.test(st); |
|
|
|
if (outdent) { |
|
st = st.replace(/\s+$/, '').replace(/^(\s+)at /, '$1'); |
|
} else { |
|
st = st.trim(); |
|
if (isAtLine) { |
|
st = st.substring(3); |
|
} |
|
} |
|
|
|
st = st.replace(this._cwd + '/', ''); |
|
|
|
if (st) { |
|
if (isAtLine) { |
|
if (lastNonAtLine) { |
|
result.push(lastNonAtLine); |
|
lastNonAtLine = null; |
|
} |
|
result.push(st); |
|
} else { |
|
outdent = true; |
|
lastNonAtLine = st; |
|
} |
|
} |
|
}, this); |
|
|
|
stack = result.join('\n').trim(); |
|
|
|
if (stack) { |
|
return stack + '\n'; |
|
} |
|
return ''; |
|
}; |
|
|
|
StackUtils.prototype.captureString = function (limit, fn) { |
|
if (typeof limit === 'function') { |
|
fn = limit; |
|
limit = Infinity; |
|
} |
|
if (!fn) { |
|
fn = this.captureString; |
|
} |
|
|
|
var limitBefore = Error.stackTraceLimit; |
|
if (limit) { |
|
Error.stackTraceLimit = limit; |
|
} |
|
|
|
var obj = {}; |
|
|
|
Error.captureStackTrace(obj, fn); |
|
var stack = obj.stack; |
|
Error.stackTraceLimit = limitBefore; |
|
|
|
return this.clean(stack); |
|
}; |
|
|
|
StackUtils.prototype.capture = function (limit, fn) { |
|
if (typeof limit === 'function') { |
|
fn = limit; |
|
limit = Infinity; |
|
} |
|
if (!fn) { |
|
fn = this.capture; |
|
} |
|
var prepBefore = Error.prepareStackTrace; |
|
var limitBefore = Error.stackTraceLimit; |
|
var wrapCallSite = this._wrapCallSite; |
|
|
|
Error.prepareStackTrace = function (obj, site) { |
|
if (wrapCallSite) { |
|
return site.map(wrapCallSite); |
|
} |
|
return site; |
|
}; |
|
|
|
if (limit) { |
|
Error.stackTraceLimit = limit; |
|
} |
|
|
|
var obj = {}; |
|
Error.captureStackTrace(obj, fn); |
|
var stack = obj.stack; |
|
Error.prepareStackTrace = prepBefore; |
|
Error.stackTraceLimit = limitBefore; |
|
|
|
return stack; |
|
}; |
|
|
|
StackUtils.prototype.at = function at(fn) { |
|
if (!fn) { |
|
fn = at; |
|
} |
|
|
|
var site = this.capture(1, fn)[0]; |
|
|
|
if (!site) { |
|
return {}; |
|
} |
|
|
|
var res = { |
|
line: site.getLineNumber(), |
|
column: site.getColumnNumber() |
|
}; |
|
|
|
this._setFile(res, site.getFileName()); |
|
|
|
if (site.isConstructor()) { |
|
res.constructor = true; |
|
} |
|
|
|
if (site.isEval()) { |
|
res.evalOrigin = site.getEvalOrigin(); |
|
} |
|
|
|
if (site.isNative()) { |
|
res.native = true; |
|
} |
|
|
|
var typename = null; |
|
try { |
|
typename = site.getTypeName(); |
|
} catch (er) {} |
|
|
|
if (typename && |
|
typename !== 'Object' && |
|
typename !== '[object Object]') { |
|
res.type = typename; |
|
} |
|
|
|
var fname = site.getFunctionName(); |
|
if (fname) { |
|
res.function = fname; |
|
} |
|
|
|
var meth = site.getMethodName(); |
|
if (meth && fname !== meth) { |
|
res.method = meth; |
|
} |
|
|
|
return res; |
|
}; |
|
|
|
StackUtils.prototype._setFile = function (result, filename) { |
|
if (filename) { |
|
filename = filename.replace(/\\/g, '/'); |
|
if ((filename.indexOf(this._cwd + '/') === 0)) { |
|
filename = filename.substr(this._cwd.length + 1); |
|
} |
|
result.file = filename; |
|
} |
|
}; |
|
|
|
var re = new RegExp( |
|
'^' + |
|
// Sometimes we strip out the ' at' because it's noisy |
|
'(?:\\s*at )?' + |
|
// $1 = ctor if 'new' |
|
'(?:(new) )?' + |
|
// $2 = function name (can be literally anything) |
|
// May contain method at the end as [as xyz] |
|
'(?:(.*?) \\()?' + |
|
// (eval at <anonymous> (file.js:1:1), |
|
// $3 = eval origin |
|
// $4:$5:$6 are eval file/line/col, but not normally reported |
|
'(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' + |
|
// file:line:col |
|
// $7:$8:$9 |
|
// $10 = 'native' if native |
|
'(?:(.+?):(\\d+):(\\d+)|(native))' + |
|
// maybe close the paren, then end |
|
// if $11 is ), then we only allow balanced parens in the filename |
|
// any imbalance is placed on the fname. This is a heuristic, and |
|
// bound to be incorrect in some edge cases. The bet is that |
|
// having weird characters in method names is more common than |
|
// having weird characters in filenames, which seems reasonable. |
|
'(\\)?)$' |
|
); |
|
|
|
var methodRe = /^(.*?) \[as (.*?)\]$/; |
|
|
|
StackUtils.prototype.parseLine = function parseLine(line) { |
|
var match = line && line.match(re); |
|
if (!match) { |
|
return null; |
|
} |
|
|
|
var ctor = match[1] === 'new'; |
|
var fname = match[2]; |
|
var evalOrigin = match[3]; |
|
var evalFile = match[4]; |
|
var evalLine = Number(match[5]); |
|
var evalCol = Number(match[6]); |
|
var file = match[7]; |
|
var lnum = match[8]; |
|
var col = match[9]; |
|
var native = match[10] === 'native'; |
|
var closeParen = match[11] === ')'; |
|
|
|
var res = {}; |
|
|
|
if (lnum) { |
|
res.line = Number(lnum); |
|
} |
|
|
|
if (col) { |
|
res.column = Number(col); |
|
} |
|
|
|
if (closeParen && file) { |
|
// make sure parens are balanced |
|
// if we have a file like "asdf) [as foo] (xyz.js", then odds are |
|
// that the fname should be += " (asdf) [as foo]" and the file |
|
// should be just "xyz.js" |
|
// walk backwards from the end to find the last unbalanced ( |
|
var closes = 0; |
|
for (var i = file.length - 1; i > 0; i--) { |
|
if (file.charAt(i) === ')') { |
|
closes ++; |
|
} else if (file.charAt(i) === '(' && file.charAt(i - 1) === ' ') { |
|
closes --; |
|
if (closes === -1 && file.charAt(i - 1) === ' ') { |
|
var before = file.substr(0, i - 1); |
|
var after = file.substr(i + 1); |
|
file = after; |
|
fname += ' (' + before; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (fname) { |
|
var methodMatch = fname.match(methodRe); |
|
if (methodMatch) { |
|
fname = methodMatch[1]; |
|
var meth = methodMatch[2]; |
|
} |
|
} |
|
|
|
this._setFile(res, file); |
|
|
|
if (ctor) { |
|
res.constructor = true; |
|
} |
|
|
|
if (evalOrigin) { |
|
res.evalOrigin = evalOrigin; |
|
res.evalLine = evalLine; |
|
res.evalColumn = evalCol; |
|
res.evalFile = evalFile && evalFile.replace(/\\/g, '/'); |
|
} |
|
|
|
if (native) { |
|
res.native = true; |
|
} |
|
|
|
if (fname) { |
|
res.function = fname; |
|
} |
|
|
|
if (meth && fname !== meth) { |
|
res.method = meth; |
|
} |
|
|
|
return res; |
|
}; |
|
|
|
var bound = new StackUtils(); |
|
|
|
Object.keys(StackUtils.prototype).forEach(function (key) { |
|
StackUtils[key] = bound[key].bind(bound); |
|
}); |
|
}); |
|
|
|
var stackUtils_1 = stackUtils.nodeInternals; |
|
var stackUtils_2 = stackUtils.natives; |
|
|
|
var _fs = ( empty$2 && empty$1 ) || empty$2; |
|
|
|
var build$5 = createCommonjsModule(function (module, exports) { |
|
Object.defineProperty(exports, "__esModule", { |
|
value: true |
|
}); |
|
exports.separateMessageFromStack = exports.formatResultsErrors = exports.formatStackTrace = exports.formatExecError = undefined; |
|
|
|
var _fs2 = _interopRequireDefault(_fs); |
|
|
|
var _path2 = _interopRequireDefault(path$2); |
|
|
|
var _chalk2 = _interopRequireDefault(fake_chalk); |
|
|
|
var _micromatch2 = _interopRequireDefault(micromatch_1); |
|
|
|
var _slash2 = _interopRequireDefault(slash); |
|
|
|
var _stackUtils2 = _interopRequireDefault(stackUtils); |
|
|
|
function _interopRequireDefault(obj) { |
|
return obj && obj.__esModule ? obj : { default: obj }; |
|
} |
|
|
|
// stack utils tries to create pretty stack by making paths relative. |
|
var stackUtils$$1 = new _stackUtils2.default({ |
|
cwd: 'something which does not exist' |
|
}); /** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var nodeInternals = []; |
|
|
|
try { |
|
nodeInternals = _stackUtils2.default.nodeInternals() |
|
// this is to have the tests be the same in node 4 and node 6. |
|
// TODO: Remove when we drop support for node 4 |
|
.concat(new RegExp('internal/process/next_tick.js')); |
|
} catch (e) { |
|
// `StackUtils.nodeInternals()` fails in browsers. We don't need to remove |
|
// node internals in the browser though, so no issue. |
|
} |
|
|
|
var PATH_NODE_MODULES = _path2.default.sep + 'node_modules' + _path2.default.sep; |
|
var PATH_EXPECT_BUILD = _path2.default.sep + 'expect' + _path2.default.sep + 'build' + _path2.default.sep; |
|
|
|
// filter for noisy stack trace lines |
|
var JASMINE_IGNORE = /^\s+at(?:(?:.*?vendor\/|jasmine\-)|\s+jasmine\.buildExpectationResult)/; |
|
var JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/; |
|
var ANONYMOUS_FN_IGNORE = /^\s+at <anonymous>.*$/; |
|
var ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/; |
|
var ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/; |
|
var NATIVE_NEXT_IGNORE = /^\s+at next \(native\).*$/; |
|
var TITLE_INDENT = ' '; |
|
var MESSAGE_INDENT = ' '; |
|
var STACK_INDENT = ' '; |
|
var ANCESTRY_SEPARATOR = ' \u203A '; |
|
var TITLE_BULLET = _chalk2.default.bold('\u25CF '); |
|
var STACK_TRACE_COLOR = _chalk2.default.dim; |
|
var STACK_PATH_REGEXP = /\s*at.*\(?(\:\d*\:\d*|native)\)?/; |
|
var EXEC_ERROR_MESSAGE = 'Test suite failed to run'; |
|
var ERROR_TEXT = 'Error: '; |
|
|
|
var trim = function trim(string) { |
|
return (string || '').trim(); |
|
}; |
|
|
|
// Some errors contain not only line numbers in stack traces |
|
// e.g. SyntaxErrors can contain snippets of code, and we don't |
|
// want to trim those, because they may have pointers to the column/character |
|
// which will get misaligned. |
|
var trimPaths = function trimPaths(string) { |
|
return string.match(STACK_PATH_REGEXP) ? trim(string) : string; |
|
}; |
|
|
|
var getRenderedCallsite = function getRenderedCallsite(fileContent, line) { |
|
var renderedCallsite = (0, lib$1.codeFrameColumns)(fileContent, { start: { line: line } }, { highlightCode: true }); |
|
|
|
renderedCallsite = renderedCallsite.split('\n').map(function (line) { |
|
return MESSAGE_INDENT + line; |
|
}).join('\n'); |
|
|
|
renderedCallsite = '\n' + renderedCallsite + '\n'; |
|
return renderedCallsite; |
|
}; |
|
|
|
// ExecError is an error thrown outside of the test suite (not inside an `it` or |
|
// `before/after each` hooks). If it's thrown, none of the tests in the file |
|
// are executed. |
|
var formatExecError = exports.formatExecError = function (testResult, config, options, testPath) { |
|
var error = testResult.testExecError; |
|
if (!error || typeof error === 'number') { |
|
error = new Error('Expected an Error, but "' + String(error) + '" was thrown'); |
|
error.stack = ''; |
|
} |
|
|
|
var _error = error; |
|
var message = _error.message, |
|
stack = _error.stack; |
|
|
|
if (typeof error === 'string' || !error) { |
|
error || (error = 'EMPTY ERROR'); |
|
message = ''; |
|
stack = error; |
|
} |
|
|
|
var separated = separateMessageFromStack(stack || ''); |
|
stack = separated.stack; |
|
|
|
if (separated.message.indexOf(trim(message)) !== -1) { |
|
// Often stack trace already contains the duplicate of the message |
|
message = separated.message; |
|
} |
|
|
|
message = message.split(/\n/).map(function (line) { |
|
return MESSAGE_INDENT + line; |
|
}).join('\n'); |
|
stack = stack && !options.noStackTrace ? '\n' + formatStackTrace(stack, config, options, testPath) : ''; |
|
|
|
if (message.match(/^\s*$/) && stack.match(/^\s*$/)) { |
|
// this can happen if an empty object is thrown. |
|
message = MESSAGE_INDENT + 'Error: No message was provided'; |
|
} |
|
|
|
return TITLE_INDENT + TITLE_BULLET + EXEC_ERROR_MESSAGE + '\n\n' + message + stack + '\n'; |
|
}; |
|
|
|
var removeInternalStackEntries = function removeInternalStackEntries(lines, options) { |
|
var pathCounter = 0; |
|
|
|
return lines.filter(function (line) { |
|
if (ANONYMOUS_FN_IGNORE.test(line)) { |
|
return false; |
|
} |
|
|
|
if (ANONYMOUS_PROMISE_IGNORE.test(line)) { |
|
return false; |
|
} |
|
|
|
if (ANONYMOUS_GENERATOR_IGNORE.test(line)) { |
|
return false; |
|
} |
|
|
|
if (NATIVE_NEXT_IGNORE.test(line)) { |
|
return false; |
|
} |
|
|
|
if (nodeInternals.some(function (internal) { |
|
return internal.test(line); |
|
})) { |
|
return false; |
|
} |
|
|
|
if (!STACK_PATH_REGEXP.test(line)) { |
|
return true; |
|
} |
|
|
|
if (JASMINE_IGNORE.test(line)) { |
|
return false; |
|
} |
|
|
|
if (++pathCounter === 1) { |
|
return true; // always keep the first line even if it's from Jest |
|
} |
|
|
|
if (options.noStackTrace) { |
|
return false; |
|
} |
|
|
|
if (JEST_INTERNALS_IGNORE.test(line)) { |
|
return false; |
|
} |
|
|
|
return true; |
|
}); |
|
}; |
|
|
|
var formatPaths = function formatPaths(config, options, relativeTestPath, line) { |
|
// Extract the file path from the trace line. |
|
var match = line.match(/(^\s*at .*?\(?)([^()]+)(:[0-9]+:[0-9]+\)?.*$)/); |
|
if (!match) { |
|
return line; |
|
} |
|
|
|
var filePath = (0, _slash2.default)(_path2.default.relative(config.rootDir, match[2])); |
|
// highlight paths from the current test file |
|
if (config.testMatch && config.testMatch.length && (0, _micromatch2.default)(filePath, config.testMatch) || filePath === relativeTestPath) { |
|
filePath = _chalk2.default.reset.cyan(filePath); |
|
} |
|
return STACK_TRACE_COLOR(match[1]) + filePath + STACK_TRACE_COLOR(match[3]); |
|
}; |
|
|
|
var getTopFrame = function getTopFrame(lines) { |
|
var _iteratorNormalCompletion = true; |
|
var _didIteratorError = false; |
|
var _iteratorError = undefined; |
|
|
|
try { |
|
for (var _iterator = _getIterator(lines), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
|
var line = _step.value; |
|
|
|
if (line.includes(PATH_NODE_MODULES) || line.includes(PATH_EXPECT_BUILD)) { |
|
continue; |
|
} |
|
|
|
var parsedFrame = stackUtils$$1.parseLine(line.trim()); |
|
|
|
if (parsedFrame && parsedFrame.file) { |
|
return parsedFrame; |
|
} |
|
} |
|
} catch (err) { |
|
_didIteratorError = true; |
|
_iteratorError = err; |
|
} finally { |
|
try { |
|
if (!_iteratorNormalCompletion && _iterator.return) { |
|
_iterator.return(); |
|
} |
|
} finally { |
|
if (_didIteratorError) { |
|
throw _iteratorError; |
|
} |
|
} |
|
} |
|
|
|
return null; |
|
}; |
|
|
|
var formatStackTrace = exports.formatStackTrace = function (stack, config, options, testPath) { |
|
var lines = stack.split(/\n/); |
|
var renderedCallsite = ''; |
|
var relativeTestPath = testPath ? (0, _slash2.default)(_path2.default.relative(config.rootDir, testPath)) : null; |
|
lines = removeInternalStackEntries(lines, options); |
|
|
|
var topFrame = getTopFrame(lines); |
|
|
|
if (topFrame) { |
|
var filename = topFrame.file; |
|
|
|
if (_path2.default.isAbsolute(filename)) { |
|
var fileContent = void 0; |
|
try { |
|
// TODO: check & read HasteFS instead of reading the filesystem: |
|
// see: https://github.com/facebook/jest/pull/5405#discussion_r164281696 |
|
fileContent = _fs2.default.readFileSync(filename, 'utf8'); |
|
renderedCallsite = getRenderedCallsite(fileContent, topFrame.line); |
|
} catch (e) { |
|
// the file does not exist or is inaccessible, we ignore |
|
} |
|
} |
|
} |
|
|
|
var stacktrace = lines.map(function (line) { |
|
return STACK_INDENT + formatPaths(config, options, relativeTestPath, trimPaths(line)); |
|
}).join('\n'); |
|
|
|
return renderedCallsite + stacktrace; |
|
}; |
|
|
|
var formatResultsErrors = exports.formatResultsErrors = function (testResults, config, options, testPath) { |
|
var failedResults = testResults.reduce(function (errors, result) { |
|
result.failureMessages.forEach(function (content) { |
|
return errors.push({ content: content, result: result }); |
|
}); |
|
return errors; |
|
}, []); |
|
|
|
if (!failedResults.length) { |
|
return null; |
|
} |
|
|
|
return failedResults.map(function (_ref) { |
|
var result = _ref.result, |
|
content = _ref.content; |
|
|
|
var _separateMessageFromS = separateMessageFromStack(content); |
|
|
|
var message = _separateMessageFromS.message, |
|
stack = _separateMessageFromS.stack; |
|
|
|
stack = options.noStackTrace ? '' : STACK_TRACE_COLOR(formatStackTrace(stack, config, options, testPath)) + '\n'; |
|
|
|
message = message.split(/\n/).map(function (line) { |
|
return MESSAGE_INDENT + line; |
|
}).join('\n'); |
|
|
|
var title = _chalk2.default.bold.red(TITLE_INDENT + TITLE_BULLET + result.ancestorTitles.join(ANCESTRY_SEPARATOR) + (result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') + result.title) + '\n'; |
|
|
|
return title + '\n' + message + '\n' + stack; |
|
}).join('\n'); |
|
}; |
|
|
|
// jasmine and worker farm sometimes don't give us access to the actual |
|
// Error object, so we have to regexp out the message from the stack string |
|
// to format it. |
|
var separateMessageFromStack = exports.separateMessageFromStack = function (content) { |
|
if (!content) { |
|
return { message: '', stack: '' }; |
|
} |
|
|
|
var messageMatch = content.match(/(^(.|\n)*?(?=\n\s*at\s.*\:\d*\:\d*))/); |
|
var message = messageMatch ? messageMatch[0] : 'Error'; |
|
var stack = messageMatch ? content.slice(message.length) : content; |
|
// If the error is a plain error instead of a SyntaxError or TypeError |
|
// we remove it from the message because it is generally not useful. |
|
if (message.startsWith(ERROR_TEXT)) { |
|
message = message.substr(ERROR_TEXT.length); |
|
} |
|
return { message: message, stack: stack }; |
|
}; |
|
}); |
|
|
|
unwrapExports(build$5); |
|
var build_1$2 = build$5.separateMessageFromStack; |
|
var build_2$2 = build$5.formatResultsErrors; |
|
var build_3$2 = build$5.formatStackTrace; |
|
var build_4$1 = build$5.formatExecError; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var createMatcher = function createMatcher(matcherName, fromPromise) { |
|
return function (actual, expected) { |
|
var value = expected; |
|
var error = void 0; |
|
|
|
if (fromPromise) { |
|
error = actual; |
|
} else { |
|
if (typeof actual !== 'function') { |
|
throw new Error(build_1(matcherName, 'function', build$1(value)) + '\n\n' + 'Received value must be a function, but instead ' + ('"' + build$1(actual) + '" was found')); |
|
} |
|
try { |
|
actual(); |
|
} catch (e) { |
|
error = e; |
|
} |
|
} |
|
|
|
if (typeof expected === 'string') { |
|
expected = new RegExp(build_2$1(expected)); |
|
} |
|
|
|
if (typeof expected === 'function') { |
|
return toThrowMatchingError(matcherName, error, expected); |
|
} else if (expected instanceof RegExp) { |
|
return toThrowMatchingStringOrRegexp(matcherName, error, expected, value); |
|
} else if (expected && (typeof expected === 'undefined' ? 'undefined' : _typeof(expected)) === 'object') { |
|
return toThrowMatchingErrorInstance(matcherName, error, expected); |
|
} else if (expected === undefined) { |
|
var pass = error !== undefined; |
|
return { |
|
message: pass ? function () { |
|
return build_1('.not' + matcherName, 'function', '') + '\n\n' + 'Expected the function not to throw an error.\n' + printActualErrorMessage(error); |
|
} : function () { |
|
return build_1(matcherName, 'function', build$1(value)) + '\n\n' + 'Expected the function to throw an error.\n' + printActualErrorMessage(error); |
|
}, |
|
pass: pass |
|
}; |
|
} else { |
|
throw new Error(build_1('.not' + matcherName, 'function', build$1(value)) + '\n\n' + 'Unexpected argument passed.\nExpected: ' + (build_8('string') + ', ' + build_8('Error (type)') + ' or ' + build_8('regexp') + '.\n') + build_7('Got', String(expected), build_8)); |
|
} |
|
}; |
|
}; |
|
|
|
var matchers$2 = { |
|
toThrow: createMatcher('.toThrow'), |
|
toThrowError: createMatcher('.toThrowError') |
|
}; |
|
|
|
var toThrowMatchingStringOrRegexp = function toThrowMatchingStringOrRegexp(name, error, pattern, value) { |
|
if (error && !error.message && !error.name) { |
|
error = new Error(error); |
|
} |
|
|
|
var pass = !!(error && error.message.match(pattern)); |
|
var message = pass ? function () { |
|
return build_1('.not' + name, 'function', build$1(value)) + '\n\n' + 'Expected the function not to throw an error matching:\n' + (' ' + build_8(value) + '\n') + printActualErrorMessage(error); |
|
} : function () { |
|
return build_1(name, 'function', build$1(value)) + '\n\n' + 'Expected the function to throw an error matching:\n' + (' ' + build_8(value) + '\n') + printActualErrorMessage(error); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}; |
|
|
|
var toThrowMatchingErrorInstance = function toThrowMatchingErrorInstance(name, error, expectedError) { |
|
if (error && !error.message && !error.name) { |
|
error = new Error(error); |
|
} |
|
|
|
var pass = equals(error, expectedError); |
|
var message = pass ? function () { |
|
return build_1('.not' + name, 'function', 'error') + '\n\n' + 'Expected the function not to throw an error matching:\n' + (' ' + build_8(expectedError) + '\n') + printActualErrorMessage(error); |
|
} : function () { |
|
return build_1(name, 'function', 'error') + '\n\n' + 'Expected the function to throw an error matching:\n' + (' ' + build_8(expectedError) + '\n') + printActualErrorMessage(error); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}; |
|
|
|
var toThrowMatchingError = function toThrowMatchingError(name, error, ErrorClass) { |
|
var pass = !!(error && error instanceof ErrorClass); |
|
var message = pass ? function () { |
|
return build_1('.not' + name, 'function', 'type') + '\n\n' + 'Expected the function not to throw an error of type:\n' + (' ' + build_8(ErrorClass.name) + '\n') + printActualErrorMessage(error); |
|
} : function () { |
|
return build_1(name, 'function', 'type') + '\n\n' + 'Expected the function to throw an error of type:\n' + (' ' + build_8(ErrorClass.name) + '\n') + printActualErrorMessage(error); |
|
}; |
|
|
|
return { message: message, pass: pass }; |
|
}; |
|
|
|
var printActualErrorMessage = function printActualErrorMessage(error) { |
|
if (error) { |
|
var _separateMessageFromS = build_1$2(error.stack), |
|
message = _separateMessageFromS.message, |
|
stack = _separateMessageFromS.stack; |
|
|
|
return 'Instead, it threw:\n' + build_13(' ' + build_10(message) + build_3$2(stack, { |
|
rootDir: process$3.cwd(), |
|
testMatch: [] |
|
}, { |
|
noStackTrace: false |
|
})); |
|
} |
|
|
|
return 'But it didn\'t throw anything.'; |
|
}; |
|
|
|
var createClass = createCommonjsModule(function (module, exports) { |
|
exports.__esModule = true; |
|
|
|
|
|
|
|
var _defineProperty2 = _interopRequireDefault(defineProperty$2); |
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
exports.default = function () { |
|
function defineProperties(target, props) { |
|
for (var i = 0; i < props.length; i++) { |
|
var descriptor = props[i]; |
|
descriptor.enumerable = descriptor.enumerable || false; |
|
descriptor.configurable = true; |
|
if ("value" in descriptor) descriptor.writable = true; |
|
(0, _defineProperty2.default)(target, descriptor.key, descriptor); |
|
} |
|
} |
|
|
|
return function (Constructor, protoProps, staticProps) { |
|
if (protoProps) defineProperties(Constructor.prototype, protoProps); |
|
if (staticProps) defineProperties(Constructor, staticProps); |
|
return Constructor; |
|
}; |
|
}(); |
|
}); |
|
|
|
var _createClass = unwrapExports(createClass); |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var AsymmetricMatcher = function AsymmetricMatcher() { |
|
_classCallCheck(this, AsymmetricMatcher); |
|
|
|
this.$$typeof = _Symbol$for('jest.asymmetricMatcher'); |
|
}; |
|
|
|
var Any = function (_AsymmetricMatcher) { |
|
_inherits(Any, _AsymmetricMatcher); |
|
|
|
function Any(sample) { |
|
_classCallCheck(this, Any); |
|
|
|
var _this = _possibleConstructorReturn(this, (Any.__proto__ || _Object$getPrototypeOf(Any)).call(this)); |
|
|
|
if (typeof sample === 'undefined') { |
|
throw new TypeError('any() expects to be passed a constructor function. ' + 'Please pass one or use anything() to match any object.'); |
|
} |
|
_this.sample = sample; |
|
return _this; |
|
} |
|
|
|
_createClass(Any, [{ |
|
key: 'asymmetricMatch', |
|
value: function asymmetricMatch(other) { |
|
if (this.sample == String) { |
|
return typeof other == 'string' || other instanceof String; |
|
} |
|
|
|
if (this.sample == Number) { |
|
return typeof other == 'number' || other instanceof Number; |
|
} |
|
|
|
if (this.sample == Function) { |
|
return typeof other == 'function' || other instanceof Function; |
|
} |
|
|
|
if (this.sample == Object) { |
|
return (typeof other === 'undefined' ? 'undefined' : _typeof(other)) == 'object'; |
|
} |
|
|
|
if (this.sample == Boolean) { |
|
return typeof other == 'boolean'; |
|
} |
|
|
|
return other instanceof this.sample; |
|
} |
|
}, { |
|
key: 'toString', |
|
value: function toString() { |
|
return 'Any'; |
|
} |
|
}, { |
|
key: 'getExpectedType', |
|
value: function getExpectedType() { |
|
if (this.sample == String) { |
|
return 'string'; |
|
} |
|
|
|
if (this.sample == Number) { |
|
return 'number'; |
|
} |
|
|
|
if (this.sample == Function) { |
|
return 'function'; |
|
} |
|
|
|
if (this.sample == Object) { |
|
return 'object'; |
|
} |
|
|
|
if (this.sample == Boolean) { |
|
return 'boolean'; |
|
} |
|
|
|
return fnNameFor(this.sample); |
|
} |
|
}, { |
|
key: 'toAsymmetricMatcher', |
|
value: function toAsymmetricMatcher() { |
|
return 'Any<' + fnNameFor(this.sample) + '>'; |
|
} |
|
}]); |
|
|
|
return Any; |
|
}(AsymmetricMatcher); |
|
|
|
var Anything = function (_AsymmetricMatcher2) { |
|
_inherits(Anything, _AsymmetricMatcher2); |
|
|
|
function Anything() { |
|
_classCallCheck(this, Anything); |
|
|
|
return _possibleConstructorReturn(this, (Anything.__proto__ || _Object$getPrototypeOf(Anything)).apply(this, arguments)); |
|
} |
|
|
|
_createClass(Anything, [{ |
|
key: 'asymmetricMatch', |
|
value: function asymmetricMatch(other) { |
|
return !isUndefined(other) && other !== null; |
|
} |
|
}, { |
|
key: 'toString', |
|
value: function toString() { |
|
return 'Anything'; |
|
} |
|
|
|
// No getExpectedType method, because it matches either null or undefined. |
|
|
|
}, { |
|
key: 'toAsymmetricMatcher', |
|
value: function toAsymmetricMatcher() { |
|
return 'Anything'; |
|
} |
|
}]); |
|
|
|
return Anything; |
|
}(AsymmetricMatcher); |
|
|
|
var ArrayContaining = function (_AsymmetricMatcher3) { |
|
_inherits(ArrayContaining, _AsymmetricMatcher3); |
|
|
|
function ArrayContaining(sample) { |
|
_classCallCheck(this, ArrayContaining); |
|
|
|
var _this3 = _possibleConstructorReturn(this, (ArrayContaining.__proto__ || _Object$getPrototypeOf(ArrayContaining)).call(this)); |
|
|
|
_this3.sample = sample; |
|
return _this3; |
|
} |
|
|
|
_createClass(ArrayContaining, [{ |
|
key: 'asymmetricMatch', |
|
value: function asymmetricMatch(other) { |
|
if (!Array.isArray(this.sample)) { |
|
throw new Error("You must provide an array to ArrayContaining, not '" + _typeof(this.sample) + "'."); |
|
} |
|
|
|
return this.sample.length === 0 || Array.isArray(other) && this.sample.every(function (item) { |
|
return other.some(function (another) { |
|
return equals(item, another); |
|
}); |
|
}); |
|
} |
|
}, { |
|
key: 'toString', |
|
value: function toString() { |
|
return 'ArrayContaining'; |
|
} |
|
}, { |
|
key: 'getExpectedType', |
|
value: function getExpectedType() { |
|
return 'array'; |
|
} |
|
}]); |
|
|
|
return ArrayContaining; |
|
}(AsymmetricMatcher); |
|
|
|
var ObjectContaining = function (_AsymmetricMatcher4) { |
|
_inherits(ObjectContaining, _AsymmetricMatcher4); |
|
|
|
function ObjectContaining(sample) { |
|
_classCallCheck(this, ObjectContaining); |
|
|
|
var _this4 = _possibleConstructorReturn(this, (ObjectContaining.__proto__ || _Object$getPrototypeOf(ObjectContaining)).call(this)); |
|
|
|
_this4.sample = sample; |
|
return _this4; |
|
} |
|
|
|
_createClass(ObjectContaining, [{ |
|
key: 'asymmetricMatch', |
|
value: function asymmetricMatch(other) { |
|
if (_typeof(this.sample) !== 'object') { |
|
throw new Error("You must provide an object to ObjectContaining, not '" + _typeof(this.sample) + "'."); |
|
} |
|
|
|
for (var property in this.sample) { |
|
if (!hasProperty(other, property) || !equals(this.sample[property], other[property])) { |
|
return false; |
|
} |
|
} |
|
|
|
return true; |
|
} |
|
}, { |
|
key: 'toString', |
|
value: function toString() { |
|
return 'ObjectContaining'; |
|
} |
|
}, { |
|
key: 'getExpectedType', |
|
value: function getExpectedType() { |
|
return 'object'; |
|
} |
|
}]); |
|
|
|
return ObjectContaining; |
|
}(AsymmetricMatcher); |
|
|
|
var StringContaining = function (_AsymmetricMatcher5) { |
|
_inherits(StringContaining, _AsymmetricMatcher5); |
|
|
|
function StringContaining(sample) { |
|
_classCallCheck(this, StringContaining); |
|
|
|
var _this5 = _possibleConstructorReturn(this, (StringContaining.__proto__ || _Object$getPrototypeOf(StringContaining)).call(this)); |
|
|
|
if (!isA('String', sample)) { |
|
throw new Error('Expected is not a string'); |
|
} |
|
_this5.sample = sample; |
|
return _this5; |
|
} |
|
|
|
_createClass(StringContaining, [{ |
|
key: 'asymmetricMatch', |
|
value: function asymmetricMatch(other) { |
|
if (!isA('String', other)) { |
|
return false; |
|
} |
|
|
|
return other.includes(this.sample); |
|
} |
|
}, { |
|
key: 'toString', |
|
value: function toString() { |
|
return 'StringContaining'; |
|
} |
|
}, { |
|
key: 'getExpectedType', |
|
value: function getExpectedType() { |
|
return 'string'; |
|
} |
|
}]); |
|
|
|
return StringContaining; |
|
}(AsymmetricMatcher); |
|
|
|
var StringMatching = function (_AsymmetricMatcher6) { |
|
_inherits(StringMatching, _AsymmetricMatcher6); |
|
|
|
function StringMatching(sample) { |
|
_classCallCheck(this, StringMatching); |
|
|
|
var _this6 = _possibleConstructorReturn(this, (StringMatching.__proto__ || _Object$getPrototypeOf(StringMatching)).call(this)); |
|
|
|
if (!isA('String', sample) && !isA('RegExp', sample)) { |
|
throw new Error('Expected is not a String or a RegExp'); |
|
} |
|
|
|
_this6.sample = new RegExp(sample); |
|
return _this6; |
|
} |
|
|
|
_createClass(StringMatching, [{ |
|
key: 'asymmetricMatch', |
|
value: function asymmetricMatch(other) { |
|
if (!isA('String', other)) { |
|
return false; |
|
} |
|
|
|
return this.sample.test(other); |
|
} |
|
}, { |
|
key: 'toString', |
|
value: function toString() { |
|
return 'StringMatching'; |
|
} |
|
}, { |
|
key: 'getExpectedType', |
|
value: function getExpectedType() { |
|
return 'string'; |
|
} |
|
}]); |
|
|
|
return StringMatching; |
|
}(AsymmetricMatcher); |
|
|
|
var any$1 = function any(expectedObject) { |
|
return new Any(expectedObject); |
|
}; |
|
var anything = function anything() { |
|
return new Anything(); |
|
}; |
|
var arrayContaining = function arrayContaining(sample) { |
|
return new ArrayContaining(sample); |
|
}; |
|
var objectContaining = function objectContaining(sample) { |
|
return new ObjectContaining(sample); |
|
}; |
|
var stringContaining = function stringContaining(expected) { |
|
return new StringContaining(expected); |
|
}; |
|
var stringMatching = function stringMatching(expected) { |
|
return new StringMatching(expected); |
|
}; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
// Global matchers object holds the list of available matchers and |
|
// the state, that can hold matcher specific values that change over time. |
|
var JEST_MATCHERS_OBJECT = _Symbol$for('$$jest-matchers-object'); |
|
|
|
// Notes a built-in/internal Jest matcher. |
|
// Jest may override the stack trace of Errors thrown by internal matchers. |
|
var INTERNAL_MATCHER_FLAG = _Symbol$for('$$jest-internal-matcher'); |
|
|
|
if (!global$2[JEST_MATCHERS_OBJECT]) { |
|
_Object$defineProperty(global$2, JEST_MATCHERS_OBJECT, { |
|
value: { |
|
matchers: _Object$create(null), |
|
state: { |
|
assertionCalls: 0, |
|
expectedAssertionsNumber: null, |
|
isExpectingAssertions: false, |
|
suppressedErrors: [] // errors that are not thrown immediately. |
|
} |
|
} |
|
}); |
|
} |
|
|
|
var getState = function getState() { |
|
return global$2[JEST_MATCHERS_OBJECT].state; |
|
}; |
|
|
|
var setState = function setState(state) { |
|
_Object$assign(global$2[JEST_MATCHERS_OBJECT].state, state); |
|
}; |
|
|
|
var getMatchers = function getMatchers() { |
|
return global$2[JEST_MATCHERS_OBJECT].matchers; |
|
}; |
|
|
|
var setMatchers = function setMatchers(matchers, isInternal) { |
|
_Object$keys(matchers).forEach(function (key) { |
|
var matcher = matchers[key]; |
|
_Object$defineProperty(matcher, INTERNAL_MATCHER_FLAG, { |
|
value: isInternal |
|
}); |
|
}); |
|
|
|
_Object$assign(global$2[JEST_MATCHERS_OBJECT].matchers, matchers); |
|
}; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var resetAssertionsLocalState = function resetAssertionsLocalState() { |
|
setState({ |
|
assertionCalls: 0, |
|
expectedAssertionsNumber: null, |
|
isExpectingAssertions: false |
|
}); |
|
}; |
|
|
|
// Create and format all errors related to the mismatched number of `expect` |
|
// calls and reset the matchers state. |
|
var extractExpectedAssertionsErrors = function extractExpectedAssertionsErrors() { |
|
var result = []; |
|
|
|
var _getState = getState(), |
|
assertionCalls = _getState.assertionCalls, |
|
expectedAssertionsNumber = _getState.expectedAssertionsNumber, |
|
isExpectingAssertions = _getState.isExpectingAssertions; |
|
|
|
resetAssertionsLocalState(); |
|
|
|
if (typeof expectedAssertionsNumber === 'number' && assertionCalls !== expectedAssertionsNumber) { |
|
var numOfAssertionsExpected = build_14(build_2('assertion', expectedAssertionsNumber)); |
|
var error = new Error(build_1('.assertions', '', String(expectedAssertionsNumber), { |
|
isDirectExpectCall: true |
|
}) + '\n\n' + ('Expected ' + numOfAssertionsExpected + ' to be called but received ') + build_13(build_2('assertion call', assertionCalls || 0)) + '.'); |
|
result.push({ |
|
actual: assertionCalls, |
|
error: error, |
|
expected: expectedAssertionsNumber |
|
}); |
|
} |
|
if (isExpectingAssertions && assertionCalls === 0) { |
|
var expected = build_14('at least one assertion'); |
|
var received = build_13('received none'); |
|
var _error = new Error(build_1('.hasAssertions', '', '', { |
|
isDirectExpectCall: true |
|
}) + '\n\n' + ('Expected ' + expected + ' to be called but ' + received + '.')); |
|
result.push({ |
|
actual: 'none', |
|
error: _error, |
|
expected: 'at least one' |
|
}); |
|
} |
|
|
|
return result; |
|
}; |
|
|
|
/** |
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
* |
|
* |
|
*/ |
|
|
|
var JestAssertionError = function (_Error) { |
|
_inherits(JestAssertionError, _Error); |
|
|
|
function JestAssertionError() { |
|
_classCallCheck(this, JestAssertionError); |
|
|
|
return _possibleConstructorReturn(this, (JestAssertionError.__proto__ || _Object$getPrototypeOf(JestAssertionError)).apply(this, arguments)); |
|
} |
|
|
|
return JestAssertionError; |
|
}(Error); |
|
|
|
var isPromise = function isPromise(obj) { |
|
return !!obj && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; |
|
}; |
|
|
|
var createToThrowErrorMatchingSnapshotMatcher = function createToThrowErrorMatchingSnapshotMatcher(matcher) { |
|
return function (received, testName) { |
|
return matcher.apply(this, [received, testName, true]); |
|
}; |
|
}; |
|
|
|
var getPromiseMatcher = function getPromiseMatcher(name, matcher) { |
|
if (name === 'toThrow' || name === 'toThrowError') { |
|
return createMatcher('.' + name, true); |
|
} else if (name === 'toThrowErrorMatchingSnapshot') { |
|
return createToThrowErrorMatchingSnapshotMatcher(matcher); |
|
} |
|
|
|
return null; |
|
}; |
|
|
|
var expect = function expect(actual) { |
|
if ((arguments.length <= 1 ? 0 : arguments.length - 1) !== 0) { |
|
throw new Error('Expect takes at most one argument.'); |
|
} |
|
|
|
var allMatchers = getMatchers(); |
|
var expectation = { |
|
not: {}, |
|
rejects: { not: {} }, |
|
resolves: { not: {} } |
|
}; |
|
|
|
_Object$keys(allMatchers).forEach(function (name) { |
|
var matcher = allMatchers[name]; |
|
var promiseMatcher = getPromiseMatcher(name, matcher) || matcher; |
|
expectation[name] = makeThrowingMatcher(matcher, false, actual); |
|
expectation.not[name] = makeThrowingMatcher(matcher, true, actual); |
|
|
|
expectation.resolves[name] = makeResolveMatcher(name, promiseMatcher, false, actual); |
|
expectation.resolves.not[name] = makeResolveMatcher(name, promiseMatcher, true, actual); |
|
|
|
expectation.rejects[name] = makeRejectMatcher(name, promiseMatcher, false, actual); |
|
expectation.rejects.not[name] = makeRejectMatcher(name, matcher, true, actual); |
|
}); |
|
|
|
return expectation; |
|
}; |
|
|
|
var getMessage = function getMessage(message) { |
|
return message && message() || build_13('No message was specified for this matcher.'); |
|
}; |
|
|
|
var makeResolveMatcher = function makeResolveMatcher(matcherName, matcher, isNot, actual) { |
|
return function () { |
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { |
|
args[_key] = arguments[_key]; |
|
} |
|
|
|
var matcherStatement = '.resolves.' + (isNot ? 'not.' : '') + matcherName; |
|
if (!isPromise(actual)) { |
|
throw new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + (build_13('received') + ' value must be a Promise.\n') + build_7('Received', actual, build_9)); |
|
} |
|
|
|
return actual.then(function (result) { |
|
return makeThrowingMatcher(matcher, isNot, result).apply(null, args); |
|
}, function (reason) { |
|
var err = new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + ('Expected ' + build_13('received') + ' Promise to resolve, ') + 'instead it rejected to value\n' + (' ' + build_9(reason))); |
|
return _Promise.reject(err); |
|
}); |
|
}; |
|
}; |
|
|
|
var makeRejectMatcher = function makeRejectMatcher(matcherName, matcher, isNot, actual) { |
|
return function () { |
|
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
args[_key2] = arguments[_key2]; |
|
} |
|
|
|
var matcherStatement = '.rejects.' + (isNot ? 'not.' : '') + matcherName; |
|
if (!isPromise(actual)) { |
|
throw new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + (build_13('received') + ' value must be a Promise.\n') + build_7('Received', actual, build_9)); |
|
} |
|
|
|
return actual.then(function (result) { |
|
var err = new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + ('Expected ' + build_13('received') + ' Promise to reject, ') + 'instead it resolved to value\n' + (' ' + build_9(result))); |
|
return _Promise.reject(err); |
|
}, function (reason) { |
|
return makeThrowingMatcher(matcher, isNot, reason).apply(null, args); |
|
}); |
|
}; |
|
}; |
|
|
|
var makeThrowingMatcher = function makeThrowingMatcher(matcher, isNot, actual) { |
|
return function throwingMatcher() { |
|
var throws = true; |
|
var matcherContext = _Object$assign( |
|
// When throws is disabled, the matcher will not throw errors during test |
|
// execution but instead add them to the global matcher state. If a |
|
// matcher throws, test execution is normally stopped immediately. The |
|
// snapshot matcher uses it because we want to log all snapshot |
|
// failures in a test. |
|
{ dontThrow: function dontThrow() { |
|
return throws = false; |
|
} }, getState(), { |
|
equals: equals, |
|
isNot: isNot, |
|
utils: utils |
|
}); |
|
var result = void 0; |
|
|
|
try { |
|
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
|
args[_key3] = arguments[_key3]; |
|
} |
|
|
|
result = matcher.apply(matcherContext, [actual].concat(args)); |
|
} catch (error) { |
|
if (matcher[INTERNAL_MATCHER_FLAG] === true && !(error instanceof JestAssertionError) && error.name !== 'PrettyFormatPluginError' && |
|
// Guard for some environments (browsers) that do not support this feature. |
|
Error.captureStackTrace) { |
|
// Try to remove this and deeper functions from the stack trace frame. |
|
Error.captureStackTrace(error, throwingMatcher); |
|
} |
|
throw error; |
|
} |
|
|
|
_validateResult(result); |
|
|
|
getState().assertionCalls++; |
|
|
|
if (result.pass && isNot || !result.pass && !isNot) { |
|
// XOR |
|
var message = getMessage(result.message); |
|
var error = new JestAssertionError(message); |
|
// Passing the result of the matcher with the error so that a custom |
|
// reporter could access the actual and expected objects of the result |
|
// for example in order to display a custom visual diff |
|
error.matcherResult = result; |
|
// Try to remove this function from the stack trace frame. |
|
// Guard for some environments (browsers) that do not support this feature. |
|
if (Error.captureStackTrace) { |
|
Error.captureStackTrace(error, throwingMatcher); |
|
} |
|
|
|
if (throws) { |
|
throw error; |
|
} else { |
|
getState().suppressedErrors.push(error); |
|
} |
|
} |
|
}; |
|
}; |
|
|
|
expect.extend = function (matchers$$1) { |
|
return setMatchers(matchers$$1, false); |
|
}; |
|
|
|
expect.anything = anything; |
|
expect.any = any$1; |
|
expect.objectContaining = objectContaining; |
|
expect.arrayContaining = arrayContaining; |
|
expect.stringContaining = stringContaining; |
|
expect.stringMatching = stringMatching; |
|
|
|
var _validateResult = function _validateResult(result) { |
|
if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) !== 'object' || typeof result.pass !== 'boolean' || result.message && typeof result.message !== 'string' && typeof result.message !== 'function') { |
|
throw new Error('Unexpected return from a matcher function.\n' + 'Matcher functions should ' + 'return an object in the following format:\n' + ' {message?: string | function, pass: boolean}\n' + ('\'' + build_11(result) + '\' was returned')); |
|
} |
|
}; |
|
|
|
// add default jest matchers |
|
setMatchers(matchers, true); |
|
setMatchers(spyMatchers, true); |
|
setMatchers(matchers$2, true); |
|
|
|
expect.addSnapshotSerializer = function () { |
|
return void 0; |
|
}; |
|
expect.assertions = function (expected) { |
|
getState().expectedAssertionsNumber = expected; |
|
}; |
|
expect.hasAssertions = function (expected) { |
|
build_6(expected, '.hasAssertions'); |
|
getState().isExpectingAssertions = true; |
|
}; |
|
expect.getState = getState; |
|
expect.setState = setState; |
|
expect.extractExpectedAssertionsErrors = extractExpectedAssertionsErrors; |
|
|
|
module.exports = expect; |
|
|
|
})));
|
|
|