PageRenderTime 56ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/lodash/lodash.js

https://gitlab.com/varunsonavne/node-hello
JavaScript | 1528 lines | 1479 code | 21 blank | 28 comment | 0 complexity | 5f5e1321aa2e2598ff1196efdbe65d34 MD5 | raw file
  1. /**
  2. * @license
  3. * Lodash <https://lodash.com/>
  4. * Copyright OpenJS Foundation and other contributors <https://openjsf.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.17.21';
  14. /** Used as the size to enable large array optimizations. */
  15. var LARGE_ARRAY_SIZE = 200;
  16. /** Error message constants. */
  17. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  18. FUNC_ERROR_TEXT = 'Expected a function',
  19. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  20. /** Used to stand-in for `undefined` hash values. */
  21. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  22. /** Used as the maximum memoize cache size. */
  23. var MAX_MEMOIZE_SIZE = 500;
  24. /** Used as the internal argument placeholder. */
  25. var PLACEHOLDER = '__lodash_placeholder__';
  26. /** Used to compose bitmasks for cloning. */
  27. var CLONE_DEEP_FLAG = 1,
  28. CLONE_FLAT_FLAG = 2,
  29. CLONE_SYMBOLS_FLAG = 4;
  30. /** Used to compose bitmasks for value comparisons. */
  31. var COMPARE_PARTIAL_FLAG = 1,
  32. COMPARE_UNORDERED_FLAG = 2;
  33. /** Used to compose bitmasks for function metadata. */
  34. var WRAP_BIND_FLAG = 1,
  35. WRAP_BIND_KEY_FLAG = 2,
  36. WRAP_CURRY_BOUND_FLAG = 4,
  37. WRAP_CURRY_FLAG = 8,
  38. WRAP_CURRY_RIGHT_FLAG = 16,
  39. WRAP_PARTIAL_FLAG = 32,
  40. WRAP_PARTIAL_RIGHT_FLAG = 64,
  41. WRAP_ARY_FLAG = 128,
  42. WRAP_REARG_FLAG = 256,
  43. WRAP_FLIP_FLAG = 512;
  44. /** Used as default options for `_.truncate`. */
  45. var DEFAULT_TRUNC_LENGTH = 30,
  46. DEFAULT_TRUNC_OMISSION = '...';
  47. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  48. var HOT_COUNT = 800,
  49. HOT_SPAN = 16;
  50. /** Used to indicate the type of lazy iteratees. */
  51. var LAZY_FILTER_FLAG = 1,
  52. LAZY_MAP_FLAG = 2,
  53. LAZY_WHILE_FLAG = 3;
  54. /** Used as references for various `Number` constants. */
  55. var INFINITY = 1 / 0,
  56. MAX_SAFE_INTEGER = 9007199254740991,
  57. MAX_INTEGER = 1.7976931348623157e+308,
  58. NAN = 0 / 0;
  59. /** Used as references for the maximum length and index of an array. */
  60. var MAX_ARRAY_LENGTH = 4294967295,
  61. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  62. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  63. /** Used to associate wrap methods with their bit flags. */
  64. var wrapFlags = [
  65. ['ary', WRAP_ARY_FLAG],
  66. ['bind', WRAP_BIND_FLAG],
  67. ['bindKey', WRAP_BIND_KEY_FLAG],
  68. ['curry', WRAP_CURRY_FLAG],
  69. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  70. ['flip', WRAP_FLIP_FLAG],
  71. ['partial', WRAP_PARTIAL_FLAG],
  72. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  73. ['rearg', WRAP_REARG_FLAG]
  74. ];
  75. /** `Object#toString` result references. */
  76. var argsTag = '[object Arguments]',
  77. arrayTag = '[object Array]',
  78. asyncTag = '[object AsyncFunction]',
  79. boolTag = '[object Boolean]',
  80. dateTag = '[object Date]',
  81. domExcTag = '[object DOMException]',
  82. errorTag = '[object Error]',
  83. funcTag = '[object Function]',
  84. genTag = '[object GeneratorFunction]',
  85. mapTag = '[object Map]',
  86. numberTag = '[object Number]',
  87. nullTag = '[object Null]',
  88. objectTag = '[object Object]',
  89. promiseTag = '[object Promise]',
  90. proxyTag = '[object Proxy]',
  91. regexpTag = '[object RegExp]',
  92. setTag = '[object Set]',
  93. stringTag = '[object String]',
  94. symbolTag = '[object Symbol]',
  95. undefinedTag = '[object Undefined]',
  96. weakMapTag = '[object WeakMap]',
  97. weakSetTag = '[object WeakSet]';
  98. var arrayBufferTag = '[object ArrayBuffer]',
  99. dataViewTag = '[object DataView]',
  100. float32Tag = '[object Float32Array]',
  101. float64Tag = '[object Float64Array]',
  102. int8Tag = '[object Int8Array]',
  103. int16Tag = '[object Int16Array]',
  104. int32Tag = '[object Int32Array]',
  105. uint8Tag = '[object Uint8Array]',
  106. uint8ClampedTag = '[object Uint8ClampedArray]',
  107. uint16Tag = '[object Uint16Array]',
  108. uint32Tag = '[object Uint32Array]';
  109. /** Used to match empty string literals in compiled template source. */
  110. var reEmptyStringLeading = /\b__p \+= '';/g,
  111. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  112. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  113. /** Used to match HTML entities and HTML characters. */
  114. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  115. reUnescapedHtml = /[&<>"']/g,
  116. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  117. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  118. /** Used to match template delimiters. */
  119. var reEscape = /<%-([\s\S]+?)%>/g,
  120. reEvaluate = /<%([\s\S]+?)%>/g,
  121. reInterpolate = /<%=([\s\S]+?)%>/g;
  122. /** Used to match property names within property paths. */
  123. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  124. reIsPlainProp = /^\w*$/,
  125. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  126. /**
  127. * Used to match `RegExp`
  128. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  129. */
  130. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  131. reHasRegExpChar = RegExp(reRegExpChar.source);
  132. /** Used to match leading whitespace. */
  133. var reTrimStart = /^\s+/;
  134. /** Used to match a single whitespace character. */
  135. var reWhitespace = /\s/;
  136. /** Used to match wrap detail comments. */
  137. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  138. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  139. reSplitDetails = /,? & /;
  140. /** Used to match words composed of alphanumeric characters. */
  141. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  142. /**
  143. * Used to validate the `validate` option in `_.template` variable.
  144. *
  145. * Forbids characters which could potentially change the meaning of the function argument definition:
  146. * - "()," (modification of function parameters)
  147. * - "=" (default value)
  148. * - "[]{}" (destructuring of function parameters)
  149. * - "/" (beginning of a comment)
  150. * - whitespace
  151. */
  152. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  153. /** Used to match backslashes in property paths. */
  154. var reEscapeChar = /\\(\\)?/g;
  155. /**
  156. * Used to match
  157. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  158. */
  159. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  160. /** Used to match `RegExp` flags from their coerced string values. */
  161. var reFlags = /\w*$/;
  162. /** Used to detect bad signed hexadecimal string values. */
  163. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  164. /** Used to detect binary string values. */
  165. var reIsBinary = /^0b[01]+$/i;
  166. /** Used to detect host constructors (Safari). */
  167. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  168. /** Used to detect octal string values. */
  169. var reIsOctal = /^0o[0-7]+$/i;
  170. /** Used to detect unsigned integer values. */
  171. var reIsUint = /^(?:0|[1-9]\d*)$/;
  172. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  173. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  174. /** Used to ensure capturing order of template delimiters. */
  175. var reNoMatch = /($^)/;
  176. /** Used to match unescaped characters in compiled string literals. */
  177. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  178. /** Used to compose unicode character classes. */
  179. var rsAstralRange = '\\ud800-\\udfff',
  180. rsComboMarksRange = '\\u0300-\\u036f',
  181. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  182. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  183. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  184. rsDingbatRange = '\\u2700-\\u27bf',
  185. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  186. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  187. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  188. rsPunctuationRange = '\\u2000-\\u206f',
  189. 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',
  190. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  191. rsVarRange = '\\ufe0e\\ufe0f',
  192. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  193. /** Used to compose unicode capture groups. */
  194. var rsApos = "['\u2019]",
  195. rsAstral = '[' + rsAstralRange + ']',
  196. rsBreak = '[' + rsBreakRange + ']',
  197. rsCombo = '[' + rsComboRange + ']',
  198. rsDigits = '\\d+',
  199. rsDingbat = '[' + rsDingbatRange + ']',
  200. rsLower = '[' + rsLowerRange + ']',
  201. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  202. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  203. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  204. rsNonAstral = '[^' + rsAstralRange + ']',
  205. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  206. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  207. rsUpper = '[' + rsUpperRange + ']',
  208. rsZWJ = '\\u200d';
  209. /** Used to compose unicode regexes. */
  210. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  211. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  212. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  213. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  214. reOptMod = rsModifier + '?',
  215. rsOptVar = '[' + rsVarRange + ']?',
  216. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  217. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  218. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  219. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  220. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  221. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  222. /** Used to match apostrophes. */
  223. var reApos = RegExp(rsApos, 'g');
  224. /**
  225. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  226. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  227. */
  228. var reComboMark = RegExp(rsCombo, 'g');
  229. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  230. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  231. /** Used to match complex or compound words. */
  232. var reUnicodeWord = RegExp([
  233. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  234. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  235. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  236. rsUpper + '+' + rsOptContrUpper,
  237. rsOrdUpper,
  238. rsOrdLower,
  239. rsDigits,
  240. rsEmoji
  241. ].join('|'), 'g');
  242. /** 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/). */
  243. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  244. /** Used to detect strings that need a more robust regexp to match words. */
  245. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  246. /** Used to assign default `context` object properties. */
  247. var contextProps = [
  248. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  249. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  250. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  251. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  252. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  253. ];
  254. /** Used to make template sourceURLs easier to identify. */
  255. var templateCounter = -1;
  256. /** Used to identify `toStringTag` values of typed arrays. */
  257. var typedArrayTags = {};
  258. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  259. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  260. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  261. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  262. typedArrayTags[uint32Tag] = true;
  263. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  264. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  265. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  266. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  267. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  268. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  269. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  270. typedArrayTags[weakMapTag] = false;
  271. /** Used to identify `toStringTag` values supported by `_.clone`. */
  272. var cloneableTags = {};
  273. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  274. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  275. cloneableTags[boolTag] = cloneableTags[dateTag] =
  276. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  277. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  278. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  279. cloneableTags[numberTag] = cloneableTags[objectTag] =
  280. cloneableTags[regexpTag] = cloneableTags[setTag] =
  281. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  282. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  283. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  284. cloneableTags[errorTag] = cloneableTags[funcTag] =
  285. cloneableTags[weakMapTag] = false;
  286. /** Used to map Latin Unicode letters to basic Latin letters. */
  287. var deburredLetters = {
  288. // Latin-1 Supplement block.
  289. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  290. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  291. '\xc7': 'C', '\xe7': 'c',
  292. '\xd0': 'D', '\xf0': 'd',
  293. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  294. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  295. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  296. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  297. '\xd1': 'N', '\xf1': 'n',
  298. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  299. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  300. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  301. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  302. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  303. '\xc6': 'Ae', '\xe6': 'ae',
  304. '\xde': 'Th', '\xfe': 'th',
  305. '\xdf': 'ss',
  306. // Latin Extended-A block.
  307. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  308. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  309. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  310. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  311. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  312. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  313. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  314. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  315. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  316. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  317. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  318. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  319. '\u0134': 'J', '\u0135': 'j',
  320. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  321. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  322. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  323. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  324. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  325. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  326. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  327. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  328. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  329. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  330. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  331. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  332. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  333. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  334. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  335. '\u0174': 'W', '\u0175': 'w',
  336. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  337. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  338. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  339. '\u0132': 'IJ', '\u0133': 'ij',
  340. '\u0152': 'Oe', '\u0153': 'oe',
  341. '\u0149': "'n", '\u017f': 's'
  342. };
  343. /** Used to map characters to HTML entities. */
  344. var htmlEscapes = {
  345. '&': '&amp;',
  346. '<': '&lt;',
  347. '>': '&gt;',
  348. '"': '&quot;',
  349. "'": '&#39;'
  350. };
  351. /** Used to map HTML entities to characters. */
  352. var htmlUnescapes = {
  353. '&amp;': '&',
  354. '&lt;': '<',
  355. '&gt;': '>',
  356. '&quot;': '"',
  357. '&#39;': "'"
  358. };
  359. /** Used to escape characters for inclusion in compiled string literals. */
  360. var stringEscapes = {
  361. '\\': '\\',
  362. "'": "'",
  363. '\n': 'n',
  364. '\r': 'r',
  365. '\u2028': 'u2028',
  366. '\u2029': 'u2029'
  367. };
  368. /** Built-in method references without a dependency on `root`. */
  369. var freeParseFloat = parseFloat,
  370. freeParseInt = parseInt;
  371. /** Detect free variable `global` from Node.js. */
  372. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  373. /** Detect free variable `self`. */
  374. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  375. /** Used as a reference to the global object. */
  376. var root = freeGlobal || freeSelf || Function('return this')();
  377. /** Detect free variable `exports`. */
  378. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  379. /** Detect free variable `module`. */
  380. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  381. /** Detect the popular CommonJS extension `module.exports`. */
  382. var moduleExports = freeModule && freeModule.exports === freeExports;
  383. /** Detect free variable `process` from Node.js. */
  384. var freeProcess = moduleExports && freeGlobal.process;
  385. /** Used to access faster Node.js helpers. */
  386. var nodeUtil = (function() {
  387. try {
  388. // Use `util.types` for Node.js 10+.
  389. var types = freeModule && freeModule.require && freeModule.require('util').types;
  390. if (types) {
  391. return types;
  392. }
  393. // Legacy `process.binding('util')` for Node.js < 10.
  394. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  395. } catch (e) {}
  396. }());
  397. /* Node.js helper references. */
  398. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  399. nodeIsDate = nodeUtil && nodeUtil.isDate,
  400. nodeIsMap = nodeUtil && nodeUtil.isMap,
  401. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  402. nodeIsSet = nodeUtil && nodeUtil.isSet,
  403. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  404. /*--------------------------------------------------------------------------*/
  405. /**
  406. * A faster alternative to `Function#apply`, this function invokes `func`
  407. * with the `this` binding of `thisArg` and the arguments of `args`.
  408. *
  409. * @private
  410. * @param {Function} func The function to invoke.
  411. * @param {*} thisArg The `this` binding of `func`.
  412. * @param {Array} args The arguments to invoke `func` with.
  413. * @returns {*} Returns the result of `func`.
  414. */
  415. function apply(func, thisArg, args) {
  416. switch (args.length) {
  417. case 0: return func.call(thisArg);
  418. case 1: return func.call(thisArg, args[0]);
  419. case 2: return func.call(thisArg, args[0], args[1]);
  420. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  421. }
  422. return func.apply(thisArg, args);
  423. }
  424. /**
  425. * A specialized version of `baseAggregator` for arrays.
  426. *
  427. * @private
  428. * @param {Array} [array] The array to iterate over.
  429. * @param {Function} setter The function to set `accumulator` values.
  430. * @param {Function} iteratee The iteratee to transform keys.
  431. * @param {Object} accumulator The initial aggregated object.
  432. * @returns {Function} Returns `accumulator`.
  433. */
  434. function arrayAggregator(array, setter, iteratee, accumulator) {
  435. var index = -1,
  436. length = array == null ? 0 : array.length;
  437. while (++index < length) {
  438. var value = array[index];
  439. setter(accumulator, value, iteratee(value), array);
  440. }
  441. return accumulator;
  442. }
  443. /**
  444. * A specialized version of `_.forEach` for arrays without support for
  445. * iteratee shorthands.
  446. *
  447. * @private
  448. * @param {Array} [array] The array to iterate over.
  449. * @param {Function} iteratee The function invoked per iteration.
  450. * @returns {Array} Returns `array`.
  451. */
  452. function arrayEach(array, iteratee) {
  453. var index = -1,
  454. length = array == null ? 0 : array.length;
  455. while (++index < length) {
  456. if (iteratee(array[index], index, array) === false) {
  457. break;
  458. }
  459. }
  460. return array;
  461. }
  462. /**
  463. * A specialized version of `_.forEachRight` for arrays without support for
  464. * iteratee shorthands.
  465. *
  466. * @private
  467. * @param {Array} [array] The array to iterate over.
  468. * @param {Function} iteratee The function invoked per iteration.
  469. * @returns {Array} Returns `array`.
  470. */
  471. function arrayEachRight(array, iteratee) {
  472. var length = array == null ? 0 : array.length;
  473. while (length--) {
  474. if (iteratee(array[length], length, array) === false) {
  475. break;
  476. }
  477. }
  478. return array;
  479. }
  480. /**
  481. * A specialized version of `_.every` for arrays without support for
  482. * iteratee shorthands.
  483. *
  484. * @private
  485. * @param {Array} [array] The array to iterate over.
  486. * @param {Function} predicate The function invoked per iteration.
  487. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  488. * else `false`.
  489. */
  490. function arrayEvery(array, predicate) {
  491. var index = -1,
  492. length = array == null ? 0 : array.length;
  493. while (++index < length) {
  494. if (!predicate(array[index], index, array)) {
  495. return false;
  496. }
  497. }
  498. return true;
  499. }
  500. /**
  501. * A specialized version of `_.filter` for arrays without support for
  502. * iteratee shorthands.
  503. *
  504. * @private
  505. * @param {Array} [array] The array to iterate over.
  506. * @param {Function} predicate The function invoked per iteration.
  507. * @returns {Array} Returns the new filtered array.
  508. */
  509. function arrayFilter(array, predicate) {
  510. var index = -1,
  511. length = array == null ? 0 : array.length,
  512. resIndex = 0,
  513. result = [];
  514. while (++index < length) {
  515. var value = array[index];
  516. if (predicate(value, index, array)) {
  517. result[resIndex++] = value;
  518. }
  519. }
  520. return result;
  521. }
  522. /**
  523. * A specialized version of `_.includes` for arrays without support for
  524. * specifying an index to search from.
  525. *
  526. * @private
  527. * @param {Array} [array] The array to inspect.
  528. * @param {*} target The value to search for.
  529. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  530. */
  531. function arrayIncludes(array, value) {
  532. var length = array == null ? 0 : array.length;
  533. return !!length && baseIndexOf(array, value, 0) > -1;
  534. }
  535. /**
  536. * This function is like `arrayIncludes` except that it accepts a comparator.
  537. *
  538. * @private
  539. * @param {Array} [array] The array to inspect.
  540. * @param {*} target The value to search for.
  541. * @param {Function} comparator The comparator invoked per element.
  542. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  543. */
  544. function arrayIncludesWith(array, value, comparator) {
  545. var index = -1,
  546. length = array == null ? 0 : array.length;
  547. while (++index < length) {
  548. if (comparator(value, array[index])) {
  549. return true;
  550. }
  551. }
  552. return false;
  553. }
  554. /**
  555. * A specialized version of `_.map` for arrays without support for iteratee
  556. * shorthands.
  557. *
  558. * @private
  559. * @param {Array} [array] The array to iterate over.
  560. * @param {Function} iteratee The function invoked per iteration.
  561. * @returns {Array} Returns the new mapped array.
  562. */
  563. function arrayMap(array, iteratee) {
  564. var index = -1,
  565. length = array == null ? 0 : array.length,
  566. result = Array(length);
  567. while (++index < length) {
  568. result[index] = iteratee(array[index], index, array);
  569. }
  570. return result;
  571. }
  572. /**
  573. * Appends the elements of `values` to `array`.
  574. *
  575. * @private
  576. * @param {Array} array The array to modify.
  577. * @param {Array} values The values to append.
  578. * @returns {Array} Returns `array`.
  579. */
  580. function arrayPush(array, values) {
  581. var index = -1,
  582. length = values.length,
  583. offset = array.length;
  584. while (++index < length) {
  585. array[offset + index] = values[index];
  586. }
  587. return array;
  588. }
  589. /**
  590. * A specialized version of `_.reduce` for arrays without support for
  591. * iteratee shorthands.
  592. *
  593. * @private
  594. * @param {Array} [array] The array to iterate over.
  595. * @param {Function} iteratee The function invoked per iteration.
  596. * @param {*} [accumulator] The initial value.
  597. * @param {boolean} [initAccum] Specify using the first element of `array` as
  598. * the initial value.
  599. * @returns {*} Returns the accumulated value.
  600. */
  601. function arrayReduce(array, iteratee, accumulator, initAccum) {
  602. var index = -1,
  603. length = array == null ? 0 : array.length;
  604. if (initAccum && length) {
  605. accumulator = array[++index];
  606. }
  607. while (++index < length) {
  608. accumulator = iteratee(accumulator, array[index], index, array);
  609. }
  610. return accumulator;
  611. }
  612. /**
  613. * A specialized version of `_.reduceRight` for arrays without support for
  614. * iteratee shorthands.
  615. *
  616. * @private
  617. * @param {Array} [array] The array to iterate over.
  618. * @param {Function} iteratee The function invoked per iteration.
  619. * @param {*} [accumulator] The initial value.
  620. * @param {boolean} [initAccum] Specify using the last element of `array` as
  621. * the initial value.
  622. * @returns {*} Returns the accumulated value.
  623. */
  624. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  625. var length = array == null ? 0 : array.length;
  626. if (initAccum && length) {
  627. accumulator = array[--length];
  628. }
  629. while (length--) {
  630. accumulator = iteratee(accumulator, array[length], length, array);
  631. }
  632. return accumulator;
  633. }
  634. /**
  635. * A specialized version of `_.some` for arrays without support for iteratee
  636. * shorthands.
  637. *
  638. * @private
  639. * @param {Array} [array] The array to iterate over.
  640. * @param {Function} predicate The function invoked per iteration.
  641. * @returns {boolean} Returns `true` if any element passes the predicate check,
  642. * else `false`.
  643. */
  644. function arraySome(array, predicate) {
  645. var index = -1,
  646. length = array == null ? 0 : array.length;
  647. while (++index < length) {
  648. if (predicate(array[index], index, array)) {
  649. return true;
  650. }
  651. }
  652. return false;
  653. }
  654. /**
  655. * Gets the size of an ASCII `string`.
  656. *
  657. * @private
  658. * @param {string} string The string inspect.
  659. * @returns {number} Returns the string size.
  660. */
  661. var asciiSize = baseProperty('length');
  662. /**
  663. * Converts an ASCII `string` to an array.
  664. *
  665. * @private
  666. * @param {string} string The string to convert.
  667. * @returns {Array} Returns the converted array.
  668. */
  669. function asciiToArray(string) {
  670. return string.split('');
  671. }
  672. /**
  673. * Splits an ASCII `string` into an array of its words.
  674. *
  675. * @private
  676. * @param {string} The string to inspect.
  677. * @returns {Array} Returns the words of `string`.
  678. */
  679. function asciiWords(string) {
  680. return string.match(reAsciiWord) || [];
  681. }
  682. /**
  683. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  684. * without support for iteratee shorthands, which iterates over `collection`
  685. * using `eachFunc`.
  686. *
  687. * @private
  688. * @param {Array|Object} collection The collection to inspect.
  689. * @param {Function} predicate The function invoked per iteration.
  690. * @param {Function} eachFunc The function to iterate over `collection`.
  691. * @returns {*} Returns the found element or its key, else `undefined`.
  692. */
  693. function baseFindKey(collection, predicate, eachFunc) {
  694. var result;
  695. eachFunc(collection, function(value, key, collection) {
  696. if (predicate(value, key, collection)) {
  697. result = key;
  698. return false;
  699. }
  700. });
  701. return result;
  702. }
  703. /**
  704. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  705. * support for iteratee shorthands.
  706. *
  707. * @private
  708. * @param {Array} array The array to inspect.
  709. * @param {Function} predicate The function invoked per iteration.
  710. * @param {number} fromIndex The index to search from.
  711. * @param {boolean} [fromRight] Specify iterating from right to left.
  712. * @returns {number} Returns the index of the matched value, else `-1`.
  713. */
  714. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  715. var length = array.length,
  716. index = fromIndex + (fromRight ? 1 : -1);
  717. while ((fromRight ? index-- : ++index < length)) {
  718. if (predicate(array[index], index, array)) {
  719. return index;
  720. }
  721. }
  722. return -1;
  723. }
  724. /**
  725. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  726. *
  727. * @private
  728. * @param {Array} array The array to inspect.
  729. * @param {*} value The value to search for.
  730. * @param {number} fromIndex The index to search from.
  731. * @returns {number} Returns the index of the matched value, else `-1`.
  732. */
  733. function baseIndexOf(array, value, fromIndex) {
  734. return value === value
  735. ? strictIndexOf(array, value, fromIndex)
  736. : baseFindIndex(array, baseIsNaN, fromIndex);
  737. }
  738. /**
  739. * This function is like `baseIndexOf` except that it accepts a comparator.
  740. *
  741. * @private
  742. * @param {Array} array The array to inspect.
  743. * @param {*} value The value to search for.
  744. * @param {number} fromIndex The index to search from.
  745. * @param {Function} comparator The comparator invoked per element.
  746. * @returns {number} Returns the index of the matched value, else `-1`.
  747. */
  748. function baseIndexOfWith(array, value, fromIndex, comparator) {
  749. var index = fromIndex - 1,
  750. length = array.length;
  751. while (++index < length) {
  752. if (comparator(array[index], value)) {
  753. return index;
  754. }
  755. }
  756. return -1;
  757. }
  758. /**
  759. * The base implementation of `_.isNaN` without support for number objects.
  760. *
  761. * @private
  762. * @param {*} value The value to check.
  763. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  764. */
  765. function baseIsNaN(value) {
  766. return value !== value;
  767. }
  768. /**
  769. * The base implementation of `_.mean` and `_.meanBy` without support for
  770. * iteratee shorthands.
  771. *
  772. * @private
  773. * @param {Array} array The array to iterate over.
  774. * @param {Function} iteratee The function invoked per iteration.
  775. * @returns {number} Returns the mean.
  776. */
  777. function baseMean(array, iteratee) {
  778. var length = array == null ? 0 : array.length;
  779. return length ? (baseSum(array, iteratee) / length) : NAN;
  780. }
  781. /**
  782. * The base implementation of `_.property` without support for deep paths.
  783. *
  784. * @private
  785. * @param {string} key The key of the property to get.
  786. * @returns {Function} Returns the new accessor function.
  787. */
  788. function baseProperty(key) {
  789. return function(object) {
  790. return object == null ? undefined : object[key];
  791. };
  792. }
  793. /**
  794. * The base implementation of `_.propertyOf` without support for deep paths.
  795. *
  796. * @private
  797. * @param {Object} object The object to query.
  798. * @returns {Function} Returns the new accessor function.
  799. */
  800. function basePropertyOf(object) {
  801. return function(key) {
  802. return object == null ? undefined : object[key];
  803. };
  804. }
  805. /**
  806. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  807. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  808. *
  809. * @private
  810. * @param {Array|Object} collection The collection to iterate over.
  811. * @param {Function} iteratee The function invoked per iteration.
  812. * @param {*} accumulator The initial value.
  813. * @param {boolean} initAccum Specify using the first or last element of
  814. * `collection` as the initial value.
  815. * @param {Function} eachFunc The function to iterate over `collection`.
  816. * @returns {*} Returns the accumulated value.
  817. */
  818. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  819. eachFunc(collection, function(value, index, collection) {
  820. accumulator = initAccum
  821. ? (initAccum = false, value)
  822. : iteratee(accumulator, value, index, collection);
  823. });
  824. return accumulator;
  825. }
  826. /**
  827. * The base implementation of `_.sortBy` which uses `comparer` to define the
  828. * sort order of `array` and replaces criteria objects with their corresponding
  829. * values.
  830. *
  831. * @private
  832. * @param {Array} array The array to sort.
  833. * @param {Function} comparer The function to define sort order.
  834. * @returns {Array} Returns `array`.
  835. */
  836. function baseSortBy(array, comparer) {
  837. var length = array.length;
  838. array.sort(comparer);
  839. while (length--) {
  840. array[length] = array[length].value;
  841. }
  842. return array;
  843. }
  844. /**
  845. * The base implementation of `_.sum` and `_.sumBy` without support for
  846. * iteratee shorthands.
  847. *
  848. * @private
  849. * @param {Array} array The array to iterate over.
  850. * @param {Function} iteratee The function invoked per iteration.
  851. * @returns {number} Returns the sum.
  852. */
  853. function baseSum(array, iteratee) {
  854. var result,
  855. index = -1,
  856. length = array.length;
  857. while (++index < length) {
  858. var current = iteratee(array[index]);
  859. if (current !== undefined) {
  860. result = result === undefined ? current : (result + current);
  861. }
  862. }
  863. return result;
  864. }
  865. /**
  866. * The base implementation of `_.times` without support for iteratee shorthands
  867. * or max array length checks.
  868. *
  869. * @private
  870. * @param {number} n The number of times to invoke `iteratee`.
  871. * @param {Function} iteratee The function invoked per iteration.
  872. * @returns {Array} Returns the array of results.
  873. */
  874. function baseTimes(n, iteratee) {
  875. var index = -1,
  876. result = Array(n);
  877. while (++index < n) {
  878. result[index] = iteratee(index);
  879. }
  880. return result;
  881. }
  882. /**
  883. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  884. * of key-value pairs for `object` corresponding to the property names of `props`.
  885. *
  886. * @private
  887. * @param {Object} object The object to query.
  888. * @param {Array} props The property names to get values for.
  889. * @returns {Object} Returns the key-value pairs.
  890. */
  891. function baseToPairs(object, props) {
  892. return arrayMap(props, function(key) {
  893. return [key, object[key]];
  894. });
  895. }
  896. /**
  897. * The base implementation of `_.trim`.
  898. *
  899. * @private
  900. * @param {string} string The string to trim.
  901. * @returns {string} Returns the trimmed string.
  902. */
  903. function baseTrim(string) {
  904. return string
  905. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  906. : string;
  907. }
  908. /**
  909. * The base implementation of `_.unary` without support for storing metadata.
  910. *
  911. * @private
  912. * @param {Function} func The function to cap arguments for.
  913. * @returns {Function} Returns the new capped function.
  914. */
  915. function baseUnary(func) {
  916. return function(value) {
  917. return func(value);
  918. };
  919. }
  920. /**
  921. * The base implementation of `_.values` and `_.valuesIn` which creates an
  922. * array of `object` property values corresponding to the property names
  923. * of `props`.
  924. *
  925. * @private
  926. * @param {Object} object The object to query.
  927. * @param {Array} props The property names to get values for.
  928. * @returns {Object} Returns the array of property values.
  929. */
  930. function baseValues(object, props) {
  931. return arrayMap(props, function(key) {
  932. return object[key];
  933. });
  934. }
  935. /**
  936. * Checks if a `cache` value for `key` exists.
  937. *
  938. * @private
  939. * @param {Object} cache The cache to query.
  940. * @param {string} key The key of the entry to check.
  941. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  942. */
  943. function cacheHas(cache, key) {
  944. return cache.has(key);
  945. }
  946. /**
  947. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  948. * that is not found in the character symbols.
  949. *
  950. * @private
  951. * @param {Array} strSymbols The string symbols to inspect.
  952. * @param {Array} chrSymbols The character symbols to find.
  953. * @returns {number} Returns the index of the first unmatched string symbol.
  954. */
  955. function charsStartIndex(strSymbols, chrSymbols) {
  956. var index = -1,
  957. length = strSymbols.length;
  958. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  959. return index;
  960. }
  961. /**
  962. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  963. * that is not found in the character symbols.
  964. *
  965. * @private
  966. * @param {Array} strSymbols The string symbols to inspect.
  967. * @param {Array} chrSymbols The character symbols to find.
  968. * @returns {number} Returns the index of the last unmatched string symbol.
  969. */
  970. function charsEndIndex(strSymbols, chrSymbols) {
  971. var index = strSymbols.length;
  972. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  973. return index;
  974. }
  975. /**
  976. * Gets the number of `placeholder` occurrences in `array`.
  977. *
  978. * @private
  979. * @param {Array} array The array to inspect.
  980. * @param {*} placeholder The placeholder to search for.
  981. * @returns {number} Returns the placeholder count.
  982. */
  983. function countHolders(array, placeholder) {
  984. var length = array.length,
  985. result = 0;
  986. while (length--) {
  987. if (array[length] === placeholder) {
  988. ++result;
  989. }
  990. }
  991. return result;
  992. }
  993. /**
  994. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  995. * letters to basic Latin letters.
  996. *
  997. * @private
  998. * @param {string} letter The matched letter to deburr.
  999. * @returns {string} Returns the deburred letter.
  1000. */
  1001. var deburrLetter = basePropertyOf(deburredLetters);
  1002. /**
  1003. * Used by `_.escape` to convert characters to HTML entities.
  1004. *
  1005. * @private
  1006. * @param {string} chr The matched character to escape.
  1007. * @returns {string} Returns the escaped character.
  1008. */
  1009. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  1010. /**
  1011. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  1012. *
  1013. * @private
  1014. * @param {string} chr The matched character to escape.
  1015. * @returns {string} Returns the escaped character.
  1016. */
  1017. function escapeStringChar(chr) {
  1018. return '\\' + stringEscapes[chr];
  1019. }
  1020. /**
  1021. * Gets the value at `key` of `object`.
  1022. *
  1023. * @private
  1024. * @param {Object} [object] The object to query.
  1025. * @param {string} key The key of the property to get.
  1026. * @returns {*} Returns the property value.
  1027. */
  1028. function getValue(object, key) {
  1029. return object == null ? undefined : object[key];
  1030. }
  1031. /**
  1032. * Checks if `string` contains Unicode symbols.
  1033. *
  1034. * @private
  1035. * @param {string} string The string to inspect.
  1036. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  1037. */
  1038. function hasUnicode(string) {
  1039. return reHasUnicode.test(string);
  1040. }
  1041. /**
  1042. * Checks if `string` contains a word composed of Unicode symbols.
  1043. *
  1044. * @private
  1045. * @param {string} string The string to inspect.
  1046. * @returns {boolean} Returns `true` if a word is found, else `false`.
  1047. */
  1048. function hasUnicodeWord(string) {
  1049. return reHasUnicodeWord.test(string);
  1050. }
  1051. /**
  1052. * Converts `iterator` to an array.
  1053. *
  1054. * @private
  1055. * @param {Object} iterator The iterator to convert.
  1056. * @returns {Array} Returns the converted array.
  1057. */
  1058. function iteratorToArray(iterator) {
  1059. var data,
  1060. result = [];
  1061. while (!(data = iterator.next()).done) {
  1062. result.push(data.value);
  1063. }
  1064. return result;
  1065. }
  1066. /**
  1067. * Converts `map` to its key-value pairs.
  1068. *
  1069. * @private
  1070. * @param {Object} map The map to convert.
  1071. * @returns {Array} Returns the key-value pairs.
  1072. */
  1073. function mapToArray(map) {
  1074. var index = -1,
  1075. result = Array(map.size);
  1076. map.forEach(function(value, key) {
  1077. result[++index] = [key, value];
  1078. });
  1079. return result;
  1080. }
  1081. /**
  1082. * Creates a unary function that invokes `func` with its argument transformed.
  1083. *
  1084. * @private
  1085. * @param {Function} func The function to wrap.
  1086. * @param {Function} transform The argument transform.
  1087. * @returns {Function} Returns the new function.
  1088. */
  1089. function overArg(func, transform) {
  1090. return function(arg) {
  1091. return func(transform(arg));
  1092. };
  1093. }
  1094. /**
  1095. * Replaces all `placeholder` elements in `array` with an internal placeholder
  1096. * and returns an array of their indexes.
  1097. *
  1098. * @private
  1099. * @param {Array} array The array to modify.
  1100. * @param {*} placeholder The placeholder to replace.
  1101. * @returns {Array} Returns the new array of placeholder indexes.
  1102. */
  1103. function replaceHolders(array, placeholder) {
  1104. var index = -1,
  1105. length = array.length,
  1106. resIndex = 0,
  1107. result = [];
  1108. while (++index < length) {
  1109. var value = array[index];
  1110. if (value === placeholder || value === PLACEHOLDER) {
  1111. array[index] = PLACEHOLDER;
  1112. result[resIndex++] = index;
  1113. }
  1114. }
  1115. return result;
  1116. }
  1117. /**
  1118. * Converts `set` to an array of its values.
  1119. *
  1120. * @private
  1121. * @param {Object} set The set to convert.
  1122. * @returns {Array} Returns the values.
  1123. */
  1124. function setToArray(set) {
  1125. var index = -1,
  1126. result = Array(set.size);
  1127. set.forEach(function(value) {
  1128. result[++index] = value;
  1129. });
  1130. return result;
  1131. }
  1132. /**
  1133. * Converts `set` to its value-value pairs.
  1134. *
  1135. * @private
  1136. * @param {Object} set The set to convert.
  1137. * @returns {Array} Returns the value-value pairs.
  1138. */
  1139. function setToPairs(set) {
  1140. var index = -1,
  1141. result = Array(set.size);
  1142. set.forEach(function(value) {
  1143. result[++index] = [value, value];
  1144. });
  1145. return result;
  1146. }
  1147. /**
  1148. * A specialized version of `_.indexOf` which performs strict equality
  1149. * comparisons of values, i.e. `===`.
  1150. *
  1151. * @private
  1152. * @param {Array} array The array to inspect.
  1153. * @param {*} value The value to search for.
  1154. * @param {number} fromIndex The index to search from.
  1155. * @returns {number} Returns the index of the matched value, else `-1`.
  1156. */
  1157. function strictIndexOf(array, value, fromIndex) {
  1158. var index = fromIndex - 1,
  1159. length = array.length;
  1160. while (++index < length) {
  1161. if (array[index] === value) {
  1162. return index;
  1163. }
  1164. }
  1165. return -1;
  1166. }
  1167. /**
  1168. * A specialized version of `_.lastIndexOf` which performs strict equality
  1169. * comparisons of values, i.e. `===`.
  1170. *
  1171. * @private
  1172. * @param {Array} array The array to inspect.
  1173. * @param {*} value The value to search for.
  1174. * @param {number} fromIndex The index to search from.
  1175. * @returns {number} Returns the index of the matched value, else `-1`.
  1176. */
  1177. function strictLastIndexOf(array, value, fromIndex) {
  1178. var index = fromIndex + 1;
  1179. while (index--) {
  1180. if (array[index] === value) {
  1181. return index;
  1182. }
  1183. }
  1184. return index;
  1185. }
  1186. /**
  1187. * Gets the number of symbols in `string`.
  1188. *
  1189. * @private
  1190. * @param {string} string The string to inspect.
  1191. * @returns {number} Returns the string size.
  1192. */
  1193. function stringSize(string) {
  1194. return hasUnicode(string)
  1195. ? unicodeSize(string)
  1196. : asciiSize(string);
  1197. }
  1198. /**
  1199. * Converts `string` to an array.
  1200. *
  1201. * @private
  1202. * @param {string} string The string to convert.
  1203. * @returns {Array} Returns the converted array.
  1204. */
  1205. function stringToArray(string) {
  1206. return hasUnicode(string)
  1207. ? unicodeToArray(string)
  1208. : asciiToArray(string);
  1209. }
  1210. /**
  1211. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  1212. * character of `string`.
  1213. *
  1214. * @private
  1215. * @param {string} string The string to inspect.
  1216. * @returns {number} Returns the index of the last non-whitespace character.
  1217. */
  1218. function trimmedEndIndex(string) {
  1219. var index = string.length;
  1220. while (index-- && reWhitespace.test(string.charAt(index))) {}
  1221. return index;
  1222. }
  1223. /**
  1224. * Used by `_.unescape` to convert HTML entities to characters.
  1225. *
  1226. * @private
  1227. * @param {string} chr The matched character to unescape.
  1228. * @returns {string} Returns the unescaped character.
  1229. */
  1230. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  1231. /**
  1232. * Gets the size of a Unicode `string`.
  1233. *
  1234. * @private
  1235. * @param {string} string The string inspect.
  1236. * @returns {number} Returns the string size.
  1237. */
  1238. function unicodeSize(string) {
  1239. var result = reUnicode.lastIndex = 0;
  1240. while (reUnicode.test(string)) {
  1241. ++result;
  1242. }
  1243. return result;
  1244. }
  1245. /**
  1246. * Converts a Unicode `string` to an array.
  1247. *
  1248. * @private
  1249. * @param {string} string The string to convert.
  1250. * @returns {Array} Returns the converted array.
  1251. */
  1252. function unicodeToArray(string) {
  1253. return string.match(reUnicode) || [];
  1254. }
  1255. /**
  1256. * Splits a Unicode `string` into an array of its words.
  1257. *
  1258. * @private
  1259. * @param {string} The string to inspect.
  1260. * @returns {Array} Returns the words of `string`.
  1261. */
  1262. function unicodeWords(string) {
  1263. return string.match(reUnicodeWord) || [];
  1264. }
  1265. /*--------------------------------------------------------------------------*/
  1266. /**
  1267. * Create a new pristine `lodash` function using the `context` object.
  1268. *
  1269. * @static
  1270. * @memberOf _
  1271. * @since 1.1.0
  1272. * @category Util
  1273. * @param {Object} [context=root] The context object.
  1274. * @returns {Function} Returns a new `lodash` function.
  1275. * @example
  1276. *
  1277. * _.mixin({ 'foo': _.constant('foo') });
  1278. *
  1279. * var lodash = _.runInContext();
  1280. * lodash.mixin({ 'bar': lodash.constant('bar') });
  1281. *
  1282. * _.isFunction(_.foo);
  1283. * // => true
  1284. * _.isFunction(_.bar);
  1285. * // => false
  1286. *
  1287. * lodash.isFunction(lodash.foo);
  1288. * // => false
  1289. * lodash.isFunction(lodash.bar);
  1290. * // => true
  1291. *
  1292. * // Create a suped-up `defer` in Node.js.
  1293. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  1294. */
  1295. var runInContext = (function runInContext(context) {
  1296. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  1297. /** Built-in constructor references. */
  1298. var Array = context.Array,
  1299. Date = context.Date,
  1300. Error = context.Error,
  1301. Function = context.Function,
  1302. Math = context.Math,
  1303. Object = context.Object,
  1304. RegExp = context.RegExp,
  1305. String = context.String,
  1306. TypeError = context.TypeError;
  1307. /** Used for built-in method references. */
  1308. var arrayProto = Array.prototype,
  1309. funcProto = Function.prototype,
  1310. objectProto = Object.prototype;
  1311. /** Used to detect overreaching core-js shims. */
  1312. var coreJsData = context['__core-js_shared__'];
  1313. /** Used to resolve the decompiled source of functions. */
  1314. var funcToString = funcProto.toString;
  1315. /** Used to check objects for own properties. */
  1316. var hasOwnProperty = objectProto.hasOwnProperty;
  1317. /** Used to generate unique IDs. */
  1318. var idCounter = 0;
  1319. /** Used to detect methods masquerading as native. */
  1320. var maskSrcKey = (function() {
  1321. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1322. return uid ? ('Symbol(src)_1.' + uid) : '';
  1323. }());
  1324. /**
  1325. * Used to resolve the
  1326. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1327. * of values.
  1328. */
  1329. var nativeObjectToString = objectProto.toString;
  1330. /** Used to infer the `Object` constructor. */
  1331. var objectCtorString = funcToString.call(Object);
  1332. /** Used to restore the original `_` reference in `_.noConflict`. */
  1333. var oldDash = root._;
  1334. /** Used to detect if a method is native. */
  1335. var reIsNative = RegExp('^' +
  1336. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  1337. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1338. );
  1339. /** Built-in value references. */
  1340. var Buffer = moduleExports ? context.Buffer : undefined,
  1341. Symbol = context.Symbol,
  1342. Uint8Array = context.Uint8Array,
  1343. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  1344. getPrototype = overArg(Object.getPrototypeOf, Object),
  1345. objectCreate = Object.create,
  1346. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1347. splice = arrayProto.splice,
  1348. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  1349. symIterator = Symbol ? Symbol.iterator : undefined,
  1350. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  1351. var defineProperty = (function() {
  1352. try {
  1353. var func = getNative(Object, 'defineProperty');
  1354. func({}, '', {});
  1355. return func;
  1356. } catch (e) {}
  1357. }());
  1358. /** Mocked built-ins. */
  1359. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  1360. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  1361. ctxSetTimeout = context.setTimeout !== ro