PageRenderTime 61ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/js/lodash.js

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