PageRenderTime 53ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/files/lodash/4.3.0/lodash.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 1441 lines | 1397 code | 18 blank | 26 comment | 0 complexity | 1292a0975f3f6aa1e5d283b25e8be776 MD5 | raw file
  1. /**
  2. * @license
  3. * lodash 4.3.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.3.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) ? exports : null;
  286. /** Detect free variable `module`. */
  287. var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
  288. /** Detect free variable `global` from Node.js. */
  289. var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
  290. /** Detect free variable `self`. */
  291. var freeSelf = checkGlobal(objectTypes[typeof self] && self);
  292. /** Detect free variable `window`. */
  293. var freeWindow = checkGlobal(objectTypes[typeof window] && window);
  294. /** Detect the popular CommonJS extension `module.exports`. */
  295. var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
  296. /** Detect `this` as the global object. */
  297. var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
  298. /**
  299. * Used as a reference to the global object.
  300. *
  301. * The `this` value is used if it's the global object to avoid Greasemonkey's
  302. * restricted `window` object, otherwise the `window` object is used.
  303. */
  304. var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
  305. /*--------------------------------------------------------------------------*/
  306. /**
  307. * Adds the key-value `pair` to `map`.
  308. *
  309. * @private
  310. * @param {Object} map The map to modify.
  311. * @param {Array} pair The key-value pair to add.
  312. * @returns {Object} Returns `map`.
  313. */
  314. function addMapEntry(map, pair) {
  315. map.set(pair[0], pair[1]);
  316. return map;
  317. }
  318. /**
  319. * Adds `value` to `set`.
  320. *
  321. * @private
  322. * @param {Object} set The set to modify.
  323. * @param {*} value The value to add.
  324. * @returns {Object} Returns `set`.
  325. */
  326. function addSetEntry(set, value) {
  327. set.add(value);
  328. return set;
  329. }
  330. /**
  331. * A faster alternative to `Function#apply`, this function invokes `func`
  332. * with the `this` binding of `thisArg` and the arguments of `args`.
  333. *
  334. * @private
  335. * @param {Function} func The function to invoke.
  336. * @param {*} thisArg The `this` binding of `func`.
  337. * @param {...*} args The arguments to invoke `func` with.
  338. * @returns {*} Returns the result of `func`.
  339. */
  340. function apply(func, thisArg, args) {
  341. var length = args.length;
  342. switch (length) {
  343. case 0: return func.call(thisArg);
  344. case 1: return func.call(thisArg, args[0]);
  345. case 2: return func.call(thisArg, args[0], args[1]);
  346. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  347. }
  348. return func.apply(thisArg, args);
  349. }
  350. /**
  351. * A specialized version of `baseAggregator` for arrays.
  352. *
  353. * @private
  354. * @param {Array} array The array to iterate over.
  355. * @param {Function} setter The function to set `accumulator` values.
  356. * @param {Function} iteratee The iteratee to transform keys.
  357. * @param {Object} accumulator The initial aggregated object.
  358. * @returns {Function} Returns `accumulator`.
  359. */
  360. function arrayAggregator(array, setter, iteratee, accumulator) {
  361. var index = -1,
  362. length = array.length;
  363. while (++index < length) {
  364. var value = array[index];
  365. setter(accumulator, value, iteratee(value), array);
  366. }
  367. return accumulator;
  368. }
  369. /**
  370. * Creates a new array concatenating `array` with `other`.
  371. *
  372. * @private
  373. * @param {Array} array The first array to concatenate.
  374. * @param {Array} other The second array to concatenate.
  375. * @returns {Array} Returns the new concatenated array.
  376. */
  377. function arrayConcat(array, other) {
  378. var index = -1,
  379. length = array.length,
  380. othIndex = -1,
  381. othLength = other.length,
  382. result = Array(length + othLength);
  383. while (++index < length) {
  384. result[index] = array[index];
  385. }
  386. while (++othIndex < othLength) {
  387. result[index++] = other[othIndex];
  388. }
  389. return result;
  390. }
  391. /**
  392. * A specialized version of `_.forEach` for arrays without support for
  393. * iteratee shorthands.
  394. *
  395. * @private
  396. * @param {Array} array The array to iterate over.
  397. * @param {Function} iteratee The function invoked per iteration.
  398. * @returns {Array} Returns `array`.
  399. */
  400. function arrayEach(array, iteratee) {
  401. var index = -1,
  402. length = array.length;
  403. while (++index < length) {
  404. if (iteratee(array[index], index, array) === false) {
  405. break;
  406. }
  407. }
  408. return array;
  409. }
  410. /**
  411. * A specialized version of `_.forEachRight` for arrays without support for
  412. * iteratee shorthands.
  413. *
  414. * @private
  415. * @param {Array} array The array to iterate over.
  416. * @param {Function} iteratee The function invoked per iteration.
  417. * @returns {Array} Returns `array`.
  418. */
  419. function arrayEachRight(array, iteratee) {
  420. var length = array.length;
  421. while (length--) {
  422. if (iteratee(array[length], length, array) === false) {
  423. break;
  424. }
  425. }
  426. return array;
  427. }
  428. /**
  429. * A specialized version of `_.every` for arrays without support for
  430. * iteratee shorthands.
  431. *
  432. * @private
  433. * @param {Array} array The array to iterate over.
  434. * @param {Function} predicate The function invoked per iteration.
  435. * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`.
  436. */
  437. function arrayEvery(array, predicate) {
  438. var index = -1,
  439. length = array.length;
  440. while (++index < length) {
  441. if (!predicate(array[index], index, array)) {
  442. return false;
  443. }
  444. }
  445. return true;
  446. }
  447. /**
  448. * A specialized version of `_.filter` for arrays without support for
  449. * iteratee shorthands.
  450. *
  451. * @private
  452. * @param {Array} array The array to iterate over.
  453. * @param {Function} predicate The function invoked per iteration.
  454. * @returns {Array} Returns the new filtered array.
  455. */
  456. function arrayFilter(array, predicate) {
  457. var index = -1,
  458. length = array.length,
  459. resIndex = -1,
  460. result = [];
  461. while (++index < length) {
  462. var value = array[index];
  463. if (predicate(value, index, array)) {
  464. result[++resIndex] = value;
  465. }
  466. }
  467. return result;
  468. }
  469. /**
  470. * A specialized version of `_.includes` for arrays without support for
  471. * specifying an index to search from.
  472. *
  473. * @private
  474. * @param {Array} array The array to search.
  475. * @param {*} target The value to search for.
  476. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  477. */
  478. function arrayIncludes(array, value) {
  479. return !!array.length && baseIndexOf(array, value, 0) > -1;
  480. }
  481. /**
  482. * A specialized version of `_.includesWith` for arrays without support for
  483. * specifying an index to search from.
  484. *
  485. * @private
  486. * @param {Array} array The array to search.
  487. * @param {*} target The value to search for.
  488. * @param {Function} comparator The comparator invoked per element.
  489. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  490. */
  491. function arrayIncludesWith(array, value, comparator) {
  492. var index = -1,
  493. length = array.length;
  494. while (++index < length) {
  495. if (comparator(value, array[index])) {
  496. return true;
  497. }
  498. }
  499. return false;
  500. }
  501. /**
  502. * A specialized version of `_.map` for arrays without support for iteratee
  503. * shorthands.
  504. *
  505. * @private
  506. * @param {Array} array The array to iterate over.
  507. * @param {Function} iteratee The function invoked per iteration.
  508. * @returns {Array} Returns the new mapped array.
  509. */
  510. function arrayMap(array, iteratee) {
  511. var index = -1,
  512. length = array.length,
  513. result = Array(length);
  514. while (++index < length) {
  515. result[index] = iteratee(array[index], index, array);
  516. }
  517. return result;
  518. }
  519. /**
  520. * Appends the elements of `values` to `array`.
  521. *
  522. * @private
  523. * @param {Array} array The array to modify.
  524. * @param {Array} values The values to append.
  525. * @returns {Array} Returns `array`.
  526. */
  527. function arrayPush(array, values) {
  528. var index = -1,
  529. length = values.length,
  530. offset = array.length;
  531. while (++index < length) {
  532. array[offset + index] = values[index];
  533. }
  534. return array;
  535. }
  536. /**
  537. * A specialized version of `_.reduce` for arrays without support for
  538. * iteratee shorthands.
  539. *
  540. * @private
  541. * @param {Array} array The array to iterate over.
  542. * @param {Function} iteratee The function invoked per iteration.
  543. * @param {*} [accumulator] The initial value.
  544. * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
  545. * @returns {*} Returns the accumulated value.
  546. */
  547. function arrayReduce(array, iteratee, accumulator, initAccum) {
  548. var index = -1,
  549. length = array.length;
  550. if (initAccum && length) {
  551. accumulator = array[++index];
  552. }
  553. while (++index < length) {
  554. accumulator = iteratee(accumulator, array[index], index, array);
  555. }
  556. return accumulator;
  557. }
  558. /**
  559. * A specialized version of `_.reduceRight` for arrays without support for
  560. * iteratee shorthands.
  561. *
  562. * @private
  563. * @param {Array} array The array to iterate over.
  564. * @param {Function} iteratee The function invoked per iteration.
  565. * @param {*} [accumulator] The initial value.
  566. * @param {boolean} [initAccum] Specify using the last element of `array` as the initial value.
  567. * @returns {*} Returns the accumulated value.
  568. */
  569. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  570. var length = array.length;
  571. if (initAccum && length) {
  572. accumulator = array[--length];
  573. }
  574. while (length--) {
  575. accumulator = iteratee(accumulator, array[length], length, array);
  576. }
  577. return accumulator;
  578. }
  579. /**
  580. * A specialized version of `_.some` for arrays without support for iteratee
  581. * shorthands.
  582. *
  583. * @private
  584. * @param {Array} array The array to iterate over.
  585. * @param {Function} predicate The function invoked per iteration.
  586. * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
  587. */
  588. function arraySome(array, predicate) {
  589. var index = -1,
  590. length = array.length;
  591. while (++index < length) {
  592. if (predicate(array[index], index, array)) {
  593. return true;
  594. }
  595. }
  596. return false;
  597. }
  598. /**
  599. * The base implementation of methods like `_.max` and `_.min` which accepts a
  600. * `comparator` to determine the extremum value.
  601. *
  602. * @private
  603. * @param {Array} array The array to iterate over.
  604. * @param {Function} iteratee The iteratee invoked per iteration.
  605. * @param {Function} comparator The comparator used to compare values.
  606. * @returns {*} Returns the extremum value.
  607. */
  608. function baseExtremum(array, iteratee, comparator) {
  609. var index = -1,
  610. length = array.length;
  611. while (++index < length) {
  612. var value = array[index],
  613. current = iteratee(value);
  614. if (current != null && (computed === undefined
  615. ? current === current
  616. : comparator(current, computed)
  617. )) {
  618. var computed = current,
  619. result = value;
  620. }
  621. }
  622. return result;
  623. }
  624. /**
  625. * The base implementation of methods like `_.find` and `_.findKey`, without
  626. * support for iteratee shorthands, which iterates over `collection` using
  627. * `eachFunc`.
  628. *
  629. * @private
  630. * @param {Array|Object} collection The collection to search.
  631. * @param {Function} predicate The function invoked per iteration.
  632. * @param {Function} eachFunc The function to iterate over `collection`.
  633. * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself.
  634. * @returns {*} Returns the found element or its key, else `undefined`.
  635. */
  636. function baseFind(collection, predicate, eachFunc, retKey) {
  637. var result;
  638. eachFunc(collection, function(value, key, collection) {
  639. if (predicate(value, key, collection)) {
  640. result = retKey ? key : value;
  641. return false;
  642. }
  643. });
  644. return result;
  645. }
  646. /**
  647. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  648. * support for iteratee shorthands.
  649. *
  650. * @private
  651. * @param {Array} array The array to search.
  652. * @param {Function} predicate The function invoked per iteration.
  653. * @param {boolean} [fromRight] Specify iterating from right to left.
  654. * @returns {number} Returns the index of the matched value, else `-1`.
  655. */
  656. function baseFindIndex(array, predicate, fromRight) {
  657. var length = array.length,
  658. index = fromRight ? length : -1;
  659. while ((fromRight ? index-- : ++index < length)) {
  660. if (predicate(array[index], index, array)) {
  661. return index;
  662. }
  663. }
  664. return -1;
  665. }
  666. /**
  667. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  668. *
  669. * @private
  670. * @param {Array} array The array to search.
  671. * @param {*} value The value to search for.
  672. * @param {number} fromIndex The index to search from.
  673. * @returns {number} Returns the index of the matched value, else `-1`.
  674. */
  675. function baseIndexOf(array, value, fromIndex) {
  676. if (value !== value) {
  677. return indexOfNaN(array, fromIndex);
  678. }
  679. var index = fromIndex - 1,
  680. length = array.length;
  681. while (++index < length) {
  682. if (array[index] === value) {
  683. return index;
  684. }
  685. }
  686. return -1;
  687. }
  688. /**
  689. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  690. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  691. *
  692. * @private
  693. * @param {Array|Object} collection The collection to iterate over.
  694. * @param {Function} iteratee The function invoked per iteration.
  695. * @param {*} accumulator The initial value.
  696. * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
  697. * @param {Function} eachFunc The function to iterate over `collection`.
  698. * @returns {*} Returns the accumulated value.
  699. */
  700. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  701. eachFunc(collection, function(value, index, collection) {
  702. accumulator = initAccum
  703. ? (initAccum = false, value)
  704. : iteratee(accumulator, value, index, collection);
  705. });
  706. return accumulator;
  707. }
  708. /**
  709. * The base implementation of `_.sortBy` which uses `comparer` to define
  710. * the sort order of `array` and replaces criteria objects with their
  711. * corresponding values.
  712. *
  713. * @private
  714. * @param {Array} array The array to sort.
  715. * @param {Function} comparer The function to define sort order.
  716. * @returns {Array} Returns `array`.
  717. */
  718. function baseSortBy(array, comparer) {
  719. var length = array.length;
  720. array.sort(comparer);
  721. while (length--) {
  722. array[length] = array[length].value;
  723. }
  724. return array;
  725. }
  726. /**
  727. * The base implementation of `_.sum` without support for iteratee shorthands.
  728. *
  729. * @private
  730. * @param {Array} array The array to iterate over.
  731. * @param {Function} iteratee The function invoked per iteration.
  732. * @returns {number} Returns the sum.
  733. */
  734. function baseSum(array, iteratee) {
  735. var result,
  736. index = -1,
  737. length = array.length;
  738. while (++index < length) {
  739. var current = iteratee(array[index]);
  740. if (current !== undefined) {
  741. result = result === undefined ? current : (result + current);
  742. }
  743. }
  744. return result;
  745. }
  746. /**
  747. * The base implementation of `_.times` without support for iteratee shorthands
  748. * or max array length checks.
  749. *
  750. * @private
  751. * @param {number} n The number of times to invoke `iteratee`.
  752. * @param {Function} iteratee The function invoked per iteration.
  753. * @returns {Array} Returns the array of results.
  754. */
  755. function baseTimes(n, iteratee) {
  756. var index = -1,
  757. result = Array(n);
  758. while (++index < n) {
  759. result[index] = iteratee(index);
  760. }
  761. return result;
  762. }
  763. /**
  764. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  765. * of key-value pairs for `object` corresponding to the property names of `props`.
  766. *
  767. * @private
  768. * @param {Object} object The object to query.
  769. * @param {Array} props The property names to get values for.
  770. * @returns {Object} Returns the new array of key-value pairs.
  771. */
  772. function baseToPairs(object, props) {
  773. return arrayMap(props, function(key) {
  774. return [key, object[key]];
  775. });
  776. }
  777. /**
  778. * The base implementation of `_.unary` without support for storing wrapper metadata.
  779. *
  780. * @private
  781. * @param {Function} func The function to cap arguments for.
  782. * @returns {Function} Returns the new function.
  783. */
  784. function baseUnary(func) {
  785. return function(value) {
  786. return func(value);
  787. };
  788. }
  789. /**
  790. * The base implementation of `_.values` and `_.valuesIn` which creates an
  791. * array of `object` property values corresponding to the property names
  792. * of `props`.
  793. *
  794. * @private
  795. * @param {Object} object The object to query.
  796. * @param {Array} props The property names to get values for.
  797. * @returns {Object} Returns the array of property values.
  798. */
  799. function baseValues(object, props) {
  800. return arrayMap(props, function(key) {
  801. return object[key];
  802. });
  803. }
  804. /**
  805. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  806. * that is not found in the character symbols.
  807. *
  808. * @private
  809. * @param {Array} strSymbols The string symbols to inspect.
  810. * @param {Array} chrSymbols The character symbols to find.
  811. * @returns {number} Returns the index of the first unmatched string symbol.
  812. */
  813. function charsStartIndex(strSymbols, chrSymbols) {
  814. var index = -1,
  815. length = strSymbols.length;
  816. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  817. return index;
  818. }
  819. /**
  820. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  821. * that is not found in the character symbols.
  822. *
  823. * @private
  824. * @param {Array} strSymbols The string symbols to inspect.
  825. * @param {Array} chrSymbols The character symbols to find.
  826. * @returns {number} Returns the index of the last unmatched string symbol.
  827. */
  828. function charsEndIndex(strSymbols, chrSymbols) {
  829. var index = strSymbols.length;
  830. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  831. return index;
  832. }
  833. /**
  834. * Checks if `value` is a global object.
  835. *
  836. * @private
  837. * @param {*} value The value to check.
  838. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  839. */
  840. function checkGlobal(value) {
  841. return (value && value.Object === Object) ? value : null;
  842. }
  843. /**
  844. * Compares values to sort them in ascending order.
  845. *
  846. * @private
  847. * @param {*} value The value to compare.
  848. * @param {*} other The other value to compare.
  849. * @returns {number} Returns the sort order indicator for `value`.
  850. */
  851. function compareAscending(value, other) {
  852. if (value !== other) {
  853. var valIsNull = value === null,
  854. valIsUndef = value === undefined,
  855. valIsReflexive = value === value;
  856. var othIsNull = other === null,
  857. othIsUndef = other === undefined,
  858. othIsReflexive = other === other;
  859. if ((value > other && !othIsNull) || !valIsReflexive ||
  860. (valIsNull && !othIsUndef && othIsReflexive) ||
  861. (valIsUndef && othIsReflexive)) {
  862. return 1;
  863. }
  864. if ((value < other && !valIsNull) || !othIsReflexive ||
  865. (othIsNull && !valIsUndef && valIsReflexive) ||
  866. (othIsUndef && valIsReflexive)) {
  867. return -1;
  868. }
  869. }
  870. return 0;
  871. }
  872. /**
  873. * Used by `_.orderBy` to compare multiple properties of a value to another
  874. * and stable sort them.
  875. *
  876. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  877. * specify an order of "desc" for descending or "asc" for ascending sort order
  878. * of corresponding values.
  879. *
  880. * @private
  881. * @param {Object} object The object to compare.
  882. * @param {Object} other The other object to compare.
  883. * @param {boolean[]|string[]} orders The order to sort by for each property.
  884. * @returns {number} Returns the sort order indicator for `object`.
  885. */
  886. function compareMultiple(object, other, orders) {
  887. var index = -1,
  888. objCriteria = object.criteria,
  889. othCriteria = other.criteria,
  890. length = objCriteria.length,
  891. ordersLength = orders.length;
  892. while (++index < length) {
  893. var result = compareAscending(objCriteria[index], othCriteria[index]);
  894. if (result) {
  895. if (index >= ordersLength) {
  896. return result;
  897. }
  898. var order = orders[index];
  899. return result * (order == 'desc' ? -1 : 1);
  900. }
  901. }
  902. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  903. // that causes it, under certain circumstances, to provide the same value for
  904. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  905. // for more details.
  906. //
  907. // This also ensures a stable sort in V8 and other engines.
  908. // See https://code.google.com/p/v8/issues/detail?id=90 for more details.
  909. return object.index - other.index;
  910. }
  911. /**
  912. * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
  913. *
  914. * @private
  915. * @param {string} letter The matched letter to deburr.
  916. * @returns {string} Returns the deburred letter.
  917. */
  918. function deburrLetter(letter) {
  919. return deburredLetters[letter];
  920. }
  921. /**
  922. * Used by `_.escape` to convert characters to HTML entities.
  923. *
  924. * @private
  925. * @param {string} chr The matched character to escape.
  926. * @returns {string} Returns the escaped character.
  927. */
  928. function escapeHtmlChar(chr) {
  929. return htmlEscapes[chr];
  930. }
  931. /**
  932. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  933. *
  934. * @private
  935. * @param {string} chr The matched character to escape.
  936. * @returns {string} Returns the escaped character.
  937. */
  938. function escapeStringChar(chr) {
  939. return '\\' + stringEscapes[chr];
  940. }
  941. /**
  942. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  943. *
  944. * @private
  945. * @param {Array} array The array to search.
  946. * @param {number} fromIndex The index to search from.
  947. * @param {boolean} [fromRight] Specify iterating from right to left.
  948. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  949. */
  950. function indexOfNaN(array, fromIndex, fromRight) {
  951. var length = array.length,
  952. index = fromIndex + (fromRight ? 0 : -1);
  953. while ((fromRight ? index-- : ++index < length)) {
  954. var other = array[index];
  955. if (other !== other) {
  956. return index;
  957. }
  958. }
  959. return -1;
  960. }
  961. /**
  962. * Checks if `value` is a host object in IE < 9.
  963. *
  964. * @private
  965. * @param {*} value The value to check.
  966. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  967. */
  968. function isHostObject(value) {
  969. // Many host objects are `Object` objects that can coerce to strings
  970. // despite having improperly defined `toString` methods.
  971. var result = false;
  972. if (value != null && typeof value.toString != 'function') {
  973. try {
  974. result = !!(value + '');
  975. } catch (e) {}
  976. }
  977. return result;
  978. }
  979. /**
  980. * Checks if `value` is a valid array-like index.
  981. *
  982. * @private
  983. * @param {*} value The value to check.
  984. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  985. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  986. */
  987. function isIndex(value, length) {
  988. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  989. length = length == null ? MAX_SAFE_INTEGER : length;
  990. return value > -1 && value % 1 == 0 && value < length;
  991. }
  992. /**
  993. * Converts `iterator` to an array.
  994. *
  995. * @private
  996. * @param {Object} iterator The iterator to convert.
  997. * @returns {Array} Returns the converted array.
  998. */
  999. function iteratorToArray(iterator) {
  1000. var data,
  1001. result = [];
  1002. while (!(data = iterator.next()).done) {
  1003. result.push(data.value);
  1004. }
  1005. return result;
  1006. }
  1007. /**
  1008. * Converts `map` to an array.
  1009. *
  1010. * @private
  1011. * @param {Object} map The map to convert.
  1012. * @returns {Array} Returns the converted array.
  1013. */
  1014. function mapToArray(map) {
  1015. var index = -1,
  1016. result = Array(map.size);
  1017. map.forEach(function(value, key) {
  1018. result[++index] = [key, value];
  1019. });
  1020. return result;
  1021. }
  1022. /**
  1023. * Replaces all `placeholder` elements in `array` with an internal placeholder
  1024. * and returns an array of their indexes.
  1025. *
  1026. * @private
  1027. * @param {Array} array The array to modify.
  1028. * @param {*} placeholder The placeholder to replace.
  1029. * @returns {Array} Returns the new array of placeholder indexes.
  1030. */
  1031. function replaceHolders(array, placeholder) {
  1032. var index = -1,
  1033. length = array.length,
  1034. resIndex = -1,
  1035. result = [];
  1036. while (++index < length) {
  1037. if (array[index] === placeholder) {
  1038. array[index] = PLACEHOLDER;
  1039. result[++resIndex] = index;
  1040. }
  1041. }
  1042. return result;
  1043. }
  1044. /**
  1045. * Converts `set` to an array.
  1046. *
  1047. * @private
  1048. * @param {Object} set The set to convert.
  1049. * @returns {Array} Returns the converted array.
  1050. */
  1051. function setToArray(set) {
  1052. var index = -1,
  1053. result = Array(set.size);
  1054. set.forEach(function(value) {
  1055. result[++index] = value;
  1056. });
  1057. return result;
  1058. }
  1059. /**
  1060. * Gets the number of symbols in `string`.
  1061. *
  1062. * @private
  1063. * @param {string} string The string to inspect.
  1064. * @returns {number} Returns the string size.
  1065. */
  1066. function stringSize(string) {
  1067. if (!(string && reHasComplexSymbol.test(string))) {
  1068. return string.length;
  1069. }
  1070. var result = reComplexSymbol.lastIndex = 0;
  1071. while (reComplexSymbol.test(string)) {
  1072. result++;
  1073. }
  1074. return result;
  1075. }
  1076. /**
  1077. * Converts `string` to an array.
  1078. *
  1079. * @private
  1080. * @param {string} string The string to convert.
  1081. * @returns {Array} Returns the converted array.
  1082. */
  1083. function stringToArray(string) {
  1084. return string.match(reComplexSymbol);
  1085. }
  1086. /**
  1087. * Used by `_.unescape` to convert HTML entities to characters.
  1088. *
  1089. * @private
  1090. * @param {string} chr The matched character to unescape.
  1091. * @returns {string} Returns the unescaped character.
  1092. */
  1093. function unescapeHtmlChar(chr) {
  1094. return htmlUnescapes[chr];
  1095. }
  1096. /*--------------------------------------------------------------------------*/
  1097. /**
  1098. * Create a new pristine `lodash` function using the `context` object.
  1099. *
  1100. * @static
  1101. * @memberOf _
  1102. * @category Util
  1103. * @param {Object} [context=root] The context object.
  1104. * @returns {Function} Returns a new `lodash` function.
  1105. * @example
  1106. *
  1107. * _.mixin({ 'foo': _.constant('foo') });
  1108. *
  1109. * var lodash = _.runInContext();
  1110. * lodash.mixin({ 'bar': lodash.constant('bar') });
  1111. *
  1112. * _.isFunction(_.foo);
  1113. * // => true
  1114. * _.isFunction(_.bar);
  1115. * // => false
  1116. *
  1117. * lodash.isFunction(lodash.foo);
  1118. * // => false
  1119. * lodash.isFunction(lodash.bar);
  1120. * // => true
  1121. *
  1122. * // Use `context` to mock `Date#getTime` use in `_.now`.
  1123. * var mock = _.runInContext({
  1124. * 'Date': function() {
  1125. * return { 'getTime': getTimeMock };
  1126. * }
  1127. * });
  1128. *
  1129. * // Create a suped-up `defer` in Node.js.
  1130. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  1131. */
  1132. function runInContext(context) {
  1133. context = context ? _.defaults({}, context, _.pick(root, contextProps)) : root;
  1134. /** Built-in constructor references. */
  1135. var Date = context.Date,
  1136. Error = context.Error,
  1137. Math = context.Math,
  1138. RegExp = context.RegExp,
  1139. TypeError = context.TypeError;
  1140. /** Used for built-in method references. */
  1141. var arrayProto = context.Array.prototype,
  1142. objectProto = context.Object.prototype;
  1143. /** Used to resolve the decompiled source of functions. */
  1144. var funcToString = context.Function.prototype.toString;
  1145. /** Used to check objects for own properties. */
  1146. var hasOwnProperty = objectProto.hasOwnProperty;
  1147. /** Used to generate unique IDs. */
  1148. var idCounter = 0;
  1149. /** Used to infer the `Object` constructor. */
  1150. var objectCtorString = funcToString.call(Object);
  1151. /**
  1152. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1153. * of values.
  1154. */
  1155. var objectToString = objectProto.toString;
  1156. /** Used to restore the original `_` reference in `_.noConflict`. */
  1157. var oldDash = root._;
  1158. /** Used to detect if a method is native. */
  1159. var reIsNative = RegExp('^' +
  1160. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  1161. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1162. );
  1163. /** Built-in value references. */
  1164. var Buffer = moduleExports ? context.Buffer : undefined,
  1165. Reflect = context.Reflect,
  1166. Symbol = context.Symbol,
  1167. Uint8Array = context.Uint8Array,
  1168. clearTimeout = context.clearTimeout,
  1169. enumerate = Reflect ? Reflect.enumerate : undefined,
  1170. getPrototypeOf = Object.getPrototypeOf,
  1171. getOwnPropertySymbols = Object.getOwnPropertySymbols,
  1172. iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
  1173. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1174. setTimeout = context.setTimeout,
  1175. splice = arrayProto.splice;
  1176. /* Built-in method references for those with the same name as other `lodash` methods. */
  1177. var nativeCeil = Math.ceil,
  1178. nativeFloor = Math.floor,
  1179. nativeIsFinite = context.isFinite,
  1180. nativeJoin = arrayProto.join,
  1181. nativeKeys = Object.keys,
  1182. nativeMax = Math.max,
  1183. nativeMin = Math.min,
  1184. nativeParseInt = context.parseInt,
  1185. nativeRandom = Math.random,
  1186. nativeReverse = arrayProto.reverse;
  1187. /* Built-in method references that are verified to be native. */
  1188. var Map = getNative(context, 'Map'),
  1189. Set = getNative(context, 'Set'),
  1190. WeakMap = getNative(context, 'WeakMap'),
  1191. nativeCreate = getNative(Object, 'create');
  1192. /** Used to store function metadata. */
  1193. var metaMap = WeakMap && new WeakMap;
  1194. /** Used to detect maps, sets, and weakmaps. */
  1195. var mapCtorString = Map ? funcToString.call(Map) : '',
  1196. setCtorString = Set ? funcToString.call(Set) : '',
  1197. weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
  1198. /** Used to convert symbols to primitives and strings. */
  1199. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1200. symbolValueOf = Symbol ? symbolProto.valueOf : undefined,
  1201. symbolToString = Symbol ? symbolProto.toString : undefined;
  1202. /** Used to lookup unminified function names. */
  1203. var realNames = {};
  1204. /*------------------------------------------------------------------------*/
  1205. /**
  1206. * Creates a `lodash` object which wraps `value` to enable implicit method
  1207. * chaining. Methods that operate on and return arrays, collections, and
  1208. * functions can be chained together. Methods that retrieve a single value or
  1209. * may return a primitive value will automatically end the chain sequence and
  1210. * return the unwrapped value. Otherwise, the value must be unwrapped with
  1211. * `_#value`.
  1212. *
  1213. * Explicit chaining, which must be unwrapped with `_#value` in all cases,
  1214. * may be enabled using `_.chain`.
  1215. *
  1216. * The execution of chained methods is lazy, that is, it's deferred until
  1217. * `_#value` is implicitly or explicitly called.
  1218. *
  1219. * Lazy evaluation allows several methods to support shortcut fusion. Shortcut
  1220. * fusion is an optimization to merge iteratee calls; this avoids the creation
  1221. * of intermediate arrays and can greatly reduce the number of iteratee executions.
  1222. * Sections of a chain sequence qualify for shortcut fusion if the section is
  1223. * applied to an array of at least two hundred elements and any iteratees
  1224. * accept only one argument. The heuristic for whether a section qualifies
  1225. * for shortcut fusion is subject to change.
  1226. *
  1227. * Chaining is supported in custom builds as long as the `_#value` method is
  1228. * directly or indirectly included in the build.
  1229. *
  1230. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  1231. *
  1232. * The wrapper `Array` methods are:
  1233. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  1234. *
  1235. * The wrapper `String` methods are:
  1236. * `replace` and `split`
  1237. *
  1238. * The wrapper methods that support shortcut fusion are:
  1239. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  1240. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  1241. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  1242. *
  1243. * The chainable wrapper methods are:
  1244. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
  1245. * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
  1246. * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
  1247. * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
  1248. * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
  1249. * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
  1250. * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
  1251. * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`,
  1252. * `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
  1253. * `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
  1254. * `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`,
  1255. * `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`,
  1256. * `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
  1257. * `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
  1258. * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
  1259. * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
  1260. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
  1261. * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
  1262. * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
  1263. * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
  1264. * `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
  1265. * `zipObjectDeep`, and `zipWith`
  1266. *
  1267. * The wrapper methods that are **not** chainable by default are:
  1268. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  1269. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`,
  1270. * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
  1271. * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`,
  1272. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  1273. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  1274. * `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
  1275. * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
  1276. * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`,
  1277. * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`,
  1278. * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`,
  1279. * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`,
  1280. * `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`,
  1281. * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
  1282. * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
  1283. * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
  1284. * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
  1285. * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`,
  1286. * `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`,
  1287. * `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId