PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/files/lodash/4.5.0/lodash.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 1449 lines | 1405 code | 18 blank | 26 comment | 0 complexity | 536c2e5dbfa8672df4b557471eb24022 MD5 | raw file
  1. /**
  2. * @license
  3. * lodash 4.5.0 (Custom Build) <https://lodash.com/>
  4. * Build: `lodash -o ./dist/lodash.js`
  5. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  6. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  7. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  8. * Available under MIT license <https://lodash.com/license>
  9. */
  10. ;(function() {
  11. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  12. var undefined;
  13. /** Used as the semantic version number. */
  14. var VERSION = '4.5.0';
  15. /** Used to compose bitmasks for wrapper metadata. */
  16. var BIND_FLAG = 1,
  17. BIND_KEY_FLAG = 2,
  18. CURRY_BOUND_FLAG = 4,
  19. CURRY_FLAG = 8,
  20. CURRY_RIGHT_FLAG = 16,
  21. PARTIAL_FLAG = 32,
  22. PARTIAL_RIGHT_FLAG = 64,
  23. ARY_FLAG = 128,
  24. REARG_FLAG = 256,
  25. FLIP_FLAG = 512;
  26. /** Used to compose bitmasks for comparison styles. */
  27. var UNORDERED_COMPARE_FLAG = 1,
  28. PARTIAL_COMPARE_FLAG = 2;
  29. /** Used as default options for `_.truncate`. */
  30. var DEFAULT_TRUNC_LENGTH = 30,
  31. DEFAULT_TRUNC_OMISSION = '...';
  32. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  33. var HOT_COUNT = 150,
  34. HOT_SPAN = 16;
  35. /** Used as the size to enable large array optimizations. */
  36. var LARGE_ARRAY_SIZE = 200;
  37. /** Used to indicate the type of lazy iteratees. */
  38. var LAZY_FILTER_FLAG = 1,
  39. LAZY_MAP_FLAG = 2,
  40. LAZY_WHILE_FLAG = 3;
  41. /** Used as the `TypeError` message for "Functions" methods. */
  42. var FUNC_ERROR_TEXT = 'Expected a function';
  43. /** Used to stand-in for `undefined` hash values. */
  44. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  45. /** Used as references for various `Number` constants. */
  46. var INFINITY = 1 / 0,
  47. MAX_SAFE_INTEGER = 9007199254740991,
  48. MAX_INTEGER = 1.7976931348623157e+308,
  49. NAN = 0 / 0;
  50. /** Used as references for the maximum length and index of an array. */
  51. var MAX_ARRAY_LENGTH = 4294967295,
  52. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  53. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  54. /** Used as the internal argument placeholder. */
  55. var PLACEHOLDER = '__lodash_placeholder__';
  56. /** `Object#toString` result references. */
  57. var argsTag = '[object Arguments]',
  58. arrayTag = '[object Array]',
  59. boolTag = '[object Boolean]',
  60. dateTag = '[object Date]',
  61. errorTag = '[object Error]',
  62. funcTag = '[object Function]',
  63. genTag = '[object GeneratorFunction]',
  64. mapTag = '[object Map]',
  65. numberTag = '[object Number]',
  66. objectTag = '[object Object]',
  67. regexpTag = '[object RegExp]',
  68. setTag = '[object Set]',
  69. stringTag = '[object String]',
  70. symbolTag = '[object Symbol]',
  71. weakMapTag = '[object WeakMap]',
  72. weakSetTag = '[object WeakSet]';
  73. var arrayBufferTag = '[object ArrayBuffer]',
  74. float32Tag = '[object Float32Array]',
  75. float64Tag = '[object Float64Array]',
  76. int8Tag = '[object Int8Array]',
  77. int16Tag = '[object Int16Array]',
  78. int32Tag = '[object Int32Array]',
  79. uint8Tag = '[object Uint8Array]',
  80. uint8ClampedTag = '[object Uint8ClampedArray]',
  81. uint16Tag = '[object Uint16Array]',
  82. uint32Tag = '[object Uint32Array]';
  83. /** Used to match empty string literals in compiled template source. */
  84. var reEmptyStringLeading = /\b__p \+= '';/g,
  85. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  86. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  87. /** Used to match HTML entities and HTML characters. */
  88. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
  89. reUnescapedHtml = /[&<>"'`]/g,
  90. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  91. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  92. /** Used to match template delimiters. */
  93. var reEscape = /<%-([\s\S]+?)%>/g,
  94. reEvaluate = /<%([\s\S]+?)%>/g,
  95. reInterpolate = /<%=([\s\S]+?)%>/g;
  96. /** Used to match property names within property paths. */
  97. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  98. reIsPlainProp = /^\w*$/,
  99. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
  100. /** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */
  101. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  102. reHasRegExpChar = RegExp(reRegExpChar.source);
  103. /** Used to match leading and trailing whitespace. */
  104. var reTrim = /^\s+|\s+$/g,
  105. reTrimStart = /^\s+/,
  106. reTrimEnd = /\s+$/;
  107. /** Used to match backslashes in property paths. */
  108. var reEscapeChar = /\\(\\)?/g;
  109. /** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */
  110. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  111. /** Used to match `RegExp` flags from their coerced string values. */
  112. var reFlags = /\w*$/;
  113. /** Used to detect hexadecimal string values. */
  114. var reHasHexPrefix = /^0x/i;
  115. /** Used to detect bad signed hexadecimal string values. */
  116. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  117. /** Used to detect binary string values. */
  118. var reIsBinary = /^0b[01]+$/i;
  119. /** Used to detect host constructors (Safari > 5). */
  120. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  121. /** Used to detect octal string values. */
  122. var reIsOctal = /^0o[0-7]+$/i;
  123. /** Used to detect unsigned integer values. */
  124. var reIsUint = /^(?:0|[1-9]\d*)$/;
  125. /** Used to match latin-1 supplementary letters (excluding mathematical operators). */
  126. var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
  127. /** Used to ensure capturing order of template delimiters. */
  128. var reNoMatch = /($^)/;
  129. /** Used to match unescaped characters in compiled string literals. */
  130. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  131. /** Used to compose unicode character classes. */
  132. var rsAstralRange = '\\ud800-\\udfff',
  133. rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
  134. rsComboSymbolsRange = '\\u20d0-\\u20f0',
  135. rsDingbatRange = '\\u2700-\\u27bf',
  136. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  137. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  138. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  139. rsQuoteRange = '\\u2018\\u2019\\u201c\\u201d',
  140. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  141. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  142. rsVarRange = '\\ufe0e\\ufe0f',
  143. rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
  144. /** Used to compose unicode capture groups. */
  145. var rsAstral = '[' + rsAstralRange + ']',
  146. rsBreak = '[' + rsBreakRange + ']',
  147. rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
  148. rsDigits = '\\d+',
  149. rsDingbat = '[' + rsDingbatRange + ']',
  150. rsLower = '[' + rsLowerRange + ']',
  151. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  152. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  153. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  154. rsNonAstral = '[^' + rsAstralRange + ']',
  155. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  156. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  157. rsUpper = '[' + rsUpperRange + ']',
  158. rsZWJ = '\\u200d';
  159. /** Used to compose unicode regexes. */
  160. var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
  161. rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
  162. reOptMod = rsModifier + '?',
  163. rsOptVar = '[' + rsVarRange + ']?',
  164. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  165. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  166. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  167. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  168. /**
  169. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  170. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  171. */
  172. var reComboMark = RegExp(rsCombo, 'g');
  173. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  174. var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  175. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  176. var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
  177. /** Used to match non-compound words composed of alphanumeric characters. */
  178. var reBasicWord = /[a-zA-Z0-9]+/g;
  179. /** Used to match complex or compound words. */
  180. var reComplexWord = RegExp([
  181. rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  182. rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
  183. rsUpper + '?' + rsLowerMisc + '+',
  184. rsUpper + '+',
  185. rsDigits,
  186. rsEmoji
  187. ].join('|'), 'g');
  188. /** Used to detect strings that need a more robust regexp to match words. */
  189. var reHasComplexWord = /[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  190. /** Used to assign default `context` object properties. */
  191. var contextProps = [
  192. 'Array', 'Buffer', 'Date', 'Error', 'Float32Array', 'Float64Array',
  193. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  194. 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  195. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', '_',
  196. 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  197. ];
  198. /** Used to make template sourceURLs easier to identify. */
  199. var templateCounter = -1;
  200. /** Used to identify `toStringTag` values of typed arrays. */
  201. var typedArrayTags = {};
  202. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  203. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  204. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  205. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  206. typedArrayTags[uint32Tag] = true;
  207. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  208. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  209. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  210. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  211. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  212. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  213. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  214. /** Used to identify `toStringTag` values supported by `_.clone`. */
  215. var cloneableTags = {};
  216. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  217. cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
  218. cloneableTags[dateTag] = cloneableTags[float32Tag] =
  219. cloneableTags[float64Tag] = cloneableTags[int8Tag] =
  220. cloneableTags[int16Tag] = cloneableTags[int32Tag] =
  221. cloneableTags[mapTag] = cloneableTags[numberTag] =
  222. cloneableTags[objectTag] = cloneableTags[regexpTag] =
  223. cloneableTags[setTag] = cloneableTags[stringTag] =
  224. cloneableTags[symbolTag] = cloneableTags[uint8Tag] =
  225. cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] =
  226. cloneableTags[uint32Tag] = true;
  227. cloneableTags[errorTag] = cloneableTags[funcTag] =
  228. cloneableTags[weakMapTag] = false;
  229. /** Used to map latin-1 supplementary letters to basic latin letters. */
  230. var deburredLetters = {
  231. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  232. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  233. '\xc7': 'C', '\xe7': 'c',
  234. '\xd0': 'D', '\xf0': 'd',
  235. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  236. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  237. '\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  238. '\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  239. '\xd1': 'N', '\xf1': 'n',
  240. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  241. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  242. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  243. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  244. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  245. '\xc6': 'Ae', '\xe6': 'ae',
  246. '\xde': 'Th', '\xfe': 'th',
  247. '\xdf': 'ss'
  248. };
  249. /** Used to map characters to HTML entities. */
  250. var htmlEscapes = {
  251. '&': '&amp;',
  252. '<': '&lt;',
  253. '>': '&gt;',
  254. '"': '&quot;',
  255. "'": '&#39;',
  256. '`': '&#96;'
  257. };
  258. /** Used to map HTML entities to characters. */
  259. var htmlUnescapes = {
  260. '&amp;': '&',
  261. '&lt;': '<',
  262. '&gt;': '>',
  263. '&quot;': '"',
  264. '&#39;': "'",
  265. '&#96;': '`'
  266. };
  267. /** Used to determine if values are of the language type `Object`. */
  268. var objectTypes = {
  269. 'function': true,
  270. 'object': true
  271. };
  272. /** Used to escape characters for inclusion in compiled string literals. */
  273. var stringEscapes = {
  274. '\\': '\\',
  275. "'": "'",
  276. '\n': 'n',
  277. '\r': 'r',
  278. '\u2028': 'u2028',
  279. '\u2029': 'u2029'
  280. };
  281. /** Built-in method references without a dependency on `root`. */
  282. var freeParseFloat = parseFloat,
  283. freeParseInt = parseInt;
  284. /** Detect free variable `exports`. */
  285. var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
  286. ? exports
  287. : undefined;
  288. /** Detect free variable `module`. */
  289. var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
  290. ? module
  291. : undefined;
  292. /** Detect the popular CommonJS extension `module.exports`. */
  293. var moduleExports = (freeModule && freeModule.exports === freeExports)
  294. ? freeExports
  295. : undefined;
  296. /** Detect free variable `global` from Node.js. */
  297. var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
  298. /** Detect free variable `self`. */
  299. var freeSelf = checkGlobal(objectTypes[typeof self] && self);
  300. /** Detect free variable `window`. */
  301. var freeWindow = checkGlobal(objectTypes[typeof window] && window);
  302. /** Detect `this` as the global object. */
  303. var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
  304. /**
  305. * Used as a reference to the global object.
  306. *
  307. * The `this` value is used if it's the global object to avoid Greasemonkey's
  308. * restricted `window` object, otherwise the `window` object is used.
  309. */
  310. var root = freeGlobal ||
  311. ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
  312. freeSelf || thisGlobal || Function('return this')();
  313. /*--------------------------------------------------------------------------*/
  314. /**
  315. * Adds the key-value `pair` to `map`.
  316. *
  317. * @private
  318. * @param {Object} map The map to modify.
  319. * @param {Array} pair The key-value pair to add.
  320. * @returns {Object} Returns `map`.
  321. */
  322. function addMapEntry(map, pair) {
  323. map.set(pair[0], pair[1]);
  324. return map;
  325. }
  326. /**
  327. * Adds `value` to `set`.
  328. *
  329. * @private
  330. * @param {Object} set The set to modify.
  331. * @param {*} value The value to add.
  332. * @returns {Object} Returns `set`.
  333. */
  334. function addSetEntry(set, value) {
  335. set.add(value);
  336. return set;
  337. }
  338. /**
  339. * A faster alternative to `Function#apply`, this function invokes `func`
  340. * with the `this` binding of `thisArg` and the arguments of `args`.
  341. *
  342. * @private
  343. * @param {Function} func The function to invoke.
  344. * @param {*} thisArg The `this` binding of `func`.
  345. * @param {...*} args The arguments to invoke `func` with.
  346. * @returns {*} Returns the result of `func`.
  347. */
  348. function apply(func, thisArg, args) {
  349. var length = args.length;
  350. switch (length) {
  351. case 0: return func.call(thisArg);
  352. case 1: return func.call(thisArg, args[0]);
  353. case 2: return func.call(thisArg, args[0], args[1]);
  354. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  355. }
  356. return func.apply(thisArg, args);
  357. }
  358. /**
  359. * A specialized version of `baseAggregator` for arrays.
  360. *
  361. * @private
  362. * @param {Array} array The array to iterate over.
  363. * @param {Function} setter The function to set `accumulator` values.
  364. * @param {Function} iteratee The iteratee to transform keys.
  365. * @param {Object} accumulator The initial aggregated object.
  366. * @returns {Function} Returns `accumulator`.
  367. */
  368. function arrayAggregator(array, setter, iteratee, accumulator) {
  369. var index = -1,
  370. length = array.length;
  371. while (++index < length) {
  372. var value = array[index];
  373. setter(accumulator, value, iteratee(value), array);
  374. }
  375. return accumulator;
  376. }
  377. /**
  378. * Creates a new array concatenating `array` with `other`.
  379. *
  380. * @private
  381. * @param {Array} array The first array to concatenate.
  382. * @param {Array} other The second array to concatenate.
  383. * @returns {Array} Returns the new concatenated array.
  384. */
  385. function arrayConcat(array, other) {
  386. var index = -1,
  387. length = array.length,
  388. othIndex = -1,
  389. othLength = other.length,
  390. result = Array(length + othLength);
  391. while (++index < length) {
  392. result[index] = array[index];
  393. }
  394. while (++othIndex < othLength) {
  395. result[index++] = other[othIndex];
  396. }
  397. return result;
  398. }
  399. /**
  400. * A specialized version of `_.forEach` for arrays without support for
  401. * iteratee shorthands.
  402. *
  403. * @private
  404. * @param {Array} array The array to iterate over.
  405. * @param {Function} iteratee The function invoked per iteration.
  406. * @returns {Array} Returns `array`.
  407. */
  408. function arrayEach(array, iteratee) {
  409. var index = -1,
  410. length = array.length;
  411. while (++index < length) {
  412. if (iteratee(array[index], index, array) === false) {
  413. break;
  414. }
  415. }
  416. return array;
  417. }
  418. /**
  419. * A specialized version of `_.forEachRight` for arrays without support for
  420. * iteratee shorthands.
  421. *
  422. * @private
  423. * @param {Array} array The array to iterate over.
  424. * @param {Function} iteratee The function invoked per iteration.
  425. * @returns {Array} Returns `array`.
  426. */
  427. function arrayEachRight(array, iteratee) {
  428. var length = array.length;
  429. while (length--) {
  430. if (iteratee(array[length], length, array) === false) {
  431. break;
  432. }
  433. }
  434. return array;
  435. }
  436. /**
  437. * A specialized version of `_.every` for arrays without support for
  438. * iteratee shorthands.
  439. *
  440. * @private
  441. * @param {Array} array The array to iterate over.
  442. * @param {Function} predicate The function invoked per iteration.
  443. * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`.
  444. */
  445. function arrayEvery(array, predicate) {
  446. var index = -1,
  447. length = array.length;
  448. while (++index < length) {
  449. if (!predicate(array[index], index, array)) {
  450. return false;
  451. }
  452. }
  453. return true;
  454. }
  455. /**
  456. * A specialized version of `_.filter` for arrays without support for
  457. * iteratee shorthands.
  458. *
  459. * @private
  460. * @param {Array} array The array to iterate over.
  461. * @param {Function} predicate The function invoked per iteration.
  462. * @returns {Array} Returns the new filtered array.
  463. */
  464. function arrayFilter(array, predicate) {
  465. var index = -1,
  466. length = array.length,
  467. resIndex = -1,
  468. result = [];
  469. while (++index < length) {
  470. var value = array[index];
  471. if (predicate(value, index, array)) {
  472. result[++resIndex] = value;
  473. }
  474. }
  475. return result;
  476. }
  477. /**
  478. * A specialized version of `_.includes` for arrays without support for
  479. * specifying an index to search from.
  480. *
  481. * @private
  482. * @param {Array} array The array to search.
  483. * @param {*} target The value to search for.
  484. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  485. */
  486. function arrayIncludes(array, value) {
  487. return !!array.length && baseIndexOf(array, value, 0) > -1;
  488. }
  489. /**
  490. * A specialized version of `_.includesWith` for arrays without support for
  491. * specifying an index to search from.
  492. *
  493. * @private
  494. * @param {Array} array The array to search.
  495. * @param {*} target The value to search for.
  496. * @param {Function} comparator The comparator invoked per element.
  497. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  498. */
  499. function arrayIncludesWith(array, value, comparator) {
  500. var index = -1,
  501. length = array.length;
  502. while (++index < length) {
  503. if (comparator(value, array[index])) {
  504. return true;
  505. }
  506. }
  507. return false;
  508. }
  509. /**
  510. * A specialized version of `_.map` for arrays without support for iteratee
  511. * shorthands.
  512. *
  513. * @private
  514. * @param {Array} array The array to iterate over.
  515. * @param {Function} iteratee The function invoked per iteration.
  516. * @returns {Array} Returns the new mapped array.
  517. */
  518. function arrayMap(array, iteratee) {
  519. var index = -1,
  520. length = array.length,
  521. result = Array(length);
  522. while (++index < length) {
  523. result[index] = iteratee(array[index], index, array);
  524. }
  525. return result;
  526. }
  527. /**
  528. * Appends the elements of `values` to `array`.
  529. *
  530. * @private
  531. * @param {Array} array The array to modify.
  532. * @param {Array} values The values to append.
  533. * @returns {Array} Returns `array`.
  534. */
  535. function arrayPush(array, values) {
  536. var index = -1,
  537. length = values.length,
  538. offset = array.length;
  539. while (++index < length) {
  540. array[offset + index] = values[index];
  541. }
  542. return array;
  543. }
  544. /**
  545. * A specialized version of `_.reduce` for arrays without support for
  546. * iteratee shorthands.
  547. *
  548. * @private
  549. * @param {Array} array The array to iterate over.
  550. * @param {Function} iteratee The function invoked per iteration.
  551. * @param {*} [accumulator] The initial value.
  552. * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
  553. * @returns {*} Returns the accumulated value.
  554. */
  555. function arrayReduce(array, iteratee, accumulator, initAccum) {
  556. var index = -1,
  557. length = array.length;
  558. if (initAccum && length) {
  559. accumulator = array[++index];
  560. }
  561. while (++index < length) {
  562. accumulator = iteratee(accumulator, array[index], index, array);
  563. }
  564. return accumulator;
  565. }
  566. /**
  567. * A specialized version of `_.reduceRight` for arrays without support for
  568. * iteratee shorthands.
  569. *
  570. * @private
  571. * @param {Array} array The array to iterate over.
  572. * @param {Function} iteratee The function invoked per iteration.
  573. * @param {*} [accumulator] The initial value.
  574. * @param {boolean} [initAccum] Specify using the last element of `array` as the initial value.
  575. * @returns {*} Returns the accumulated value.
  576. */
  577. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  578. var length = array.length;
  579. if (initAccum && length) {
  580. accumulator = array[--length];
  581. }
  582. while (length--) {
  583. accumulator = iteratee(accumulator, array[length], length, array);
  584. }
  585. return accumulator;
  586. }
  587. /**
  588. * A specialized version of `_.some` for arrays without support for iteratee
  589. * shorthands.
  590. *
  591. * @private
  592. * @param {Array} array The array to iterate over.
  593. * @param {Function} predicate The function invoked per iteration.
  594. * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
  595. */
  596. function arraySome(array, predicate) {
  597. var index = -1,
  598. length = array.length;
  599. while (++index < length) {
  600. if (predicate(array[index], index, array)) {
  601. return true;
  602. }
  603. }
  604. return false;
  605. }
  606. /**
  607. * The base implementation of methods like `_.max` and `_.min` which accepts a
  608. * `comparator` to determine the extremum value.
  609. *
  610. * @private
  611. * @param {Array} array The array to iterate over.
  612. * @param {Function} iteratee The iteratee invoked per iteration.
  613. * @param {Function} comparator The comparator used to compare values.
  614. * @returns {*} Returns the extremum value.
  615. */
  616. function baseExtremum(array, iteratee, comparator) {
  617. var index = -1,
  618. length = array.length;
  619. while (++index < length) {
  620. var value = array[index],
  621. current = iteratee(value);
  622. if (current != null && (computed === undefined
  623. ? current === current
  624. : comparator(current, computed)
  625. )) {
  626. var computed = current,
  627. result = value;
  628. }
  629. }
  630. return result;
  631. }
  632. /**
  633. * The base implementation of methods like `_.find` and `_.findKey`, without
  634. * support for iteratee shorthands, which iterates over `collection` using
  635. * `eachFunc`.
  636. *
  637. * @private
  638. * @param {Array|Object} collection The collection to search.
  639. * @param {Function} predicate The function invoked per iteration.
  640. * @param {Function} eachFunc The function to iterate over `collection`.
  641. * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself.
  642. * @returns {*} Returns the found element or its key, else `undefined`.
  643. */
  644. function baseFind(collection, predicate, eachFunc, retKey) {
  645. var result;
  646. eachFunc(collection, function(value, key, collection) {
  647. if (predicate(value, key, collection)) {
  648. result = retKey ? key : value;
  649. return false;
  650. }
  651. });
  652. return result;
  653. }
  654. /**
  655. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  656. * support for iteratee shorthands.
  657. *
  658. * @private
  659. * @param {Array} array The array to search.
  660. * @param {Function} predicate The function invoked per iteration.
  661. * @param {boolean} [fromRight] Specify iterating from right to left.
  662. * @returns {number} Returns the index of the matched value, else `-1`.
  663. */
  664. function baseFindIndex(array, predicate, fromRight) {
  665. var length = array.length,
  666. index = fromRight ? length : -1;
  667. while ((fromRight ? index-- : ++index < length)) {
  668. if (predicate(array[index], index, array)) {
  669. return index;
  670. }
  671. }
  672. return -1;
  673. }
  674. /**
  675. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  676. *
  677. * @private
  678. * @param {Array} array The array to search.
  679. * @param {*} value The value to search for.
  680. * @param {number} fromIndex The index to search from.
  681. * @returns {number} Returns the index of the matched value, else `-1`.
  682. */
  683. function baseIndexOf(array, value, fromIndex) {
  684. if (value !== value) {
  685. return indexOfNaN(array, fromIndex);
  686. }
  687. var index = fromIndex - 1,
  688. length = array.length;
  689. while (++index < length) {
  690. if (array[index] === value) {
  691. return index;
  692. }
  693. }
  694. return -1;
  695. }
  696. /**
  697. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  698. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  699. *
  700. * @private
  701. * @param {Array|Object} collection The collection to iterate over.
  702. * @param {Function} iteratee The function invoked per iteration.
  703. * @param {*} accumulator The initial value.
  704. * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
  705. * @param {Function} eachFunc The function to iterate over `collection`.
  706. * @returns {*} Returns the accumulated value.
  707. */
  708. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  709. eachFunc(collection, function(value, index, collection) {
  710. accumulator = initAccum
  711. ? (initAccum = false, value)
  712. : iteratee(accumulator, value, index, collection);
  713. });
  714. return accumulator;
  715. }
  716. /**
  717. * The base implementation of `_.sortBy` which uses `comparer` to define
  718. * the sort order of `array` and replaces criteria objects with their
  719. * corresponding values.
  720. *
  721. * @private
  722. * @param {Array} array The array to sort.
  723. * @param {Function} comparer The function to define sort order.
  724. * @returns {Array} Returns `array`.
  725. */
  726. function baseSortBy(array, comparer) {
  727. var length = array.length;
  728. array.sort(comparer);
  729. while (length--) {
  730. array[length] = array[length].value;
  731. }
  732. return array;
  733. }
  734. /**
  735. * The base implementation of `_.sum` without support for iteratee shorthands.
  736. *
  737. * @private
  738. * @param {Array} array The array to iterate over.
  739. * @param {Function} iteratee The function invoked per iteration.
  740. * @returns {number} Returns the sum.
  741. */
  742. function baseSum(array, iteratee) {
  743. var result,
  744. index = -1,
  745. length = array.length;
  746. while (++index < length) {
  747. var current = iteratee(array[index]);
  748. if (current !== undefined) {
  749. result = result === undefined ? current : (result + current);
  750. }
  751. }
  752. return result;
  753. }
  754. /**
  755. * The base implementation of `_.times` without support for iteratee shorthands
  756. * or max array length checks.
  757. *
  758. * @private
  759. * @param {number} n The number of times to invoke `iteratee`.
  760. * @param {Function} iteratee The function invoked per iteration.
  761. * @returns {Array} Returns the array of results.
  762. */
  763. function baseTimes(n, iteratee) {
  764. var index = -1,
  765. result = Array(n);
  766. while (++index < n) {
  767. result[index] = iteratee(index);
  768. }
  769. return result;
  770. }
  771. /**
  772. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  773. * of key-value pairs for `object` corresponding to the property names of `props`.
  774. *
  775. * @private
  776. * @param {Object} object The object to query.
  777. * @param {Array} props The property names to get values for.
  778. * @returns {Object} Returns the new array of key-value pairs.
  779. */
  780. function baseToPairs(object, props) {
  781. return arrayMap(props, function(key) {
  782. return [key, object[key]];
  783. });
  784. }
  785. /**
  786. * The base implementation of `_.unary` without support for storing wrapper metadata.
  787. *
  788. * @private
  789. * @param {Function} func The function to cap arguments for.
  790. * @returns {Function} Returns the new function.
  791. */
  792. function baseUnary(func) {
  793. return function(value) {
  794. return func(value);
  795. };
  796. }
  797. /**
  798. * The base implementation of `_.values` and `_.valuesIn` which creates an
  799. * array of `object` property values corresponding to the property names
  800. * of `props`.
  801. *
  802. * @private
  803. * @param {Object} object The object to query.
  804. * @param {Array} props The property names to get values for.
  805. * @returns {Object} Returns the array of property values.
  806. */
  807. function baseValues(object, props) {
  808. return arrayMap(props, function(key) {
  809. return object[key];
  810. });
  811. }
  812. /**
  813. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  814. * that is not found in the character symbols.
  815. *
  816. * @private
  817. * @param {Array} strSymbols The string symbols to inspect.
  818. * @param {Array} chrSymbols The character symbols to find.
  819. * @returns {number} Returns the index of the first unmatched string symbol.
  820. */
  821. function charsStartIndex(strSymbols, chrSymbols) {
  822. var index = -1,
  823. length = strSymbols.length;
  824. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  825. return index;
  826. }
  827. /**
  828. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  829. * that is not found in the character symbols.
  830. *
  831. * @private
  832. * @param {Array} strSymbols The string symbols to inspect.
  833. * @param {Array} chrSymbols The character symbols to find.
  834. * @returns {number} Returns the index of the last unmatched string symbol.
  835. */
  836. function charsEndIndex(strSymbols, chrSymbols) {
  837. var index = strSymbols.length;
  838. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  839. return index;
  840. }
  841. /**
  842. * Checks if `value` is a global object.
  843. *
  844. * @private
  845. * @param {*} value The value to check.
  846. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  847. */
  848. function checkGlobal(value) {
  849. return (value && value.Object === Object) ? value : null;
  850. }
  851. /**
  852. * Compares values to sort them in ascending order.
  853. *
  854. * @private
  855. * @param {*} value The value to compare.
  856. * @param {*} other The other value to compare.
  857. * @returns {number} Returns the sort order indicator for `value`.
  858. */
  859. function compareAscending(value, other) {
  860. if (value !== other) {
  861. var valIsNull = value === null,
  862. valIsUndef = value === undefined,
  863. valIsReflexive = value === value;
  864. var othIsNull = other === null,
  865. othIsUndef = other === undefined,
  866. othIsReflexive = other === other;
  867. if ((value > other && !othIsNull) || !valIsReflexive ||
  868. (valIsNull && !othIsUndef && othIsReflexive) ||
  869. (valIsUndef && othIsReflexive)) {
  870. return 1;
  871. }
  872. if ((value < other && !valIsNull) || !othIsReflexive ||
  873. (othIsNull && !valIsUndef && valIsReflexive) ||
  874. (othIsUndef && valIsReflexive)) {
  875. return -1;
  876. }
  877. }
  878. return 0;
  879. }
  880. /**
  881. * Used by `_.orderBy` to compare multiple properties of a value to another
  882. * and stable sort them.
  883. *
  884. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  885. * specify an order of "desc" for descending or "asc" for ascending sort order
  886. * of corresponding values.
  887. *
  888. * @private
  889. * @param {Object} object The object to compare.
  890. * @param {Object} other The other object to compare.
  891. * @param {boolean[]|string[]} orders The order to sort by for each property.
  892. * @returns {number} Returns the sort order indicator for `object`.
  893. */
  894. function compareMultiple(object, other, orders) {
  895. var index = -1,
  896. objCriteria = object.criteria,
  897. othCriteria = other.criteria,
  898. length = objCriteria.length,
  899. ordersLength = orders.length;
  900. while (++index < length) {
  901. var result = compareAscending(objCriteria[index], othCriteria[index]);
  902. if (result) {
  903. if (index >= ordersLength) {
  904. return result;
  905. }
  906. var order = orders[index];
  907. return result * (order == 'desc' ? -1 : 1);
  908. }
  909. }
  910. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  911. // that causes it, under certain circumstances, to provide the same value for
  912. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  913. // for more details.
  914. //
  915. // This also ensures a stable sort in V8 and other engines.
  916. // See https://code.google.com/p/v8/issues/detail?id=90 for more details.
  917. return object.index - other.index;
  918. }
  919. /**
  920. * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
  921. *
  922. * @private
  923. * @param {string} letter The matched letter to deburr.
  924. * @returns {string} Returns the deburred letter.
  925. */
  926. function deburrLetter(letter) {
  927. return deburredLetters[letter];
  928. }
  929. /**
  930. * Used by `_.escape` to convert characters to HTML entities.
  931. *
  932. * @private
  933. * @param {string} chr The matched character to escape.
  934. * @returns {string} Returns the escaped character.
  935. */
  936. function escapeHtmlChar(chr) {
  937. return htmlEscapes[chr];
  938. }
  939. /**
  940. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  941. *
  942. * @private
  943. * @param {string} chr The matched character to escape.
  944. * @returns {string} Returns the escaped character.
  945. */
  946. function escapeStringChar(chr) {
  947. return '\\' + stringEscapes[chr];
  948. }
  949. /**
  950. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  951. *
  952. * @private
  953. * @param {Array} array The array to search.
  954. * @param {number} fromIndex The index to search from.
  955. * @param {boolean} [fromRight] Specify iterating from right to left.
  956. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  957. */
  958. function indexOfNaN(array, fromIndex, fromRight) {
  959. var length = array.length,
  960. index = fromIndex + (fromRight ? 0 : -1);
  961. while ((fromRight ? index-- : ++index < length)) {
  962. var other = array[index];
  963. if (other !== other) {
  964. return index;
  965. }
  966. }
  967. return -1;
  968. }
  969. /**
  970. * Checks if `value` is a host object in IE < 9.
  971. *
  972. * @private
  973. * @param {*} value The value to check.
  974. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  975. */
  976. function isHostObject(value) {
  977. // Many host objects are `Object` objects that can coerce to strings
  978. // despite having improperly defined `toString` methods.
  979. var result = false;
  980. if (value != null && typeof value.toString != 'function') {
  981. try {
  982. result = !!(value + '');
  983. } catch (e) {}
  984. }
  985. return result;
  986. }
  987. /**
  988. * Checks if `value` is a valid array-like index.
  989. *
  990. * @private
  991. * @param {*} value The value to check.
  992. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  993. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  994. */
  995. function isIndex(value, length) {
  996. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  997. length = length == null ? MAX_SAFE_INTEGER : length;
  998. return value > -1 && value % 1 == 0 && value < length;
  999. }
  1000. /**
  1001. * Converts `iterator` to an array.
  1002. *
  1003. * @private
  1004. * @param {Object} iterator The iterator to convert.
  1005. * @returns {Array} Returns the converted array.
  1006. */
  1007. function iteratorToArray(iterator) {
  1008. var data,
  1009. result = [];
  1010. while (!(data = iterator.next()).done) {
  1011. result.push(data.value);
  1012. }
  1013. return result;
  1014. }
  1015. /**
  1016. * Converts `map` to an array.
  1017. *
  1018. * @private
  1019. * @param {Object} map The map to convert.
  1020. * @returns {Array} Returns the converted array.
  1021. */
  1022. function mapToArray(map) {
  1023. var index = -1,
  1024. result = Array(map.size);
  1025. map.forEach(function(value, key) {
  1026. result[++index] = [key, value];
  1027. });
  1028. return result;
  1029. }
  1030. /**
  1031. * Replaces all `placeholder` elements in `array` with an internal placeholder
  1032. * and returns an array of their indexes.
  1033. *
  1034. * @private
  1035. * @param {Array} array The array to modify.
  1036. * @param {*} placeholder The placeholder to replace.
  1037. * @returns {Array} Returns the new array of placeholder indexes.
  1038. */
  1039. function replaceHolders(array, placeholder) {
  1040. var index = -1,
  1041. length = array.length,
  1042. resIndex = -1,
  1043. result = [];
  1044. while (++index < length) {
  1045. if (array[index] === placeholder) {
  1046. array[index] = PLACEHOLDER;
  1047. result[++resIndex] = index;
  1048. }
  1049. }
  1050. return result;
  1051. }
  1052. /**
  1053. * Converts `set` to an array.
  1054. *
  1055. * @private
  1056. * @param {Object} set The set to convert.
  1057. * @returns {Array} Returns the converted array.
  1058. */
  1059. function setToArray(set) {
  1060. var index = -1,
  1061. result = Array(set.size);
  1062. set.forEach(function(value) {
  1063. result[++index] = value;
  1064. });
  1065. return result;
  1066. }
  1067. /**
  1068. * Gets the number of symbols in `string`.
  1069. *
  1070. * @private
  1071. * @param {string} string The string to inspect.
  1072. * @returns {number} Returns the string size.
  1073. */
  1074. function stringSize(string) {
  1075. if (!(string && reHasComplexSymbol.test(string))) {
  1076. return string.length;
  1077. }
  1078. var result = reComplexSymbol.lastIndex = 0;
  1079. while (reComplexSymbol.test(string)) {
  1080. result++;
  1081. }
  1082. return result;
  1083. }
  1084. /**
  1085. * Converts `string` to an array.
  1086. *
  1087. * @private
  1088. * @param {string} string The string to convert.
  1089. * @returns {Array} Returns the converted array.
  1090. */
  1091. function stringToArray(string) {
  1092. return string.match(reComplexSymbol);
  1093. }
  1094. /**
  1095. * Used by `_.unescape` to convert HTML entities to characters.
  1096. *
  1097. * @private
  1098. * @param {string} chr The matched character to unescape.
  1099. * @returns {string} Returns the unescaped character.
  1100. */
  1101. function unescapeHtmlChar(chr) {
  1102. return htmlUnescapes[chr];
  1103. }
  1104. /*--------------------------------------------------------------------------*/
  1105. /**
  1106. * Create a new pristine `lodash` function using the `context` object.
  1107. *
  1108. * @static
  1109. * @memberOf _
  1110. * @category Util
  1111. * @param {Object} [context=root] The context object.
  1112. * @returns {Function} Returns a new `lodash` function.
  1113. * @example
  1114. *
  1115. * _.mixin({ 'foo': _.constant('foo') });
  1116. *
  1117. * var lodash = _.runInContext();
  1118. * lodash.mixin({ 'bar': lodash.constant('bar') });
  1119. *
  1120. * _.isFunction(_.foo);
  1121. * // => true
  1122. * _.isFunction(_.bar);
  1123. * // => false
  1124. *
  1125. * lodash.isFunction(lodash.foo);
  1126. * // => false
  1127. * lodash.isFunction(lodash.bar);
  1128. * // => true
  1129. *
  1130. * // Use `context` to mock `Date#getTime` use in `_.now`.
  1131. * var mock = _.runInContext({
  1132. * 'Date': function() {
  1133. * return { 'getTime': getTimeMock };
  1134. * }
  1135. * });
  1136. *
  1137. * // Create a suped-up `defer` in Node.js.
  1138. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  1139. */
  1140. function runInContext(context) {
  1141. context = context ? _.defaults({}, context, _.pick(root, contextProps)) : root;
  1142. /** Built-in constructor references. */
  1143. var Date = context.Date,
  1144. Error = context.Error,
  1145. Math = context.Math,
  1146. RegExp = context.RegExp,
  1147. TypeError = context.TypeError;
  1148. /** Used for built-in method references. */
  1149. var arrayProto = context.Array.prototype,
  1150. objectProto = context.Object.prototype;
  1151. /** Used to resolve the decompiled source of functions. */
  1152. var funcToString = context.Function.prototype.toString;
  1153. /** Used to check objects for own properties. */
  1154. var hasOwnProperty = objectProto.hasOwnProperty;
  1155. /** Used to generate unique IDs. */
  1156. var idCounter = 0;
  1157. /** Used to infer the `Object` constructor. */
  1158. var objectCtorString = funcToString.call(Object);
  1159. /**
  1160. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1161. * of values.
  1162. */
  1163. var objectToString = objectProto.toString;
  1164. /** Used to restore the original `_` reference in `_.noConflict`. */
  1165. var oldDash = root._;
  1166. /** Used to detect if a method is native. */
  1167. var reIsNative = RegExp('^' +
  1168. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  1169. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1170. );
  1171. /** Built-in value references. */
  1172. var Buffer = moduleExports ? context.Buffer : undefined,
  1173. Reflect = context.Reflect,
  1174. Symbol = context.Symbol,
  1175. Uint8Array = context.Uint8Array,
  1176. clearTimeout = context.clearTimeout,
  1177. enumerate = Reflect ? Reflect.enumerate : undefined,
  1178. getPrototypeOf = Object.getPrototypeOf,
  1179. getOwnPropertySymbols = Object.getOwnPropertySymbols,
  1180. iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
  1181. objectCreate = Object.create,
  1182. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1183. setTimeout = context.setTimeout,
  1184. splice = arrayProto.splice;
  1185. /* Built-in method references for those with the same name as other `lodash` methods. */
  1186. var nativeCeil = Math.ceil,
  1187. nativeFloor = Math.floor,
  1188. nativeIsFinite = context.isFinite,
  1189. nativeJoin = arrayProto.join,
  1190. nativeKeys = Object.keys,
  1191. nativeMax = Math.max,
  1192. nativeMin = Math.min,
  1193. nativeParseInt = context.parseInt,
  1194. nativeRandom = Math.random,
  1195. nativeReverse = arrayProto.reverse;
  1196. /* Built-in method references that are verified to be native. */
  1197. var Map = getNative(context, 'Map'),
  1198. Set = getNative(context, 'Set'),
  1199. WeakMap = getNative(context, 'WeakMap'),
  1200. nativeCreate = getNative(Object, 'create');
  1201. /** Used to store function metadata. */
  1202. var metaMap = WeakMap && new WeakMap;
  1203. /** Used to detect maps, sets, and weakmaps. */
  1204. var mapCtorString = Map ? funcToString.call(Map) : '',
  1205. setCtorString = Set ? funcToString.call(Set) : '',
  1206. weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
  1207. /** Used to convert symbols to primitives and strings. */
  1208. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1209. symbolValueOf = Symbol ? symbolProto.valueOf : undefined,
  1210. symbolToString = Symbol ? symbolProto.toString : undefined;
  1211. /** Used to lookup unminified function names. */
  1212. var realNames = {};
  1213. /*------------------------------------------------------------------------*/
  1214. /**
  1215. * Creates a `lodash` object which wraps `value` to enable implicit method
  1216. * chaining. Methods that operate on and return arrays, collections, and
  1217. * functions can be chained together. Methods that retrieve a single value or
  1218. * may return a primitive value will automatically end the chain sequence and
  1219. * return the unwrapped value. Otherwise, the value must be unwrapped with
  1220. * `_#value`.
  1221. *
  1222. * Explicit chaining, which must be unwrapped with `_#value` in all cases,
  1223. * may be enabled using `_.chain`.
  1224. *
  1225. * The execution of chained methods is lazy, that is, it's deferred until
  1226. * `_#value` is implicitly or explicitly called.
  1227. *
  1228. * Lazy evaluation allows several methods to support shortcut fusion. Shortcut
  1229. * fusion is an optimization to merge iteratee calls; this avoids the creation
  1230. * of intermediate arrays and can greatly reduce the number of iteratee executions.
  1231. * Sections of a chain sequence qualify for shortcut fusion if the section is
  1232. * applied to an array of at least two hundred elements and any iteratees
  1233. * accept only one argument. The heuristic for whether a section qualifies
  1234. * for shortcut fusion is subject to change.
  1235. *
  1236. * Chaining is supported in custom builds as long as the `_#value` method is
  1237. * directly or indirectly included in the build.
  1238. *
  1239. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  1240. *
  1241. * The wrapper `Array` methods are:
  1242. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  1243. *
  1244. * The wrapper `String` methods are:
  1245. * `replace` and `split`
  1246. *
  1247. * The wrapper methods that support shortcut fusion are:
  1248. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  1249. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  1250. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  1251. *
  1252. * The chainable wrapper methods are:
  1253. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  1254. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  1255. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  1256. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
  1257. * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
  1258. * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`,
  1259. * `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`,
  1260. * `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`,
  1261. * `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`,
  1262. * `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`,
  1263. * `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`,
  1264. * `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`,
  1265. * `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`,
  1266. * `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`,
  1267. * `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
  1268. * `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
  1269. * `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
  1270. * `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`,
  1271. * `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
  1272. * `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
  1273. * `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
  1274. * `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith`
  1275. *
  1276. * The wrapper methods that are **not** chainable by default are:
  1277. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  1278. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`,
  1279. * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  1280. * `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`, `forIn`,
  1281. * `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`,
  1282. * `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`,
  1283. * `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
  1284. * `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
  1285. * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`,
  1286. * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
  1287. * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
  1288. * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
  1289. * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
  1290. * `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`,
  1291. * `now`, `pad`, `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`,
  1292. * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `sample`,
  1293. * `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`,
  1294. * `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`,
  1295. * `sum`, `