PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/project/dexter-server/public/js/ng-lodash.js

https://gitlab.com/admin-github-cloud/Dexter
JavaScript | 1040 lines | 1019 code | 0 blank | 21 comment | 0 complexity | ed575485fdbda6b65dc81eab01e8d343 MD5 | raw file
  1. /**
  2. * @license
  3. * lodash 3.8.0 (Custom Build) <https://lodash.com/>
  4. * Build: `lodash modern exports="amd,commonjs,node" iife="angular.module('ngLodash', []).constant('lodash', null).config(function ($provide) { %output% $provide.constant('lodash', _);});" --output build/ng-lodash.js`
  5. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  6. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  7. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  8. * Available under MIT license <https://lodash.com/license>
  9. */
  10. angular.module('ngLodash', []).constant('lodash', null).config([
  11. '$provide',
  12. function ($provide) {
  13. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  14. var undefined;
  15. /** Used as the semantic version number. */
  16. var VERSION = '3.8.0';
  17. /** Used to compose bitmasks for wrapper metadata. */
  18. var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_BOUND_FLAG = 4, CURRY_FLAG = 8, CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, ARY_FLAG = 128, REARG_FLAG = 256;
  19. /** Used as default options for `_.trunc`. */
  20. var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = '...';
  21. /** Used to detect when a function becomes hot. */
  22. var HOT_COUNT = 150, HOT_SPAN = 16;
  23. /** Used to indicate the type of lazy iteratees. */
  24. var LAZY_DROP_WHILE_FLAG = 0, LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2;
  25. /** Used as the `TypeError` message for "Functions" methods. */
  26. var FUNC_ERROR_TEXT = 'Expected a function';
  27. /** Used as the internal argument placeholder. */
  28. var PLACEHOLDER = '__lodash_placeholder__';
  29. /** `Object#toString` result references. */
  30. var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]';
  31. var arrayBufferTag = '[object ArrayBuffer]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]';
  32. /** Used to match empty string literals in compiled template source. */
  33. var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  34. /** Used to match HTML entities and HTML characters. */
  35. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g, reHasEscapedHtml = RegExp(reEscapedHtml.source), reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  36. /** Used to match template delimiters. */
  37. var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g;
  38. /** Used to match property names within property paths. */
  39. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  40. /**
  41. * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
  42. * In addition to special characters the forward slash is escaped to allow for
  43. * easier `eval` use and `Function` compilation.
  44. */
  45. var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, reHasRegExpChars = RegExp(reRegExpChars.source);
  46. /** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */
  47. var reComboMark = /[\u0300-\u036f\ufe20-\ufe23]/g;
  48. /** Used to match backslashes in property paths. */
  49. var reEscapeChar = /\\(\\)?/g;
  50. /** Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */
  51. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  52. /** Used to match `RegExp` flags from their coerced string values. */
  53. var reFlags = /\w*$/;
  54. /** Used to detect hexadecimal string values. */
  55. var reHasHexPrefix = /^0[xX]/;
  56. /** Used to detect host constructors (Safari > 5). */
  57. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  58. /** Used to match latin-1 supplementary letters (excluding mathematical operators). */
  59. var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
  60. /** Used to ensure capturing order of template delimiters. */
  61. var reNoMatch = /($^)/;
  62. /** Used to match unescaped characters in compiled string literals. */
  63. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  64. /** Used to match words to create compound words. */
  65. var reWords = function () {
  66. var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+';
  67. return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
  68. }();
  69. /** Used to detect and test for whitespace. */
  70. var whitespace = ' \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';
  71. /** Used to assign default `context` object properties. */
  72. var contextProps = [
  73. 'Array',
  74. 'ArrayBuffer',
  75. 'Date',
  76. 'Error',
  77. 'Float32Array',
  78. 'Float64Array',
  79. 'Function',
  80. 'Int8Array',
  81. 'Int16Array',
  82. 'Int32Array',
  83. 'Math',
  84. 'Number',
  85. 'Object',
  86. 'RegExp',
  87. 'Set',
  88. 'String',
  89. '_',
  90. 'clearTimeout',
  91. 'document',
  92. 'isFinite',
  93. 'parseInt',
  94. 'setTimeout',
  95. 'TypeError',
  96. 'Uint8Array',
  97. 'Uint8ClampedArray',
  98. 'Uint16Array',
  99. 'Uint32Array',
  100. 'WeakMap',
  101. 'window'
  102. ];
  103. /** Used to make template sourceURLs easier to identify. */
  104. var templateCounter = -1;
  105. /** Used to identify `toStringTag` values of typed arrays. */
  106. var typedArrayTags = {};
  107. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  108. typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  109. /** Used to identify `toStringTag` values supported by `_.clone`. */
  110. var cloneableTags = {};
  111. cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[stringTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  112. cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[mapTag] = cloneableTags[setTag] = cloneableTags[weakMapTag] = false;
  113. /** Used as an internal `_.debounce` options object by `_.throttle`. */
  114. var debounceOptions = {
  115. 'leading': false,
  116. 'maxWait': 0,
  117. 'trailing': false
  118. };
  119. /** Used to map latin-1 supplementary letters to basic latin letters. */
  120. var deburredLetters = {
  121. '\xc0': 'A',
  122. '\xc1': 'A',
  123. '\xc2': 'A',
  124. '\xc3': 'A',
  125. '\xc4': 'A',
  126. '\xc5': 'A',
  127. '\xe0': 'a',
  128. '\xe1': 'a',
  129. '\xe2': 'a',
  130. '\xe3': 'a',
  131. '\xe4': 'a',
  132. '\xe5': 'a',
  133. '\xc7': 'C',
  134. '\xe7': 'c',
  135. '\xd0': 'D',
  136. '\xf0': 'd',
  137. '\xc8': 'E',
  138. '\xc9': 'E',
  139. '\xca': 'E',
  140. '\xcb': 'E',
  141. '\xe8': 'e',
  142. '\xe9': 'e',
  143. '\xea': 'e',
  144. '\xeb': 'e',
  145. '\xcc': 'I',
  146. '\xcd': 'I',
  147. '\xce': 'I',
  148. '\xcf': 'I',
  149. '\xec': 'i',
  150. '\xed': 'i',
  151. '\xee': 'i',
  152. '\xef': 'i',
  153. '\xd1': 'N',
  154. '\xf1': 'n',
  155. '\xd2': 'O',
  156. '\xd3': 'O',
  157. '\xd4': 'O',
  158. '\xd5': 'O',
  159. '\xd6': 'O',
  160. '\xd8': 'O',
  161. '\xf2': 'o',
  162. '\xf3': 'o',
  163. '\xf4': 'o',
  164. '\xf5': 'o',
  165. '\xf6': 'o',
  166. '\xf8': 'o',
  167. '\xd9': 'U',
  168. '\xda': 'U',
  169. '\xdb': 'U',
  170. '\xdc': 'U',
  171. '\xf9': 'u',
  172. '\xfa': 'u',
  173. '\xfb': 'u',
  174. '\xfc': 'u',
  175. '\xdd': 'Y',
  176. '\xfd': 'y',
  177. '\xff': 'y',
  178. '\xc6': 'Ae',
  179. '\xe6': 'ae',
  180. '\xde': 'Th',
  181. '\xfe': 'th',
  182. '\xdf': 'ss'
  183. };
  184. /** Used to map characters to HTML entities. */
  185. var htmlEscapes = {
  186. '&': '&amp;',
  187. '<': '&lt;',
  188. '>': '&gt;',
  189. '"': '&quot;',
  190. '\'': '&#39;',
  191. '`': '&#96;'
  192. };
  193. /** Used to map HTML entities to characters. */
  194. var htmlUnescapes = {
  195. '&amp;': '&',
  196. '&lt;': '<',
  197. '&gt;': '>',
  198. '&quot;': '"',
  199. '&#39;': '\'',
  200. '&#96;': '`'
  201. };
  202. /** Used to determine if values are of the language type `Object`. */
  203. var objectTypes = {
  204. 'function': true,
  205. 'object': true
  206. };
  207. /** Used to escape characters for inclusion in compiled string literals. */
  208. var stringEscapes = {
  209. '\\': '\\',
  210. '\'': '\'',
  211. '\n': 'n',
  212. '\r': 'r',
  213. '\u2028': 'u2028',
  214. '\u2029': 'u2029'
  215. };
  216. /** Detect free variable `exports`. */
  217. var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
  218. /** Detect free variable `module`. */
  219. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  220. /** Detect free variable `global` from Node.js. */
  221. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
  222. /** Detect free variable `self`. */
  223. var freeSelf = objectTypes[typeof self] && self && self.Object && self;
  224. /** Detect free variable `window`. */
  225. var freeWindow = objectTypes[typeof window] && window && window.Object && window;
  226. /** Detect the popular CommonJS extension `module.exports`. */
  227. var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
  228. /**
  229. * Used as a reference to the global object.
  230. *
  231. * The `this` value is used if it is the global object to avoid Greasemonkey's
  232. * restricted `window` object, otherwise the `window` object is used.
  233. */
  234. var root = freeGlobal || freeWindow !== (this && this.window) && freeWindow || freeSelf || this;
  235. /**
  236. * The base implementation of `compareAscending` which compares values and
  237. * sorts them in ascending order without guaranteeing a stable sort.
  238. *
  239. * @private
  240. * @param {*} value The value to compare to `other`.
  241. * @param {*} other The value to compare to `value`.
  242. * @returns {number} Returns the sort order indicator for `value`.
  243. */
  244. function baseCompareAscending(value, other) {
  245. if (value !== other) {
  246. var valIsReflexive = value === value, othIsReflexive = other === other;
  247. if (value > other || !valIsReflexive || value === undefined && othIsReflexive) {
  248. return 1;
  249. }
  250. if (value < other || !othIsReflexive || other === undefined && valIsReflexive) {
  251. return -1;
  252. }
  253. }
  254. return 0;
  255. }
  256. /**
  257. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  258. * support for callback shorthands and `this` binding.
  259. *
  260. * @private
  261. * @param {Array} array The array to search.
  262. * @param {Function} predicate The function invoked per iteration.
  263. * @param {boolean} [fromRight] Specify iterating from right to left.
  264. * @returns {number} Returns the index of the matched value, else `-1`.
  265. */
  266. function baseFindIndex(array, predicate, fromRight) {
  267. var length = array.length, index = fromRight ? length : -1;
  268. while (fromRight ? index-- : ++index < length) {
  269. if (predicate(array[index], index, array)) {
  270. return index;
  271. }
  272. }
  273. return -1;
  274. }
  275. /**
  276. * The base implementation of `_.indexOf` without support for binary searches.
  277. *
  278. * @private
  279. * @param {Array} array The array to search.
  280. * @param {*} value The value to search for.
  281. * @param {number} fromIndex The index to search from.
  282. * @returns {number} Returns the index of the matched value, else `-1`.
  283. */
  284. function baseIndexOf(array, value, fromIndex) {
  285. if (value !== value) {
  286. return indexOfNaN(array, fromIndex);
  287. }
  288. var index = fromIndex - 1, length = array.length;
  289. while (++index < length) {
  290. if (array[index] === value) {
  291. return index;
  292. }
  293. }
  294. return -1;
  295. }
  296. /**
  297. * The base implementation of `_.isFunction` without support for environments
  298. * with incorrect `typeof` results.
  299. *
  300. * @private
  301. * @param {*} value The value to check.
  302. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  303. */
  304. function baseIsFunction(value) {
  305. // Avoid a Chakra JIT bug in compatibility modes of IE 11.
  306. // See https://github.com/jashkenas/underscore/issues/1621 for more details.
  307. return typeof value == 'function' || false;
  308. }
  309. /**
  310. * Converts `value` to a string if it is not one. An empty string is returned
  311. * for `null` or `undefined` values.
  312. *
  313. * @private
  314. * @param {*} value The value to process.
  315. * @returns {string} Returns the string.
  316. */
  317. function baseToString(value) {
  318. if (typeof value == 'string') {
  319. return value;
  320. }
  321. return value == null ? '' : value + '';
  322. }
  323. /**
  324. * Used by `_.max` and `_.min` as the default callback for string values.
  325. *
  326. * @private
  327. * @param {string} string The string to inspect.
  328. * @returns {number} Returns the code unit of the first character of the string.
  329. */
  330. function charAtCallback(string) {
  331. return string.charCodeAt(0);
  332. }
  333. /**
  334. * Used by `_.trim` and `_.trimLeft` to get the index of the first character
  335. * of `string` that is not found in `chars`.
  336. *
  337. * @private
  338. * @param {string} string The string to inspect.
  339. * @param {string} chars The characters to find.
  340. * @returns {number} Returns the index of the first character not found in `chars`.
  341. */
  342. function charsLeftIndex(string, chars) {
  343. var index = -1, length = string.length;
  344. while (++index < length && chars.indexOf(string.charAt(index)) > -1) {
  345. }
  346. return index;
  347. }
  348. /**
  349. * Used by `_.trim` and `_.trimRight` to get the index of the last character
  350. * of `string` that is not found in `chars`.
  351. *
  352. * @private
  353. * @param {string} string The string to inspect.
  354. * @param {string} chars The characters to find.
  355. * @returns {number} Returns the index of the last character not found in `chars`.
  356. */
  357. function charsRightIndex(string, chars) {
  358. var index = string.length;
  359. while (index-- && chars.indexOf(string.charAt(index)) > -1) {
  360. }
  361. return index;
  362. }
  363. /**
  364. * Used by `_.sortBy` to compare transformed elements of a collection and stable
  365. * sort them in ascending order.
  366. *
  367. * @private
  368. * @param {Object} object The object to compare to `other`.
  369. * @param {Object} other The object to compare to `object`.
  370. * @returns {number} Returns the sort order indicator for `object`.
  371. */
  372. function compareAscending(object, other) {
  373. return baseCompareAscending(object.criteria, other.criteria) || object.index - other.index;
  374. }
  375. /**
  376. * Used by `_.sortByOrder` to compare multiple properties of each element
  377. * in a collection and stable sort them in the following order:
  378. *
  379. * If `orders` is unspecified, sort in ascending order for all properties.
  380. * Otherwise, for each property, sort in ascending order if its corresponding value in
  381. * orders is true, and descending order if false.
  382. *
  383. * @private
  384. * @param {Object} object The object to compare to `other`.
  385. * @param {Object} other The object to compare to `object`.
  386. * @param {boolean[]} orders The order to sort by for each property.
  387. * @returns {number} Returns the sort order indicator for `object`.
  388. */
  389. function compareMultiple(object, other, orders) {
  390. var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length = objCriteria.length, ordersLength = orders.length;
  391. while (++index < length) {
  392. var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
  393. if (result) {
  394. if (index >= ordersLength) {
  395. return result;
  396. }
  397. return result * (orders[index] ? 1 : -1);
  398. }
  399. }
  400. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  401. // that causes it, under certain circumstances, to provide the same value for
  402. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  403. // for more details.
  404. //
  405. // This also ensures a stable sort in V8 and other engines.
  406. // See https://code.google.com/p/v8/issues/detail?id=90 for more details.
  407. return object.index - other.index;
  408. }
  409. /**
  410. * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
  411. *
  412. * @private
  413. * @param {string} letter The matched letter to deburr.
  414. * @returns {string} Returns the deburred letter.
  415. */
  416. function deburrLetter(letter) {
  417. return deburredLetters[letter];
  418. }
  419. /**
  420. * Used by `_.escape` to convert characters to HTML entities.
  421. *
  422. * @private
  423. * @param {string} chr The matched character to escape.
  424. * @returns {string} Returns the escaped character.
  425. */
  426. function escapeHtmlChar(chr) {
  427. return htmlEscapes[chr];
  428. }
  429. /**
  430. * Used by `_.template` to escape characters for inclusion in compiled
  431. * string literals.
  432. *
  433. * @private
  434. * @param {string} chr The matched character to escape.
  435. * @returns {string} Returns the escaped character.
  436. */
  437. function escapeStringChar(chr) {
  438. return '\\' + stringEscapes[chr];
  439. }
  440. /**
  441. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  442. *
  443. * @private
  444. * @param {Array} array The array to search.
  445. * @param {number} fromIndex The index to search from.
  446. * @param {boolean} [fromRight] Specify iterating from right to left.
  447. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  448. */
  449. function indexOfNaN(array, fromIndex, fromRight) {
  450. var length = array.length, index = fromIndex + (fromRight ? 0 : -1);
  451. while (fromRight ? index-- : ++index < length) {
  452. var other = array[index];
  453. if (other !== other) {
  454. return index;
  455. }
  456. }
  457. return -1;
  458. }
  459. /**
  460. * Checks if `value` is object-like.
  461. *
  462. * @private
  463. * @param {*} value The value to check.
  464. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  465. */
  466. function isObjectLike(value) {
  467. return !!value && typeof value == 'object';
  468. }
  469. /**
  470. * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a
  471. * character code is whitespace.
  472. *
  473. * @private
  474. * @param {number} charCode The character code to inspect.
  475. * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.
  476. */
  477. function isSpace(charCode) {
  478. return charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160 || charCode == 5760 || charCode == 6158 || charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279);
  479. }
  480. /**
  481. * Replaces all `placeholder` elements in `array` with an internal placeholder
  482. * and returns an array of their indexes.
  483. *
  484. * @private
  485. * @param {Array} array The array to modify.
  486. * @param {*} placeholder The placeholder to replace.
  487. * @returns {Array} Returns the new array of placeholder indexes.
  488. */
  489. function replaceHolders(array, placeholder) {
  490. var index = -1, length = array.length, resIndex = -1, result = [];
  491. while (++index < length) {
  492. if (array[index] === placeholder) {
  493. array[index] = PLACEHOLDER;
  494. result[++resIndex] = index;
  495. }
  496. }
  497. return result;
  498. }
  499. /**
  500. * An implementation of `_.uniq` optimized for sorted arrays without support
  501. * for callback shorthands and `this` binding.
  502. *
  503. * @private
  504. * @param {Array} array The array to inspect.
  505. * @param {Function} [iteratee] The function invoked per iteration.
  506. * @returns {Array} Returns the new duplicate-value-free array.
  507. */
  508. function sortedUniq(array, iteratee) {
  509. var seen, index = -1, length = array.length, resIndex = -1, result = [];
  510. while (++index < length) {
  511. var value = array[index], computed = iteratee ? iteratee(value, index, array) : value;
  512. if (!index || seen !== computed) {
  513. seen = computed;
  514. result[++resIndex] = value;
  515. }
  516. }
  517. return result;
  518. }
  519. /**
  520. * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace
  521. * character of `string`.
  522. *
  523. * @private
  524. * @param {string} string The string to inspect.
  525. * @returns {number} Returns the index of the first non-whitespace character.
  526. */
  527. function trimmedLeftIndex(string) {
  528. var index = -1, length = string.length;
  529. while (++index < length && isSpace(string.charCodeAt(index))) {
  530. }
  531. return index;
  532. }
  533. /**
  534. * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace
  535. * character of `string`.
  536. *
  537. * @private
  538. * @param {string} string The string to inspect.
  539. * @returns {number} Returns the index of the last non-whitespace character.
  540. */
  541. function trimmedRightIndex(string) {
  542. var index = string.length;
  543. while (index-- && isSpace(string.charCodeAt(index))) {
  544. }
  545. return index;
  546. }
  547. /**
  548. * Used by `_.unescape` to convert HTML entities to characters.
  549. *
  550. * @private
  551. * @param {string} chr The matched character to unescape.
  552. * @returns {string} Returns the unescaped character.
  553. */
  554. function unescapeHtmlChar(chr) {
  555. return htmlUnescapes[chr];
  556. }
  557. /**
  558. * Create a new pristine `lodash` function using the given `context` object.
  559. *
  560. * @static
  561. * @memberOf _
  562. * @category Utility
  563. * @param {Object} [context=root] The context object.
  564. * @returns {Function} Returns a new `lodash` function.
  565. * @example
  566. *
  567. * _.mixin({ 'foo': _.constant('foo') });
  568. *
  569. * var lodash = _.runInContext();
  570. * lodash.mixin({ 'bar': lodash.constant('bar') });
  571. *
  572. * _.isFunction(_.foo);
  573. * // => true
  574. * _.isFunction(_.bar);
  575. * // => false
  576. *
  577. * lodash.isFunction(lodash.foo);
  578. * // => false
  579. * lodash.isFunction(lodash.bar);
  580. * // => true
  581. *
  582. * // using `context` to mock `Date#getTime` use in `_.now`
  583. * var mock = _.runInContext({
  584. * 'Date': function() {
  585. * return { 'getTime': getTimeMock };
  586. * }
  587. * });
  588. *
  589. * // or creating a suped-up `defer` in Node.js
  590. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  591. */
  592. function runInContext(context) {
  593. // Avoid issues with some ES3 environments that attempt to use values, named
  594. // after built-in constructors like `Object`, for the creation of literals.
  595. // ES5 clears this up by stating that literals must use built-in constructors.
  596. // See https://es5.github.io/#x11.1.5 for more details.
  597. context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
  598. /** Native constructor references. */
  599. var Array = context.Array, Date = context.Date, Error = context.Error, Function = context.Function, Math = context.Math, Number = context.Number, Object = context.Object, RegExp = context.RegExp, String = context.String, TypeError = context.TypeError;
  600. /** Used for native method references. */
  601. var arrayProto = Array.prototype, objectProto = Object.prototype, stringProto = String.prototype;
  602. /** Used to detect DOM support. */
  603. var document = (document = context.window) && document.document;
  604. /** Used to resolve the decompiled source of functions. */
  605. var fnToString = Function.prototype.toString;
  606. /** Used to check objects for own properties. */
  607. var hasOwnProperty = objectProto.hasOwnProperty;
  608. /** Used to generate unique IDs. */
  609. var idCounter = 0;
  610. /**
  611. * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
  612. * of values.
  613. */
  614. var objToString = objectProto.toString;
  615. /** Used to restore the original `_` reference in `_.noConflict`. */
  616. var oldDash = context._;
  617. /** Used to detect if a method is native. */
  618. var reIsNative = RegExp('^' + escapeRegExp(objToString).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  619. /** Native method references. */
  620. var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, ceil = Math.ceil, clearTimeout = context.clearTimeout, floor = Math.floor, getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols, getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, push = arrayProto.push, preventExtensions = isNative(preventExtensions = Object.preventExtensions) && preventExtensions, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = isNative(Set = context.Set) && Set, setTimeout = context.setTimeout, splice = arrayProto.splice, Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap;
  621. /** Used to clone array buffers. */
  622. var Float64Array = function () {
  623. // Safari 5 errors when using an array buffer to initialize a typed array
  624. // where the array buffer's `byteLength` is not a multiple of the typed
  625. // array's `BYTES_PER_ELEMENT`.
  626. try {
  627. var func = isNative(func = context.Float64Array) && func, result = new func(new ArrayBuffer(10), 0, 1) && func;
  628. } catch (e) {
  629. }
  630. return result;
  631. }();
  632. /** Used as `baseAssign`. */
  633. var nativeAssign = function () {
  634. // Avoid `Object.assign` in Firefox 34-37 which have an early implementation
  635. // with a now defunct try/catch behavior. See https://bugzilla.mozilla.org/show_bug.cgi?id=1103344
  636. // for more details.
  637. //
  638. // Use `Object.preventExtensions` on a plain object instead of simply using
  639. // `Object('x')` because Chrome and IE fail to throw an error when attempting
  640. // to assign values to readonly indexes of strings.
  641. var func = preventExtensions && isNative(func = Object.assign) && func;
  642. try {
  643. if (func) {
  644. var object = preventExtensions({ '1': 0 });
  645. object[0] = 1;
  646. }
  647. } catch (e) {
  648. // Only attempt in strict mode.
  649. try {
  650. func(object, 'xo');
  651. } catch (e) {
  652. }
  653. return !object[1] && func;
  654. }
  655. return false;
  656. }();
  657. /* Native method references for those with the same name as other `lodash` methods. */
  658. var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, nativeMin = Math.min, nativeNow = isNative(nativeNow = Date.now) && nativeNow, nativeNumIsFinite = isNative(nativeNumIsFinite = Number.isFinite) && nativeNumIsFinite, nativeParseInt = context.parseInt, nativeRandom = Math.random;
  659. /** Used as references for `-Infinity` and `Infinity`. */
  660. var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
  661. /** Used as references for the maximum length and index of an array. */
  662. var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  663. /** Used as the size, in bytes, of each `Float64Array` element. */
  664. var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
  665. /**
  666. * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
  667. * of an array-like value.
  668. */
  669. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  670. /** Used to store function metadata. */
  671. var metaMap = WeakMap && new WeakMap();
  672. /** Used to lookup unminified function names. */
  673. var realNames = {};
  674. /**
  675. * Creates a `lodash` object which wraps `value` to enable implicit chaining.
  676. * Methods that operate on and return arrays, collections, and functions can
  677. * be chained together. Methods that return a boolean or single value will
  678. * automatically end the chain returning the unwrapped value. Explicit chaining
  679. * may be enabled using `_.chain`. The execution of chained methods is lazy,
  680. * that is, execution is deferred until `_#value` is implicitly or explicitly
  681. * called.
  682. *
  683. * Lazy evaluation allows several methods to support shortcut fusion. Shortcut
  684. * fusion is an optimization that merges iteratees to avoid creating intermediate
  685. * arrays and reduce the number of iteratee executions.
  686. *
  687. * Chaining is supported in custom builds as long as the `_#value` method is
  688. * directly or indirectly included in the build.
  689. *
  690. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  691. *
  692. * The wrapper `Array` methods are:
  693. * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
  694. * `splice`, and `unshift`
  695. *
  696. * The wrapper `String` methods are:
  697. * `replace` and `split`
  698. *
  699. * The wrapper methods that support shortcut fusion are:
  700. * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
  701. * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,
  702. * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,
  703. * and `where`
  704. *
  705. * The chainable wrapper methods are:
  706. * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
  707. * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
  708. * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,
  709. * `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,
  710. * `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
  711. * `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
  712. * `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
  713. * `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`,
  714. * `merge`, `mixin`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
  715. * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
  716. * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
  717. * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`,
  718. * `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`,
  719. * `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`,
  720. * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`,
  721. * `without`, `wrap`, `xor`, `zip`, and `zipObject`
  722. *
  723. * The wrapper methods that are **not** chainable by default are:
  724. * `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
  725. * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
  726. * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
  727. * `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`,
  728. * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`
  729. * `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`,
  730. * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `isTypedArray`,
  731. * `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, `noConflict`,
  732. * `noop`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`,
  733. * `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, `shift`, `size`,
  734. * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, `startsWith`,
  735. * `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, `unescape`,
  736. * `uniqueId`, `value`, and `words`
  737. *
  738. * The wrapper method `sample` will return a wrapped value when `n` is provided,
  739. * otherwise an unwrapped value is returned.
  740. *
  741. * @name _
  742. * @constructor
  743. * @category Chain
  744. * @param {*} value The value to wrap in a `lodash` instance.
  745. * @returns {Object} Returns the new `lodash` wrapper instance.
  746. * @example
  747. *
  748. * var wrapped = _([1, 2, 3]);
  749. *
  750. * // returns an unwrapped value
  751. * wrapped.reduce(function(total, n) {
  752. * return total + n;
  753. * });
  754. * // => 6
  755. *
  756. * // returns a wrapped value
  757. * var squares = wrapped.map(function(n) {
  758. * return n * n;
  759. * });
  760. *
  761. * _.isArray(squares);
  762. * // => false
  763. *
  764. * _.isArray(squares.value());
  765. * // => true
  766. */
  767. function lodash(value) {
  768. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  769. if (value instanceof LodashWrapper) {
  770. return value;
  771. }
  772. if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
  773. return wrapperClone(value);
  774. }
  775. }
  776. return new LodashWrapper(value);
  777. }
  778. /**
  779. * The function whose prototype all chaining wrappers inherit from.
  780. *
  781. * @private
  782. */
  783. function baseLodash() {
  784. }
  785. /**
  786. * The base constructor for creating `lodash` wrapper objects.
  787. *
  788. * @private
  789. * @param {*} value The value to wrap.
  790. * @param {boolean} [chainAll] Enable chaining for all wrapper methods.
  791. * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.
  792. */
  793. function LodashWrapper(value, chainAll, actions) {
  794. this.__wrapped__ = value;
  795. this.__actions__ = actions || [];
  796. this.__chain__ = !!chainAll;
  797. }
  798. /**
  799. * An object environment feature flags.
  800. *
  801. * @static
  802. * @memberOf _
  803. * @type Object
  804. */
  805. var support = lodash.support = {};
  806. (function (x) {
  807. var Ctor = function () {
  808. this.x = x;
  809. }, args = arguments, object = {
  810. '0': x,
  811. 'length': x
  812. }, props = [];
  813. Ctor.prototype = {
  814. 'valueOf': x,
  815. 'y': x
  816. };
  817. for (var key in new Ctor()) {
  818. props.push(key);
  819. }
  820. /**
  821. * Detect if functions can be decompiled by `Function#toString`
  822. * (all but Firefox OS certified apps, older Opera mobile browsers, and
  823. * the PlayStation 3; forced `false` for Windows 8 apps).
  824. *
  825. * @memberOf _.support
  826. * @type boolean
  827. */
  828. support.funcDecomp = /\bthis\b/.test(function () {
  829. return this;
  830. });
  831. /**
  832. * Detect if `Function#name` is supported (all but IE).
  833. *
  834. * @memberOf _.support
  835. * @type boolean
  836. */
  837. support.funcNames = typeof Function.name == 'string';
  838. /**
  839. * Detect if the DOM is supported.
  840. *
  841. * @memberOf _.support
  842. * @type boolean
  843. */
  844. try {
  845. support.dom = document.createDocumentFragment().nodeType === 11;
  846. } catch (e) {
  847. support.dom = false;
  848. }
  849. /**
  850. * Detect if `arguments` object indexes are non-enumerable.
  851. *
  852. * In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object
  853. * indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat
  854. * `arguments` object indexes as non-enumerable and fail `hasOwnProperty`
  855. * checks for indexes that exceed the number of function parameters and
  856. * whose associated argument values are `0`.
  857. *
  858. * @memberOf _.support
  859. * @type boolean
  860. */
  861. try {
  862. support.nonEnumArgs = !propertyIsEnumerable.call(args, 1);
  863. } catch (e) {
  864. support.nonEnumArgs = true;
  865. }
  866. }(1, 0));
  867. /**
  868. * By default, the template delimiters used by lodash are like those in
  869. * embedded Ruby (ERB). Change the following template settings to use
  870. * alternative delimiters.
  871. *
  872. * @static
  873. * @memberOf _
  874. * @type Object
  875. */
  876. lodash.templateSettings = {
  877. 'escape': reEscape,
  878. 'evaluate': reEvaluate,
  879. 'interpolate': reInterpolate,
  880. 'variable': '',
  881. 'imports': { '_': lodash }
  882. };
  883. /**
  884. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  885. *
  886. * @private
  887. * @param {*} value The value to wrap.
  888. */
  889. function LazyWrapper(value) {
  890. this.__wrapped__ = value;
  891. this.__actions__ = null;
  892. this.__dir__ = 1;
  893. this.__dropCount__ = 0;
  894. this.__filtered__ = false;
  895. this.__iteratees__ = null;
  896. this.__takeCount__ = POSITIVE_INFINITY;
  897. this.__views__ = null;
  898. }
  899. /**
  900. * Creates a clone of the lazy wrapper object.
  901. *
  902. * @private
  903. * @name clone
  904. * @memberOf LazyWrapper
  905. * @returns {Object} Returns the cloned `LazyWrapper` object.
  906. */
  907. function lazyClone() {
  908. var actions = this.__actions__, iteratees = this.__iteratees__, views = this.__views__, result = new LazyWrapper(this.__wrapped__);
  909. result.__actions__ = actions ? arrayCopy(actions) : null;
  910. result.__dir__ = this.__dir__;
  911. result.__filtered__ = this.__filtered__;
  912. result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
  913. result.__takeCount__ = this.__takeCount__;
  914. result.__views__ = views ? arrayCopy(views) : null;
  915. return result;
  916. }
  917. /**
  918. * Reverses the direction of lazy iteration.
  919. *
  920. * @private
  921. * @name reverse
  922. * @memberOf LazyWrapper
  923. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  924. */
  925. function lazyReverse() {
  926. if (this.__filtered__) {
  927. var result = new LazyWrapper(this);
  928. result.__dir__ = -1;
  929. result.__filtered__ = true;
  930. } else {
  931. result = this.clone();
  932. result.__dir__ *= -1;
  933. }
  934. return result;
  935. }
  936. /**
  937. * Extracts the unwrapped value from its lazy wrapper.
  938. *
  939. * @private
  940. * @name value
  941. * @memberOf LazyWrapper
  942. * @returns {*} Returns the unwrapped value.
  943. */
  944. function lazyValue() {
  945. var array = this.__wrapped__.value();
  946. if (!isArray(array)) {
  947. return baseWrapperValue(array, this.__actions__);
  948. }
  949. var dir = this.__dir__, isRight = dir < 0, view = getView(0, array.length, this.__views__), start = view.start, end = view.end, length = end - start, index = isRight ? end : start - 1, takeCount = nativeMin(length, this.__takeCount__), iteratees = this.__iteratees__, iterLength = iteratees ? iteratees.length : 0, resIndex = 0, result = [];
  950. outer:
  951. while (length-- && resIndex < takeCount) {
  952. index += dir;
  953. var iterIndex = -1, value = array[index];
  954. while (++iterIndex < iterLength) {
  955. var data = iteratees[iterIndex], iteratee = data.iteratee, type = data.type;
  956. if (type == LAZY_DROP_WHILE_FLAG) {
  957. if (data.done && (isRight ? index > data.index : index < data.index)) {
  958. data.count = 0;
  959. data.done = false;
  960. }
  961. data.index = index;
  962. if (!data.done) {
  963. var limit = data.limit;
  964. if (!(data.done = limit > -1 ? data.count++ >= limit : !iteratee(value))) {
  965. continue outer;
  966. }
  967. }
  968. } else {
  969. var computed = iteratee(value);
  970. if (type == LAZY_MAP_FLAG) {
  971. value = computed;
  972. } else if (!computed) {
  973. if (type == LAZY_FILTER_FLAG) {
  974. continue outer;
  975. } else {
  976. break outer;
  977. }
  978. }
  979. }
  980. }
  981. result[resIndex++] = value;
  982. }
  983. return result;
  984. }
  985. /**
  986. * Creates a cache object to store key/value pairs.
  987. *
  988. * @private
  989. * @static
  990. * @name Cache
  991. * @memberOf _.memoize
  992. */
  993. function MapCache() {
  994. this.__data__ = {};
  995. }
  996. /**
  997. * Removes `key` and its value from the cache.
  998. *
  999. * @private
  1000. * @name delete
  1001. * @memberOf _.memoize.Cache
  1002. * @param {string} key The key of the value to remove.
  1003. * @returns {boolean} Returns `true` if the entry was removed successfully, else `false`.
  1004. */
  1005. function mapDelete(key) {
  1006. return this.has(key) && delete this.__data__[key];
  1007. }
  1008. /**
  1009. * Gets the cached value for `key`.
  1010. *
  1011. * @private
  1012. * @name get
  1013. * @memberOf _.memoize.Cache
  1014. * @param {string} key The key of the value to get.
  1015. * @returns {*} Returns the cached value.
  1016. */
  1017. function mapGet(key) {
  1018. return key == '__proto__' ? undefined : this.__data__[key];
  1019. }
  1020. /**
  1021. * Checks if a cached value for `key` exists.
  1022. *
  1023. * @private
  1024. * @name has
  1025. * @memberOf _.memoize.Cache
  1026. * @param {string} key The key of the entry to check.
  1027. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1028. */
  1029. function mapHas(key) {
  1030. return key != '__proto__' && hasOwnProperty.call(this.__data__, key);
  1031. }
  1032. /**
  1033. * Sets `value` to `key` of the cache.
  1034. *
  1035. * @private
  1036. * @name set
  1037. * @memberOf _.memoize.Cache
  1038. * @param {string} key The key of the value to cache.
  1039. * @param {*} value The value to cache.