PageRenderTime 29ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/node_modules/lite-server/node_modules/lodash/lodash.js

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