From 10b8988d36fbe1d9bc81b054de28d6a29402e0df Mon Sep 17 00:00:00 2001 From: Pavel Tiunov Date: Mon, 28 Oct 2019 23:07:05 -0700 Subject: [PATCH] fix(react): Refetch hook only actual query changes --- .../cubejs-react/dist/cubejs-react.esm.js | 2 +- packages/cubejs-react/dist/cubejs-react.js | 2 +- .../cubejs-react/dist/cubejs-react.umd.js | 3721 +++++++++++++---- packages/cubejs-react/src/useCubeQuery.js | 2 +- 4 files changed, 2849 insertions(+), 878 deletions(-) diff --git a/packages/cubejs-react/dist/cubejs-react.esm.js b/packages/cubejs-react/dist/cubejs-react.esm.js index 9347ab4ee59e0..c51274266f55e 100644 --- a/packages/cubejs-react/dist/cubejs-react.esm.js +++ b/packages/cubejs-react/dist/cubejs-react.esm.js @@ -869,7 +869,7 @@ var useCubeQuery = (function (query) { subscribeRequest = null; } }; - }, [query, options.cubejsApi, context]); + }, [JSON.stringify(query), options.cubejsApi, context]); return { isLoading: isLoading, resultSet: resultSet, diff --git a/packages/cubejs-react/dist/cubejs-react.js b/packages/cubejs-react/dist/cubejs-react.js index 0dcd07d46b12d..0c6b19242f390 100644 --- a/packages/cubejs-react/dist/cubejs-react.js +++ b/packages/cubejs-react/dist/cubejs-react.js @@ -876,7 +876,7 @@ var useCubeQuery = (function (query) { subscribeRequest = null; } }; - }, [query, options.cubejsApi, context]); + }, [JSON.stringify(query), options.cubejsApi, context]); return { isLoading: isLoading, resultSet: resultSet, diff --git a/packages/cubejs-react/dist/cubejs-react.umd.js b/packages/cubejs-react/dist/cubejs-react.umd.js index 51f72faa9f404..fae8fc83077b9 100644 --- a/packages/cubejs-react/dist/cubejs-react.umd.js +++ b/packages/cubejs-react/dist/cubejs-react.umd.js @@ -20,7 +20,7 @@ }); var _core = createCommonjsModule(function (module) { - var core = module.exports = { version: '2.5.7' }; + var core = module.exports = { version: '2.6.5' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef }); var _core_1 = _core.version; @@ -116,14 +116,31 @@ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; + var _library = false; + + var _shared = createCommonjsModule(function (module) { + var SHARED = '__core-js_shared__'; + var store = _global[SHARED] || (_global[SHARED] = {}); + + (module.exports = function (key, value) { + return store[key] || (store[key] = value !== undefined ? value : {}); + })('versions', []).push({ + version: _core.version, + mode: 'global', + copyright: '© 2019 Denis Pushkarev (zloirock.ru)' + }); + }); + + var _functionToString = _shared('native-function-to-string', Function.toString); + var _redefine = createCommonjsModule(function (module) { var SRC = _uid('src'); + var TO_STRING = 'toString'; - var $toString = Function[TO_STRING]; - var TPL = ('' + $toString).split(TO_STRING); + var TPL = ('' + _functionToString).split(TO_STRING); _core.inspectSource = function (it) { - return $toString.call(it); + return _functionToString.call(it); }; (module.exports = function (O, key, val, safe) { @@ -143,7 +160,7 @@ } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString() { - return typeof this == 'function' && this[SRC] || $toString.call(this); + return typeof this == 'function' && this[SRC] || _functionToString.call(this); }); }); @@ -257,21 +274,6 @@ return _cof(arg) == 'Array'; }; - var _library = false; - - var _shared = createCommonjsModule(function (module) { - var SHARED = '__core-js_shared__'; - var store = _global[SHARED] || (_global[SHARED] = {}); - - (module.exports = function (key, value) { - return store[key] || (store[key] = value !== undefined ? value : {}); - })('versions', []).push({ - version: _core.version, - mode: 'global', - copyright: '© 2018 Denis Pushkarev (zloirock.ru)' - }); - }); - var _wks = createCommonjsModule(function (module) { var store = _shared('wks'); @@ -369,6 +371,20 @@ } }); + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); @@ -1563,7 +1579,7 @@ }); function _isPlaceholder(a) { - return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true; + return a != null && _typeof(a) === 'object' && a['@@functional/placeholder'] === true; } /** @@ -1574,6 +1590,7 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curry1(fn) { return function f1(a) { if (arguments.length === 0 || _isPlaceholder(a)) { @@ -1603,7 +1620,10 @@ * var t = R.always('Tee'); * t(); //=> 'Tee' */ - var always = /*#__PURE__*/_curry1(function always(val) { + + var always = + /*#__PURE__*/ + _curry1(function always(val) { return function () { return val; }; @@ -1624,7 +1644,10 @@ * * R.F(); //=> false */ - var F = /*#__PURE__*/always(false); + + var F = + /*#__PURE__*/ + always(false); /** * A function that always returns `true`. Any passed in parameters are ignored. @@ -1641,7 +1664,10 @@ * * R.T(); //=> true */ - var T = /*#__PURE__*/always(true); + + var T = + /*#__PURE__*/ + always(true); /** * A special placeholder value used to specify "gaps" within curried functions, @@ -1670,6 +1696,167 @@ * greet('Alice'); //=> 'Hello, Alice!' */ + var f$2 = {}.propertyIsEnumerable; + + var _objectPie = { + f: f$2 + }; + + var gOPD = Object.getOwnPropertyDescriptor; + + var f$3 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { + O = _toIobject(O); + P = _toPrimitive(P, true); + if (_ie8DomDefine) try { + return gOPD(O, P); + } catch (e) { /* empty */ } + if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); + }; + + var _objectGopd = { + f: f$3 + }; + + // 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 + }; + + var setPrototypeOf = _setProto.set; + var _inheritIfRequired = function (that, target, C) { + var S = target.constructor; + var P; + if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) { + setPrototypeOf(that, P); + } return that; + }; + + // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) + + var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); + + var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return _objectKeysInternal(O, hiddenKeys); + }; + + var _objectGopn = { + f: f$4 + }; + + var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + + var space = '[' + _stringWs + ']'; + var non = '\u200b\u0085'; + var ltrim = RegExp('^' + space + space + '*'); + var rtrim = RegExp(space + space + '*$'); + + var exporter = function (KEY, exec, ALIAS) { + var exp = {}; + var FORCE = _fails(function () { + return !!_stringWs[KEY]() || non[KEY]() != non; + }); + var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY]; + if (ALIAS) exp[ALIAS] = fn; + _export(_export.P + _export.F * FORCE, 'String', exp); + }; + + // 1 -> String#trimLeft + // 2 -> String#trimRight + // 3 -> String#trim + var trim = exporter.trim = function (string, TYPE) { + string = String(_defined(string)); + if (TYPE & 1) string = string.replace(ltrim, ''); + if (TYPE & 2) string = string.replace(rtrim, ''); + return string; + }; + + var _stringTrim = exporter; + + var gOPN = _objectGopn.f; + var gOPD$1 = _objectGopd.f; + var dP$1 = _objectDp.f; + var $trim = _stringTrim.trim; + var NUMBER = 'Number'; + var $Number = _global[NUMBER]; + var Base = $Number; + var proto$1 = $Number.prototype; + // Opera ~12 has broken Object#toString + var BROKEN_COF = _cof(_objectCreate(proto$1)) == NUMBER; + var TRIM = 'trim' in String.prototype; + + // 7.1.3 ToNumber(argument) + var toNumber = function (argument) { + var it = _toPrimitive(argument, false); + if (typeof it == 'string' && it.length > 2) { + it = TRIM ? it.trim() : $trim(it, 3); + var first = it.charCodeAt(0); + var third, radix, maxCode; + if (first === 43 || first === 45) { + third = it.charCodeAt(2); + if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix + } else if (first === 48) { + switch (it.charCodeAt(1)) { + case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i + case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i + default: return +it; + } + for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) { + code = digits.charCodeAt(i); + // parseInt parses a string to a first unavailable symbol + // but ToNumber should return NaN if a string contains unavailable symbols + if (code < 48 || code > maxCode) return NaN; + } return parseInt(digits, radix); + } + } return +it; + }; + + if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { + $Number = function Number(value) { + var it = arguments.length < 1 ? 0 : value; + var that = this; + return that instanceof $Number + // check on 1..constructor(foo) case + && (BROKEN_COF ? _fails(function () { proto$1.valueOf.call(that); }) : _cof(that) != NUMBER) + ? _inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it); + }; + for (var keys = _descriptors ? gOPN(Base) : ( + // ES3: + 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + + // ES6 (in case, if modules with ES6 Number statics required before): + 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + + 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger' + ).split(','), j = 0, key$1; keys.length > j; j++) { + if (_has(Base, key$1 = keys[j]) && !_has($Number, key$1)) { + dP$1($Number, key$1, gOPD$1(Base, key$1)); + } + } + $Number.prototype = proto$1; + proto$1.constructor = $Number; + _redefine(_global, NUMBER, $Number); + } + /** * Optimized internal two-arity curry function. * @@ -1678,15 +1865,18 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curry2(fn) { return function f2(a, b) { switch (arguments.length) { case 0: return f2; + case 1: return _isPlaceholder(a) ? f2 : _curry1(function (_b) { return fn(a, _b); }); + default: return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function (_a) { return fn(_a, b); @@ -1714,7 +1904,10 @@ * R.add(2, 3); //=> 5 * R.add(7)(10); //=> 17 */ - var add = /*#__PURE__*/_curry2(function add(a, b) { + + var add = + /*#__PURE__*/ + _curry2(function add(a, b) { return Number(a) + Number(b); }); @@ -1736,17 +1929,20 @@ var len1 = set1.length; var len2 = set2.length; var result = []; - idx = 0; + while (idx < len1) { result[result.length] = set1[idx]; idx += 1; } + idx = 0; + while (idx < len2) { result[result.length] = set2[idx]; idx += 1; } + return result; } @@ -1757,46 +1953,57 @@ return function () { return fn.apply(this, arguments); }; + case 1: return function (a0) { return fn.apply(this, arguments); }; + case 2: return function (a0, a1) { return fn.apply(this, arguments); }; + case 3: return function (a0, a1, a2) { return fn.apply(this, arguments); }; + case 4: return function (a0, a1, a2, a3) { return fn.apply(this, arguments); }; + case 5: return function (a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; + case 6: return function (a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; + case 7: return function (a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; + case 8: return function (a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; + case 9: return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; + case 10: return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; + default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); } @@ -1812,26 +2019,33 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curryN(length, received, fn) { return function () { var combined = []; var argsIdx = 0; var left = length; var combinedIdx = 0; + while (combinedIdx < received.length || argsIdx < arguments.length) { var result; + if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) { result = received[combinedIdx]; } else { result = arguments[argsIdx]; argsIdx += 1; } + combined[combinedIdx] = result; + if (!_isPlaceholder(result)) { left -= 1; } + combinedIdx += 1; } + return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn)); }; } @@ -1878,10 +2092,14 @@ * var g = f(3); * g(4); //=> 10 */ - var curryN = /*#__PURE__*/_curry2(function curryN(length, fn) { + + var curryN = + /*#__PURE__*/ + _curry2(function curryN(length, fn) { if (length === 1) { return _curry1(fn); } + return _arity(length, _curryN(length, [], fn)); }); @@ -1893,15 +2111,18 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curry3(fn) { return function f3(a, b, c) { switch (arguments.length) { case 0: return f3; + case 1: return _isPlaceholder(a) ? f3 : _curry2(function (_b, _c) { return fn(a, _b, _c); }); + case 2: return _isPlaceholder(a) && _isPlaceholder(b) ? f3 : _isPlaceholder(a) ? _curry2(function (_a, _c) { return fn(_a, b, _c); @@ -1910,6 +2131,7 @@ }) : _curry1(function (_c) { return fn(a, b, _c); }); + default: return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function (_a, _b) { return fn(_a, _b, c); @@ -1928,6 +2150,64 @@ }; } + // 21.2.5.3 get RegExp.prototype.flags + + var _flags = function () { + var that = _anObject(this); + var result = ''; + if (that.global) result += 'g'; + if (that.ignoreCase) result += 'i'; + if (that.multiline) result += 'm'; + if (that.unicode) result += 'u'; + if (that.sticky) result += 'y'; + return result; + }; + + // 21.2.5.3 get RegExp.prototype.flags() + if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', { + configurable: true, + get: _flags + }); + + var TO_STRING = 'toString'; + var $toString = /./[TO_STRING]; + + var define = function (fn) { + _redefine(RegExp.prototype, TO_STRING, fn, true); + }; + + // 21.2.5.14 RegExp.prototype.toString() + if (_fails(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) { + define(function toString() { + var R = _anObject(this); + return '/'.concat(R.source, '/', + 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined); + }); + // FF44- RegExp#toString has a wrong name + } else if ($toString.name != TO_STRING) { + define(function toString() { + return $toString.call(this); + }); + } + + var DateProto = Date.prototype; + var INVALID_DATE = 'Invalid Date'; + var TO_STRING$1 = 'toString'; + var $toString$1 = DateProto[TO_STRING$1]; + var getTime = DateProto.getTime; + if (new Date(NaN) + '' != INVALID_DATE) { + _redefine(DateProto, TO_STRING$1, function toString() { + var value = getTime.call(this); + // eslint-disable-next-line no-self-compare + return value === value ? $toString$1.call(this) : INVALID_DATE; + }); + } + + // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) + + + _export(_export.S, 'Array', { isArray: _isArray }); + /** * Tests whether or not an object is an array. * @@ -1962,36 +2242,43 @@ * @param {Function} fn default ramda implementation * @return {Function} A function that dispatches on object in list position */ + function _dispatchable(methodNames, xf, fn) { return function () { if (arguments.length === 0) { return fn(); } + var args = Array.prototype.slice.call(arguments, 0); var obj = args.pop(); + if (!_isArray$1(obj)) { var idx = 0; + while (idx < methodNames.length) { if (typeof obj[methodNames[idx]] === 'function') { return obj[methodNames[idx]].apply(obj, args); } + idx += 1; } + if (_isTransformer(obj)) { var transducer = xf.apply(null, args); return transducer(obj); } } + return fn.apply(this, arguments); }; } var _xfBase = { - init: function () { + init: function init() { return this.xf['@@transducer/init'](); }, - result: function (result) { - return this.xf['@@transducer/result'](result); + result: function result(_result) { + return this.xf['@@transducer/result'](_result); } }; @@ -2012,7 +2299,10 @@ * R.max(789, 123); //=> 789 * R.max('a', 'b'); //=> 'b' */ - var max$1 = /*#__PURE__*/_curry2(function max(a, b) { + + var max$1 = + /*#__PURE__*/ + _curry2(function max(a, b) { return b > a ? b : a; }); @@ -2020,132 +2310,546 @@ var idx = 0; var len = functor.length; var result = Array(len); + while (idx < len) { result[idx] = fn(functor[idx]); idx += 1; } - return result; - } - function _isString(x) { - return Object.prototype.toString.call(x) === '[object String]'; + return result; } - /** - * Tests whether or not an object is similar to an array. - * - * @private - * @category Type - * @category List - * @sig * -> Boolean - * @param {*} x The object to test. - * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. - * @example - * - * _isArrayLike([]); //=> true - * _isArrayLike(true); //=> false - * _isArrayLike({}); //=> false - * _isArrayLike({length: 10}); //=> false - * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true - */ - var _isArrayLike = /*#__PURE__*/_curry1(function isArrayLike(x) { - if (_isArray$1(x)) { - return true; - } - if (!x) { - return false; - } - if (typeof x !== 'object') { - return false; - } - if (_isString(x)) { - return false; - } - if (x.nodeType === 1) { - return !!x.length; + var _arrayReduce = function (that, callbackfn, aLen, memo, isRight) { + _aFunction(callbackfn); + var O = _toObject(that); + var self = _iobject(O); + var length = _toLength(O.length); + var index = isRight ? length - 1 : 0; + var i = isRight ? -1 : 1; + if (aLen < 2) for (;;) { + if (index in self) { + memo = self[index]; + index += i; + break; + } + index += i; + if (isRight ? index < 0 : length <= index) { + throw TypeError('Reduce of empty array with no initial value'); + } } - if (x.length === 0) { - return true; + for (;isRight ? index >= 0 : length > index; index += i) if (index in self) { + memo = callbackfn(memo, self[index], index, O); } - if (x.length > 0) { - return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); + return memo; + }; + + _export(_export.P + _export.F * !_strictMethod([].reduce, true), 'Array', { + // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) + reduce: function reduce(callbackfn /* , initialValue */) { + return _arrayReduce(this, callbackfn, arguments.length, arguments[1], false); } - return false; }); - var XWrap = /*#__PURE__*/function () { - function XWrap(fn) { - this.f = fn; - } - XWrap.prototype['@@transducer/init'] = function () { - throw new Error('init not implemented on XWrap'); - }; - XWrap.prototype['@@transducer/result'] = function (acc) { - return acc; - }; - XWrap.prototype['@@transducer/step'] = function (acc, x) { - return this.f(acc, x); - }; + var f$5 = _wks; - return XWrap; - }(); + var _wksExt = { + f: f$5 + }; - function _xwrap(fn) { - return new XWrap(fn); - } + var defineProperty = _objectDp.f; + var _wksDefine = function (name) { + var $Symbol = _core.Symbol || (_core.Symbol = _global.Symbol || {}); + if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: _wksExt.f(name) }); + }; - /** - * Creates a function that is bound to a context. - * Note: `R.bind` does not provide the additional argument-binding capabilities of - * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Function - * @category Object - * @sig (* -> *) -> {*} -> (* -> *) - * @param {Function} fn The function to bind to context - * @param {Object} thisObj The context to bind `fn` to - * @return {Function} A function that will execute in the context of `thisObj`. - * @see R.partial - * @example - * - * var log = R.bind(console.log, console); - * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} - * // logs {a: 2} - * @symb R.bind(f, o)(a, b) = f.call(o, a, b) - */ - var bind = /*#__PURE__*/_curry2(function bind(fn, thisObj) { - return _arity(fn.length, function () { - return fn.apply(thisObj, arguments); - }); - }); + _wksDefine('asyncIterator'); + + 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 f$6 = Object.getOwnPropertySymbols; + + var _objectGops = { + f: f$6 + }; + + // 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; + }; + + // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window + + var gOPN$1 = _objectGopn.f; + var toString$1 = {}.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$7 = function getOwnPropertyNames(it) { + return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN$1(_toIobject(it)); + }; + + var _objectGopnExt = { + f: f$7 + }; + + // ECMAScript 6 symbols shim + + + + + + var META = _meta.KEY; + + + + + + + + + + + + + + + + + + + + var gOPD$2 = _objectGopd.f; + var dP$2 = _objectDp.f; + var gOPN$2 = _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$2({}, 'a', { + get: function () { return dP$2(this, 'a', { value: 7 }).a; } + })).a != 7; + }) ? function (it, key, D) { + var protoDesc = gOPD$2(ObjectProto$1, key); + if (protoDesc) delete ObjectProto$1[key]; + dP$2(it, key, D); + if (protoDesc && it !== ObjectProto$1) dP$2(ObjectProto$1, key, protoDesc); + } : dP$2; + + 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 = function defineProperty(it, key, D) { + if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D); + _anObject(it); + key = _toPrimitive(key, true); + _anObject(D); + if (_has(AllSymbols, key)) { + if (!D.enumerable) { + if (!_has(it, HIDDEN)) dP$2(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$2(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(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$2(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$2(_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$2(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; + _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$1 = 0; es6Symbols.length > j$1;)_wks(es6Symbols[j$1++]); + + 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, + // 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); + + function _isString(x) { + return Object.prototype.toString.call(x) === '[object String]'; + } + + /** + * Tests whether or not an object is similar to an array. + * + * @private + * @category Type + * @category List + * @sig * -> Boolean + * @param {*} x The object to test. + * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. + * @example + * + * _isArrayLike([]); //=> true + * _isArrayLike(true); //=> false + * _isArrayLike({}); //=> false + * _isArrayLike({length: 10}); //=> false + * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true + */ + + var _isArrayLike = + /*#__PURE__*/ + _curry1(function isArrayLike(x) { + if (_isArray$1(x)) { + return true; + } + + if (!x) { + return false; + } + + if (_typeof(x) !== 'object') { + return false; + } + + if (_isString(x)) { + return false; + } + + if (x.nodeType === 1) { + return !!x.length; + } + + if (x.length === 0) { + return true; + } + + if (x.length > 0) { + return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); + } + + return false; + }); + + var XWrap = + /*#__PURE__*/ + function () { + function XWrap(fn) { + this.f = fn; + } + + XWrap.prototype['@@transducer/init'] = function () { + throw new Error('init not implemented on XWrap'); + }; + + XWrap.prototype['@@transducer/result'] = function (acc) { + return acc; + }; + + XWrap.prototype['@@transducer/step'] = function (acc, x) { + return this.f(acc, x); + }; + + return XWrap; + }(); + + function _xwrap(fn) { + return new XWrap(fn); + } + + /** + * Creates a function that is bound to a context. + * Note: `R.bind` does not provide the additional argument-binding capabilities of + * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Function + * @category Object + * @sig (* -> *) -> {*} -> (* -> *) + * @param {Function} fn The function to bind to context + * @param {Object} thisObj The context to bind `fn` to + * @return {Function} A function that will execute in the context of `thisObj`. + * @see R.partial + * @example + * + * var log = R.bind(console.log, console); + * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} + * // logs {a: 2} + * @symb R.bind(f, o)(a, b) = f.call(o, a, b) + */ + + var bind = + /*#__PURE__*/ + _curry2(function bind(fn, thisObj) { + return _arity(fn.length, function () { + return fn.apply(thisObj, arguments); + }); + }); + + function _arrayReduce$1(xf, acc, list) { + var idx = 0; + var len = list.length; + + while (idx < len) { + acc = xf['@@transducer/step'](acc, list[idx]); + + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } - function _arrayReduce(xf, acc, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - acc = xf['@@transducer/step'](acc, list[idx]); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } idx += 1; } + return xf['@@transducer/result'](acc); } function _iterableReduce(xf, acc, iter) { var step = iter.next(); + while (!step.done) { acc = xf['@@transducer/step'](acc, step.value); + if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } + step = iter.next(); } + return xf['@@transducer/result'](acc); } @@ -2154,23 +2858,27 @@ } var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator'; - function _reduce(fn, acc, list) { if (typeof fn === 'function') { fn = _xwrap(fn); } + if (_isArrayLike(list)) { - return _arrayReduce(fn, acc, list); + return _arrayReduce$1(fn, acc, list); } + if (typeof list['fantasy-land/reduce'] === 'function') { return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); } + if (list[symIterator] != null) { return _iterableReduce(fn, acc, list[symIterator]()); } + if (typeof list.next === 'function') { return _iterableReduce(fn, acc, list); } + if (typeof list.reduce === 'function') { return _methodReduce(fn, acc, list, 'reduce'); } @@ -2178,13 +2886,17 @@ throw new TypeError('reduce: list must be array or iterable'); } - var XMap = /*#__PURE__*/function () { + var XMap = + /*#__PURE__*/ + function () { function XMap(f, xf) { this.xf = xf; this.f = f; } + XMap.prototype['@@transducer/init'] = _xfBase.init; XMap.prototype['@@transducer/result'] = _xfBase.result; + XMap.prototype['@@transducer/step'] = function (result, input) { return this.xf['@@transducer/step'](result, this.f(input)); }; @@ -2192,43 +2904,74 @@ return XMap; }(); - var _xmap = /*#__PURE__*/_curry2(function _xmap(f, xf) { + var _xmap = + /*#__PURE__*/ + _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); + // 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)); + }; + }); + function _has$1(prop, obj) { return Object.prototype.hasOwnProperty.call(obj, prop); } - var toString$1 = Object.prototype.toString; - var _isArguments = function () { - return toString$1.call(arguments) === '[object Arguments]' ? function _isArguments(x) { - return toString$1.call(x) === '[object Arguments]'; + var toString$2 = Object.prototype.toString; + + var _isArguments = function _isArguments() { + return toString$2.call(arguments) === '[object Arguments]' ? function _isArguments(x) { + return toString$2.call(x) === '[object Arguments]'; } : function _isArguments(x) { return _has$1('callee', x); }; }; - // cover IE < 9 keys issues - var hasEnumBug = ! /*#__PURE__*/{ toString: null }.propertyIsEnumerable('toString'); - var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - // Safari bug - var hasArgsEnumBug = /*#__PURE__*/function () { + var hasEnumBug = ! + /*#__PURE__*/ + { + toString: null + }.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug + + var hasArgsEnumBug = + /*#__PURE__*/ + function () { return arguments.propertyIsEnumerable('length'); }(); var contains = function contains(list, item) { var idx = 0; + while (idx < list.length) { if (list[idx] === item) { return true; } + idx += 1; } + return false; }; - /** * Returns a list containing the names of all the enumerable own properties of * the supplied object. @@ -2247,33 +2990,46 @@ * * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] */ + + var _keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? function keys(obj) { return Object(obj) !== obj ? [] : Object.keys(obj); } : function keys(obj) { if (Object(obj) !== obj) { return []; } + var prop, nIdx; var ks = []; + var checkArgsLength = hasArgsEnumBug && _isArguments(obj); + for (prop in obj) { if (_has$1(prop, obj) && (!checkArgsLength || prop !== 'length')) { ks[ks.length] = prop; } } + if (hasEnumBug) { nIdx = nonEnumerableProps.length - 1; + while (nIdx >= 0) { prop = nonEnumerableProps[nIdx]; + if (_has$1(prop, obj) && !contains(ks, prop)) { ks[ks.length] = prop; } + nIdx -= 1; } } + return ks; }; - var keys = /*#__PURE__*/_curry1(_keys); + + var keys$1 = + /*#__PURE__*/ + _curry1(_keys); /** * Takes a function and @@ -2310,17 +3066,24 @@ * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } * @symb R.map(f, functor_o) = functor_o.map(f) */ - var map = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { + + var map = + /*#__PURE__*/ + _curry2( + /*#__PURE__*/ + _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { switch (Object.prototype.toString.call(functor)) { case '[object Function]': return curryN(functor.length, function () { return fn.call(this, functor.apply(this, arguments)); }); + case '[object Object]': return _reduce(function (acc, key) { acc[key] = fn(functor[key]); return acc; - }, {}, keys(functor)); + }, {}, keys$1(functor)); + default: return _map(fn, functor); } @@ -2344,16 +3107,22 @@ * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined */ - var path = /*#__PURE__*/_curry2(function path(paths, obj) { + + var path = + /*#__PURE__*/ + _curry2(function path(paths, obj) { var val = obj; var idx = 0; + while (idx < paths.length) { if (val == null) { return; } + val = val[paths[idx]]; idx += 1; } + return val; }); @@ -2376,7 +3145,9 @@ * R.prop('x', {}); //=> undefined */ - var prop = /*#__PURE__*/_curry2(function prop(p, obj) { + var prop = + /*#__PURE__*/ + _curry2(function prop(p, obj) { return path([p], obj); }); @@ -2405,7 +3176,10 @@ * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] */ - var pluck = /*#__PURE__*/_curry2(function pluck(p, list) { + + var pluck = + /*#__PURE__*/ + _curry2(function pluck(p, list) { return map(prop(p), list); }); @@ -2455,7 +3229,10 @@ * * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) */ - var reduce = /*#__PURE__*/_curry3(_reduce); + + var reduce = + /*#__PURE__*/ + _curry3(_reduce); /** * ap applies a list of functions to a list of values. @@ -2483,24 +3260,29 @@ * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] */ - var ap = /*#__PURE__*/_curry2(function ap(applyF, applyX) { + + var ap = + /*#__PURE__*/ + _curry2(function ap(applyF, applyX) { return typeof applyX['fantasy-land/ap'] === 'function' ? applyX['fantasy-land/ap'](applyF) : typeof applyF.ap === 'function' ? applyF.ap(applyX) : typeof applyF === 'function' ? function (x) { return applyF(x)(applyX(x)); - } : - // else + } : // else _reduce(function (acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF); }); - /** - * Determine if the passed argument is an integer. - * - * @private - * @param {*} n - * @category Type - * @return {Boolean} - */ + // 20.1.2.3 Number.isInteger(number) + + var floor$1 = Math.floor; + var _isInteger = function isInteger(it) { + return !_isObject(it) && isFinite(it) && floor$1(it) === it; + }; + + // 20.1.2.3 Number.isInteger(number) + + + _export(_export.S, 'Number', { isInteger: _isInteger }); function _isFunction(x) { return Object.prototype.toString.call(x) === '[object Function]'; @@ -2523,7 +3305,10 @@ * var madd3 = R.liftN(3, (...args) => R.sum(args)); * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] */ - var liftN = /*#__PURE__*/_curry2(function liftN(arity, fn) { + + var liftN = + /*#__PURE__*/ + _curry2(function liftN(arity, fn) { var lifted = curryN(arity, fn); return curryN(arity, function () { return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); @@ -2552,7 +3337,10 @@ * * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] */ - var lift = /*#__PURE__*/_curry1(function lift(fn) { + + var lift = + /*#__PURE__*/ + _curry1(function lift(fn) { return liftN(fn.length, fn); }); @@ -2597,7 +3385,10 @@ * var g = f(3); * g(4); //=> 10 */ - var curry = /*#__PURE__*/_curry1(function curry(fn) { + + var curry = + /*#__PURE__*/ + _curry1(function curry(fn) { return curryN(fn.length, fn); }); @@ -2633,7 +3424,10 @@ * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' * @symb R.call(f, a, b) = f(a, b) */ - var call = /*#__PURE__*/curry(function call(fn) { + + var call = + /*#__PURE__*/ + curry(function call(fn) { return fn.apply(this, Array.prototype.slice.call(arguments, 1)); }); @@ -2643,6 +3437,7 @@ * * @private */ + function _makeFlat(recursive) { return function flatt(list) { var value, jlen, j; @@ -2655,6 +3450,7 @@ value = recursive ? flatt(list[idx]) : list[idx]; j = 0; jlen = value.length; + while (j < jlen) { result[result.length] = value[j]; j += 1; @@ -2662,8 +3458,10 @@ } else { result[result.length] = list[idx]; } + idx += 1; } + return result; }; } @@ -2675,13 +3473,13 @@ }; } - var preservingReduced = function (xf) { + var preservingReduced = function preservingReduced(xf) { return { '@@transducer/init': _xfBase.init, - '@@transducer/result': function (result) { + '@@transducer/result': function transducerResult(result) { return xf['@@transducer/result'](result); }, - '@@transducer/step': function (result, input) { + '@@transducer/step': function transducerStep(result, input) { var ret = xf['@@transducer/step'](result, input); return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; } @@ -2692,16 +3490,18 @@ var rxf = preservingReduced(xf); return { '@@transducer/init': _xfBase.init, - '@@transducer/result': function (result) { + '@@transducer/result': function transducerResult(result) { return rxf['@@transducer/result'](result); }, - '@@transducer/step': function (result, input) { + '@@transducer/step': function transducerStep(result, input) { return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); } }; }; - var _xchain = /*#__PURE__*/_curry2(function _xchain(f, xf) { + var _xchain = + /*#__PURE__*/ + _curry2(function _xchain(f, xf) { return map(f, _flatCat(xf)); }); @@ -2727,15 +3527,72 @@ * * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] */ - var chain = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { + + var chain = + /*#__PURE__*/ + _curry2( + /*#__PURE__*/ + _dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { if (typeof monad === 'function') { return function (x) { return fn(monad(x))(x); }; } + return _makeFlat(false)(map(fn, monad)); })); + // 7.2.8 IsRegExp(argument) + + + var MATCH = _wks('match'); + var _isRegexp = function (it) { + var isRegExp; + return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp'); + }; + + var dP$3 = _objectDp.f; + var gOPN$3 = _objectGopn.f; + + + var $RegExp = _global.RegExp; + var Base$1 = $RegExp; + var proto$2 = $RegExp.prototype; + var re1 = /a/g; + var re2 = /a/g; + // "new" creates a new object, old webkit buggy here + var CORRECT_NEW = new $RegExp(re1) !== re1; + + if (_descriptors && (!CORRECT_NEW || _fails(function () { + re2[_wks('match')] = false; + // RegExp constructor can alter flags and IsRegExp works correct with @@match + return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i'; + }))) { + $RegExp = function RegExp(p, f) { + var tiRE = this instanceof $RegExp; + var piRE = _isRegexp(p); + var fiU = f === undefined; + return !tiRE && piRE && p.constructor === $RegExp && fiU ? p + : _inheritIfRequired(CORRECT_NEW + ? new Base$1(piRE && !fiU ? p.source : p, f) + : Base$1((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? _flags.call(p) : f) + , tiRE ? this : proto$2, $RegExp); + }; + var proxy = function (key) { + key in $RegExp || dP$3($RegExp, key, { + configurable: true, + get: function () { return Base$1[key]; }, + set: function (it) { Base$1[key] = it; } + }); + }; + for (var keys$2 = gOPN$3(Base$1), i$1 = 0; keys$2.length > i$1;) proxy(keys$2[i$1++]); + proto$2.constructor = $RegExp; + $RegExp.prototype = proto$2; + _redefine(_global, 'RegExp', $RegExp); + } + + _setSpecies('RegExp'); + /** * Gives a single-word string description of the (native) type of a value, * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not @@ -2761,7 +3618,10 @@ * R.type(() => {}); //=> "Function" * R.type(undefined); //=> "Undefined" */ - var type = /*#__PURE__*/_curry1(function type(val) { + + var type = + /*#__PURE__*/ + _curry1(function type(val) { return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1); }); @@ -2784,7 +3644,10 @@ * R.not(0); //=> true * R.not(1); //=> false */ - var not = /*#__PURE__*/_curry1(function not(a) { + + var not = + /*#__PURE__*/ + _curry1(function not(a) { return !a; }); @@ -2810,7 +3673,10 @@ * isNil(7); //=> false * isNotNil(7); //=> true */ - var complement = /*#__PURE__*/lift(not); + + var complement = + /*#__PURE__*/ + lift(not); function _pipe(f, g) { return function () { @@ -2828,12 +3694,15 @@ * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ + function _checkForMethod(methodname, fn) { return function () { var length = arguments.length; + if (length === 0) { return fn(); } + var obj = arguments[length - 1]; return _isArray$1(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); }; @@ -2863,7 +3732,12 @@ * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] * R.slice(0, 3, 'ramda'); //=> 'ram' */ - var slice = /*#__PURE__*/_curry3( /*#__PURE__*/_checkForMethod('slice', function slice(fromIndex, toIndex, list) { + + var slice = + /*#__PURE__*/ + _curry3( + /*#__PURE__*/ + _checkForMethod('slice', function slice(fromIndex, toIndex, list) { return Array.prototype.slice.call(list, fromIndex, toIndex); })); @@ -2894,7 +3768,14 @@ * R.tail('a'); //=> '' * R.tail(''); //=> '' */ - var tail = /*#__PURE__*/_curry1( /*#__PURE__*/_checkForMethod('tail', /*#__PURE__*/slice(1, Infinity))); + + var tail = + /*#__PURE__*/ + _curry1( + /*#__PURE__*/ + _checkForMethod('tail', + /*#__PURE__*/ + slice(1, Infinity))); /** * Performs left-to-right function composition. The leftmost function may have @@ -2919,13 +3800,318 @@ * f(3, 4); // -(3^4) + 1 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) */ + function pipe() { if (arguments.length === 0) { throw new Error('pipe requires at least one argument'); } + return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments))); } + var at = _stringAt(true); + + // `AdvanceStringIndex` abstract operation + // https://tc39.github.io/ecma262/#sec-advancestringindex + var _advanceStringIndex = function (S, index, unicode) { + return index + (unicode ? at(S, index).length : 1); + }; + + var builtinExec = RegExp.prototype.exec; + + // `RegExpExec` abstract operation + // https://tc39.github.io/ecma262/#sec-regexpexec + var _regexpExecAbstract = function (R, S) { + var exec = R.exec; + if (typeof exec === 'function') { + var result = exec.call(R, S); + if (typeof result !== 'object') { + throw new TypeError('RegExp exec method returned something other than an Object or null'); + } + return result; + } + if (_classof(R) !== 'RegExp') { + throw new TypeError('RegExp#exec called on incompatible receiver'); + } + return builtinExec.call(R, S); + }; + + var nativeExec = RegExp.prototype.exec; + // This always refers to the native implementation, because the + // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, + // which loads this file before patching the method. + var nativeReplace = String.prototype.replace; + + var patchedExec = nativeExec; + + var LAST_INDEX = 'lastIndex'; + + var UPDATES_LAST_INDEX_WRONG = (function () { + var re1 = /a/, + re2 = /b*/g; + nativeExec.call(re1, 'a'); + nativeExec.call(re2, 'a'); + return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0; + })(); + + // nonparticipating capturing group, copied from es5-shim's String#split patch. + var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; + + var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED; + + if (PATCH) { + patchedExec = function exec(str) { + var re = this; + var lastIndex, reCopy, match, i; + + if (NPCG_INCLUDED) { + reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re)); + } + if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX]; + + match = nativeExec.call(re, str); + + if (UPDATES_LAST_INDEX_WRONG && match) { + re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex; + } + if (NPCG_INCLUDED && match && match.length > 1) { + // Fix browsers whose `exec` methods don't consistently return `undefined` + // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ + // eslint-disable-next-line no-loop-func + nativeReplace.call(match[0], reCopy, function () { + for (i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) match[i] = undefined; + } + }); + } + + return match; + }; + } + + var _regexpExec = patchedExec; + + _export({ + target: 'RegExp', + proto: true, + forced: _regexpExec !== /./.exec + }, { + exec: _regexpExec + }); + + var SPECIES$3 = _wks('species'); + + var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () { + // #replace needs built-in support for named groups. + // #match works fine because it just return the exec results, even if it has + // a "grops" property. + var re = /./; + re.exec = function () { + var result = []; + result.groups = { a: '7' }; + return result; + }; + return ''.replace(re, '$') !== '7'; + }); + + var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () { + // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec + var re = /(?:)/; + var originalExec = re.exec; + re.exec = function () { return originalExec.apply(this, arguments); }; + var result = 'ab'.split(re); + return result.length === 2 && result[0] === 'a' && result[1] === 'b'; + })(); + + var _fixReWks = function (KEY, length, exec) { + var SYMBOL = _wks(KEY); + + var DELEGATES_TO_SYMBOL = !_fails(function () { + // String methods call symbol-named RegEp methods + var O = {}; + O[SYMBOL] = function () { return 7; }; + return ''[KEY](O) != 7; + }); + + var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () { + // Symbol-named RegExp methods call .exec + var execCalled = false; + var re = /a/; + re.exec = function () { execCalled = true; return null; }; + if (KEY === 'split') { + // RegExp[@@split] doesn't call the regex's exec method, but first creates + // a new one. We need to return the patched regex when creating the new one. + re.constructor = {}; + re.constructor[SPECIES$3] = function () { return re; }; + } + re[SYMBOL](''); + return !execCalled; + }) : undefined; + + if ( + !DELEGATES_TO_SYMBOL || + !DELEGATES_TO_EXEC || + (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) || + (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) + ) { + var nativeRegExpMethod = /./[SYMBOL]; + var fns = exec( + _defined, + SYMBOL, + ''[KEY], + function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) { + if (regexp.exec === _regexpExec) { + if (DELEGATES_TO_SYMBOL && !forceStringMethod) { + // The native String method already delegates to @@method (this + // polyfilled function), leasing to infinite recursion. + // We avoid it by directly calling the native @@method method. + return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; + } + return { done: true, value: nativeMethod.call(str, regexp, arg2) }; + } + return { done: false }; + } + ); + var strfn = fns[0]; + var rxfn = fns[1]; + + _redefine(String.prototype, KEY, strfn); + _hide(RegExp.prototype, SYMBOL, length == 2 + // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) + // 21.2.5.11 RegExp.prototype[@@split](string, limit) + ? function (string, arg) { return rxfn.call(string, this, arg); } + // 21.2.5.6 RegExp.prototype[@@match](string) + // 21.2.5.9 RegExp.prototype[@@search](string) + : function (string) { return rxfn.call(string, this); } + ); + } + }; + + var $min = Math.min; + var $push = [].push; + var $SPLIT = 'split'; + var LENGTH = 'length'; + var LAST_INDEX$1 = 'lastIndex'; + var MAX_UINT32 = 0xffffffff; + + // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError + var SUPPORTS_Y = !_fails(function () { }); + + // @@split logic + _fixReWks('split', 2, function (defined, SPLIT, $split, maybeCallNative) { + var internalSplit; + if ( + 'abbc'[$SPLIT](/(b)*/)[1] == 'c' || + 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || + 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 || + '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 || + '.'[$SPLIT](/()()/)[LENGTH] > 1 || + ''[$SPLIT](/.?/)[LENGTH] + ) { + // based on es5-shim implementation, need to rework it + internalSplit = function (separator, limit) { + var string = String(this); + if (separator === undefined && limit === 0) return []; + // If `separator` is not a regex, use native split + if (!_isRegexp(separator)) return $split.call(string, separator, limit); + var output = []; + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') + + (separator.sticky ? 'y' : ''); + var lastLastIndex = 0; + var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0; + // Make `global` and avoid `lastIndex` issues by working with a copy + var separatorCopy = new RegExp(separator.source, flags + 'g'); + var match, lastIndex, lastLength; + while (match = _regexpExec.call(separatorCopy, string)) { + lastIndex = separatorCopy[LAST_INDEX$1]; + if (lastIndex > lastLastIndex) { + output.push(string.slice(lastLastIndex, match.index)); + if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); + lastLength = match[0][LENGTH]; + lastLastIndex = lastIndex; + if (output[LENGTH] >= splitLimit) break; + } + if (separatorCopy[LAST_INDEX$1] === match.index) separatorCopy[LAST_INDEX$1]++; // Avoid an infinite loop + } + if (lastLastIndex === string[LENGTH]) { + if (lastLength || !separatorCopy.test('')) output.push(''); + } else output.push(string.slice(lastLastIndex)); + return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output; + }; + // Chakra, V8 + } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { + internalSplit = function (separator, limit) { + return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit); + }; + } else { + internalSplit = $split; + } + + return [ + // `String.prototype.split` method + // https://tc39.github.io/ecma262/#sec-string.prototype.split + function split(separator, limit) { + var O = defined(this); + var splitter = separator == undefined ? undefined : separator[SPLIT]; + return splitter !== undefined + ? splitter.call(separator, O, limit) + : internalSplit.call(String(O), separator, limit); + }, + // `RegExp.prototype[@@split]` method + // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split + // + // NOTE: This cannot be properly polyfilled in engines that don't support + // the 'y' flag. + function (regexp, limit) { + var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split); + if (res.done) return res.value; + + var rx = _anObject(regexp); + var S = String(this); + var C = _speciesConstructor(rx, RegExp); + + var unicodeMatching = rx.unicode; + var flags = (rx.ignoreCase ? 'i' : '') + + (rx.multiline ? 'm' : '') + + (rx.unicode ? 'u' : '') + + (SUPPORTS_Y ? 'y' : 'g'); + + // ^(? + rx + ) is needed, in combination with some S slicing, to + // simulate the 'y' flag. + var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags); + var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; + if (lim === 0) return []; + if (S.length === 0) return _regexpExecAbstract(splitter, S) === null ? [S] : []; + var p = 0; + var q = 0; + var A = []; + while (q < S.length) { + splitter.lastIndex = SUPPORTS_Y ? q : 0; + var z = _regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q)); + var e; + if ( + z === null || + (e = $min(_toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p + ) { + q = _advanceStringIndex(S, q, unicodeMatching); + } else { + A.push(S.slice(p, q)); + if (A.length === lim) return A; + for (var i = 1; i <= z.length - 1; i++) { + A.push(z[i]); + if (A.length === lim) return A; + } + q = p = e; + } + } + A.push(S.slice(p)); + return A; + } + ]; + }); + /** * Returns a new list or string with the elements or characters in reverse * order. @@ -2950,7 +4136,10 @@ * R.reverse('a'); //=> 'a' * R.reverse(''); //=> '' */ - var reverse = /*#__PURE__*/_curry1(function reverse(list) { + + var reverse = + /*#__PURE__*/ + _curry1(function reverse(list) { return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse(); }); @@ -2978,19 +4167,73 @@ * * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) */ + function compose() { if (arguments.length === 0) { throw new Error('compose requires at least one argument'); } + return pipe.apply(this, reverse(arguments)); } + var $sort = [].sort; + var test = [1, 2, 3]; + + _export(_export.P + _export.F * (_fails(function () { + // IE8- + test.sort(undefined); + }) || !_fails(function () { + // V8 bug + test.sort(null); + // Old WebKit + }) || !_strictMethod($sort)), 'Array', { + // 22.1.3.25 Array.prototype.sort(comparefn) + sort: function sort(comparefn) { + return comparefn === undefined + ? $sort.call(_toObject(this)) + : $sort.call(_toObject(this), _aFunction(comparefn)); + } + }); + + var $indexOf = _arrayIncludes(false); + var $native = [].indexOf; + var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0; + + _export(_export.P + _export.F * (NEGATIVE_ZERO || !_strictMethod($native)), 'Array', { + // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex]) + indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { + return NEGATIVE_ZERO + // convert -0 to +0 + ? $native.apply(this, arguments) || 0 + : $indexOf(this, searchElement, arguments[1]); + } + }); + + var dP$4 = _objectDp.f; + var FProto = Function.prototype; + var nameRE = /^\s*function ([^ (]*)/; + var NAME$1 = 'name'; + + // 19.2.4.2 name + NAME$1 in FProto || _descriptors && dP$4(FProto, NAME$1, { + configurable: true, + get: function () { + try { + return ('' + this).match(nameRE)[1]; + } catch (e) { + return ''; + } + } + }); + function _arrayFromIterator(iter) { var list = []; var next; + while (!(next = iter.next()).done) { list.push(next.value); } + return list; } @@ -3002,11 +4245,47 @@ if (pred(x, list[idx])) { return true; } + idx += 1; } + return false; } + // @@match logic + _fixReWks('match', 1, function (defined, MATCH, $match, maybeCallNative) { + return [ + // `String.prototype.match` method + // https://tc39.github.io/ecma262/#sec-string.prototype.match + function match(regexp) { + var O = defined(this); + var fn = regexp == undefined ? undefined : regexp[MATCH]; + return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); + }, + // `RegExp.prototype[@@match]` method + // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match + function (regexp) { + var res = maybeCallNative($match, regexp, this); + if (res.done) return res.value; + var rx = _anObject(regexp); + var S = String(this); + if (!rx.global) return _regexpExecAbstract(rx, S); + var fullUnicode = rx.unicode; + rx.lastIndex = 0; + var A = []; + var n = 0; + var result; + while ((result = _regexpExecAbstract(rx, S)) !== null) { + var matchStr = String(result[0]); + A[n] = matchStr; + if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); + n++; + } + return n === 0 ? null : A; + } + ]; + }); + function _functionName(f) { // String(x => x) evaluates to "x => x", so the pattern may not match. var match = String(f).match(/^function (\w*)/); @@ -3036,7 +4315,10 @@ * R.identical(0, -0); //=> false * R.identical(NaN, NaN); //=> true */ - var identical = /*#__PURE__*/_curry2(function identical(a, b) { + + var identical = + /*#__PURE__*/ + _curry2(function identical(a, b) { // SameValue algorithm if (a === b) { // Steps 1-5, 7-10 @@ -3061,13 +4343,14 @@ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { var a = _arrayFromIterator(aIterator); + var b = _arrayFromIterator(bIterator); function eq(_a, _b) { return _equals(_a, _b, stackA.slice(), stackB.slice()); - } + } // if *a* array contains any element that is not included in *b* + - // if *a* array contains any element that is not included in *b* return !_containsWith(function (b, aItem) { return !_containsWith(eq, aItem, b); }, b, a); @@ -3103,33 +4386,43 @@ if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') { return a === b; } + break; + case 'Boolean': case 'Number': case 'String': - if (!(typeof a === typeof b && identical(a.valueOf(), b.valueOf()))) { + if (!(_typeof(a) === _typeof(b) && identical(a.valueOf(), b.valueOf()))) { return false; } + break; + case 'Date': if (!identical(a.valueOf(), b.valueOf())) { return false; } + break; + case 'Error': return a.name === b.name && a.message === b.message; + case 'RegExp': if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) { return false; } + break; } var idx = stackA.length - 1; + while (idx >= 0) { if (stackA[idx] === a) { return stackB[idx] === b; } + idx -= 1; } @@ -3140,12 +4433,14 @@ } return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); + case 'Set': if (a.size !== b.size) { return false; } return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); + case 'Arguments': case 'Array': case 'Object': @@ -3166,27 +4461,32 @@ case 'Float64Array': case 'ArrayBuffer': break; + default: // Values of other types are only equal if identical. return false; } - var keysA = keys(a); - if (keysA.length !== keys(b).length) { + var keysA = keys$1(a); + + if (keysA.length !== keys$1(b).length) { return false; } var extendedStackA = stackA.concat([a]); var extendedStackB = stackB.concat([b]); - idx = keysA.length - 1; + while (idx >= 0) { var key = keysA[idx]; + if (!(_has$1(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { return false; } + idx -= 1; } + return true; } @@ -3215,42 +4515,53 @@ * var b = {}; b.v = b; * R.equals(a, b); //=> true */ - var equals = /*#__PURE__*/_curry2(function equals(a, b) { + + var equals = + /*#__PURE__*/ + _curry2(function equals(a, b) { return _equals(a, b, [], []); }); function _indexOf(list, a, idx) { - var inf, item; - // Array.prototype.indexOf doesn't exist below IE9 + var inf, item; // Array.prototype.indexOf doesn't exist below IE9 + if (typeof list.indexOf === 'function') { - switch (typeof a) { + switch (_typeof(a)) { case 'number': if (a === 0) { // manually crawl the list to distinguish between +0 and -0 inf = 1 / a; + while (idx < list.length) { item = list[idx]; + if (item === 0 && 1 / item === inf) { return idx; } + idx += 1; } + return -1; } else if (a !== a) { // NaN while (idx < list.length) { item = list[idx]; + if (typeof item === 'number' && item !== item) { return idx; } + idx += 1; } + return -1; - } - // non-zero numbers can utilise Set - return list.indexOf(a, idx); + } // non-zero numbers can utilise Set + + return list.indexOf(a, idx); // all these types can utilise Set + case 'string': case 'boolean': case 'function': @@ -3262,15 +4573,19 @@ // null can utilise Set return list.indexOf(a, idx); } + } - } - // anything else not covered above, defer to R.equals + } // anything else not covered above, defer to R.equals + + while (idx < list.length) { if (equals(list[idx], a)) { return idx; } + idx += 1; } + return -1; } @@ -3278,12 +4593,157 @@ return _indexOf(list, a, 0) >= 0; } + var max$2 = Math.max; + var min$2 = Math.min; + var floor$2 = Math.floor; + var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g; + var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g; + + var maybeToString = function (it) { + return it === undefined ? it : String(it); + }; + + // @@replace logic + _fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) { + return [ + // `String.prototype.replace` method + // https://tc39.github.io/ecma262/#sec-string.prototype.replace + function replace(searchValue, replaceValue) { + var O = defined(this); + var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; + return fn !== undefined + ? fn.call(searchValue, O, replaceValue) + : $replace.call(String(O), searchValue, replaceValue); + }, + // `RegExp.prototype[@@replace]` method + // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace + function (regexp, replaceValue) { + var res = maybeCallNative($replace, regexp, this, replaceValue); + if (res.done) return res.value; + + var rx = _anObject(regexp); + var S = String(this); + var functionalReplace = typeof replaceValue === 'function'; + if (!functionalReplace) replaceValue = String(replaceValue); + var global = rx.global; + if (global) { + var fullUnicode = rx.unicode; + rx.lastIndex = 0; + } + var results = []; + while (true) { + var result = _regexpExecAbstract(rx, S); + if (result === null) break; + results.push(result); + if (!global) break; + var matchStr = String(result[0]); + if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); + } + var accumulatedResult = ''; + var nextSourcePosition = 0; + for (var i = 0; i < results.length; i++) { + result = results[i]; + var matched = String(result[0]); + var position = max$2(min$2(_toInteger(result.index), S.length), 0); + var captures = []; + // NOTE: This is equivalent to + // captures = result.slice(1).map(maybeToString) + // but for some reason `nativeSlice.call(result, 1, result.length)` (called in + // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and + // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. + for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); + var namedCaptures = result.groups; + if (functionalReplace) { + var replacerArgs = [matched].concat(captures, position, S); + if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); + var replacement = String(replaceValue.apply(undefined, replacerArgs)); + } else { + replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); + } + if (position >= nextSourcePosition) { + accumulatedResult += S.slice(nextSourcePosition, position) + replacement; + nextSourcePosition = position + matched.length; + } + } + return accumulatedResult + S.slice(nextSourcePosition); + } + ]; + + // https://tc39.github.io/ecma262/#sec-getsubstitution + function getSubstitution(matched, str, position, captures, namedCaptures, replacement) { + var tailPos = position + matched.length; + var m = captures.length; + var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; + if (namedCaptures !== undefined) { + namedCaptures = _toObject(namedCaptures); + symbols = SUBSTITUTION_SYMBOLS; + } + return $replace.call(replacement, symbols, function (match, ch) { + var capture; + switch (ch.charAt(0)) { + case '$': return '$'; + case '&': return matched; + case '`': return str.slice(0, position); + case "'": return str.slice(tailPos); + case '<': + capture = namedCaptures[ch.slice(1, -1)]; + break; + default: // \d\d? + var n = +ch; + if (n === 0) return match; + if (n > m) { + var f = floor$2(n / 10); + if (f === 0) return match; + if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); + return match; + } + capture = captures[n - 1]; + } + return capture === undefined ? '' : capture; + }); + } + }); + function _quote(s) { var escaped = s.replace(/\\/g, '\\\\').replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace .replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/\v/g, '\\v').replace(/\0/g, '\\0'); + return '"' + escaped.replace(/"/g, '\\"') + '"'; + } + + // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() + + var getTime$1 = Date.prototype.getTime; + var $toISOString = Date.prototype.toISOString; + + var lz = function (num) { + return num > 9 ? num : '0' + num; + }; - return '"' + escaped.replace(/"/g, '\\"') + '"'; - } + // PhantomJS / old WebKit has a broken implementations + var _dateToIsoString = (_fails(function () { + return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z'; + }) || !_fails(function () { + $toISOString.call(new Date(NaN)); + })) ? function toISOString() { + if (!isFinite(getTime$1.call(this))) throw RangeError('Invalid time value'); + var d = this; + var y = d.getUTCFullYear(); + var m = d.getUTCMilliseconds(); + var s = y < 0 ? '-' : y > 9999 ? '+' : ''; + return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) + + '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) + + 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) + + ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; + } : $toISOString; + + // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() + + + + // PhantomJS / old WebKit has a broken implementations + _export(_export.P + _export.F * (Date.prototype.toISOString !== _dateToIsoString), 'Date', { + toISOString: _dateToIsoString + }); /** * Polyfill from . @@ -3313,8 +4773,10 @@ if (fn(list[idx])) { result[result.length] = list[idx]; } + idx += 1; } + return result; } @@ -3322,13 +4784,17 @@ return Object.prototype.toString.call(x) === '[object Object]'; } - var XFilter = /*#__PURE__*/function () { + var XFilter = + /*#__PURE__*/ + function () { function XFilter(f, xf) { this.xf = xf; this.f = f; } + XFilter.prototype['@@transducer/init'] = _xfBase.init; XFilter.prototype['@@transducer/result'] = _xfBase.result; + XFilter.prototype['@@transducer/step'] = function (result, input) { return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; }; @@ -3336,7 +4802,9 @@ return XFilter; }(); - var _xfilter = /*#__PURE__*/_curry2(function _xfilter(f, xf) { + var _xfilter = + /*#__PURE__*/ + _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); @@ -3367,14 +4835,19 @@ * * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ - var filter = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['filter'], _xfilter, function (pred, filterable) { + + var filter = + /*#__PURE__*/ + _curry2( + /*#__PURE__*/ + _dispatchable(['filter'], _xfilter, function (pred, filterable) { return _isObject$1(filterable) ? _reduce(function (acc, key) { if (pred(filterable[key])) { acc[key] = filterable[key]; } + return acc; - }, {}, keys(filterable)) : - // else + }, {}, keys$1(filterable)) : // else _filter(pred, filterable); })); @@ -3402,7 +4875,10 @@ * * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ - var reject = /*#__PURE__*/_curry2(function reject(pred, filterable) { + + var reject = + /*#__PURE__*/ + _curry2(function reject(pred, filterable) { return filter(_complement(pred), filterable); }); @@ -3410,43 +4886,52 @@ var recur = function recur(y) { var xs = seen.concat([x]); return _contains(y, xs) ? '' : _toString(y, xs); - }; + }; // mapPairs :: (Object, [String]) -> [String] + - // mapPairs :: (Object, [String]) -> [String] - var mapPairs = function (obj, keys$$1) { + var mapPairs = function mapPairs(obj, keys) { return _map(function (k) { return _quote(k) + ': ' + recur(obj[k]); - }, keys$$1.slice().sort()); + }, keys.slice().sort()); }; switch (Object.prototype.toString.call(x)) { case '[object Arguments]': return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; + case '[object Array]': return '[' + _map(recur, x).concat(mapPairs(x, reject(function (k) { - return (/^\d+$/.test(k) - ); - }, keys(x)))).join(', ') + ']'; + return /^\d+$/.test(k); + }, keys$1(x)))).join(', ') + ']'; + case '[object Boolean]': - return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); + return _typeof(x) === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); + case '[object Date]': return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; + case '[object Null]': return 'null'; + case '[object Number]': - return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + return _typeof(x) === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + case '[object String]': - return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); + return _typeof(x) === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); + case '[object Undefined]': return 'undefined'; + default: if (typeof x.toString === 'function') { var repr = x.toString(); + if (repr !== '[object Object]') { return repr; } } - return '{' + mapPairs(x, keys(x)).join(', ') + '}'; + + return '{' + mapPairs(x, keys$1(x)).join(', ') + '}'; } } @@ -3486,7 +4971,10 @@ * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' */ - var toString$2 = /*#__PURE__*/_curry1(function toString(val) { + + var toString$3 = + /*#__PURE__*/ + _curry1(function toString(val) { return _toString(val, []); }); @@ -3517,7 +5005,10 @@ * * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) */ - var converge = /*#__PURE__*/_curry2(function converge(after, fns) { + + var converge = + /*#__PURE__*/ + _curry2(function converge(after, fns) { return curryN(reduce(max$1, 0, pluck('length', fns)), function () { var args = arguments; var context = this; @@ -3527,7 +5018,9 @@ }); }); - var XReduceBy = /*#__PURE__*/function () { + var XReduceBy = + /*#__PURE__*/ + function () { function XReduceBy(valueFn, valueAcc, keyFn, xf) { this.valueFn = valueFn; this.valueAcc = valueAcc; @@ -3535,21 +5028,27 @@ this.xf = xf; this.inputs = {}; } + XReduceBy.prototype['@@transducer/init'] = _xfBase.init; + XReduceBy.prototype['@@transducer/result'] = function (result) { var key; + for (key in this.inputs) { if (_has$1(key, this.inputs)) { result = this.xf['@@transducer/step'](result, this.inputs[key]); + if (result['@@transducer/reduced']) { result = result['@@transducer/value']; break; } } } + this.inputs = null; return this.xf['@@transducer/result'](result); }; + XReduceBy.prototype['@@transducer/step'] = function (result, input) { var key = this.keyFn(input); this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; @@ -3560,7 +5059,9 @@ return XReduceBy; }(); - var _xreduceBy = /*#__PURE__*/_curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) { + var _xreduceBy = + /*#__PURE__*/ + _curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) { return new XReduceBy(valueFn, valueAcc, keyFn, xf); }); @@ -3608,7 +5109,12 @@ * // 'F': ['Bart'] * // } */ - var reduceBy = /*#__PURE__*/_curryN(4, [], /*#__PURE__*/_dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { + + var reduceBy = + /*#__PURE__*/ + _curryN(4, [], + /*#__PURE__*/ + _dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { return _reduce(function (acc, elt) { var key = keyFn(elt); acc[key] = valueFn(_has$1(key, acc) ? acc[key] : valueAcc, elt); @@ -3640,7 +5146,10 @@ * var letters = ['a', 'b', 'A', 'a', 'B', 'c']; * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} */ - var countBy = /*#__PURE__*/reduceBy(function (acc, elem) { + + var countBy = + /*#__PURE__*/ + reduceBy(function (acc, elem) { return acc + 1; }, 0); @@ -3659,9 +5168,14 @@ * * R.dec(42); //=> 41 */ - var dec = /*#__PURE__*/add(-1); - var XDropRepeatsWith = /*#__PURE__*/function () { + var dec = + /*#__PURE__*/ + add(-1); + + var XDropRepeatsWith = + /*#__PURE__*/ + function () { function XDropRepeatsWith(pred, xf) { this.xf = xf; this.pred = pred; @@ -3671,13 +5185,16 @@ XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; + XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) { var sameAsLast = false; + if (!this.seenFirstValue) { this.seenFirstValue = true; } else if (this.pred(this.lastValue, input)) { sameAsLast = true; } + this.lastValue = input; return sameAsLast ? result : this.xf['@@transducer/step'](result, input); }; @@ -3685,7 +5202,9 @@ return XDropRepeatsWith; }(); - var _xdropRepeatsWith = /*#__PURE__*/_curry2(function _xdropRepeatsWith(pred, xf) { + var _xdropRepeatsWith = + /*#__PURE__*/ + _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); @@ -3715,7 +5234,10 @@ * @symb R.nth(0, [a, b, c]) = a * @symb R.nth(1, [a, b, c]) = b */ - var nth = /*#__PURE__*/_curry2(function nth(offset, list) { + + var nth = + /*#__PURE__*/ + _curry2(function nth(offset, list) { var idx = offset < 0 ? list.length + offset : offset; return _isString(list) ? list.charAt(idx) : list[idx]; }); @@ -3740,7 +5262,10 @@ * R.last('abc'); //=> 'c' * R.last(''); //=> '' */ - var last = /*#__PURE__*/nth(-1); + + var last = + /*#__PURE__*/ + nth(-1); /** * Returns a new list without any consecutively repeating elements. Equality is @@ -3763,19 +5288,28 @@ * var l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] */ - var dropRepeatsWith = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { + + var dropRepeatsWith = + /*#__PURE__*/ + _curry2( + /*#__PURE__*/ + _dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { var result = []; var idx = 1; var len = list.length; + if (len !== 0) { result[0] = list[0]; + while (idx < len) { if (!pred(last(result), list[idx])) { result[result.length] = list[idx]; } + idx += 1; } } + return result; })); @@ -3797,7 +5331,16 @@ * * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] */ - var dropRepeats = /*#__PURE__*/_curry1( /*#__PURE__*/_dispatchable([], /*#__PURE__*/_xdropRepeatsWith(equals), /*#__PURE__*/dropRepeatsWith(equals))); + + var dropRepeats = + /*#__PURE__*/ + _curry1( + /*#__PURE__*/ + _dispatchable([], + /*#__PURE__*/ + _xdropRepeatsWith(equals), + /*#__PURE__*/ + dropRepeatsWith(equals))); /** * Returns a new function much like the supplied one, except that the first two @@ -3819,7 +5362,10 @@ * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] * @symb R.flip(f)(a, b, c) = f(b, a, c) */ - var flip = /*#__PURE__*/_curry1(function flip(fn) { + + var flip = + /*#__PURE__*/ + _curry1(function flip(fn) { return curryN(fn.length, function (a, b) { var args = Array.prototype.slice.call(arguments, 0); args[0] = b; @@ -3844,13 +5390,18 @@ * * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} */ - var fromPairs = /*#__PURE__*/_curry1(function fromPairs(pairs) { + + var fromPairs = + /*#__PURE__*/ + _curry1(function fromPairs(pairs) { var result = {}; var idx = 0; + while (idx < pairs.length) { result[pairs[idx][0]] = pairs[idx][1]; idx += 1; } + return result; }); @@ -3894,10 +5445,18 @@ * // 'F': [{name: 'Eddy', score: 58}] * // } */ - var groupBy = /*#__PURE__*/_curry2( /*#__PURE__*/_checkForMethod('groupBy', /*#__PURE__*/reduceBy(function (acc, item) { + + var groupBy = + /*#__PURE__*/ + _curry2( + /*#__PURE__*/ + _checkForMethod('groupBy', + /*#__PURE__*/ + reduceBy(function (acc, item) { if (acc == null) { acc = []; } + acc.push(item); return acc; }, null))); @@ -3923,7 +5482,10 @@ * R.head('abc'); //=> 'a' * R.head(''); //=> '' */ - var head = /*#__PURE__*/nth(0); + + var head = + /*#__PURE__*/ + nth(0); function _identity(x) { return x; @@ -3948,7 +5510,10 @@ * R.identity(obj) === obj; //=> true * @symb R.identity(a) = a */ - var identity = /*#__PURE__*/_curry1(_identity); + + var identity = + /*#__PURE__*/ + _curry1(_identity); /** * Increments its argument. @@ -3965,7 +5530,10 @@ * * R.inc(42); //=> 43 */ - var inc = /*#__PURE__*/add(1); + + var inc = + /*#__PURE__*/ + add(1); /** * Given a function that generates a key, turns a list of objects into an @@ -3989,7 +5557,10 @@ * R.indexBy(R.prop('id'), list); * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} */ - var indexBy = /*#__PURE__*/reduceBy(function (acc, elem) { + + var indexBy = + /*#__PURE__*/ + reduceBy(function (acc, elem) { return elem; }, null); @@ -4017,32 +5588,268 @@ * R.init('a'); //=> '' * R.init(''); //=> '' */ - var init = /*#__PURE__*/slice(0, -1); - var _Set = /*#__PURE__*/function () { + var init = + /*#__PURE__*/ + slice(0, -1); + + var _validateCollection = function (it, TYPE) { + if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); + return it; + }; + + var dP$5 = _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$5(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 _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 = {}; + var fixMethod = function (KEY) { + var fn = proto[KEY]; + _redefine(proto, KEY, + KEY == 'delete' ? function (a) { + return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); + } : KEY == 'has' ? function has(a) { + return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); + } : KEY == 'get' ? function get(a) { + return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); + } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; } + : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; } + ); + }; + if (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 { + var instance = new C(); + // early implementations not supports chaining + var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; + // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false + var THROWS_ON_PRIMITIVES = _fails(function () { instance.has(1); }); + // most early implementations doesn't supports iterables, most modern - not close it correctly + var ACCEPT_ITERABLES = _iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new + // for early implementations -0 and +0 not the same + var BUGGY_ZERO = !IS_WEAK && _fails(function () { + // V8 ~ Chromium 42- fails only with 5+ elements + var $instance = new C(); + var index = 5; + while (index--) $instance[ADDER](index, index); + return !$instance.has(-0); + }); + if (!ACCEPT_ITERABLES) { + C = wrapper(function (target, iterable) { + _anInstance(target, C, NAME); + var that = _inheritIfRequired(new Base(), target, C); + if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); + return that; + }); + C.prototype = proto; + proto.constructor = C; + } + if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { + fixMethod('delete'); + fixMethod('has'); + IS_MAP && fixMethod('get'); + } + if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); + // weak collections should not contains .clear method + if (IS_WEAK && proto.clear) delete proto.clear; + } + + _setToStringTag(C, NAME); + + O[NAME] = C; + _export(_export.G + _export.W + _export.F * (C != Base), O); + + if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); + + return C; + }; + + 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); + + var _Set = + /*#__PURE__*/ + function () { function _Set() { /* globals Set */ this._nativeSet = typeof Set === 'function' ? new Set() : null; this._items = {}; - } - - // until we figure out why jsdoc chokes on this + } // until we figure out why jsdoc chokes on this // @param item The item to add to the Set // @returns {boolean} true if the item did not exist prior, otherwise false // + + _Set.prototype.add = function (item) { return !hasOrAdd(item, true, this); - }; - - // + }; // // @param item The item to check for existence in the Set // @returns {boolean} true if the item exists in the Set, otherwise false // + + _Set.prototype.has = function (item) { return hasOrAdd(item, false, this); - }; - - // + }; // // Combines the logic for checking whether an item is a member of the set and // for adding a new item to the set. // @@ -4052,12 +5859,16 @@ // @param set The set instance to check or add to. // @return {boolean} true if the item already existed, otherwise false. // + + return _Set; }(); function hasOrAdd(item, shouldAdd, set) { - var type = typeof item; + var type = _typeof(item); + var prevSize, newSize; + switch (type) { case 'string': case 'number': @@ -4069,14 +5880,18 @@ if (shouldAdd) { set._items['-0'] = true; } + return false; } - } - // these types can all utilise the native Set + } // these types can all utilise the native Set + + if (set._nativeSet !== null) { if (shouldAdd) { prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; return newSize === prevSize; } else { @@ -4088,6 +5903,7 @@ set._items[type] = {}; set._items[type][item] = true; } + return false; } else if (item in set._items[type]) { return true; @@ -4095,6 +5911,7 @@ if (shouldAdd) { set._items[type][item] = true; } + return false; } } @@ -4104,18 +5921,21 @@ // representing [ falseExists, trueExists ] if (type in set._items) { var bIdx = item ? 1 : 0; + if (set._items[type][bIdx]) { return true; } else { if (shouldAdd) { set._items[type][bIdx] = true; } + return false; } } else { if (shouldAdd) { set._items[type] = item ? [false, true] : [true, false]; } + return false; } @@ -4124,7 +5944,9 @@ if (set._nativeSet !== null) { if (shouldAdd) { prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; return newSize === prevSize; } else { @@ -4135,14 +5957,18 @@ if (shouldAdd) { set._items[type] = [item]; } + return false; } + if (!_contains(item, set._items[type])) { if (shouldAdd) { set._items[type].push(item); } + return false; } + return true; } @@ -4153,6 +5979,7 @@ if (shouldAdd) { set._items[type] = true; } + return false; } @@ -4162,31 +5989,40 @@ if (shouldAdd) { set._items['null'] = true; } + return false; } + return true; } + /* falls through */ + default: // reduce the search size of heterogeneous sets by creating buckets // for each type. type = Object.prototype.toString.call(item); + if (!(type in set._items)) { if (shouldAdd) { set._items[type] = [item]; } + return false; - } - // scan through all previously applied items + } // scan through all previously applied items + + if (!_contains(item, set._items[type])) { if (shouldAdd) { set._items[type].push(item); } + return false; } + return true; } - } + } // A simple Set type that honours R.equals semantics /** * Returns a new list containing only one copy of each element in the original @@ -4206,7 +6042,10 @@ * * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] */ - var uniqBy = /*#__PURE__*/_curry2(function uniqBy(fn, list) { + + var uniqBy = + /*#__PURE__*/ + _curry2(function uniqBy(fn, list) { var set = new _Set(); var result = []; var idx = 0; @@ -4215,11 +6054,14 @@ while (idx < list.length) { item = list[idx]; appliedItem = fn(item); + if (set.add(appliedItem)) { result.push(item); } + idx += 1; } + return result; }); @@ -4240,7 +6082,49 @@ * R.uniq([1, '1']); //=> [1, '1'] * R.uniq([[42], [42]]); //=> [[42]] */ - var uniq = /*#__PURE__*/uniqBy(identity); + + var uniq = + /*#__PURE__*/ + uniqBy(identity); + + // 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 }); /** * Turns a named method with a specified arity into a function that can be @@ -4269,13 +6153,18 @@ * @symb R.invoker(1, 'method')(a, o) = o['method'](a) * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) */ - var invoker = /*#__PURE__*/_curry2(function invoker(arity, method) { + + var invoker = + /*#__PURE__*/ + _curry2(function invoker(arity, method) { return curryN(arity + 1, function () { var target = arguments[arity]; + if (target != null && _isFunction(target[method])) { return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); } - throw new TypeError(toString$2(target) + ' does not have a method named "' + method + '"'); + + throw new TypeError(toString$3(target) + ' does not have a method named "' + method + '"'); }); }); @@ -4298,7 +6187,10 @@ * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' * R.join('|', [1, 2, 3]); //=> '1|2|3' */ - var join = /*#__PURE__*/invoker(1, 'join'); + + var join = + /*#__PURE__*/ + invoker(1, 'join'); /** * juxt applies a list of functions to a list of values. @@ -4317,12 +6209,33 @@ * getRange(3, 4, 9, -3); //=> [-3, 9] * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] */ - var juxt = /*#__PURE__*/_curry1(function juxt(fns) { + + var juxt = + /*#__PURE__*/ + _curry1(function juxt(fns) { return converge(function () { return Array.prototype.slice.call(arguments, 0); }, fns); }); + var $native$1 = [].lastIndexOf; + var NEGATIVE_ZERO$1 = !!$native$1 && 1 / [1].lastIndexOf(1, -0) < 0; + + _export(_export.P + _export.F * (NEGATIVE_ZERO$1 || !_strictMethod($native$1)), 'Array', { + // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex]) + lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { + // convert -0 to +0 + if (NEGATIVE_ZERO$1) return $native$1.apply(this, arguments) || 0; + var O = _toIobject(this); + var length = _toLength(O.length); + var index = length - 1; + if (arguments.length > 1) index = Math.min(index, _toInteger(arguments[1])); + if (index < 0) index = length + index; + for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0; + return -1; + } + }); + /** * Adds together all the elements of a list. * @@ -4338,7 +6251,10 @@ * * R.sum([2,4,6,8,100,1]); //=> 121 */ - var sum = /*#__PURE__*/reduce(add, 0); + + var sum = + /*#__PURE__*/ + reduce(add, 0); /** * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an @@ -4369,13 +6285,18 @@ * factorial(5); //=> 120 * count; //=> 1 */ - var memoizeWith = /*#__PURE__*/_curry2(function memoizeWith(mFn, fn) { + + var memoizeWith = + /*#__PURE__*/ + _curry2(function memoizeWith(mFn, fn) { var cache = {}; return _arity(fn.length, function () { var key = mFn.apply(this, arguments); + if (!_has$1(key, cache)) { cache[key] = fn.apply(this, arguments); } + return cache[key]; }); }); @@ -4408,8 +6329,11 @@ * factorial(5); //=> 120 * count; //=> 1 */ - var memoize = /*#__PURE__*/memoizeWith(function () { - return toString$2(arguments); + + var memoize = + /*#__PURE__*/ + memoizeWith(function () { + return toString$3(arguments); }); /** @@ -4432,7 +6356,10 @@ * triple(4); //=> 12 * R.multiply(2, 5); //=> 10 */ - var multiply = /*#__PURE__*/_curry2(function multiply(a, b) { + + var multiply = + /*#__PURE__*/ + _curry2(function multiply(a, b) { return a * b; }); @@ -4468,7 +6395,12 @@ * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) */ - var partialRight = /*#__PURE__*/_createPartialApplicator( /*#__PURE__*/flip(_concat)); + + var partialRight = + /*#__PURE__*/ + _createPartialApplicator( + /*#__PURE__*/ + flip(_concat)); /** * Takes a predicate and a list or other `Filterable` object and returns the @@ -4494,7 +6426,10 @@ * R.partition(R.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] */ - var partition = /*#__PURE__*/juxt([filter, reject]); + + var partition = + /*#__PURE__*/ + juxt([filter, reject]); /** * Similar to `pick` except that this one includes a `key: undefined` pair for @@ -4514,15 +6449,20 @@ * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} */ - var pickAll = /*#__PURE__*/_curry2(function pickAll(names, obj) { + + var pickAll = + /*#__PURE__*/ + _curry2(function pickAll(names, obj) { var result = {}; var idx = 0; var len = names.length; + while (idx < len) { var name = names[idx]; result[name] = obj[name]; idx += 1; } + return result; }); @@ -4541,7 +6481,10 @@ * * R.product([2,4,6,8,100,1]); //=> 38400 */ - var product = /*#__PURE__*/reduce(multiply, 1); + + var product = + /*#__PURE__*/ + reduce(multiply, 1); /** * Accepts a function `fn` and a list of transformer functions and returns a @@ -4572,14 +6515,19 @@ * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) */ - var useWith = /*#__PURE__*/_curry2(function useWith(fn, transformers) { + + var useWith = + /*#__PURE__*/ + _curry2(function useWith(fn, transformers) { return curryN(transformers.length, function () { var args = []; var idx = 0; + while (idx < transformers.length) { args.push(transformers[idx].call(this, arguments[idx])); idx += 1; } + return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); }); }); @@ -4603,7 +6551,10 @@ * var kids = [abby, fred]; * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] */ - var project = /*#__PURE__*/useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity + + var project = + /*#__PURE__*/ + useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity /** * Splits a string into an array of strings based on the given @@ -4625,7 +6576,10 @@ * * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] */ - var split = /*#__PURE__*/invoker(1, 'split'); + + var split = + /*#__PURE__*/ + invoker(1, 'split'); /** * The lower case version of a string. @@ -4642,7 +6596,10 @@ * * R.toLower('XYZ'); //=> 'xyz' */ - var toLower = /*#__PURE__*/invoker(0, 'toLowerCase'); + + var toLower = + /*#__PURE__*/ + invoker(0, 'toLowerCase'); /** * Converts an object into an array of key, value arrays. Only the object's @@ -4662,13 +6619,18 @@ * * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] */ - var toPairs = /*#__PURE__*/_curry1(function toPairs(obj) { + + var toPairs = + /*#__PURE__*/ + _curry1(function toPairs(obj) { var pairs = []; + for (var prop in obj) { if (_has$1(prop, obj)) { pairs[pairs.length] = [prop, obj[prop]]; } } + return pairs; }); @@ -4687,7 +6649,10 @@ * * R.toUpper('abc'); //=> 'ABC' */ - var toUpper = /*#__PURE__*/invoker(0, 'toUpperCase'); + + var toUpper = + /*#__PURE__*/ + invoker(0, 'toUpperCase'); /** * Initializes a transducer using supplied iterator function. Returns a single @@ -4736,12 +6701,22 @@ * var firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] */ - var transduce = /*#__PURE__*/curryN(4, function transduce(xf, fn, acc, list) { + + var transduce = + /*#__PURE__*/ + curryN(4, function transduce(xf, fn, acc, list) { return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); }); - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + '\u2029\uFEFF'; - var zeroWidth = '\u200b'; + // 21.1.3.25 String.prototype.trim() + _stringTrim('trim', function ($trim) { + return function trim() { + return $trim(this, 3); + }; + }); + + var ws = "\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003" + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + "\u2029\uFEFF"; + var zeroWidth = "\u200B"; var hasProtoTrim = typeof String.prototype.trim === 'function'; /** * Removes (strips) whitespace from both ends of the string. @@ -4758,7 +6733,12 @@ * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ - var _trim = !hasProtoTrim || /*#__PURE__*/ws.trim() || ! /*#__PURE__*/zeroWidth.trim() ? function trim(str) { + + var _trim = !hasProtoTrim || + /*#__PURE__*/ + ws.trim() || ! + /*#__PURE__*/ + zeroWidth.trim() ? function trim(str) { var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); return str.replace(beginRx, '').replace(endRx, ''); @@ -4783,7 +6763,12 @@ * * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] */ - var union = /*#__PURE__*/_curry2( /*#__PURE__*/compose(uniq, _concat)); + + var union = + /*#__PURE__*/ + _curry2( + /*#__PURE__*/ + compose(uniq, _concat)); /** * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from @@ -4802,7 +6787,10 @@ * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] */ - var unnest = /*#__PURE__*/chain(_identity); + + var unnest = + /*#__PURE__*/ + chain(_identity); var isQueryPresent = (function (query) { return query.measures && query.measures.length || query.dimensions && query.dimensions.length || query.timeDimensions && query.timeDimensions.length; @@ -5089,213 +7077,216 @@ } }); - var dP$1 = _objectDp.f; - var FProto = Function.prototype; - var nameRE = /^\s*function ([^ (]*)/; - var NAME$1 = 'name'; + // 19.1.3.19 Object.setPrototypeOf(O, proto) - // 19.2.4.2 name - NAME$1 in FProto || _descriptors && dP$1(FProto, NAME$1, { - configurable: true, - get: function () { - try { - return ('' + this).match(nameRE)[1]; - } catch (e) { - return ''; - } + _export(_export.S, 'Object', { setPrototypeOf: _setProto.set }); + + var $forEach = _arrayMethods(0); + var STRICT = _strictMethod([].forEach, true); + + _export(_export.P + _export.F * !STRICT, 'Array', { + // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) + forEach: function forEach(callbackfn /* , thisArg */) { + return $forEach(this, callbackfn, arguments[1]); } }); + // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + _export(_export.S, 'Object', { create: _objectCreate }); + var runtime = createCommonjsModule(function (module) { - /** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ + /** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + !function (global) { + + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; + var runtime = global.regeneratorRuntime; + + if (runtime) { + { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; + } // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. - !(function(global) { - - var Op = Object.prototype; - var hasOwn = Op.hasOwnProperty; - var undefined; // More compressible than void 0. - var $Symbol = typeof Symbol === "function" ? Symbol : {}; - var iteratorSymbol = $Symbol.iterator || "@@iterator"; - var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; - var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - var runtime = global.regeneratorRuntime; - if (runtime) { - { - // If regeneratorRuntime is defined globally and we're in a module, - // make the exports object identical to regeneratorRuntime. - module.exports = runtime; - } - // Don't bother evaluating the rest of this file if the runtime was - // already defined globally. - return; - } - // Define the runtime globally (as expected by generated code) as either - // module.exports (if we're in a module) or a new, empty object. - runtime = global.regeneratorRuntime = module.exports; + return; + } // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. - function wrap(innerFn, outerFn, self, tryLocsList) { - // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; - var generator = Object.create(protoGenerator.prototype); - var context = new Context(tryLocsList || []); - // The ._invoke method unifies the implementations of the .next, - // .throw, and .return methods. - generator._invoke = makeInvokeMethod(innerFn, self, context); + runtime = global.regeneratorRuntime = module.exports; - return generator; - } - runtime.wrap = wrap; - - // Try/catch helper to minimize deoptimizations. Returns a completion - // record like context.tryEntries[i].completion. This interface could - // have been (and was previously) designed to take a closure to be - // invoked without arguments, but in all the cases we care about we - // already have an existing method we want to call, so there's no need - // to create a new function object. We can even get away with assuming - // the method takes exactly one argument, since that happens to be true - // in every case, so we don't have to touch the arguments object. The - // only additional allocation required is the completion record, which - // has a stable shape and so hopefully should be cheap to allocate. - function tryCatch(fn, obj, arg) { - try { - return { type: "normal", arg: fn.call(obj, arg) }; - } catch (err) { - return { type: "throw", arg: err }; + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + + generator._invoke = makeInvokeMethod(innerFn, self, context); + return generator; } - } - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; - - // Returning this object from the innerFn has the same effect as - // breaking out of the dispatch switch statement. - var ContinueSentinel = {}; - - // Dummy constructor functions that we use as the .constructor and - // .constructor.prototype properties for functions that return Generator - // objects. For full spec compliance, you may wish to configure your - // minifier not to mangle the names of these two functions. - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} - - // This is a polyfill for %IteratorPrototype% for environments that - // don't natively support it. - var IteratorPrototype = {}; - IteratorPrototype[iteratorSymbol] = function () { - return this; - }; + runtime.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + + function tryCatch(fn, obj, arg) { + try { + return { + type: "normal", + arg: fn.call(obj, arg) + }; + } catch (err) { + return { + type: "throw", + arg: err + }; + } + } - var getProto = Object.getPrototypeOf; - var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - if (NativeIteratorPrototype && - NativeIteratorPrototype !== Op && - hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { - // This environment has a native %IteratorPrototype%; use it instead - // of the polyfill. - IteratorPrototype = NativeIteratorPrototype; - } + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. - var Gp = GeneratorFunctionPrototype.prototype = - Generator.prototype = Object.create(IteratorPrototype); - GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; - GeneratorFunctionPrototype.constructor = GeneratorFunction; - GeneratorFunctionPrototype[toStringTagSymbol] = - GeneratorFunction.displayName = "GeneratorFunction"; - - // Helper for defining the .next, .throw, and .return methods of the - // Iterator interface in terms of a single ._invoke method. - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function(method) { - prototype[method] = function(arg) { - return this._invoke(method, arg); - }; - }); - } + var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. - runtime.isGeneratorFunction = function(genFun) { - var ctor = typeof genFun === "function" && genFun.constructor; - return ctor - ? ctor === GeneratorFunction || - // For the native GeneratorFunction constructor, the best we can - // do is to check its .name property. - (ctor.displayName || ctor.name) === "GeneratorFunction" - : false; - }; + function Generator() {} - runtime.mark = function(genFun) { - if (Object.setPrototypeOf) { - Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); - } else { - genFun.__proto__ = GeneratorFunctionPrototype; - if (!(toStringTagSymbol in genFun)) { - genFun[toStringTagSymbol] = "GeneratorFunction"; - } + function GeneratorFunction() {} + + function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + + + var IteratorPrototype = {}; + + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; + + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + + if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; } - genFun.prototype = Object.create(Gp); - return genFun; - }; - // Within the body of any async function, `await x` is transformed to - // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `hasOwn.call(value, "__await")` to determine if the yielded value is - // meant to be awaited. - runtime.awrap = function(arg) { - return { __await: arg }; - }; + var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. - function AsyncIterator(generator) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - if (record.type === "throw") { - reject(record.arg); + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function (method) { + prototype[method] = function (arg) { + return this._invoke(method, arg); + }; + }); + } + + runtime.isGeneratorFunction = function (genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" : false; + }; + + runtime.mark = function (genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); } else { - var result = record.arg; - var value = result.value; - if (value && - typeof value === "object" && - hasOwn.call(value, "__await")) { - return Promise.resolve(value.__await).then(function(value) { - invoke("next", value, resolve, reject); - }, function(err) { - invoke("throw", err, resolve, reject); - }); - } + genFun.__proto__ = GeneratorFunctionPrototype; - return Promise.resolve(value).then(function(unwrapped) { - // When a yielded Promise is resolved, its final value becomes - // the .value of the Promise<{value,done}> result for the - // current iteration. - result.value = unwrapped; - resolve(result); - }, function(error) { - // If a rejected Promise was yielded, throw the rejection back - // into the async generator function so it can be handled there. - return invoke("throw", error, resolve, reject); - }); + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } } - } - var previousPromise; + genFun.prototype = Object.create(Gp); + return genFun; + }; // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. - function enqueue(method, arg) { - function callInvokeWithMethodAndArg() { - return new Promise(function(resolve, reject) { - invoke(method, arg, resolve, reject); - }); + + runtime.awrap = function (arg) { + return { + __await: arg + }; + }; + + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + + if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function (value) { + invoke("next", value, resolve, reject); + }, function (err) { + invoke("throw", err, resolve, reject); + }); + } + + return Promise.resolve(value).then(function (unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. + result.value = unwrapped; + resolve(result); + }, function (error) { + // If a rejected Promise was yielded, throw the rejection back + // into the async generator function so it can be handled there. + return invoke("throw", error, resolve, reject); + }); + } } - return previousPromise = - // If enqueue has been called before, then we want to wait until + var previousPromise; + + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function (resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } + + return previousPromise = // If enqueue has been called before, then we want to wait until // all previous Promises have been resolved before calling invoke, // so that results are always delivered in the correct order. If // enqueue has not been called before, then it is important to @@ -5307,524 +7298,504 @@ // execute code before the first await. Since we implement simple // async functions in terms of async generators, it is especially // important to get this right, even though it requires care. - previousPromise ? previousPromise.then( - callInvokeWithMethodAndArg, - // Avoid propagating failures to Promises returned by later - // invocations of the iterator. - callInvokeWithMethodAndArg - ) : callInvokeWithMethodAndArg(); + previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); + } // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + + + this._invoke = enqueue; } - // Define the unified helper method that is used to implement .next, - // .throw, and .return (see defineIteratorMethods). - this._invoke = enqueue; - } + defineIteratorMethods(AsyncIterator.prototype); - defineIteratorMethods(AsyncIterator.prototype); - AsyncIterator.prototype[asyncIteratorSymbol] = function () { - return this; - }; - runtime.AsyncIterator = AsyncIterator; - - // Note that simple async functions are implemented on top of - // AsyncIterator objects; they just return a Promise for the value of - // the final result produced by the iterator. - runtime.async = function(innerFn, outerFn, self, tryLocsList) { - var iter = new AsyncIterator( - wrap(innerFn, outerFn, self, tryLocsList) - ); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; - return runtime.isGeneratorFunction(outerFn) - ? iter // If outerFn is a generator, return the full iterator. - : iter.next().then(function(result) { - return result.done ? result.value : iter.next(); - }); - }; + runtime.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + + runtime.async = function (innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList)); + return runtime.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function (result) { + return result.done ? result.value : iter.next(); + }); + }; + + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; + } // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; + return doneResult(); } - // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume - return doneResult(); - } + context.method = method; + context.arg = arg; - context.method = method; - context.arg = arg; + while (true) { + var delegate = context.delegate; - while (true) { - var delegate = context.delegate; - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; + } } - } - if (context.method === "next") { - // Setting context._sent for legacy support of Babel's - // function.sent implementation. - context.sent = context._sent = context.arg; + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; + } - } else if (context.method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw context.arg; + context.dispatchException(context.arg); + } else if (context.method === "return") { + context.abrupt("return", context.arg); } - context.dispatchException(context.arg); + state = GenStateExecuting; + var record = tryCatch(innerFn, self, context); - } else if (context.method === "return") { - context.abrupt("return", context.arg); - } + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done ? GenStateCompleted : GenStateSuspendedYield; - state = GenStateExecuting; + if (record.arg === ContinueSentinel) { + continue; + } - var record = tryCatch(innerFn, self, context); - if (record.type === "normal") { - // If an exception is thrown from innerFn, we leave state === - // GenStateExecuting and loop back for another invocation. - state = context.done - ? GenStateCompleted - : GenStateSuspendedYield; + return { + value: record.arg, + done: context.done + }; + } else if (record.type === "throw") { + state = GenStateCompleted; // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. - if (record.arg === ContinueSentinel) { - continue; + context.method = "throw"; + context.arg = record.arg; + } + } + }; + } // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + + + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; + + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); + + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } } - return { - value: record.arg, - done: context.done - }; - - } else if (record.type === "throw") { - state = GenStateCompleted; - // Dispatch the exception by looping back around to the - // context.dispatchException(context.arg) call above. context.method = "throw"; - context.arg = record.arg; + context.arg = new TypeError("The iterator does not provide a 'throw' method"); } + + return ContinueSentinel; } - }; - } - // Call delegate.iterator[context.method](context.arg) and handle the - // result, either by returning a { value, done } result from the - // delegate iterator, or by modifying context.method and context.arg, - // setting context.delegate to null, and returning the ContinueSentinel. - function maybeInvokeDelegate(delegate, context) { - var method = delegate.iterator[context.method]; - if (method === undefined) { - // A .throw or .return when the delegate iterator has no .throw - // method always terminates the yield* loop. - context.delegate = null; + var record = tryCatch(method, delegate.iterator, context.arg); - if (context.method === "throw") { - if (delegate.iterator.return) { - // If the delegate iterator has a return method, give it a - // chance to clean up. - context.method = "return"; - context.arg = undefined; - maybeInvokeDelegate(delegate, context); + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } - if (context.method === "throw") { - // If maybeInvokeDelegate(context) changed context.method from - // "return" to "throw", let that override the TypeError below. - return ContinueSentinel; - } - } + var info = record.arg; + if (!info) { context.method = "throw"; - context.arg = new TypeError( - "The iterator does not provide a 'throw' method"); + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; } - return ContinueSentinel; - } + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). - var record = tryCatch(method, delegate.iterator, context.arg); + context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. - if (record.type === "throw") { - context.method = "throw"; - context.arg = record.arg; - context.delegate = null; - return ContinueSentinel; - } + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } + } else { + // Re-yield the result returned by the delegate method. + return info; + } // The delegate iterator is finished, so forget it and continue with + // the outer generator. - var info = record.arg; - if (! info) { - context.method = "throw"; - context.arg = new TypeError("iterator result is not an object"); context.delegate = null; return ContinueSentinel; - } - - if (info.done) { - // Assign the result of the finished delegate to the temporary - // variable specified by delegate.resultName (see delegateYield). - context[delegate.resultName] = info.value; - - // Resume execution at the desired location (see delegateYield). - context.next = delegate.nextLoc; - - // If context.method was "throw" but the delegate handled the - // exception, let the outer generator proceed normally. If - // context.method was "next", forget context.arg since it has been - // "consumed" by the delegate iterator. If context.method was - // "return", allow the original .return call to continue in the - // outer generator. - if (context.method !== "return") { - context.method = "next"; - context.arg = undefined; - } + } // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. - } else { - // Re-yield the result returned by the delegate method. - return info; - } - // The delegate iterator is finished, so forget it and continue with - // the outer generator. - context.delegate = null; - return ContinueSentinel; - } + defineIteratorMethods(Gp); + Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. - // Define Generator.prototype.{next,throw,return} in terms of the - // unified ._invoke helper method. - defineIteratorMethods(Gp); + Gp[iteratorSymbol] = function () { + return this; + }; - Gp[toStringTagSymbol] = "Generator"; + Gp.toString = function () { + return "[object Generator]"; + }; - // A Generator should always return itself as the iterator object when the - // @@iterator function is called on it. Some browsers' implementations of the - // iterator prototype chain incorrectly implement this, causing the Generator - // object to not be returned from this call. This ensures that doesn't happen. - // See https://github.com/facebook/regenerator/issues/274 for more details. - Gp[iteratorSymbol] = function() { - return this; - }; + function pushTryEntry(locs) { + var entry = { + tryLoc: locs[0] + }; - Gp.toString = function() { - return "[object Generator]"; - }; + if (1 in locs) { + entry.catchLoc = locs[1]; + } - function pushTryEntry(locs) { - var entry = { tryLoc: locs[0] }; + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; + } - if (1 in locs) { - entry.catchLoc = locs[1]; + this.tryEntries.push(entry); } - if (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; } - this.tryEntries.push(entry); - } - - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal"; - delete record.arg; - entry.completion = record; - } - - function Context(tryLocsList) { - // The root entry object (effectively a try statement without a catch - // or a finally block) gives us a place to store values thrown from - // locations where there is no enclosing try statement. - this.tryEntries = [{ tryLoc: "root" }]; - tryLocsList.forEach(pushTryEntry, this); - this.reset(true); - } - - runtime.keys = function(object) { - var keys = []; - for (var key in object) { - keys.push(key); + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ + tryLoc: "root" + }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); } - keys.reverse(); - - // Rather than returning an object with a next method, we keep - // things simple and return the next function itself. - return function next() { - while (keys.length) { - var key = keys.pop(); - if (key in object) { - next.value = key; - next.done = false; - return next; - } - } - - // To avoid creating an additional object, we just hang the .value - // and .done properties off the next function object itself. This - // also ensures that the minifier will not anonymize the function. - next.done = true; - return next; - }; - }; - function values(iterable) { - if (iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } + runtime.keys = function (object) { + var keys = []; - if (typeof iterable.next === "function") { - return iterable; + for (var key in object) { + keys.push(key); } - if (!isNaN(iterable.length)) { - var i = -1, next = function next() { - while (++i < iterable.length) { - if (hasOwn.call(iterable, i)) { - next.value = iterable[i]; - next.done = false; - return next; - } - } + keys.reverse(); // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. - next.value = undefined; - next.done = true; + return function next() { + while (keys.length) { + var key = keys.pop(); - return next; - }; + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. - return next.next = next; - } - } - // Return an iterator with no values. - return { next: doneResult }; - } - runtime.values = values; + next.done = true; + return next; + }; + }; - function doneResult() { - return { value: undefined, done: true }; - } + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; - Context.prototype = { - constructor: Context, - - reset: function(skipTempReset) { - this.prev = 0; - this.next = 0; - // Resetting context._sent for legacy support of Babel's - // function.sent implementation. - this.sent = this._sent = undefined; - this.done = false; - this.delegate = null; - - this.method = "next"; - this.arg = undefined; - - this.tryEntries.forEach(resetTryEntry); - - if (!skipTempReset) { - for (var name in this) { - // Not sure about the optimal order of these conditions: - if (name.charAt(0) === "t" && - hasOwn.call(this, name) && - !isNaN(+name.slice(1))) { - this[name] = undefined; - } + if (iteratorMethod) { + return iteratorMethod.call(iterable); } - } - }, - stop: function() { - this.done = true; - - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } - - return this.rval; - }, + if (typeof iterable.next === "function") { + return iterable; + } - dispatchException: function(exception) { - if (this.done) { - throw exception; - } + if (!isNaN(iterable.length)) { + var i = -1, + next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; + } + } - var context = this; - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; + next.value = undefined; + next.done = true; + return next; + }; - if (caught) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - context.method = "next"; - context.arg = undefined; + return next.next = next; } + } // Return an iterator with no values. - return !! caught; - } - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; + return { + next: doneResult + }; + } - if (entry.tryLoc === "root") { - // Exception thrown outside of any try block that could handle - // it, so set the completion value of the entire function to - // throw the exception. - return handle("end"); - } + runtime.values = values; - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); + function doneResult() { + return { + value: undefined, + done: true + }; + } - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } + Context.prototype = { + constructor: Context, + reset: function reset(skipTempReset) { + this.prev = 0; + this.next = 0; // Resetting context._sent for legacy support of Babel's + // function.sent implementation. - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; + this.method = "next"; + this.arg = undefined; + this.tryEntries.forEach(resetTryEntry); - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { + this[name] = undefined; } - - } else { - throw new Error("try statement without catch or finally"); } } - } - }, + }, + stop: function stop() { + this.done = true; + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } - abrupt: function(type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && - hasOwn.call(entry, "finallyLoc") && - this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; + return this.rval; + }, + dispatchException: function dispatchException(exception) { + if (this.done) { + throw exception; } - } - if (finallyEntry && - (type === "break" || - type === "continue") && - finallyEntry.tryLoc <= arg && - arg <= finallyEntry.finallyLoc) { - // Ignore the finally entry if control is not jumping to a - // location outside the try/catch block. - finallyEntry = null; - } + var context = this; - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; - if (finallyEntry) { - this.method = "next"; - this.next = finallyEntry.finallyLoc; - return ContinueSentinel; - } + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } - return this.complete(record); - }, + return !!caught; + } - complete: function(record, afterLoc) { - if (record.type === "throw") { - throw record.arg; - } + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; - if (record.type === "break" || - record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = this.arg = record.arg; - this.method = "return"; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; - } + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); + } - return ContinueSentinel; - }, + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); + + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, + abrupt: function abrupt(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + + if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; + } + } + + if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } + + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; - finish: function(finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) { - this.complete(entry.completion, entry.afterLoc); - resetTryEntry(entry); + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; return ContinueSentinel; } - } - }, - "catch": function(tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if (record.type === "throw") { - var thrown = record.arg; + return this.complete(record); + }, + complete: function complete(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } + + if (record.type === "break" || record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + + return ContinueSentinel; + }, + finish: function finish(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); resetTryEntry(entry); + return ContinueSentinel; } - return thrown; } - } + }, + "catch": function _catch(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; - // The context.catch method must only be called with a location - // argument that corresponds to a known catch block. - throw new Error("illegal catch attempt"); - }, + if (entry.tryLoc === tryLoc) { + var record = entry.completion; - delegateYield: function(iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } - if (this.method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - this.arg = undefined; - } + return thrown; + } + } // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. - return ContinueSentinel; - } - }; - })( - // In sloppy mode, unbound `this` refers to the global object, fallback to + + throw new Error("illegal catch attempt"); + }, + delegateYield: function delegateYield(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; + + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; + } + + return ContinueSentinel; + } + }; + }( // In sloppy mode, unbound `this` refers to the global object, fallback to // Function constructor if we're in global strict mode. That is sadly a form // of indirect eval which violates Content Security Policy. - (function() { - return this || (typeof self === "object" && self); - })() || Function("return this")() - ); + function () { + return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self; + }() || Function("return this")()); }); var QueryBuilder = @@ -6398,7 +8369,7 @@ subscribeRequest = null; } }; - }, [query, options.cubejsApi, context]); + }, [JSON.stringify(query), options.cubejsApi, context]); return { isLoading: isLoading, resultSet: resultSet, diff --git a/packages/cubejs-react/src/useCubeQuery.js b/packages/cubejs-react/src/useCubeQuery.js index f47c6e487b59e..1c54ea6c00356 100644 --- a/packages/cubejs-react/src/useCubeQuery.js +++ b/packages/cubejs-react/src/useCubeQuery.js @@ -62,7 +62,7 @@ export default (query, options = {}) => { subscribeRequest = null; } }; - }, [query, options.cubejsApi, context]); + }, [JSON.stringify(query), options.cubejsApi, context]); return { isLoading, resultSet, error }; };