4715 lines
166 KiB
JavaScript
4715 lines
166 KiB
JavaScript
|
|
(function (factory) {
|
|||
|
|
typeof define === 'function' && define.amd ? define(factory) :
|
|||
|
|
factory();
|
|||
|
|
})((function () { 'use strict';
|
|||
|
|
|
|||
|
|
// this file is generate by genGroup for rollup
|
|||
|
|
// don't edit this file
|
|||
|
|
const _TLD__CN_ = "center";
|
|||
|
|
var groupObject = {"express-sdb.kucoin.biz":{"MAIN_HOST":"https://sandbox.kucoin.biz/express","MAINSITE_HOST":"https://sandbox.kucoin.biz","KUCOIN_HOST":"https://sandbox.kucoin.biz","KUCOIN_HOST_CHINA":"https://www.kucoin.biz","KUMEX_HOST":"https://sandbox-futures.kucoin.biz","KUMEX_BASIC_HOST":"https://sandbox-futures.kucoin.biz/lite","POOLX_HOST":"https://sandbox.kucoin.biz/earn","M_POOLX_HOST":"https://sandbox.kucoin.biz/earn","TRADE_HOST":"https://sandbox.kucoin.biz/trade","TRADE_V2_HOST":"https://trade-v2.kucoin.biz","DOCS_HOST":"https://sandbox-docs.kucoin.biz","SANDBOX_HOST":"https://sandbox.kucoin.biz","LANDING_HOST":"https://sandbox.kucoin.biz/land","FASTCOIN_HOST":"https://sandbox.kucoin.biz/express","TOKEN_INFO_HOST":"https://sandbox.kucoin.biz/token-info","TRADING_BOT_HOST":"https://sandbox.kucoin.biz/trading-bot","ROBOT_HOST":"https://robot.kucoin.biz","M_KUCOIN_HOST":"https://m.kucoin.biz"},"express-sdb.kucoin.cc":{"MAIN_HOST":"https://sandbox.kucoin.cc/express","MAINSITE_HOST":"https://sandbox.kucoin.cc","KUCOIN_HOST":"https://sandbox.kucoin.cc","KUCOIN_HOST_CHINA":"https://www.kucoin.cc","KUMEX_HOST":"https://sandbox-futures.kucoin.cc","KUMEX_BASIC_HOST":"https://sandbox-futures.kucoin.cc/lite","POOLX_HOST":"https://sandbox.kucoin.cc/earn","M_POOLX_HOST":"https://sandbox.kucoin.cc/earn","TRADE_HOST":"https://sandbox.kucoin.cc/trade","TRADE_V2_HOST":"https://trade-v2.kucoin.cc","DOCS_HOST":"https://sandbox-docs.kucoin.cc","SANDBOX_HOST":"https://sandbox.kucoin.cc","LANDING_HOST":"https://sandbox.kucoin.cc/land","FASTCOIN_HOST":"https://sandbox.kucoin.cc/express","TOKEN_INFO_HOST":"https://sandbox.kucoin.cc/token-info","TRADING_BOT_HOST":"https://sandbox.kucoin.cc/trading-bot","ROBOT_HOST":"https://robot.kucoin.cc","M_KUCOIN_HOST":"https://m.kucoin.cc"},"express-sdb.kucoin.center":{"MAIN_HOST":"https://sandbox.kucoin.center/express","MAINSITE_HOST":"https://sandbox.kucoin.center","KUCOIN_HOST":"https://sandbox.kucoin.center","KUCOIN_HOST_CHINA":"https://www.kucoin.center","KUMEX_HOST":"https://sandbox-futures.kucoin.center","KUMEX_BASIC_HOST":"https://sandbox-futures.kucoin.center/lite","POOLX_HOST":"https://sandbox.kucoin.center/earn","M_POOLX_HOST":"https://sandbox.kucoin.center/earn","TRADE_HOST":"https://sandbox.kucoin.center/trade","TRADE_V2_HOST":"https://trade-v2.kucoin.center","DOCS_HOST":"https://sandbox-docs.kucoin.center","SANDBOX_HOST":"https://sandbox.kucoin.center","LANDING_HOST":"https://sandbox.kucoin.center/land","FASTCOIN_HOST":"https://sandbox.kucoin.center/express","TOKEN_INFO_HOST":"https://sandbox.kucoin.center/token-info","TRADING_BOT_HOST":"https://sandbox.kucoin.center/trading-bot","ROBOT_HOST":"https://robot.kucoin.center","M_KUCOIN_HOST":"https://m.kucoin.center"},"express-sdb.kucoin.cloud":{"MAIN_HOST":"https://sandbox.kucoin.cloud/express","MAINSITE_HOST":"https://sandbox.kucoin.cloud","KUCOIN_HOST":"https://sandbox.kucoin.cloud","KUCOIN_HOST_CHINA":"https://www.kucoin.cloud","KUMEX_HOST":"https://sandbox-futures.kucoin.cloud","KUMEX_BASIC_HOST":"https://sandbox-futures.kucoin.cloud/lite","POOLX_HOST":"https://sandbox.kucoin.cloud/earn","M_POOLX_HOST":"https://sandbox.kucoin.cloud/earn","TRADE_HOST":"https://sandbox.kucoin.cloud/trade","TRADE_V2_HOST":"https://trade-v2.kucoin.cloud","DOCS_HOST":"https://sandbox-docs.kucoin.cloud","SANDBOX_HOST":"https://sandbox.kucoin.cloud","LANDING_HOST":"https://sandbox.kucoin.cloud/land","FASTCOIN_HOST":"https://sandbox.kucoin.cloud/express","TOKEN_INFO_HOST":"https://sandbox.kucoin.cloud/token-info","TRADING_BOT_HOST":"https://sandbox.kucoin.cloud/trading-bot","ROBOT_HOST":"https://robot.kucoin.cloud","M_KUCOIN_HOST":"https://m.kucoin.cloud"},"express-sdb.kucoin.com":{"MAIN_HOST":"https://sandbox.kucoin.com/express","MAINSITE_HOST":"https://sandbox.kucoin.com","KUCOIN_HOST":"https://sandbox.kucoin.com","KUCOIN_HOST_CHINA":"https://www.kucoin.center","KUMEX_HOST":"https://sandbox-futures.kucoin.com","KUMEX_BASIC_HOST":"https://sandbox-futures.kucoin.com/lite","POOLX_HOST":"https://sandbox.kucoin.com/earn","M_POOLX_HOST":"https://sandbox.k
|
|||
|
|
|
|||
|
|
const baseConfig = {
|
|||
|
|
/** 入口地址,同文件名 */
|
|||
|
|
MAIN_HOST: 'https://www.kucoin.{tld}',
|
|||
|
|
/** 主站地址 */
|
|||
|
|
MAINSITE_HOST: 'https://www.kucoin.{tld}',
|
|||
|
|
/** KuCoin地址 */
|
|||
|
|
KUCOIN_HOST: 'https://www.kucoin.{tld}',
|
|||
|
|
/** KuCoin国内站地址 */
|
|||
|
|
KUCOIN_HOST_CHINA: 'https://www.kucoin.{tld}',
|
|||
|
|
/** KuMEX地址 */
|
|||
|
|
KUMEX_HOST: 'https://www.kucoin.{tld}/futures',
|
|||
|
|
/** KuMEX简约版地址 */
|
|||
|
|
KUMEX_BASIC_HOST: 'https://www.kucoin.{tld}/futures/lite',
|
|||
|
|
/** PoolX地址 */
|
|||
|
|
POOLX_HOST: 'https://www.kucoin.{tld}/earn',
|
|||
|
|
/** PoolX M站地址 */
|
|||
|
|
M_POOLX_HOST: 'https://www.kucoin.{tld}/earn',
|
|||
|
|
/** trade 地址 */
|
|||
|
|
TRADE_HOST: 'https://www.kucoin.{tld}/trade',
|
|||
|
|
/** trade-v2 地址 */
|
|||
|
|
TRADE_V2_HOST: 'https://trade-v2.kucoin.{tld}',
|
|||
|
|
/** 文档 地址 */
|
|||
|
|
DOCS_HOST: 'https://docs.kucoin.{tld}',
|
|||
|
|
/** 沙盒模拟 地址 */
|
|||
|
|
SANDBOX_HOST: 'https://sandbox.kucoin.{tld}',
|
|||
|
|
/** 流量落地页 地址 */
|
|||
|
|
LANDING_HOST: 'https://www.kucoin.{tld}/land',
|
|||
|
|
/** 一键买币项目 地址 */
|
|||
|
|
FASTCOIN_HOST: 'https://www.kucoin.{tld}/express',
|
|||
|
|
/** token-info 地址 */
|
|||
|
|
TOKEN_INFO_HOST: 'https://www.kucoin.{tld}/token-info',
|
|||
|
|
/** 机器人交易 地址 */
|
|||
|
|
ROBOT_HOST: 'https://robot.kucoin.{tld}',
|
|||
|
|
/** 机器人新地址 */
|
|||
|
|
TRADING_BOT_HOST: 'https://www.kucoin.{tld}/trading-bot',
|
|||
|
|
/** kucoin-h5 地址 */
|
|||
|
|
M_KUCOIN_HOST: 'https://m.kucoin.{tld}',
|
|||
|
|
/** 合约sandbox */
|
|||
|
|
KUMEX_SANDBOX_HOST: 'https://sandbox-futures.kucoin.{tld}',
|
|||
|
|
/** 合约网关 */
|
|||
|
|
KUMEX_GATE_WAY: 'https://www.kucoin.{tld}/_api_kumex',
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
const rewriteConsole = function (isDebug) {
|
|||
|
|
window.console.log = (function (origConsole) {
|
|||
|
|
return function () {
|
|||
|
|
isDebug && origConsole && origConsole.apply(origConsole, arguments);
|
|||
|
|
};
|
|||
|
|
})(window.console.log);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|||
|
|
|
|||
|
|
var lodash_reduce = {exports: {}};
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* lodash (Custom Build) <https://lodash.com/>
|
|||
|
|
* Build: `lodash modularize exports="npm" -o ./`
|
|||
|
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|||
|
|
* Released under MIT license <https://lodash.com/license>
|
|||
|
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|||
|
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
(function (module, exports) {
|
|||
|
|
/** Used as the size to enable large array optimizations. */
|
|||
|
|
var LARGE_ARRAY_SIZE = 200;
|
|||
|
|
|
|||
|
|
/** Used as the `TypeError` message for "Functions" methods. */
|
|||
|
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|||
|
|
|
|||
|
|
/** Used to stand-in for `undefined` hash values. */
|
|||
|
|
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|||
|
|
|
|||
|
|
/** Used to compose bitmasks for comparison styles. */
|
|||
|
|
var UNORDERED_COMPARE_FLAG = 1,
|
|||
|
|
PARTIAL_COMPARE_FLAG = 2;
|
|||
|
|
|
|||
|
|
/** Used as references for various `Number` constants. */
|
|||
|
|
var INFINITY = 1 / 0,
|
|||
|
|
MAX_SAFE_INTEGER = 9007199254740991;
|
|||
|
|
|
|||
|
|
/** `Object#toString` result references. */
|
|||
|
|
var argsTag = '[object Arguments]',
|
|||
|
|
arrayTag = '[object Array]',
|
|||
|
|
boolTag = '[object Boolean]',
|
|||
|
|
dateTag = '[object Date]',
|
|||
|
|
errorTag = '[object Error]',
|
|||
|
|
funcTag = '[object Function]',
|
|||
|
|
genTag = '[object GeneratorFunction]',
|
|||
|
|
mapTag = '[object Map]',
|
|||
|
|
numberTag = '[object Number]',
|
|||
|
|
objectTag = '[object Object]',
|
|||
|
|
promiseTag = '[object Promise]',
|
|||
|
|
regexpTag = '[object RegExp]',
|
|||
|
|
setTag = '[object Set]',
|
|||
|
|
stringTag = '[object String]',
|
|||
|
|
symbolTag = '[object Symbol]',
|
|||
|
|
weakMapTag = '[object WeakMap]';
|
|||
|
|
|
|||
|
|
var arrayBufferTag = '[object ArrayBuffer]',
|
|||
|
|
dataViewTag = '[object DataView]',
|
|||
|
|
float32Tag = '[object Float32Array]',
|
|||
|
|
float64Tag = '[object Float64Array]',
|
|||
|
|
int8Tag = '[object Int8Array]',
|
|||
|
|
int16Tag = '[object Int16Array]',
|
|||
|
|
int32Tag = '[object Int32Array]',
|
|||
|
|
uint8Tag = '[object Uint8Array]',
|
|||
|
|
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|||
|
|
uint16Tag = '[object Uint16Array]',
|
|||
|
|
uint32Tag = '[object Uint32Array]';
|
|||
|
|
|
|||
|
|
/** Used to match property names within property paths. */
|
|||
|
|
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|||
|
|
reIsPlainProp = /^\w*$/,
|
|||
|
|
reLeadingDot = /^\./,
|
|||
|
|
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Used to match `RegExp`
|
|||
|
|
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|||
|
|
*/
|
|||
|
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|||
|
|
|
|||
|
|
/** Used to match backslashes in property paths. */
|
|||
|
|
var reEscapeChar = /\\(\\)?/g;
|
|||
|
|
|
|||
|
|
/** Used to detect host constructors (Safari). */
|
|||
|
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|||
|
|
|
|||
|
|
/** Used to detect unsigned integer values. */
|
|||
|
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|||
|
|
|
|||
|
|
/** Used to identify `toStringTag` values of typed arrays. */
|
|||
|
|
var typedArrayTags = {};
|
|||
|
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|||
|
|
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|||
|
|
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|||
|
|
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|||
|
|
typedArrayTags[uint32Tag] = true;
|
|||
|
|
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|||
|
|
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|||
|
|
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|||
|
|
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|||
|
|
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
|||
|
|
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
|||
|
|
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
|||
|
|
typedArrayTags[weakMapTag] = false;
|
|||
|
|
|
|||
|
|
/** Detect free variable `global` from Node.js. */
|
|||
|
|
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|||
|
|
|
|||
|
|
/** Detect free variable `self`. */
|
|||
|
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|||
|
|
|
|||
|
|
/** Used as a reference to the global object. */
|
|||
|
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|||
|
|
|
|||
|
|
/** Detect free variable `exports`. */
|
|||
|
|
var freeExports = exports && !exports.nodeType && exports;
|
|||
|
|
|
|||
|
|
/** Detect free variable `module`. */
|
|||
|
|
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|||
|
|
|
|||
|
|
/** Detect the popular CommonJS extension `module.exports`. */
|
|||
|
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|||
|
|
|
|||
|
|
/** Detect free variable `process` from Node.js. */
|
|||
|
|
var freeProcess = moduleExports && freeGlobal.process;
|
|||
|
|
|
|||
|
|
/** Used to access faster Node.js helpers. */
|
|||
|
|
var nodeUtil = (function() {
|
|||
|
|
try {
|
|||
|
|
return freeProcess && freeProcess.binding('util');
|
|||
|
|
} catch (e) {}
|
|||
|
|
}());
|
|||
|
|
|
|||
|
|
/* Node.js helper references. */
|
|||
|
|
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `_.reduce` for arrays without support for
|
|||
|
|
* iteratee shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} [array] The array to iterate over.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @param {*} [accumulator] The initial value.
|
|||
|
|
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
|||
|
|
* the initial value.
|
|||
|
|
* @returns {*} Returns the accumulated value.
|
|||
|
|
*/
|
|||
|
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = array ? array.length : 0;
|
|||
|
|
|
|||
|
|
if (initAccum && length) {
|
|||
|
|
accumulator = array[++index];
|
|||
|
|
}
|
|||
|
|
while (++index < length) {
|
|||
|
|
accumulator = iteratee(accumulator, array[index], index, array);
|
|||
|
|
}
|
|||
|
|
return accumulator;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `_.some` for arrays without support for iteratee
|
|||
|
|
* shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} [array] The array to iterate over.
|
|||
|
|
* @param {Function} predicate The function invoked per iteration.
|
|||
|
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|||
|
|
* else `false`.
|
|||
|
|
*/
|
|||
|
|
function arraySome(array, predicate) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = array ? array.length : 0;
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
if (predicate(array[index], index, array)) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.property` without support for deep paths.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {string} key The key of the property to get.
|
|||
|
|
* @returns {Function} Returns the new accessor function.
|
|||
|
|
*/
|
|||
|
|
function baseProperty(key) {
|
|||
|
|
return function(object) {
|
|||
|
|
return object == null ? undefined : object[key];
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
|||
|
|
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array|Object} collection The collection to iterate over.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @param {*} accumulator The initial value.
|
|||
|
|
* @param {boolean} initAccum Specify using the first or last element of
|
|||
|
|
* `collection` as the initial value.
|
|||
|
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
|||
|
|
* @returns {*} Returns the accumulated value.
|
|||
|
|
*/
|
|||
|
|
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
|||
|
|
eachFunc(collection, function(value, index, collection) {
|
|||
|
|
accumulator = initAccum
|
|||
|
|
? (initAccum = false, value)
|
|||
|
|
: iteratee(accumulator, value, index, collection);
|
|||
|
|
});
|
|||
|
|
return accumulator;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.times` without support for iteratee shorthands
|
|||
|
|
* or max array length checks.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {number} n The number of times to invoke `iteratee`.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @returns {Array} Returns the array of results.
|
|||
|
|
*/
|
|||
|
|
function baseTimes(n, iteratee) {
|
|||
|
|
var index = -1,
|
|||
|
|
result = Array(n);
|
|||
|
|
|
|||
|
|
while (++index < n) {
|
|||
|
|
result[index] = iteratee(index);
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.unary` without support for storing metadata.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to cap arguments for.
|
|||
|
|
* @returns {Function} Returns the new capped function.
|
|||
|
|
*/
|
|||
|
|
function baseUnary(func) {
|
|||
|
|
return function(value) {
|
|||
|
|
return func(value);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the value at `key` of `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} [object] The object to query.
|
|||
|
|
* @param {string} key The key of the property to get.
|
|||
|
|
* @returns {*} Returns the property value.
|
|||
|
|
*/
|
|||
|
|
function getValue(object, key) {
|
|||
|
|
return object == null ? undefined : object[key];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a host object in IE < 9.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isHostObject(value) {
|
|||
|
|
// Many host objects are `Object` objects that can coerce to strings
|
|||
|
|
// despite having improperly defined `toString` methods.
|
|||
|
|
var result = false;
|
|||
|
|
if (value != null && typeof value.toString != 'function') {
|
|||
|
|
try {
|
|||
|
|
result = !!(value + '');
|
|||
|
|
} catch (e) {}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `map` to its key-value pairs.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} map The map to convert.
|
|||
|
|
* @returns {Array} Returns the key-value pairs.
|
|||
|
|
*/
|
|||
|
|
function mapToArray(map) {
|
|||
|
|
var index = -1,
|
|||
|
|
result = Array(map.size);
|
|||
|
|
|
|||
|
|
map.forEach(function(value, key) {
|
|||
|
|
result[++index] = [key, value];
|
|||
|
|
});
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a unary function that invokes `func` with its argument transformed.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to wrap.
|
|||
|
|
* @param {Function} transform The argument transform.
|
|||
|
|
* @returns {Function} Returns the new function.
|
|||
|
|
*/
|
|||
|
|
function overArg(func, transform) {
|
|||
|
|
return function(arg) {
|
|||
|
|
return func(transform(arg));
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `set` to an array of its values.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} set The set to convert.
|
|||
|
|
* @returns {Array} Returns the values.
|
|||
|
|
*/
|
|||
|
|
function setToArray(set) {
|
|||
|
|
var index = -1,
|
|||
|
|
result = Array(set.size);
|
|||
|
|
|
|||
|
|
set.forEach(function(value) {
|
|||
|
|
result[++index] = value;
|
|||
|
|
});
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** Used for built-in method references. */
|
|||
|
|
var arrayProto = Array.prototype,
|
|||
|
|
funcProto = Function.prototype,
|
|||
|
|
objectProto = Object.prototype;
|
|||
|
|
|
|||
|
|
/** Used to detect overreaching core-js shims. */
|
|||
|
|
var coreJsData = root['__core-js_shared__'];
|
|||
|
|
|
|||
|
|
/** Used to detect methods masquerading as native. */
|
|||
|
|
var maskSrcKey = (function() {
|
|||
|
|
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|||
|
|
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|||
|
|
}());
|
|||
|
|
|
|||
|
|
/** Used to resolve the decompiled source of functions. */
|
|||
|
|
var funcToString = funcProto.toString;
|
|||
|
|
|
|||
|
|
/** Used to check objects for own properties. */
|
|||
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Used to resolve the
|
|||
|
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|||
|
|
* of values.
|
|||
|
|
*/
|
|||
|
|
var objectToString = objectProto.toString;
|
|||
|
|
|
|||
|
|
/** Used to detect if a method is native. */
|
|||
|
|
var reIsNative = RegExp('^' +
|
|||
|
|
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
|||
|
|
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
/** Built-in value references. */
|
|||
|
|
var Symbol = root.Symbol,
|
|||
|
|
Uint8Array = root.Uint8Array,
|
|||
|
|
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|||
|
|
splice = arrayProto.splice;
|
|||
|
|
|
|||
|
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|||
|
|
var nativeKeys = overArg(Object.keys, Object);
|
|||
|
|
|
|||
|
|
/* Built-in method references that are verified to be native. */
|
|||
|
|
var DataView = getNative(root, 'DataView'),
|
|||
|
|
Map = getNative(root, 'Map'),
|
|||
|
|
Promise = getNative(root, 'Promise'),
|
|||
|
|
Set = getNative(root, 'Set'),
|
|||
|
|
WeakMap = getNative(root, 'WeakMap'),
|
|||
|
|
nativeCreate = getNative(Object, 'create');
|
|||
|
|
|
|||
|
|
/** Used to detect maps, sets, and weakmaps. */
|
|||
|
|
var dataViewCtorString = toSource(DataView),
|
|||
|
|
mapCtorString = toSource(Map),
|
|||
|
|
promiseCtorString = toSource(Promise),
|
|||
|
|
setCtorString = toSource(Set),
|
|||
|
|
weakMapCtorString = toSource(WeakMap);
|
|||
|
|
|
|||
|
|
/** Used to convert symbols to primitives and strings. */
|
|||
|
|
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|||
|
|
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
|
|||
|
|
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a hash object.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function Hash(entries) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = entries ? entries.length : 0;
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
while (++index < length) {
|
|||
|
|
var entry = entries[index];
|
|||
|
|
this.set(entry[0], entry[1]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the hash.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf Hash
|
|||
|
|
*/
|
|||
|
|
function hashClear() {
|
|||
|
|
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the hash.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {Object} hash The hash to modify.
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function hashDelete(key) {
|
|||
|
|
return this.has(key) && delete this.__data__[key];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the hash value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function hashGet(key) {
|
|||
|
|
var data = this.__data__;
|
|||
|
|
if (nativeCreate) {
|
|||
|
|
var result = data[key];
|
|||
|
|
return result === HASH_UNDEFINED ? undefined : result;
|
|||
|
|
}
|
|||
|
|
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a hash value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function hashHas(key) {
|
|||
|
|
var data = this.__data__;
|
|||
|
|
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the hash `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the hash instance.
|
|||
|
|
*/
|
|||
|
|
function hashSet(key, value) {
|
|||
|
|
var data = this.__data__;
|
|||
|
|
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `Hash`.
|
|||
|
|
Hash.prototype.clear = hashClear;
|
|||
|
|
Hash.prototype['delete'] = hashDelete;
|
|||
|
|
Hash.prototype.get = hashGet;
|
|||
|
|
Hash.prototype.has = hashHas;
|
|||
|
|
Hash.prototype.set = hashSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates an list cache object.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function ListCache(entries) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = entries ? entries.length : 0;
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
while (++index < length) {
|
|||
|
|
var entry = entries[index];
|
|||
|
|
this.set(entry[0], entry[1]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the list cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
*/
|
|||
|
|
function listCacheClear() {
|
|||
|
|
this.__data__ = [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the list cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function listCacheDelete(key) {
|
|||
|
|
var data = this.__data__,
|
|||
|
|
index = assocIndexOf(data, key);
|
|||
|
|
|
|||
|
|
if (index < 0) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var lastIndex = data.length - 1;
|
|||
|
|
if (index == lastIndex) {
|
|||
|
|
data.pop();
|
|||
|
|
} else {
|
|||
|
|
splice.call(data, index, 1);
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the list cache value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function listCacheGet(key) {
|
|||
|
|
var data = this.__data__,
|
|||
|
|
index = assocIndexOf(data, key);
|
|||
|
|
|
|||
|
|
return index < 0 ? undefined : data[index][1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a list cache value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function listCacheHas(key) {
|
|||
|
|
return assocIndexOf(this.__data__, key) > -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the list cache `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the list cache instance.
|
|||
|
|
*/
|
|||
|
|
function listCacheSet(key, value) {
|
|||
|
|
var data = this.__data__,
|
|||
|
|
index = assocIndexOf(data, key);
|
|||
|
|
|
|||
|
|
if (index < 0) {
|
|||
|
|
data.push([key, value]);
|
|||
|
|
} else {
|
|||
|
|
data[index][1] = value;
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `ListCache`.
|
|||
|
|
ListCache.prototype.clear = listCacheClear;
|
|||
|
|
ListCache.prototype['delete'] = listCacheDelete;
|
|||
|
|
ListCache.prototype.get = listCacheGet;
|
|||
|
|
ListCache.prototype.has = listCacheHas;
|
|||
|
|
ListCache.prototype.set = listCacheSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a map cache object to store key-value pairs.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function MapCache(entries) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = entries ? entries.length : 0;
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
while (++index < length) {
|
|||
|
|
var entry = entries[index];
|
|||
|
|
this.set(entry[0], entry[1]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the map.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
*/
|
|||
|
|
function mapCacheClear() {
|
|||
|
|
this.__data__ = {
|
|||
|
|
'hash': new Hash,
|
|||
|
|
'map': new (Map || ListCache),
|
|||
|
|
'string': new Hash
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the map.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function mapCacheDelete(key) {
|
|||
|
|
return getMapData(this, key)['delete'](key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the map value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function mapCacheGet(key) {
|
|||
|
|
return getMapData(this, key).get(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a map value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function mapCacheHas(key) {
|
|||
|
|
return getMapData(this, key).has(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the map `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the map cache instance.
|
|||
|
|
*/
|
|||
|
|
function mapCacheSet(key, value) {
|
|||
|
|
getMapData(this, key).set(key, value);
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `MapCache`.
|
|||
|
|
MapCache.prototype.clear = mapCacheClear;
|
|||
|
|
MapCache.prototype['delete'] = mapCacheDelete;
|
|||
|
|
MapCache.prototype.get = mapCacheGet;
|
|||
|
|
MapCache.prototype.has = mapCacheHas;
|
|||
|
|
MapCache.prototype.set = mapCacheSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
*
|
|||
|
|
* Creates an array cache object to store unique values.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [values] The values to cache.
|
|||
|
|
*/
|
|||
|
|
function SetCache(values) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = values ? values.length : 0;
|
|||
|
|
|
|||
|
|
this.__data__ = new MapCache;
|
|||
|
|
while (++index < length) {
|
|||
|
|
this.add(values[index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Adds `value` to the array cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name add
|
|||
|
|
* @memberOf SetCache
|
|||
|
|
* @alias push
|
|||
|
|
* @param {*} value The value to cache.
|
|||
|
|
* @returns {Object} Returns the cache instance.
|
|||
|
|
*/
|
|||
|
|
function setCacheAdd(value) {
|
|||
|
|
this.__data__.set(value, HASH_UNDEFINED);
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is in the array cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf SetCache
|
|||
|
|
* @param {*} value The value to search for.
|
|||
|
|
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|||
|
|
*/
|
|||
|
|
function setCacheHas(value) {
|
|||
|
|
return this.__data__.has(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `SetCache`.
|
|||
|
|
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|||
|
|
SetCache.prototype.has = setCacheHas;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a stack cache object to store key-value pairs.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function Stack(entries) {
|
|||
|
|
this.__data__ = new ListCache(entries);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the stack.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf Stack
|
|||
|
|
*/
|
|||
|
|
function stackClear() {
|
|||
|
|
this.__data__ = new ListCache;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the stack.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf Stack
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function stackDelete(key) {
|
|||
|
|
return this.__data__['delete'](key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the stack value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf Stack
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function stackGet(key) {
|
|||
|
|
return this.__data__.get(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a stack value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf Stack
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function stackHas(key) {
|
|||
|
|
return this.__data__.has(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the stack `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf Stack
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the stack cache instance.
|
|||
|
|
*/
|
|||
|
|
function stackSet(key, value) {
|
|||
|
|
var cache = this.__data__;
|
|||
|
|
if (cache instanceof ListCache) {
|
|||
|
|
var pairs = cache.__data__;
|
|||
|
|
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|||
|
|
pairs.push([key, value]);
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
cache = this.__data__ = new MapCache(pairs);
|
|||
|
|
}
|
|||
|
|
cache.set(key, value);
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `Stack`.
|
|||
|
|
Stack.prototype.clear = stackClear;
|
|||
|
|
Stack.prototype['delete'] = stackDelete;
|
|||
|
|
Stack.prototype.get = stackGet;
|
|||
|
|
Stack.prototype.has = stackHas;
|
|||
|
|
Stack.prototype.set = stackSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates an array of the enumerable property names of the array-like `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to query.
|
|||
|
|
* @param {boolean} inherited Specify returning inherited property names.
|
|||
|
|
* @returns {Array} Returns the array of property names.
|
|||
|
|
*/
|
|||
|
|
function arrayLikeKeys(value, inherited) {
|
|||
|
|
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|||
|
|
// Safari 9 makes `arguments.length` enumerable in strict mode.
|
|||
|
|
var result = (isArray(value) || isArguments(value))
|
|||
|
|
? baseTimes(value.length, String)
|
|||
|
|
: [];
|
|||
|
|
|
|||
|
|
var length = result.length,
|
|||
|
|
skipIndexes = !!length;
|
|||
|
|
|
|||
|
|
for (var key in value) {
|
|||
|
|
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|||
|
|
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
|||
|
|
result.push(key);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to inspect.
|
|||
|
|
* @param {*} key The key to search for.
|
|||
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|||
|
|
*/
|
|||
|
|
function assocIndexOf(array, key) {
|
|||
|
|
var length = array.length;
|
|||
|
|
while (length--) {
|
|||
|
|
if (eq(array[length][0], key)) {
|
|||
|
|
return length;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array|Object} collection The collection to iterate over.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @returns {Array|Object} Returns `collection`.
|
|||
|
|
*/
|
|||
|
|
var baseEach = createBaseEach(baseForOwn);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `baseForOwn` which iterates over `object`
|
|||
|
|
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
|||
|
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to iterate over.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
|||
|
|
* @returns {Object} Returns `object`.
|
|||
|
|
*/
|
|||
|
|
var baseFor = createBaseFor();
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to iterate over.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @returns {Object} Returns `object`.
|
|||
|
|
*/
|
|||
|
|
function baseForOwn(object, iteratee) {
|
|||
|
|
return object && baseFor(object, iteratee, keys);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.get` without support for default values.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @param {Array|string} path The path of the property to get.
|
|||
|
|
* @returns {*} Returns the resolved value.
|
|||
|
|
*/
|
|||
|
|
function baseGet(object, path) {
|
|||
|
|
path = isKey(path, object) ? [path] : castPath(path);
|
|||
|
|
|
|||
|
|
var index = 0,
|
|||
|
|
length = path.length;
|
|||
|
|
|
|||
|
|
while (object != null && index < length) {
|
|||
|
|
object = object[toKey(path[index++])];
|
|||
|
|
}
|
|||
|
|
return (index && index == length) ? object : undefined;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `getTag`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to query.
|
|||
|
|
* @returns {string} Returns the `toStringTag`.
|
|||
|
|
*/
|
|||
|
|
function baseGetTag(value) {
|
|||
|
|
return objectToString.call(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.hasIn` without support for deep paths.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} [object] The object to query.
|
|||
|
|
* @param {Array|string} key The key to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseHasIn(object, key) {
|
|||
|
|
return object != null && key in Object(object);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.isEqual` which supports partial comparisons
|
|||
|
|
* and tracks traversed objects.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to compare.
|
|||
|
|
* @param {*} other The other value to compare.
|
|||
|
|
* @param {Function} [customizer] The function to customize comparisons.
|
|||
|
|
* @param {boolean} [bitmask] The bitmask of comparison flags.
|
|||
|
|
* The bitmask may be composed of the following flags:
|
|||
|
|
* 1 - Unordered comparison
|
|||
|
|
* 2 - Partial comparison
|
|||
|
|
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
|||
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsEqual(value, other, customizer, bitmask, stack) {
|
|||
|
|
if (value === other) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
|
|||
|
|
return value !== value && other !== other;
|
|||
|
|
}
|
|||
|
|
return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|||
|
|
* deep comparisons and tracks traversed objects enabling objects with circular
|
|||
|
|
* references to be compared.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to compare.
|
|||
|
|
* @param {Object} other The other object to compare.
|
|||
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|||
|
|
* @param {Function} [customizer] The function to customize comparisons.
|
|||
|
|
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
|
|||
|
|
* for more details.
|
|||
|
|
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
|||
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
|||
|
|
var objIsArr = isArray(object),
|
|||
|
|
othIsArr = isArray(other),
|
|||
|
|
objTag = arrayTag,
|
|||
|
|
othTag = arrayTag;
|
|||
|
|
|
|||
|
|
if (!objIsArr) {
|
|||
|
|
objTag = getTag(object);
|
|||
|
|
objTag = objTag == argsTag ? objectTag : objTag;
|
|||
|
|
}
|
|||
|
|
if (!othIsArr) {
|
|||
|
|
othTag = getTag(other);
|
|||
|
|
othTag = othTag == argsTag ? objectTag : othTag;
|
|||
|
|
}
|
|||
|
|
var objIsObj = objTag == objectTag && !isHostObject(object),
|
|||
|
|
othIsObj = othTag == objectTag && !isHostObject(other),
|
|||
|
|
isSameTag = objTag == othTag;
|
|||
|
|
|
|||
|
|
if (isSameTag && !objIsObj) {
|
|||
|
|
stack || (stack = new Stack);
|
|||
|
|
return (objIsArr || isTypedArray(object))
|
|||
|
|
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
|
|||
|
|
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
|
|||
|
|
}
|
|||
|
|
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
|||
|
|
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|||
|
|
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|||
|
|
|
|||
|
|
if (objIsWrapped || othIsWrapped) {
|
|||
|
|
var objUnwrapped = objIsWrapped ? object.value() : object,
|
|||
|
|
othUnwrapped = othIsWrapped ? other.value() : other;
|
|||
|
|
|
|||
|
|
stack || (stack = new Stack);
|
|||
|
|
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!isSameTag) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
stack || (stack = new Stack);
|
|||
|
|
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to inspect.
|
|||
|
|
* @param {Object} source The object of property values to match.
|
|||
|
|
* @param {Array} matchData The property names, values, and compare flags to match.
|
|||
|
|
* @param {Function} [customizer] The function to customize comparisons.
|
|||
|
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsMatch(object, source, matchData, customizer) {
|
|||
|
|
var index = matchData.length,
|
|||
|
|
length = index,
|
|||
|
|
noCustomizer = !customizer;
|
|||
|
|
|
|||
|
|
if (object == null) {
|
|||
|
|
return !length;
|
|||
|
|
}
|
|||
|
|
object = Object(object);
|
|||
|
|
while (index--) {
|
|||
|
|
var data = matchData[index];
|
|||
|
|
if ((noCustomizer && data[2])
|
|||
|
|
? data[1] !== object[data[0]]
|
|||
|
|
: !(data[0] in object)
|
|||
|
|
) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
while (++index < length) {
|
|||
|
|
data = matchData[index];
|
|||
|
|
var key = data[0],
|
|||
|
|
objValue = object[key],
|
|||
|
|
srcValue = data[1];
|
|||
|
|
|
|||
|
|
if (noCustomizer && data[2]) {
|
|||
|
|
if (objValue === undefined && !(key in object)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
var stack = new Stack;
|
|||
|
|
if (customizer) {
|
|||
|
|
var result = customizer(objValue, srcValue, key, object, source, stack);
|
|||
|
|
}
|
|||
|
|
if (!(result === undefined
|
|||
|
|
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
|
|||
|
|
: result
|
|||
|
|
)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.isNative` without bad shim checks.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a native function,
|
|||
|
|
* else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsNative(value) {
|
|||
|
|
if (!isObject(value) || isMasked(value)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
|||
|
|
return pattern.test(toSource(value));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsTypedArray(value) {
|
|||
|
|
return isObjectLike(value) &&
|
|||
|
|
isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.iteratee`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
|||
|
|
* @returns {Function} Returns the iteratee.
|
|||
|
|
*/
|
|||
|
|
function baseIteratee(value) {
|
|||
|
|
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
|||
|
|
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
|||
|
|
if (typeof value == 'function') {
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
if (value == null) {
|
|||
|
|
return identity;
|
|||
|
|
}
|
|||
|
|
if (typeof value == 'object') {
|
|||
|
|
return isArray(value)
|
|||
|
|
? baseMatchesProperty(value[0], value[1])
|
|||
|
|
: baseMatches(value);
|
|||
|
|
}
|
|||
|
|
return property(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @returns {Array} Returns the array of property names.
|
|||
|
|
*/
|
|||
|
|
function baseKeys(object) {
|
|||
|
|
if (!isPrototype(object)) {
|
|||
|
|
return nativeKeys(object);
|
|||
|
|
}
|
|||
|
|
var result = [];
|
|||
|
|
for (var key in Object(object)) {
|
|||
|
|
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|||
|
|
result.push(key);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.matches` which doesn't clone `source`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} source The object of property values to match.
|
|||
|
|
* @returns {Function} Returns the new spec function.
|
|||
|
|
*/
|
|||
|
|
function baseMatches(source) {
|
|||
|
|
var matchData = getMatchData(source);
|
|||
|
|
if (matchData.length == 1 && matchData[0][2]) {
|
|||
|
|
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
|||
|
|
}
|
|||
|
|
return function(object) {
|
|||
|
|
return object === source || baseIsMatch(object, source, matchData);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {string} path The path of the property to get.
|
|||
|
|
* @param {*} srcValue The value to match.
|
|||
|
|
* @returns {Function} Returns the new spec function.
|
|||
|
|
*/
|
|||
|
|
function baseMatchesProperty(path, srcValue) {
|
|||
|
|
if (isKey(path) && isStrictComparable(srcValue)) {
|
|||
|
|
return matchesStrictComparable(toKey(path), srcValue);
|
|||
|
|
}
|
|||
|
|
return function(object) {
|
|||
|
|
var objValue = get(object, path);
|
|||
|
|
return (objValue === undefined && objValue === srcValue)
|
|||
|
|
? hasIn(object, path)
|
|||
|
|
: baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `baseProperty` which supports deep paths.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array|string} path The path of the property to get.
|
|||
|
|
* @returns {Function} Returns the new accessor function.
|
|||
|
|
*/
|
|||
|
|
function basePropertyDeep(path) {
|
|||
|
|
return function(object) {
|
|||
|
|
return baseGet(object, path);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.toString` which doesn't convert nullish
|
|||
|
|
* values to empty strings.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to process.
|
|||
|
|
* @returns {string} Returns the string.
|
|||
|
|
*/
|
|||
|
|
function baseToString(value) {
|
|||
|
|
// Exit early for strings to avoid a performance hit in some environments.
|
|||
|
|
if (typeof value == 'string') {
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
if (isSymbol(value)) {
|
|||
|
|
return symbolToString ? symbolToString.call(value) : '';
|
|||
|
|
}
|
|||
|
|
var result = (value + '');
|
|||
|
|
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Casts `value` to a path array if it's not one.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to inspect.
|
|||
|
|
* @returns {Array} Returns the cast property path array.
|
|||
|
|
*/
|
|||
|
|
function castPath(value) {
|
|||
|
|
return isArray(value) ? value : stringToPath(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a `baseEach` or `baseEachRight` function.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} eachFunc The function to iterate over a collection.
|
|||
|
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|||
|
|
* @returns {Function} Returns the new base function.
|
|||
|
|
*/
|
|||
|
|
function createBaseEach(eachFunc, fromRight) {
|
|||
|
|
return function(collection, iteratee) {
|
|||
|
|
if (collection == null) {
|
|||
|
|
return collection;
|
|||
|
|
}
|
|||
|
|
if (!isArrayLike(collection)) {
|
|||
|
|
return eachFunc(collection, iteratee);
|
|||
|
|
}
|
|||
|
|
var length = collection.length,
|
|||
|
|
index = fromRight ? length : -1,
|
|||
|
|
iterable = Object(collection);
|
|||
|
|
|
|||
|
|
while ((fromRight ? index-- : ++index < length)) {
|
|||
|
|
if (iteratee(iterable[index], index, iterable) === false) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return collection;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|||
|
|
* @returns {Function} Returns the new base function.
|
|||
|
|
*/
|
|||
|
|
function createBaseFor(fromRight) {
|
|||
|
|
return function(object, iteratee, keysFunc) {
|
|||
|
|
var index = -1,
|
|||
|
|
iterable = Object(object),
|
|||
|
|
props = keysFunc(object),
|
|||
|
|
length = props.length;
|
|||
|
|
|
|||
|
|
while (length--) {
|
|||
|
|
var key = props[fromRight ? length : ++index];
|
|||
|
|
if (iteratee(iterable[key], key, iterable) === false) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return object;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|||
|
|
* partial deep comparisons.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to compare.
|
|||
|
|
* @param {Array} other The other array to compare.
|
|||
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|||
|
|
* @param {Function} customizer The function to customize comparisons.
|
|||
|
|
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
|
|||
|
|
* for more details.
|
|||
|
|
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
|||
|
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|||
|
|
*/
|
|||
|
|
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
|||
|
|
var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
|
|||
|
|
arrLength = array.length,
|
|||
|
|
othLength = other.length;
|
|||
|
|
|
|||
|
|
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
// Assume cyclic values are equal.
|
|||
|
|
var stacked = stack.get(array);
|
|||
|
|
if (stacked && stack.get(other)) {
|
|||
|
|
return stacked == other;
|
|||
|
|
}
|
|||
|
|
var index = -1,
|
|||
|
|
result = true,
|
|||
|
|
seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
|
|||
|
|
|
|||
|
|
stack.set(array, other);
|
|||
|
|
stack.set(other, array);
|
|||
|
|
|
|||
|
|
// Ignore non-index properties.
|
|||
|
|
while (++index < arrLength) {
|
|||
|
|
var arrValue = array[index],
|
|||
|
|
othValue = other[index];
|
|||
|
|
|
|||
|
|
if (customizer) {
|
|||
|
|
var compared = isPartial
|
|||
|
|
? customizer(othValue, arrValue, index, other, array, stack)
|
|||
|
|
: customizer(arrValue, othValue, index, array, other, stack);
|
|||
|
|
}
|
|||
|
|
if (compared !== undefined) {
|
|||
|
|
if (compared) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
result = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
// Recursively compare arrays (susceptible to call stack limits).
|
|||
|
|
if (seen) {
|
|||
|
|
if (!arraySome(other, function(othValue, othIndex) {
|
|||
|
|
if (!seen.has(othIndex) &&
|
|||
|
|
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
|||
|
|
return seen.add(othIndex);
|
|||
|
|
}
|
|||
|
|
})) {
|
|||
|
|
result = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
} else if (!(
|
|||
|
|
arrValue === othValue ||
|
|||
|
|
equalFunc(arrValue, othValue, customizer, bitmask, stack)
|
|||
|
|
)) {
|
|||
|
|
result = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
stack['delete'](array);
|
|||
|
|
stack['delete'](other);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|||
|
|
* the same `toStringTag`.
|
|||
|
|
*
|
|||
|
|
* **Note:** This function only supports comparing values with tags of
|
|||
|
|
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to compare.
|
|||
|
|
* @param {Object} other The other object to compare.
|
|||
|
|
* @param {string} tag The `toStringTag` of the objects to compare.
|
|||
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|||
|
|
* @param {Function} customizer The function to customize comparisons.
|
|||
|
|
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
|
|||
|
|
* for more details.
|
|||
|
|
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|||
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|||
|
|
*/
|
|||
|
|
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
|||
|
|
switch (tag) {
|
|||
|
|
case dataViewTag:
|
|||
|
|
if ((object.byteLength != other.byteLength) ||
|
|||
|
|
(object.byteOffset != other.byteOffset)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
object = object.buffer;
|
|||
|
|
other = other.buffer;
|
|||
|
|
|
|||
|
|
case arrayBufferTag:
|
|||
|
|
if ((object.byteLength != other.byteLength) ||
|
|||
|
|
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
case boolTag:
|
|||
|
|
case dateTag:
|
|||
|
|
case numberTag:
|
|||
|
|
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
|||
|
|
// Invalid dates are coerced to `NaN`.
|
|||
|
|
return eq(+object, +other);
|
|||
|
|
|
|||
|
|
case errorTag:
|
|||
|
|
return object.name == other.name && object.message == other.message;
|
|||
|
|
|
|||
|
|
case regexpTag:
|
|||
|
|
case stringTag:
|
|||
|
|
// Coerce regexes to strings and treat strings, primitives and objects,
|
|||
|
|
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
|||
|
|
// for more details.
|
|||
|
|
return object == (other + '');
|
|||
|
|
|
|||
|
|
case mapTag:
|
|||
|
|
var convert = mapToArray;
|
|||
|
|
|
|||
|
|
case setTag:
|
|||
|
|
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
|||
|
|
convert || (convert = setToArray);
|
|||
|
|
|
|||
|
|
if (object.size != other.size && !isPartial) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
// Assume cyclic values are equal.
|
|||
|
|
var stacked = stack.get(object);
|
|||
|
|
if (stacked) {
|
|||
|
|
return stacked == other;
|
|||
|
|
}
|
|||
|
|
bitmask |= UNORDERED_COMPARE_FLAG;
|
|||
|
|
|
|||
|
|
// Recursively compare objects (susceptible to call stack limits).
|
|||
|
|
stack.set(object, other);
|
|||
|
|
var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
|
|||
|
|
stack['delete'](object);
|
|||
|
|
return result;
|
|||
|
|
|
|||
|
|
case symbolTag:
|
|||
|
|
if (symbolValueOf) {
|
|||
|
|
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|||
|
|
* partial deep comparisons.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to compare.
|
|||
|
|
* @param {Object} other The other object to compare.
|
|||
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|||
|
|
* @param {Function} customizer The function to customize comparisons.
|
|||
|
|
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
|
|||
|
|
* for more details.
|
|||
|
|
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
|||
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|||
|
|
*/
|
|||
|
|
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
|||
|
|
var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
|
|||
|
|
objProps = keys(object),
|
|||
|
|
objLength = objProps.length,
|
|||
|
|
othProps = keys(other),
|
|||
|
|
othLength = othProps.length;
|
|||
|
|
|
|||
|
|
if (objLength != othLength && !isPartial) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var index = objLength;
|
|||
|
|
while (index--) {
|
|||
|
|
var key = objProps[index];
|
|||
|
|
if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// Assume cyclic values are equal.
|
|||
|
|
var stacked = stack.get(object);
|
|||
|
|
if (stacked && stack.get(other)) {
|
|||
|
|
return stacked == other;
|
|||
|
|
}
|
|||
|
|
var result = true;
|
|||
|
|
stack.set(object, other);
|
|||
|
|
stack.set(other, object);
|
|||
|
|
|
|||
|
|
var skipCtor = isPartial;
|
|||
|
|
while (++index < objLength) {
|
|||
|
|
key = objProps[index];
|
|||
|
|
var objValue = object[key],
|
|||
|
|
othValue = other[key];
|
|||
|
|
|
|||
|
|
if (customizer) {
|
|||
|
|
var compared = isPartial
|
|||
|
|
? customizer(othValue, objValue, key, other, object, stack)
|
|||
|
|
: customizer(objValue, othValue, key, object, other, stack);
|
|||
|
|
}
|
|||
|
|
// Recursively compare objects (susceptible to call stack limits).
|
|||
|
|
if (!(compared === undefined
|
|||
|
|
? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
|
|||
|
|
: compared
|
|||
|
|
)) {
|
|||
|
|
result = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
skipCtor || (skipCtor = key == 'constructor');
|
|||
|
|
}
|
|||
|
|
if (result && !skipCtor) {
|
|||
|
|
var objCtor = object.constructor,
|
|||
|
|
othCtor = other.constructor;
|
|||
|
|
|
|||
|
|
// Non `Object` object instances with different constructors are not equal.
|
|||
|
|
if (objCtor != othCtor &&
|
|||
|
|
('constructor' in object && 'constructor' in other) &&
|
|||
|
|
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
|||
|
|
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|||
|
|
result = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
stack['delete'](object);
|
|||
|
|
stack['delete'](other);
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the data for `map`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} map The map to query.
|
|||
|
|
* @param {string} key The reference key.
|
|||
|
|
* @returns {*} Returns the map data.
|
|||
|
|
*/
|
|||
|
|
function getMapData(map, key) {
|
|||
|
|
var data = map.__data__;
|
|||
|
|
return isKeyable(key)
|
|||
|
|
? data[typeof key == 'string' ? 'string' : 'hash']
|
|||
|
|
: data.map;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the property names, values, and compare flags of `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @returns {Array} Returns the match data of `object`.
|
|||
|
|
*/
|
|||
|
|
function getMatchData(object) {
|
|||
|
|
var result = keys(object),
|
|||
|
|
length = result.length;
|
|||
|
|
|
|||
|
|
while (length--) {
|
|||
|
|
var key = result[length],
|
|||
|
|
value = object[key];
|
|||
|
|
|
|||
|
|
result[length] = [key, value, isStrictComparable(value)];
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the native function at `key` of `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @param {string} key The key of the method to get.
|
|||
|
|
* @returns {*} Returns the function if it's native, else `undefined`.
|
|||
|
|
*/
|
|||
|
|
function getNative(object, key) {
|
|||
|
|
var value = getValue(object, key);
|
|||
|
|
return baseIsNative(value) ? value : undefined;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the `toStringTag` of `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to query.
|
|||
|
|
* @returns {string} Returns the `toStringTag`.
|
|||
|
|
*/
|
|||
|
|
var getTag = baseGetTag;
|
|||
|
|
|
|||
|
|
// Fallback for data views, maps, sets, and weak maps in IE 11,
|
|||
|
|
// for data views in Edge < 14, and promises in Node.js.
|
|||
|
|
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
|||
|
|
(Map && getTag(new Map) != mapTag) ||
|
|||
|
|
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
|||
|
|
(Set && getTag(new Set) != setTag) ||
|
|||
|
|
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
|||
|
|
getTag = function(value) {
|
|||
|
|
var result = objectToString.call(value),
|
|||
|
|
Ctor = result == objectTag ? value.constructor : undefined,
|
|||
|
|
ctorString = Ctor ? toSource(Ctor) : undefined;
|
|||
|
|
|
|||
|
|
if (ctorString) {
|
|||
|
|
switch (ctorString) {
|
|||
|
|
case dataViewCtorString: return dataViewTag;
|
|||
|
|
case mapCtorString: return mapTag;
|
|||
|
|
case promiseCtorString: return promiseTag;
|
|||
|
|
case setCtorString: return setTag;
|
|||
|
|
case weakMapCtorString: return weakMapTag;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `path` exists on `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @param {Array|string} path The path to check.
|
|||
|
|
* @param {Function} hasFunc The function to check properties.
|
|||
|
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function hasPath(object, path, hasFunc) {
|
|||
|
|
path = isKey(path, object) ? [path] : castPath(path);
|
|||
|
|
|
|||
|
|
var result,
|
|||
|
|
index = -1,
|
|||
|
|
length = path.length;
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
var key = toKey(path[index]);
|
|||
|
|
if (!(result = object != null && hasFunc(object, key))) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
object = object[key];
|
|||
|
|
}
|
|||
|
|
if (result) {
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
var length = object ? object.length : 0;
|
|||
|
|
return !!length && isLength(length) && isIndex(key, length) &&
|
|||
|
|
(isArray(object) || isArguments(object));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a valid array-like index.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isIndex(value, length) {
|
|||
|
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
|||
|
|
return !!length &&
|
|||
|
|
(typeof value == 'number' || reIsUint.test(value)) &&
|
|||
|
|
(value > -1 && value % 1 == 0 && value < length);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a property name and not a property path.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @param {Object} [object] The object to query keys on.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isKey(value, object) {
|
|||
|
|
if (isArray(value)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var type = typeof value;
|
|||
|
|
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
|||
|
|
value == null || isSymbol(value)) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
|||
|
|
(object != null && value in Object(object));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is suitable for use as unique object key.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isKeyable(value) {
|
|||
|
|
var type = typeof value;
|
|||
|
|
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|||
|
|
? (value !== '__proto__')
|
|||
|
|
: (value === null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `func` has its source masked.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isMasked(func) {
|
|||
|
|
return !!maskSrcKey && (maskSrcKey in func);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is likely a prototype object.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isPrototype(value) {
|
|||
|
|
var Ctor = value && value.constructor,
|
|||
|
|
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|||
|
|
|
|||
|
|
return value === proto;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
|||
|
|
* equality comparisons, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isStrictComparable(value) {
|
|||
|
|
return value === value && !isObject(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `matchesProperty` for source values suitable
|
|||
|
|
* for strict equality comparisons, i.e. `===`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {string} key The key of the property to get.
|
|||
|
|
* @param {*} srcValue The value to match.
|
|||
|
|
* @returns {Function} Returns the new spec function.
|
|||
|
|
*/
|
|||
|
|
function matchesStrictComparable(key, srcValue) {
|
|||
|
|
return function(object) {
|
|||
|
|
if (object == null) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return object[key] === srcValue &&
|
|||
|
|
(srcValue !== undefined || (key in Object(object)));
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `string` to a property path array.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {string} string The string to convert.
|
|||
|
|
* @returns {Array} Returns the property path array.
|
|||
|
|
*/
|
|||
|
|
var stringToPath = memoize(function(string) {
|
|||
|
|
string = toString(string);
|
|||
|
|
|
|||
|
|
var result = [];
|
|||
|
|
if (reLeadingDot.test(string)) {
|
|||
|
|
result.push('');
|
|||
|
|
}
|
|||
|
|
string.replace(rePropName, function(match, number, quote, string) {
|
|||
|
|
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
|||
|
|
});
|
|||
|
|
return result;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `value` to a string key if it's not a string or symbol.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to inspect.
|
|||
|
|
* @returns {string|symbol} Returns the key.
|
|||
|
|
*/
|
|||
|
|
function toKey(value) {
|
|||
|
|
if (typeof value == 'string' || isSymbol(value)) {
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
var result = (value + '');
|
|||
|
|
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `func` to its source code.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to process.
|
|||
|
|
* @returns {string} Returns the source code.
|
|||
|
|
*/
|
|||
|
|
function toSource(func) {
|
|||
|
|
if (func != null) {
|
|||
|
|
try {
|
|||
|
|
return funcToString.call(func);
|
|||
|
|
} catch (e) {}
|
|||
|
|
try {
|
|||
|
|
return (func + '');
|
|||
|
|
} catch (e) {}
|
|||
|
|
}
|
|||
|
|
return '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Reduces `collection` to a value which is the accumulated result of running
|
|||
|
|
* each element in `collection` thru `iteratee`, where each successive
|
|||
|
|
* invocation is supplied the return value of the previous. If `accumulator`
|
|||
|
|
* is not given, the first element of `collection` is used as the initial
|
|||
|
|
* value. The iteratee is invoked with four arguments:
|
|||
|
|
* (accumulator, value, index|key, collection).
|
|||
|
|
*
|
|||
|
|
* Many lodash methods are guarded to work as iteratees for methods like
|
|||
|
|
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
|||
|
|
*
|
|||
|
|
* The guarded methods are:
|
|||
|
|
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
|
|||
|
|
* and `sortBy`
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Collection
|
|||
|
|
* @param {Array|Object} collection The collection to iterate over.
|
|||
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|||
|
|
* @param {*} [accumulator] The initial value.
|
|||
|
|
* @returns {*} Returns the accumulated value.
|
|||
|
|
* @see _.reduceRight
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.reduce([1, 2], function(sum, n) {
|
|||
|
|
* return sum + n;
|
|||
|
|
* }, 0);
|
|||
|
|
* // => 3
|
|||
|
|
*
|
|||
|
|
* _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
|||
|
|
* (result[value] || (result[value] = [])).push(key);
|
|||
|
|
* return result;
|
|||
|
|
* }, {});
|
|||
|
|
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
|
|||
|
|
*/
|
|||
|
|
function reduce(collection, iteratee, accumulator) {
|
|||
|
|
var func = isArray(collection) ? arrayReduce : baseReduce,
|
|||
|
|
initAccum = arguments.length < 3;
|
|||
|
|
|
|||
|
|
return func(collection, baseIteratee(iteratee), accumulator, initAccum, baseEach);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|||
|
|
* provided, it determines the cache key for storing the result based on the
|
|||
|
|
* arguments provided to the memoized function. By default, the first argument
|
|||
|
|
* provided to the memoized function is used as the map cache key. The `func`
|
|||
|
|
* is invoked with the `this` binding of the memoized function.
|
|||
|
|
*
|
|||
|
|
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|||
|
|
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|||
|
|
* constructor with one whose instances implement the
|
|||
|
|
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|||
|
|
* method interface of `delete`, `get`, `has`, and `set`.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Function
|
|||
|
|
* @param {Function} func The function to have its output memoized.
|
|||
|
|
* @param {Function} [resolver] The function to resolve the cache key.
|
|||
|
|
* @returns {Function} Returns the new memoized function.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = { 'a': 1, 'b': 2 };
|
|||
|
|
* var other = { 'c': 3, 'd': 4 };
|
|||
|
|
*
|
|||
|
|
* var values = _.memoize(_.values);
|
|||
|
|
* values(object);
|
|||
|
|
* // => [1, 2]
|
|||
|
|
*
|
|||
|
|
* values(other);
|
|||
|
|
* // => [3, 4]
|
|||
|
|
*
|
|||
|
|
* object.a = 2;
|
|||
|
|
* values(object);
|
|||
|
|
* // => [1, 2]
|
|||
|
|
*
|
|||
|
|
* // Modify the result cache.
|
|||
|
|
* values.cache.set(object, ['a', 'b']);
|
|||
|
|
* values(object);
|
|||
|
|
* // => ['a', 'b']
|
|||
|
|
*
|
|||
|
|
* // Replace `_.memoize.Cache`.
|
|||
|
|
* _.memoize.Cache = WeakMap;
|
|||
|
|
*/
|
|||
|
|
function memoize(func, resolver) {
|
|||
|
|
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
|
|||
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|||
|
|
}
|
|||
|
|
var memoized = function() {
|
|||
|
|
var args = arguments,
|
|||
|
|
key = resolver ? resolver.apply(this, args) : args[0],
|
|||
|
|
cache = memoized.cache;
|
|||
|
|
|
|||
|
|
if (cache.has(key)) {
|
|||
|
|
return cache.get(key);
|
|||
|
|
}
|
|||
|
|
var result = func.apply(this, args);
|
|||
|
|
memoized.cache = cache.set(key, result);
|
|||
|
|
return result;
|
|||
|
|
};
|
|||
|
|
memoized.cache = new (memoize.Cache || MapCache);
|
|||
|
|
return memoized;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Assign cache to `_.memoize`.
|
|||
|
|
memoize.Cache = MapCache;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Performs a
|
|||
|
|
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|||
|
|
* comparison between two values to determine if they are equivalent.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to compare.
|
|||
|
|
* @param {*} other The other value to compare.
|
|||
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = { 'a': 1 };
|
|||
|
|
* var other = { 'a': 1 };
|
|||
|
|
*
|
|||
|
|
* _.eq(object, object);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.eq(object, other);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.eq('a', 'a');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.eq('a', Object('a'));
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.eq(NaN, NaN);
|
|||
|
|
* // => true
|
|||
|
|
*/
|
|||
|
|
function eq(value, other) {
|
|||
|
|
return value === other || (value !== value && other !== other);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is likely an `arguments` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|||
|
|
* else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArguments(function() { return arguments; }());
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArguments([1, 2, 3]);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArguments(value) {
|
|||
|
|
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|||
|
|
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
|||
|
|
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as an `Array` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArray([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArray(document.body.children);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArray('abc');
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArray(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
var isArray = Array.isArray;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is array-like. A value is considered array-like if it's
|
|||
|
|
* not a function and has a `value.length` that's an integer greater than or
|
|||
|
|
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike(document.body.children);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike('abc');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArrayLike(value) {
|
|||
|
|
return value != null && isLength(value.length) && !isFunction(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|||
|
|
* is an object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|||
|
|
* else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject(document.body.children);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject('abc');
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArrayLikeObject(value) {
|
|||
|
|
return isObjectLike(value) && isArrayLike(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as a `Function` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isFunction(_);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isFunction(/abc/);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isFunction(value) {
|
|||
|
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|||
|
|
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|||
|
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
|||
|
|
return tag == funcTag || tag == genTag;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a valid array-like length.
|
|||
|
|
*
|
|||
|
|
* **Note:** This method is loosely based on
|
|||
|
|
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isLength(3);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isLength(Number.MIN_VALUE);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isLength(Infinity);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isLength('3');
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isLength(value) {
|
|||
|
|
return typeof value == 'number' &&
|
|||
|
|
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is the
|
|||
|
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|||
|
|
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObject({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(_.noop);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObject(value) {
|
|||
|
|
var type = typeof value;
|
|||
|
|
return !!value && (type == 'object' || type == 'function');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|||
|
|
* and has a `typeof` result of "object".
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObjectLike(value) {
|
|||
|
|
return !!value && typeof value == 'object';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isSymbol(Symbol.iterator);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isSymbol('abc');
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isSymbol(value) {
|
|||
|
|
return typeof value == 'symbol' ||
|
|||
|
|
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as a typed array.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 3.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isTypedArray(new Uint8Array);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isTypedArray([]);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `value` to a string. An empty string is returned for `null`
|
|||
|
|
* and `undefined` values. The sign of `-0` is preserved.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to process.
|
|||
|
|
* @returns {string} Returns the string.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.toString(null);
|
|||
|
|
* // => ''
|
|||
|
|
*
|
|||
|
|
* _.toString(-0);
|
|||
|
|
* // => '-0'
|
|||
|
|
*
|
|||
|
|
* _.toString([1, 2, 3]);
|
|||
|
|
* // => '1,2,3'
|
|||
|
|
*/
|
|||
|
|
function toString(value) {
|
|||
|
|
return value == null ? '' : baseToString(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the value at `path` of `object`. If the resolved value is
|
|||
|
|
* `undefined`, the `defaultValue` is returned in its place.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 3.7.0
|
|||
|
|
* @category Object
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @param {Array|string} path The path of the property to get.
|
|||
|
|
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|||
|
|
* @returns {*} Returns the resolved value.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|||
|
|
*
|
|||
|
|
* _.get(object, 'a[0].b.c');
|
|||
|
|
* // => 3
|
|||
|
|
*
|
|||
|
|
* _.get(object, ['a', '0', 'b', 'c']);
|
|||
|
|
* // => 3
|
|||
|
|
*
|
|||
|
|
* _.get(object, 'a.b.c', 'default');
|
|||
|
|
* // => 'default'
|
|||
|
|
*/
|
|||
|
|
function get(object, path, defaultValue) {
|
|||
|
|
var result = object == null ? undefined : baseGet(object, path);
|
|||
|
|
return result === undefined ? defaultValue : result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `path` is a direct or inherited property of `object`.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Object
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @param {Array|string} path The path to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
|||
|
|
*
|
|||
|
|
* _.hasIn(object, 'a');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.hasIn(object, 'a.b');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.hasIn(object, ['a', 'b']);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.hasIn(object, 'b');
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function hasIn(object, path) {
|
|||
|
|
return object != null && hasPath(object, path, baseHasIn);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates an array of the own enumerable property names of `object`.
|
|||
|
|
*
|
|||
|
|
* **Note:** Non-object values are coerced to objects. See the
|
|||
|
|
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|||
|
|
* for more details.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @memberOf _
|
|||
|
|
* @category Object
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @returns {Array} Returns the array of property names.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* function Foo() {
|
|||
|
|
* this.a = 1;
|
|||
|
|
* this.b = 2;
|
|||
|
|
* }
|
|||
|
|
*
|
|||
|
|
* Foo.prototype.c = 3;
|
|||
|
|
*
|
|||
|
|
* _.keys(new Foo);
|
|||
|
|
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|||
|
|
*
|
|||
|
|
* _.keys('hi');
|
|||
|
|
* // => ['0', '1']
|
|||
|
|
*/
|
|||
|
|
function keys(object) {
|
|||
|
|
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This method returns the first argument it receives.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @memberOf _
|
|||
|
|
* @category Util
|
|||
|
|
* @param {*} value Any value.
|
|||
|
|
* @returns {*} Returns `value`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = { 'a': 1 };
|
|||
|
|
*
|
|||
|
|
* console.log(_.identity(object) === object);
|
|||
|
|
* // => true
|
|||
|
|
*/
|
|||
|
|
function identity(value) {
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a function that returns the value at `path` of a given object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 2.4.0
|
|||
|
|
* @category Util
|
|||
|
|
* @param {Array|string} path The path of the property to get.
|
|||
|
|
* @returns {Function} Returns the new accessor function.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var objects = [
|
|||
|
|
* { 'a': { 'b': 2 } },
|
|||
|
|
* { 'a': { 'b': 1 } }
|
|||
|
|
* ];
|
|||
|
|
*
|
|||
|
|
* _.map(objects, _.property('a.b'));
|
|||
|
|
* // => [2, 1]
|
|||
|
|
*
|
|||
|
|
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
|
|||
|
|
* // => [1, 2]
|
|||
|
|
*/
|
|||
|
|
function property(path) {
|
|||
|
|
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
module.exports = reduce;
|
|||
|
|
}(lodash_reduce, lodash_reduce.exports));
|
|||
|
|
|
|||
|
|
var _reduce = lodash_reduce.exports;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* lodash (Custom Build) <https://lodash.com/>
|
|||
|
|
* Build: `lodash modularize exports="npm" -o ./`
|
|||
|
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|||
|
|
* Released under MIT license <https://lodash.com/license>
|
|||
|
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|||
|
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/** Used as the size to enable large array optimizations. */
|
|||
|
|
var LARGE_ARRAY_SIZE = 200;
|
|||
|
|
|
|||
|
|
/** Used to stand-in for `undefined` hash values. */
|
|||
|
|
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|||
|
|
|
|||
|
|
/** Used as references for various `Number` constants. */
|
|||
|
|
var INFINITY = 1 / 0;
|
|||
|
|
|
|||
|
|
/** `Object#toString` result references. */
|
|||
|
|
var funcTag$2 = '[object Function]',
|
|||
|
|
genTag$2 = '[object GeneratorFunction]';
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Used to match `RegExp`
|
|||
|
|
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|||
|
|
*/
|
|||
|
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|||
|
|
|
|||
|
|
/** Used to detect host constructors (Safari). */
|
|||
|
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|||
|
|
|
|||
|
|
/** Detect free variable `global` from Node.js. */
|
|||
|
|
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|||
|
|
|
|||
|
|
/** Detect free variable `self`. */
|
|||
|
|
var freeSelf$1 = typeof self == 'object' && self && self.Object === Object && self;
|
|||
|
|
|
|||
|
|
/** Used as a reference to the global object. */
|
|||
|
|
var root$1 = freeGlobal$1 || freeSelf$1 || Function('return this')();
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A specialized version of `_.includes` for arrays without support for
|
|||
|
|
* specifying an index to search from.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} [array] The array to inspect.
|
|||
|
|
* @param {*} target The value to search for.
|
|||
|
|
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|||
|
|
*/
|
|||
|
|
function arrayIncludes(array, value) {
|
|||
|
|
var length = array ? array.length : 0;
|
|||
|
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} [array] The array to inspect.
|
|||
|
|
* @param {*} target The value to search for.
|
|||
|
|
* @param {Function} comparator The comparator invoked per element.
|
|||
|
|
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|||
|
|
*/
|
|||
|
|
function arrayIncludesWith(array, value, comparator) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = array ? array.length : 0;
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
if (comparator(value, array[index])) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|||
|
|
* support for iteratee shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to inspect.
|
|||
|
|
* @param {Function} predicate The function invoked per iteration.
|
|||
|
|
* @param {number} fromIndex The index to search from.
|
|||
|
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|||
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|||
|
|
*/
|
|||
|
|
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|||
|
|
var length = array.length,
|
|||
|
|
index = fromIndex + (fromRight ? 1 : -1);
|
|||
|
|
|
|||
|
|
while ((fromRight ? index-- : ++index < length)) {
|
|||
|
|
if (predicate(array[index], index, array)) {
|
|||
|
|
return index;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to inspect.
|
|||
|
|
* @param {*} value The value to search for.
|
|||
|
|
* @param {number} fromIndex The index to search from.
|
|||
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|||
|
|
*/
|
|||
|
|
function baseIndexOf(array, value, fromIndex) {
|
|||
|
|
if (value !== value) {
|
|||
|
|
return baseFindIndex(array, baseIsNaN, fromIndex);
|
|||
|
|
}
|
|||
|
|
var index = fromIndex - 1,
|
|||
|
|
length = array.length;
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
if (array[index] === value) {
|
|||
|
|
return index;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.isNaN` without support for number objects.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsNaN(value) {
|
|||
|
|
return value !== value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a cache value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} cache The cache to query.
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function cacheHas(cache, key) {
|
|||
|
|
return cache.has(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the value at `key` of `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} [object] The object to query.
|
|||
|
|
* @param {string} key The key of the property to get.
|
|||
|
|
* @returns {*} Returns the property value.
|
|||
|
|
*/
|
|||
|
|
function getValue(object, key) {
|
|||
|
|
return object == null ? undefined : object[key];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a host object in IE < 9.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isHostObject(value) {
|
|||
|
|
// Many host objects are `Object` objects that can coerce to strings
|
|||
|
|
// despite having improperly defined `toString` methods.
|
|||
|
|
var result = false;
|
|||
|
|
if (value != null && typeof value.toString != 'function') {
|
|||
|
|
try {
|
|||
|
|
result = !!(value + '');
|
|||
|
|
} catch (e) {}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `set` to an array of its values.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} set The set to convert.
|
|||
|
|
* @returns {Array} Returns the values.
|
|||
|
|
*/
|
|||
|
|
function setToArray(set) {
|
|||
|
|
var index = -1,
|
|||
|
|
result = Array(set.size);
|
|||
|
|
|
|||
|
|
set.forEach(function(value) {
|
|||
|
|
result[++index] = value;
|
|||
|
|
});
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** Used for built-in method references. */
|
|||
|
|
var arrayProto = Array.prototype,
|
|||
|
|
funcProto = Function.prototype,
|
|||
|
|
objectProto$2 = Object.prototype;
|
|||
|
|
|
|||
|
|
/** Used to detect overreaching core-js shims. */
|
|||
|
|
var coreJsData = root$1['__core-js_shared__'];
|
|||
|
|
|
|||
|
|
/** Used to detect methods masquerading as native. */
|
|||
|
|
var maskSrcKey = (function() {
|
|||
|
|
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|||
|
|
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|||
|
|
}());
|
|||
|
|
|
|||
|
|
/** Used to resolve the decompiled source of functions. */
|
|||
|
|
var funcToString = funcProto.toString;
|
|||
|
|
|
|||
|
|
/** Used to check objects for own properties. */
|
|||
|
|
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Used to resolve the
|
|||
|
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|||
|
|
* of values.
|
|||
|
|
*/
|
|||
|
|
var objectToString$2 = objectProto$2.toString;
|
|||
|
|
|
|||
|
|
/** Used to detect if a method is native. */
|
|||
|
|
var reIsNative = RegExp('^' +
|
|||
|
|
funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
|
|||
|
|
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
/** Built-in value references. */
|
|||
|
|
var splice = arrayProto.splice;
|
|||
|
|
|
|||
|
|
/* Built-in method references that are verified to be native. */
|
|||
|
|
var Map = getNative(root$1, 'Map'),
|
|||
|
|
Set = getNative(root$1, 'Set'),
|
|||
|
|
nativeCreate = getNative(Object, 'create');
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a hash object.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function Hash(entries) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = entries ? entries.length : 0;
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
while (++index < length) {
|
|||
|
|
var entry = entries[index];
|
|||
|
|
this.set(entry[0], entry[1]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the hash.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf Hash
|
|||
|
|
*/
|
|||
|
|
function hashClear() {
|
|||
|
|
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the hash.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {Object} hash The hash to modify.
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function hashDelete(key) {
|
|||
|
|
return this.has(key) && delete this.__data__[key];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the hash value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function hashGet(key) {
|
|||
|
|
var data = this.__data__;
|
|||
|
|
if (nativeCreate) {
|
|||
|
|
var result = data[key];
|
|||
|
|
return result === HASH_UNDEFINED ? undefined : result;
|
|||
|
|
}
|
|||
|
|
return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a hash value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function hashHas(key) {
|
|||
|
|
var data = this.__data__;
|
|||
|
|
return nativeCreate ? data[key] !== undefined : hasOwnProperty$2.call(data, key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the hash `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf Hash
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the hash instance.
|
|||
|
|
*/
|
|||
|
|
function hashSet(key, value) {
|
|||
|
|
var data = this.__data__;
|
|||
|
|
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `Hash`.
|
|||
|
|
Hash.prototype.clear = hashClear;
|
|||
|
|
Hash.prototype['delete'] = hashDelete;
|
|||
|
|
Hash.prototype.get = hashGet;
|
|||
|
|
Hash.prototype.has = hashHas;
|
|||
|
|
Hash.prototype.set = hashSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates an list cache object.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function ListCache(entries) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = entries ? entries.length : 0;
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
while (++index < length) {
|
|||
|
|
var entry = entries[index];
|
|||
|
|
this.set(entry[0], entry[1]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the list cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
*/
|
|||
|
|
function listCacheClear() {
|
|||
|
|
this.__data__ = [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the list cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function listCacheDelete(key) {
|
|||
|
|
var data = this.__data__,
|
|||
|
|
index = assocIndexOf(data, key);
|
|||
|
|
|
|||
|
|
if (index < 0) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var lastIndex = data.length - 1;
|
|||
|
|
if (index == lastIndex) {
|
|||
|
|
data.pop();
|
|||
|
|
} else {
|
|||
|
|
splice.call(data, index, 1);
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the list cache value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function listCacheGet(key) {
|
|||
|
|
var data = this.__data__,
|
|||
|
|
index = assocIndexOf(data, key);
|
|||
|
|
|
|||
|
|
return index < 0 ? undefined : data[index][1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a list cache value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function listCacheHas(key) {
|
|||
|
|
return assocIndexOf(this.__data__, key) > -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the list cache `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf ListCache
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the list cache instance.
|
|||
|
|
*/
|
|||
|
|
function listCacheSet(key, value) {
|
|||
|
|
var data = this.__data__,
|
|||
|
|
index = assocIndexOf(data, key);
|
|||
|
|
|
|||
|
|
if (index < 0) {
|
|||
|
|
data.push([key, value]);
|
|||
|
|
} else {
|
|||
|
|
data[index][1] = value;
|
|||
|
|
}
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `ListCache`.
|
|||
|
|
ListCache.prototype.clear = listCacheClear;
|
|||
|
|
ListCache.prototype['delete'] = listCacheDelete;
|
|||
|
|
ListCache.prototype.get = listCacheGet;
|
|||
|
|
ListCache.prototype.has = listCacheHas;
|
|||
|
|
ListCache.prototype.set = listCacheSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a map cache object to store key-value pairs.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [entries] The key-value pairs to cache.
|
|||
|
|
*/
|
|||
|
|
function MapCache(entries) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = entries ? entries.length : 0;
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
while (++index < length) {
|
|||
|
|
var entry = entries[index];
|
|||
|
|
this.set(entry[0], entry[1]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes all key-value entries from the map.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name clear
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
*/
|
|||
|
|
function mapCacheClear() {
|
|||
|
|
this.__data__ = {
|
|||
|
|
'hash': new Hash,
|
|||
|
|
'map': new (Map || ListCache),
|
|||
|
|
'string': new Hash
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes `key` and its value from the map.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name delete
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the value to remove.
|
|||
|
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|||
|
|
*/
|
|||
|
|
function mapCacheDelete(key) {
|
|||
|
|
return getMapData(this, key)['delete'](key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the map value for `key`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name get
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the value to get.
|
|||
|
|
* @returns {*} Returns the entry value.
|
|||
|
|
*/
|
|||
|
|
function mapCacheGet(key) {
|
|||
|
|
return getMapData(this, key).get(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if a map value for `key` exists.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the entry to check.
|
|||
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|||
|
|
*/
|
|||
|
|
function mapCacheHas(key) {
|
|||
|
|
return getMapData(this, key).has(key);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the map `key` to `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name set
|
|||
|
|
* @memberOf MapCache
|
|||
|
|
* @param {string} key The key of the value to set.
|
|||
|
|
* @param {*} value The value to set.
|
|||
|
|
* @returns {Object} Returns the map cache instance.
|
|||
|
|
*/
|
|||
|
|
function mapCacheSet(key, value) {
|
|||
|
|
getMapData(this, key).set(key, value);
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `MapCache`.
|
|||
|
|
MapCache.prototype.clear = mapCacheClear;
|
|||
|
|
MapCache.prototype['delete'] = mapCacheDelete;
|
|||
|
|
MapCache.prototype.get = mapCacheGet;
|
|||
|
|
MapCache.prototype.has = mapCacheHas;
|
|||
|
|
MapCache.prototype.set = mapCacheSet;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
*
|
|||
|
|
* Creates an array cache object to store unique values.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @constructor
|
|||
|
|
* @param {Array} [values] The values to cache.
|
|||
|
|
*/
|
|||
|
|
function SetCache(values) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = values ? values.length : 0;
|
|||
|
|
|
|||
|
|
this.__data__ = new MapCache;
|
|||
|
|
while (++index < length) {
|
|||
|
|
this.add(values[index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Adds `value` to the array cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name add
|
|||
|
|
* @memberOf SetCache
|
|||
|
|
* @alias push
|
|||
|
|
* @param {*} value The value to cache.
|
|||
|
|
* @returns {Object} Returns the cache instance.
|
|||
|
|
*/
|
|||
|
|
function setCacheAdd(value) {
|
|||
|
|
this.__data__.set(value, HASH_UNDEFINED);
|
|||
|
|
return this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is in the array cache.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @name has
|
|||
|
|
* @memberOf SetCache
|
|||
|
|
* @param {*} value The value to search for.
|
|||
|
|
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|||
|
|
*/
|
|||
|
|
function setCacheHas(value) {
|
|||
|
|
return this.__data__.has(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Add methods to `SetCache`.
|
|||
|
|
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|||
|
|
SetCache.prototype.has = setCacheHas;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to inspect.
|
|||
|
|
* @param {*} key The key to search for.
|
|||
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|||
|
|
*/
|
|||
|
|
function assocIndexOf(array, key) {
|
|||
|
|
var length = array.length;
|
|||
|
|
while (length--) {
|
|||
|
|
if (eq$1(array[length][0], key)) {
|
|||
|
|
return length;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.isNative` without bad shim checks.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a native function,
|
|||
|
|
* else `false`.
|
|||
|
|
*/
|
|||
|
|
function baseIsNative(value) {
|
|||
|
|
if (!isObject$2(value) || isMasked(value)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var pattern = (isFunction$2(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
|||
|
|
return pattern.test(toSource(value));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to inspect.
|
|||
|
|
* @param {Function} [iteratee] The iteratee invoked per element.
|
|||
|
|
* @param {Function} [comparator] The comparator invoked per element.
|
|||
|
|
* @returns {Array} Returns the new duplicate free array.
|
|||
|
|
*/
|
|||
|
|
function baseUniq(array, iteratee, comparator) {
|
|||
|
|
var index = -1,
|
|||
|
|
includes = arrayIncludes,
|
|||
|
|
length = array.length,
|
|||
|
|
isCommon = true,
|
|||
|
|
result = [],
|
|||
|
|
seen = result;
|
|||
|
|
|
|||
|
|
if (comparator) {
|
|||
|
|
isCommon = false;
|
|||
|
|
includes = arrayIncludesWith;
|
|||
|
|
}
|
|||
|
|
else if (length >= LARGE_ARRAY_SIZE) {
|
|||
|
|
var set = iteratee ? null : createSet(array);
|
|||
|
|
if (set) {
|
|||
|
|
return setToArray(set);
|
|||
|
|
}
|
|||
|
|
isCommon = false;
|
|||
|
|
includes = cacheHas;
|
|||
|
|
seen = new SetCache;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
seen = iteratee ? [] : result;
|
|||
|
|
}
|
|||
|
|
outer:
|
|||
|
|
while (++index < length) {
|
|||
|
|
var value = array[index],
|
|||
|
|
computed = iteratee ? iteratee(value) : value;
|
|||
|
|
|
|||
|
|
value = (comparator || value !== 0) ? value : 0;
|
|||
|
|
if (isCommon && computed === computed) {
|
|||
|
|
var seenIndex = seen.length;
|
|||
|
|
while (seenIndex--) {
|
|||
|
|
if (seen[seenIndex] === computed) {
|
|||
|
|
continue outer;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (iteratee) {
|
|||
|
|
seen.push(computed);
|
|||
|
|
}
|
|||
|
|
result.push(value);
|
|||
|
|
}
|
|||
|
|
else if (!includes(seen, computed, comparator)) {
|
|||
|
|
if (seen !== result) {
|
|||
|
|
seen.push(computed);
|
|||
|
|
}
|
|||
|
|
result.push(value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a set object of `values`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} values The values to add to the set.
|
|||
|
|
* @returns {Object} Returns the new set.
|
|||
|
|
*/
|
|||
|
|
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
|
|||
|
|
return new Set(values);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the data for `map`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} map The map to query.
|
|||
|
|
* @param {string} key The reference key.
|
|||
|
|
* @returns {*} Returns the map data.
|
|||
|
|
*/
|
|||
|
|
function getMapData(map, key) {
|
|||
|
|
var data = map.__data__;
|
|||
|
|
return isKeyable(key)
|
|||
|
|
? data[typeof key == 'string' ? 'string' : 'hash']
|
|||
|
|
: data.map;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gets the native function at `key` of `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @param {string} key The key of the method to get.
|
|||
|
|
* @returns {*} Returns the function if it's native, else `undefined`.
|
|||
|
|
*/
|
|||
|
|
function getNative(object, key) {
|
|||
|
|
var value = getValue(object, key);
|
|||
|
|
return baseIsNative(value) ? value : undefined;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is suitable for use as unique object key.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isKeyable(value) {
|
|||
|
|
var type = typeof value;
|
|||
|
|
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|||
|
|
? (value !== '__proto__')
|
|||
|
|
: (value === null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `func` has its source masked.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isMasked(func) {
|
|||
|
|
return !!maskSrcKey && (maskSrcKey in func);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Converts `func` to its source code.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to process.
|
|||
|
|
* @returns {string} Returns the source code.
|
|||
|
|
*/
|
|||
|
|
function toSource(func) {
|
|||
|
|
if (func != null) {
|
|||
|
|
try {
|
|||
|
|
return funcToString.call(func);
|
|||
|
|
} catch (e) {}
|
|||
|
|
try {
|
|||
|
|
return (func + '');
|
|||
|
|
} catch (e) {}
|
|||
|
|
}
|
|||
|
|
return '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a duplicate-free version of an array, using
|
|||
|
|
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|||
|
|
* for equality comparisons, in which only the first occurrence of each
|
|||
|
|
* element is kept.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Array
|
|||
|
|
* @param {Array} array The array to inspect.
|
|||
|
|
* @returns {Array} Returns the new duplicate free array.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.uniq([2, 1, 2]);
|
|||
|
|
* // => [2, 1]
|
|||
|
|
*/
|
|||
|
|
function uniq(array) {
|
|||
|
|
return (array && array.length)
|
|||
|
|
? baseUniq(array)
|
|||
|
|
: [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Performs a
|
|||
|
|
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|||
|
|
* comparison between two values to determine if they are equivalent.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to compare.
|
|||
|
|
* @param {*} other The other value to compare.
|
|||
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = { 'a': 1 };
|
|||
|
|
* var other = { 'a': 1 };
|
|||
|
|
*
|
|||
|
|
* _.eq(object, object);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.eq(object, other);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.eq('a', 'a');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.eq('a', Object('a'));
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.eq(NaN, NaN);
|
|||
|
|
* // => true
|
|||
|
|
*/
|
|||
|
|
function eq$1(value, other) {
|
|||
|
|
return value === other || (value !== value && other !== other);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as a `Function` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isFunction(_);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isFunction(/abc/);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isFunction$2(value) {
|
|||
|
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|||
|
|
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|||
|
|
var tag = isObject$2(value) ? objectToString$2.call(value) : '';
|
|||
|
|
return tag == funcTag$2 || tag == genTag$2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is the
|
|||
|
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|||
|
|
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObject({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(_.noop);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObject$2(value) {
|
|||
|
|
var type = typeof value;
|
|||
|
|
return !!value && (type == 'object' || type == 'function');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This method returns `undefined`.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 2.3.0
|
|||
|
|
* @category Util
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.times(2, _.noop);
|
|||
|
|
* // => [undefined, undefined]
|
|||
|
|
*/
|
|||
|
|
function noop() {
|
|||
|
|
// No operation performed.
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var lodash_uniq = uniq;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* lodash (Custom Build) <https://lodash.com/>
|
|||
|
|
* Build: `lodash modularize exports="npm" -o ./`
|
|||
|
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|||
|
|
* Released under MIT license <https://lodash.com/license>
|
|||
|
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|||
|
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/** Used as references for various `Number` constants. */
|
|||
|
|
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|||
|
|
|
|||
|
|
/** `Object#toString` result references. */
|
|||
|
|
var argsTag$1 = '[object Arguments]',
|
|||
|
|
funcTag$1 = '[object Function]',
|
|||
|
|
genTag$1 = '[object GeneratorFunction]';
|
|||
|
|
|
|||
|
|
/** Detect free variable `global` from Node.js. */
|
|||
|
|
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|||
|
|
|
|||
|
|
/** Detect free variable `self`. */
|
|||
|
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|||
|
|
|
|||
|
|
/** Used as a reference to the global object. */
|
|||
|
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Appends the elements of `values` to `array`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to modify.
|
|||
|
|
* @param {Array} values The values to append.
|
|||
|
|
* @returns {Array} Returns `array`.
|
|||
|
|
*/
|
|||
|
|
function arrayPush(array, values) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = values.length,
|
|||
|
|
offset = array.length;
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
array[offset + index] = values[index];
|
|||
|
|
}
|
|||
|
|
return array;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** Used for built-in method references. */
|
|||
|
|
var objectProto$1 = Object.prototype;
|
|||
|
|
|
|||
|
|
/** Used to check objects for own properties. */
|
|||
|
|
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Used to resolve the
|
|||
|
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|||
|
|
* of values.
|
|||
|
|
*/
|
|||
|
|
var objectToString$1 = objectProto$1.toString;
|
|||
|
|
|
|||
|
|
/** Built-in value references. */
|
|||
|
|
var Symbol = root.Symbol,
|
|||
|
|
propertyIsEnumerable$1 = objectProto$1.propertyIsEnumerable,
|
|||
|
|
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.flatten` with support for restricting flattening.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} array The array to flatten.
|
|||
|
|
* @param {number} depth The maximum recursion depth.
|
|||
|
|
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|||
|
|
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|||
|
|
* @param {Array} [result=[]] The initial result value.
|
|||
|
|
* @returns {Array} Returns the new flattened array.
|
|||
|
|
*/
|
|||
|
|
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = array.length;
|
|||
|
|
|
|||
|
|
predicate || (predicate = isFlattenable);
|
|||
|
|
result || (result = []);
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
var value = array[index];
|
|||
|
|
if (depth > 0 && predicate(value)) {
|
|||
|
|
if (depth > 1) {
|
|||
|
|
// Recursively flatten arrays (susceptible to call stack limits).
|
|||
|
|
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|||
|
|
} else {
|
|||
|
|
arrayPush(result, value);
|
|||
|
|
}
|
|||
|
|
} else if (!isStrict) {
|
|||
|
|
result[result.length] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Copies the values of `source` to `array`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Array} source The array to copy values from.
|
|||
|
|
* @param {Array} [array=[]] The array to copy values to.
|
|||
|
|
* @returns {Array} Returns `array`.
|
|||
|
|
*/
|
|||
|
|
function copyArray(source, array) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = source.length;
|
|||
|
|
|
|||
|
|
array || (array = Array(length));
|
|||
|
|
while (++index < length) {
|
|||
|
|
array[index] = source[index];
|
|||
|
|
}
|
|||
|
|
return array;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a flattenable `arguments` object or array.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isFlattenable(value) {
|
|||
|
|
return isArray$1(value) || isArguments$1(value) ||
|
|||
|
|
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a new array concatenating `array` with any additional arrays
|
|||
|
|
* and/or values.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Array
|
|||
|
|
* @param {Array} array The array to concatenate.
|
|||
|
|
* @param {...*} [values] The values to concatenate.
|
|||
|
|
* @returns {Array} Returns the new concatenated array.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var array = [1];
|
|||
|
|
* var other = _.concat(array, 2, [3], [[4]]);
|
|||
|
|
*
|
|||
|
|
* console.log(other);
|
|||
|
|
* // => [1, 2, 3, [4]]
|
|||
|
|
*
|
|||
|
|
* console.log(array);
|
|||
|
|
* // => [1]
|
|||
|
|
*/
|
|||
|
|
function concat() {
|
|||
|
|
var length = arguments.length,
|
|||
|
|
args = Array(length ? length - 1 : 0),
|
|||
|
|
array = arguments[0],
|
|||
|
|
index = length;
|
|||
|
|
|
|||
|
|
while (index--) {
|
|||
|
|
args[index - 1] = arguments[index];
|
|||
|
|
}
|
|||
|
|
return length
|
|||
|
|
? arrayPush(isArray$1(array) ? copyArray(array) : [array], baseFlatten(args, 1))
|
|||
|
|
: [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is likely an `arguments` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|||
|
|
* else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArguments(function() { return arguments; }());
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArguments([1, 2, 3]);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArguments$1(value) {
|
|||
|
|
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|||
|
|
return isArrayLikeObject$1(value) && hasOwnProperty$1.call(value, 'callee') &&
|
|||
|
|
(!propertyIsEnumerable$1.call(value, 'callee') || objectToString$1.call(value) == argsTag$1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as an `Array` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArray([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArray(document.body.children);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArray('abc');
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArray(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
var isArray$1 = Array.isArray;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is array-like. A value is considered array-like if it's
|
|||
|
|
* not a function and has a `value.length` that's an integer greater than or
|
|||
|
|
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike(document.body.children);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike('abc');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArrayLike$1(value) {
|
|||
|
|
return value != null && isLength$1(value.length) && !isFunction$1(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|||
|
|
* is an object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|||
|
|
* else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject(document.body.children);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject('abc');
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArrayLikeObject$1(value) {
|
|||
|
|
return isObjectLike$1(value) && isArrayLike$1(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as a `Function` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isFunction(_);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isFunction(/abc/);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isFunction$1(value) {
|
|||
|
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|||
|
|
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|||
|
|
var tag = isObject$1(value) ? objectToString$1.call(value) : '';
|
|||
|
|
return tag == funcTag$1 || tag == genTag$1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a valid array-like length.
|
|||
|
|
*
|
|||
|
|
* **Note:** This method is loosely based on
|
|||
|
|
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isLength(3);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isLength(Number.MIN_VALUE);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isLength(Infinity);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isLength('3');
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isLength$1(value) {
|
|||
|
|
return typeof value == 'number' &&
|
|||
|
|
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is the
|
|||
|
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|||
|
|
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObject({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(_.noop);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObject$1(value) {
|
|||
|
|
var type = typeof value;
|
|||
|
|
return !!value && (type == 'object' || type == 'function');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|||
|
|
* and has a `typeof` result of "object".
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObjectLike$1(value) {
|
|||
|
|
return !!value && typeof value == 'object';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var lodash_concat = concat;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* lodash (Custom Build) <https://lodash.com/>
|
|||
|
|
* Build: `lodash modularize exports="npm" -o ./`
|
|||
|
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|||
|
|
* Released under MIT license <https://lodash.com/license>
|
|||
|
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|||
|
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/** Used as references for various `Number` constants. */
|
|||
|
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|||
|
|
|
|||
|
|
/** `Object#toString` result references. */
|
|||
|
|
var argsTag = '[object Arguments]',
|
|||
|
|
funcTag = '[object Function]',
|
|||
|
|
genTag = '[object GeneratorFunction]';
|
|||
|
|
|
|||
|
|
/** Used to detect unsigned integer values. */
|
|||
|
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A faster alternative to `Function#apply`, this function invokes `func`
|
|||
|
|
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to invoke.
|
|||
|
|
* @param {*} thisArg The `this` binding of `func`.
|
|||
|
|
* @param {Array} args The arguments to invoke `func` with.
|
|||
|
|
* @returns {*} Returns the result of `func`.
|
|||
|
|
*/
|
|||
|
|
function apply(func, thisArg, args) {
|
|||
|
|
switch (args.length) {
|
|||
|
|
case 0: return func.call(thisArg);
|
|||
|
|
case 1: return func.call(thisArg, args[0]);
|
|||
|
|
case 2: return func.call(thisArg, args[0], args[1]);
|
|||
|
|
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|||
|
|
}
|
|||
|
|
return func.apply(thisArg, args);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.times` without support for iteratee shorthands
|
|||
|
|
* or max array length checks.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {number} n The number of times to invoke `iteratee`.
|
|||
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|||
|
|
* @returns {Array} Returns the array of results.
|
|||
|
|
*/
|
|||
|
|
function baseTimes(n, iteratee) {
|
|||
|
|
var index = -1,
|
|||
|
|
result = Array(n);
|
|||
|
|
|
|||
|
|
while (++index < n) {
|
|||
|
|
result[index] = iteratee(index);
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a unary function that invokes `func` with its argument transformed.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to wrap.
|
|||
|
|
* @param {Function} transform The argument transform.
|
|||
|
|
* @returns {Function} Returns the new function.
|
|||
|
|
*/
|
|||
|
|
function overArg(func, transform) {
|
|||
|
|
return function(arg) {
|
|||
|
|
return func(transform(arg));
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** Used for built-in method references. */
|
|||
|
|
var objectProto = Object.prototype;
|
|||
|
|
|
|||
|
|
/** Used to check objects for own properties. */
|
|||
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Used to resolve the
|
|||
|
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|||
|
|
* of values.
|
|||
|
|
*/
|
|||
|
|
var objectToString = objectProto.toString;
|
|||
|
|
|
|||
|
|
/** Built-in value references. */
|
|||
|
|
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|||
|
|
|
|||
|
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|||
|
|
var nativeKeys = overArg(Object.keys, Object),
|
|||
|
|
nativeMax = Math.max;
|
|||
|
|
|
|||
|
|
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
|||
|
|
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates an array of the enumerable property names of the array-like `value`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to query.
|
|||
|
|
* @param {boolean} inherited Specify returning inherited property names.
|
|||
|
|
* @returns {Array} Returns the array of property names.
|
|||
|
|
*/
|
|||
|
|
function arrayLikeKeys(value, inherited) {
|
|||
|
|
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|||
|
|
// Safari 9 makes `arguments.length` enumerable in strict mode.
|
|||
|
|
var result = (isArray(value) || isArguments(value))
|
|||
|
|
? baseTimes(value.length, String)
|
|||
|
|
: [];
|
|||
|
|
|
|||
|
|
var length = result.length,
|
|||
|
|
skipIndexes = !!length;
|
|||
|
|
|
|||
|
|
for (var key in value) {
|
|||
|
|
if ((inherited || hasOwnProperty.call(value, key)) &&
|
|||
|
|
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
|||
|
|
result.push(key);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
|||
|
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|||
|
|
* for equality comparisons.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to modify.
|
|||
|
|
* @param {string} key The key of the property to assign.
|
|||
|
|
* @param {*} value The value to assign.
|
|||
|
|
*/
|
|||
|
|
function assignValue(object, key, value) {
|
|||
|
|
var objValue = object[key];
|
|||
|
|
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
|||
|
|
(value === undefined && !(key in object))) {
|
|||
|
|
object[key] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @returns {Array} Returns the array of property names.
|
|||
|
|
*/
|
|||
|
|
function baseKeys(object) {
|
|||
|
|
if (!isPrototype(object)) {
|
|||
|
|
return nativeKeys(object);
|
|||
|
|
}
|
|||
|
|
var result = [];
|
|||
|
|
for (var key in Object(object)) {
|
|||
|
|
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
|||
|
|
result.push(key);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} func The function to apply a rest parameter to.
|
|||
|
|
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|||
|
|
* @returns {Function} Returns the new function.
|
|||
|
|
*/
|
|||
|
|
function baseRest(func, start) {
|
|||
|
|
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|||
|
|
return function() {
|
|||
|
|
var args = arguments,
|
|||
|
|
index = -1,
|
|||
|
|
length = nativeMax(args.length - start, 0),
|
|||
|
|
array = Array(length);
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
array[index] = args[start + index];
|
|||
|
|
}
|
|||
|
|
index = -1;
|
|||
|
|
var otherArgs = Array(start + 1);
|
|||
|
|
while (++index < start) {
|
|||
|
|
otherArgs[index] = args[index];
|
|||
|
|
}
|
|||
|
|
otherArgs[start] = array;
|
|||
|
|
return apply(func, this, otherArgs);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Copies properties of `source` to `object`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Object} source The object to copy properties from.
|
|||
|
|
* @param {Array} props The property identifiers to copy.
|
|||
|
|
* @param {Object} [object={}] The object to copy properties to.
|
|||
|
|
* @param {Function} [customizer] The function to customize copied values.
|
|||
|
|
* @returns {Object} Returns `object`.
|
|||
|
|
*/
|
|||
|
|
function copyObject(source, props, object, customizer) {
|
|||
|
|
object || (object = {});
|
|||
|
|
|
|||
|
|
var index = -1,
|
|||
|
|
length = props.length;
|
|||
|
|
|
|||
|
|
while (++index < length) {
|
|||
|
|
var key = props[index];
|
|||
|
|
|
|||
|
|
var newValue = customizer
|
|||
|
|
? customizer(object[key], source[key], key, object, source)
|
|||
|
|
: undefined;
|
|||
|
|
|
|||
|
|
assignValue(object, key, newValue === undefined ? source[key] : newValue);
|
|||
|
|
}
|
|||
|
|
return object;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates a function like `_.assign`.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {Function} assigner The function to assign values.
|
|||
|
|
* @returns {Function} Returns the new assigner function.
|
|||
|
|
*/
|
|||
|
|
function createAssigner(assigner) {
|
|||
|
|
return baseRest(function(object, sources) {
|
|||
|
|
var index = -1,
|
|||
|
|
length = sources.length,
|
|||
|
|
customizer = length > 1 ? sources[length - 1] : undefined,
|
|||
|
|
guard = length > 2 ? sources[2] : undefined;
|
|||
|
|
|
|||
|
|
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
|||
|
|
? (length--, customizer)
|
|||
|
|
: undefined;
|
|||
|
|
|
|||
|
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|||
|
|
customizer = length < 3 ? undefined : customizer;
|
|||
|
|
length = 1;
|
|||
|
|
}
|
|||
|
|
object = Object(object);
|
|||
|
|
while (++index < length) {
|
|||
|
|
var source = sources[index];
|
|||
|
|
if (source) {
|
|||
|
|
assigner(object, source, index, customizer);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return object;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a valid array-like index.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isIndex(value, length) {
|
|||
|
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
|||
|
|
return !!length &&
|
|||
|
|
(typeof value == 'number' || reIsUint.test(value)) &&
|
|||
|
|
(value > -1 && value % 1 == 0 && value < length);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if the given arguments are from an iteratee call.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The potential iteratee value argument.
|
|||
|
|
* @param {*} index The potential iteratee index or key argument.
|
|||
|
|
* @param {*} object The potential iteratee object argument.
|
|||
|
|
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
|||
|
|
* else `false`.
|
|||
|
|
*/
|
|||
|
|
function isIterateeCall(value, index, object) {
|
|||
|
|
if (!isObject(object)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
var type = typeof index;
|
|||
|
|
if (type == 'number'
|
|||
|
|
? (isArrayLike(object) && isIndex(index, object.length))
|
|||
|
|
: (type == 'string' && index in object)
|
|||
|
|
) {
|
|||
|
|
return eq(object[index], value);
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is likely a prototype object.
|
|||
|
|
*
|
|||
|
|
* @private
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|||
|
|
*/
|
|||
|
|
function isPrototype(value) {
|
|||
|
|
var Ctor = value && value.constructor,
|
|||
|
|
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
|||
|
|
|
|||
|
|
return value === proto;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Performs a
|
|||
|
|
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|||
|
|
* comparison between two values to determine if they are equivalent.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to compare.
|
|||
|
|
* @param {*} other The other value to compare.
|
|||
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* var object = { 'a': 1 };
|
|||
|
|
* var other = { 'a': 1 };
|
|||
|
|
*
|
|||
|
|
* _.eq(object, object);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.eq(object, other);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.eq('a', 'a');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.eq('a', Object('a'));
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.eq(NaN, NaN);
|
|||
|
|
* // => true
|
|||
|
|
*/
|
|||
|
|
function eq(value, other) {
|
|||
|
|
return value === other || (value !== value && other !== other);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is likely an `arguments` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|||
|
|
* else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArguments(function() { return arguments; }());
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArguments([1, 2, 3]);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArguments(value) {
|
|||
|
|
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
|||
|
|
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
|||
|
|
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as an `Array` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArray([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArray(document.body.children);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArray('abc');
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArray(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
var isArray = Array.isArray;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is array-like. A value is considered array-like if it's
|
|||
|
|
* not a function and has a `value.length` that's an integer greater than or
|
|||
|
|
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike(document.body.children);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike('abc');
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLike(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArrayLike(value) {
|
|||
|
|
return value != null && isLength(value.length) && !isFunction(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|||
|
|
* is an object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|||
|
|
* else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject(document.body.children);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject('abc');
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isArrayLikeObject(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isArrayLikeObject(value) {
|
|||
|
|
return isObjectLike(value) && isArrayLike(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is classified as a `Function` object.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isFunction(_);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isFunction(/abc/);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isFunction(value) {
|
|||
|
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|||
|
|
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|||
|
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
|||
|
|
return tag == funcTag || tag == genTag;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is a valid array-like length.
|
|||
|
|
*
|
|||
|
|
* **Note:** This method is loosely based on
|
|||
|
|
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isLength(3);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isLength(Number.MIN_VALUE);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isLength(Infinity);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isLength('3');
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isLength(value) {
|
|||
|
|
return typeof value == 'number' &&
|
|||
|
|
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is the
|
|||
|
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|||
|
|
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObject({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(_.noop);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObject(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObject(value) {
|
|||
|
|
var type = typeof value;
|
|||
|
|
return !!value && (type == 'object' || type == 'function');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|||
|
|
* and has a `typeof` result of "object".
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 4.0.0
|
|||
|
|
* @category Lang
|
|||
|
|
* @param {*} value The value to check.
|
|||
|
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike({});
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike([1, 2, 3]);
|
|||
|
|
* // => true
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike(_.noop);
|
|||
|
|
* // => false
|
|||
|
|
*
|
|||
|
|
* _.isObjectLike(null);
|
|||
|
|
* // => false
|
|||
|
|
*/
|
|||
|
|
function isObjectLike(value) {
|
|||
|
|
return !!value && typeof value == 'object';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Assigns own enumerable string keyed properties of source objects to the
|
|||
|
|
* destination object. Source objects are applied from left to right.
|
|||
|
|
* Subsequent sources overwrite property assignments of previous sources.
|
|||
|
|
*
|
|||
|
|
* **Note:** This method mutates `object` and is loosely based on
|
|||
|
|
* [`Object.assign`](https://mdn.io/Object/assign).
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @memberOf _
|
|||
|
|
* @since 0.10.0
|
|||
|
|
* @category Object
|
|||
|
|
* @param {Object} object The destination object.
|
|||
|
|
* @param {...Object} [sources] The source objects.
|
|||
|
|
* @returns {Object} Returns `object`.
|
|||
|
|
* @see _.assignIn
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* function Foo() {
|
|||
|
|
* this.a = 1;
|
|||
|
|
* }
|
|||
|
|
*
|
|||
|
|
* function Bar() {
|
|||
|
|
* this.c = 3;
|
|||
|
|
* }
|
|||
|
|
*
|
|||
|
|
* Foo.prototype.b = 2;
|
|||
|
|
* Bar.prototype.d = 4;
|
|||
|
|
*
|
|||
|
|
* _.assign({ 'a': 0 }, new Foo, new Bar);
|
|||
|
|
* // => { 'a': 1, 'c': 3 }
|
|||
|
|
*/
|
|||
|
|
var assign = createAssigner(function(object, source) {
|
|||
|
|
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
|||
|
|
copyObject(source, keys(source), object);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
for (var key in source) {
|
|||
|
|
if (hasOwnProperty.call(source, key)) {
|
|||
|
|
assignValue(object, key, source[key]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Creates an array of the own enumerable property names of `object`.
|
|||
|
|
*
|
|||
|
|
* **Note:** Non-object values are coerced to objects. See the
|
|||
|
|
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|||
|
|
* for more details.
|
|||
|
|
*
|
|||
|
|
* @static
|
|||
|
|
* @since 0.1.0
|
|||
|
|
* @memberOf _
|
|||
|
|
* @category Object
|
|||
|
|
* @param {Object} object The object to query.
|
|||
|
|
* @returns {Array} Returns the array of property names.
|
|||
|
|
* @example
|
|||
|
|
*
|
|||
|
|
* function Foo() {
|
|||
|
|
* this.a = 1;
|
|||
|
|
* this.b = 2;
|
|||
|
|
* }
|
|||
|
|
*
|
|||
|
|
* Foo.prototype.c = 3;
|
|||
|
|
*
|
|||
|
|
* _.keys(new Foo);
|
|||
|
|
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|||
|
|
*
|
|||
|
|
* _.keys('hi');
|
|||
|
|
* // => ['0', '1']
|
|||
|
|
*/
|
|||
|
|
function keys(object) {
|
|||
|
|
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var lodash_assign = assign;
|
|||
|
|
|
|||
|
|
var expressWeb = [
|
|||
|
|
"de_DE",
|
|||
|
|
"en_US",
|
|||
|
|
"es_ES",
|
|||
|
|
"fr_FR",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"it_IT",
|
|||
|
|
"id_ID",
|
|||
|
|
"ms_MY",
|
|||
|
|
"hi_IN",
|
|||
|
|
"th_TH",
|
|||
|
|
"ja_JP",
|
|||
|
|
"bn_BD",
|
|||
|
|
"pl_PL",
|
|||
|
|
"fil_PH",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var futuresH5 = [
|
|||
|
|
"de_DE",
|
|||
|
|
"en_US",
|
|||
|
|
"es_ES",
|
|||
|
|
"fr_FR",
|
|||
|
|
"it_IT",
|
|||
|
|
"ja_JP",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var futuresLiteWeb = [
|
|||
|
|
"en_US",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"es_ES",
|
|||
|
|
"ko_KR",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ja_JP",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var futuresProWeb = [
|
|||
|
|
"en_US",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"ru_RU",
|
|||
|
|
"vi_VN",
|
|||
|
|
"tr_TR",
|
|||
|
|
"de_DE",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"fr_FR",
|
|||
|
|
"es_ES",
|
|||
|
|
"it_IT",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ja_JP",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var kucoinH5 = [
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"en_US",
|
|||
|
|
"ru_RU",
|
|||
|
|
"hi_IN",
|
|||
|
|
"ko_KR",
|
|||
|
|
"es_ES",
|
|||
|
|
"de_DE",
|
|||
|
|
"fr_FR",
|
|||
|
|
"id_ID",
|
|||
|
|
"it_IT",
|
|||
|
|
"ms_MY",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var landWeb = [
|
|||
|
|
"de_DE",
|
|||
|
|
"en_US",
|
|||
|
|
"es_ES",
|
|||
|
|
"fr_FR",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"it_IT",
|
|||
|
|
"id_ID",
|
|||
|
|
"ms_MY",
|
|||
|
|
"hi_IN",
|
|||
|
|
"th_TH",
|
|||
|
|
"ja_JP",
|
|||
|
|
"bn_BD",
|
|||
|
|
"pl_PL",
|
|||
|
|
"fil_PH",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var mainWeb = [
|
|||
|
|
"de_DE",
|
|||
|
|
"en_US",
|
|||
|
|
"es_ES",
|
|||
|
|
"fr_FR",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"it_IT",
|
|||
|
|
"id_ID",
|
|||
|
|
"ms_MY",
|
|||
|
|
"hi_IN",
|
|||
|
|
"th_TH",
|
|||
|
|
"ja_JP",
|
|||
|
|
"bn_BD",
|
|||
|
|
"pl_PL",
|
|||
|
|
"fil_PH",
|
|||
|
|
"ar_AE",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var miningPoolWeb = ["en_US", "ja_JP", "ko_KR", "zh_CN", "ru_RU", "zh_HK"];
|
|||
|
|
|
|||
|
|
var poolX = ["zh_CN", "en_US", "zh_HK", "ko_KR", "ja_JP"];
|
|||
|
|
|
|||
|
|
var publicWeb = [
|
|||
|
|
"de_DE",
|
|||
|
|
"en_US",
|
|||
|
|
"es_ES",
|
|||
|
|
"fr_FR",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"it_IT",
|
|||
|
|
"id_ID",
|
|||
|
|
"ms_MY",
|
|||
|
|
"hi_IN",
|
|||
|
|
"th_TH",
|
|||
|
|
"ja_JP",
|
|||
|
|
"bn_BD",
|
|||
|
|
"pl_PL",
|
|||
|
|
"fil_PH",
|
|||
|
|
"ar_AE",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var tradeWeb = [
|
|||
|
|
"de_DE",
|
|||
|
|
"en_US",
|
|||
|
|
"es_ES",
|
|||
|
|
"fr_FR",
|
|||
|
|
"ko_KR",
|
|||
|
|
"nl_NL",
|
|||
|
|
"pt_PT",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR",
|
|||
|
|
"vi_VN",
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"it_IT",
|
|||
|
|
"id_ID",
|
|||
|
|
"ms_MY",
|
|||
|
|
"hi_IN",
|
|||
|
|
"th_TH",
|
|||
|
|
"ja_JP",
|
|||
|
|
"bn_BD",
|
|||
|
|
"pl_PL",
|
|||
|
|
"fil_PH",
|
|||
|
|
"ar_AE",
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var tradingBotH5 = ["zh_CN", "en_US", "ru_RU", "tr_TR"];
|
|||
|
|
|
|||
|
|
var tradingBotWeb = ["zh_CN", "en_US", "ru_RU", "tr_TR"];
|
|||
|
|
|
|||
|
|
var kucoinsWeb = [
|
|||
|
|
"zh_CN",
|
|||
|
|
"zh_HK",
|
|||
|
|
"en_US",
|
|||
|
|
"ru_RU",
|
|||
|
|
"tr_TR"
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
var __KC_LANGUAGES__ = /*#__PURE__*/Object.freeze({
|
|||
|
|
__proto__: null,
|
|||
|
|
expressWeb: expressWeb,
|
|||
|
|
futuresH5: futuresH5,
|
|||
|
|
futuresLiteWeb: futuresLiteWeb,
|
|||
|
|
futuresProWeb: futuresProWeb,
|
|||
|
|
kucoinH5: kucoinH5,
|
|||
|
|
landWeb: landWeb,
|
|||
|
|
mainWeb: mainWeb,
|
|||
|
|
miningPoolWeb: miningPoolWeb,
|
|||
|
|
poolx: poolX,
|
|||
|
|
publicWeb: publicWeb,
|
|||
|
|
tradeWeb: tradeWeb,
|
|||
|
|
tradingBotH5: tradingBotH5,
|
|||
|
|
tradingBotWeb: tradingBotWeb,
|
|||
|
|
kucoinsWeb: kucoinsWeb
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
const __ALL__ = _reduce(
|
|||
|
|
__KC_LANGUAGES__,
|
|||
|
|
function (result, value) {
|
|||
|
|
return lodash_uniq(lodash_concat(result, value));
|
|||
|
|
},
|
|||
|
|
[]
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// app支持阿拉伯语
|
|||
|
|
if(!__ALL__.includes('ar_AE')){
|
|||
|
|
__ALL__.push('ar_AE');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
window.__KC_LANGUAGES__ = lodash_assign({ __ALL__ }, __KC_LANGUAGES__);
|
|||
|
|
|
|||
|
|
/** 引导文件 */
|
|||
|
|
|
|||
|
|
// default
|
|||
|
|
window._WEB_RELATION_ = {};
|
|||
|
|
// lock boot
|
|||
|
|
window._KC_WEB_RELATION_BOOTED_ = false;
|
|||
|
|
(function () {
|
|||
|
|
/**
|
|||
|
|
* Check if loaded
|
|||
|
|
*/
|
|||
|
|
if (window._KC_WEB_RELATION_BOOTED_) {
|
|||
|
|
console.warn('KC_WEB_DOMAIN TRY TO REEVAL!!!');
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
window._KC_WEB_RELATION_BOOTED_ = true;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 动态加载脚本
|
|||
|
|
* @param {*} url
|
|||
|
|
*/
|
|||
|
|
function loadScript() {
|
|||
|
|
// Get current script
|
|||
|
|
var scrs = document.getElementsByTagName('script');
|
|||
|
|
var last = scrs[scrs.length - 1];
|
|||
|
|
// Parse load src
|
|||
|
|
var p = parseURL(last.src);
|
|||
|
|
var dev = p.searchObject['dev'];
|
|||
|
|
var sub = p.searchObject['sub'];
|
|||
|
|
var host = p.searchObject['host'];
|
|||
|
|
// Set config name & src
|
|||
|
|
var fhost = host || window.location.host;
|
|||
|
|
if (sub) {
|
|||
|
|
fhost = '' + sub + '/' + fhost;
|
|||
|
|
if (dev) {
|
|||
|
|
fhost = '' + sub + '/dev/' + dev;
|
|||
|
|
}
|
|||
|
|
} else if (dev) {
|
|||
|
|
fhost = 'dev/' + dev;
|
|||
|
|
}
|
|||
|
|
let curTld = location.host.split('.').reverse()[0];
|
|||
|
|
const isLocalDev = curTld.indexOf('localhost') > -1;
|
|||
|
|
// 当本地开发时,使用net
|
|||
|
|
if (isLocalDev) {
|
|||
|
|
curTld = 'net';
|
|||
|
|
}
|
|||
|
|
rewriteConsole(isLocalDev);
|
|||
|
|
const autoParsed = {};
|
|||
|
|
Object.keys(baseConfig).forEach((v) => {
|
|||
|
|
autoParsed[v] = baseConfig[v]
|
|||
|
|
.replace(/\{tld\}/g, curTld)
|
|||
|
|
.replace(/\{tldCN\}/g, curTld === 'com' ? _TLD__CN_ : curTld);
|
|||
|
|
});
|
|||
|
|
// 当前的域名
|
|||
|
|
autoParsed.MAIN_HOST = window.location.origin;
|
|||
|
|
// 当本地开发时,使用www.kucoin.net
|
|||
|
|
if (isLocalDev) {
|
|||
|
|
autoParsed.MAIN_HOST = 'www.kucoin.net';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
window._WEB_RELATION_ = groupObject[fhost] || { ...autoParsed } || {
|
|||
|
|
_fallback_: true,
|
|||
|
|
};
|
|||
|
|
// 所有的配置增加一个合约网关的变量 @Clyne 2022.08.09
|
|||
|
|
// 如果没有合约网关的变量则添加一个
|
|||
|
|
if (!window._WEB_RELATION_.KUMEX_GATE_WAY) {
|
|||
|
|
window._WEB_RELATION_.KUMEX_GATE_WAY = autoParsed.KUMEX_GATE_WAY;
|
|||
|
|
}
|
|||
|
|
// console.log(`Load boot ${!groupObject[fhost] ? 'Failed' : 'Success'}`);
|
|||
|
|
if (window._WEB_RELATION_ && window._WEB_RELATION_._fallback_) {
|
|||
|
|
console.log(`Load boot ${fhost} Failed`);
|
|||
|
|
} else {
|
|||
|
|
console.log(`Load boot ${fhost} Success`);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 解析地址
|
|||
|
|
* @param {*} url
|
|||
|
|
*/
|
|||
|
|
function parseURL(url) {
|
|||
|
|
var parser = document.createElement('a'),
|
|||
|
|
searchObject = {},
|
|||
|
|
queries,
|
|||
|
|
split,
|
|||
|
|
i;
|
|||
|
|
// Let the browser do the work
|
|||
|
|
parser.href = url;
|
|||
|
|
// Convert query string to object
|
|||
|
|
queries = parser.search.replace(/^\?/, '').split('&');
|
|||
|
|
for (i = 0; i < queries.length; i++) {
|
|||
|
|
split = queries[i].split('=');
|
|||
|
|
searchObject[split[0]] = split[1];
|
|||
|
|
}
|
|||
|
|
return {
|
|||
|
|
protocol: parser.protocol,
|
|||
|
|
host: parser.host,
|
|||
|
|
hostname: parser.hostname,
|
|||
|
|
port: parser.port,
|
|||
|
|
pathname: parser.pathname,
|
|||
|
|
search: parser.search,
|
|||
|
|
searchObject: searchObject,
|
|||
|
|
hash: parser.hash,
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 引导加载
|
|||
|
|
try {
|
|||
|
|
loadScript();
|
|||
|
|
} catch (e) {
|
|||
|
|
console.log('BOOT RELATION ERR', e);
|
|||
|
|
}
|
|||
|
|
})();
|
|||
|
|
|
|||
|
|
}));
|