PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/files/lodash/4.2.0/lodash.js

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