/node_modules/lodash/lodash.js

https://bitbucket.org/coleman333/smartsite · JavaScript · 17097 lines · 15207 code · 179 blank · 1711 comment · 151 complexity · a08a27a72d5c5e36583e6aef1e72642b MD5 · raw file

Large files are truncated click here to view the full file

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