underscore.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3. typeof define === 'function' && define.amd ? define('underscore', factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
  5. var current = global._;
  6. var exports = global._ = factory();
  7. exports.noConflict = function () { global._ = current; return exports; };
  8. }()));
  9. }(this, (function () {
  10. // Underscore.js 1.13.1
  11. // https://underscorejs.org
  12. // (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
  13. // Underscore may be freely distributed under the MIT license.
  14. // Current version.
  15. var VERSION = '1.13.1';
  16. // Establish the root object, `window` (`self`) in the browser, `global`
  17. // on the server, or `this` in some virtual machines. We use `self`
  18. // instead of `window` for `WebWorker` support.
  19. var root = typeof self == 'object' && self.self === self && self ||
  20. typeof global == 'object' && global.global === global && global ||
  21. Function('return this')() ||
  22. {};
  23. // Save bytes in the minified (but not gzipped) version:
  24. var ArrayProto = Array.prototype, ObjProto = Object.prototype;
  25. var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
  26. // Create quick reference variables for speed access to core prototypes.
  27. var push = ArrayProto.push,
  28. slice = ArrayProto.slice,
  29. toString = ObjProto.toString,
  30. hasOwnProperty = ObjProto.hasOwnProperty;
  31. // Modern feature detection.
  32. var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',
  33. supportsDataView = typeof DataView !== 'undefined';
  34. // All **ECMAScript 5+** native function implementations that we hope to use
  35. // are declared here.
  36. var nativeIsArray = Array.isArray,
  37. nativeKeys = Object.keys,
  38. nativeCreate = Object.create,
  39. nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
  40. // Create references to these builtin functions because we override them.
  41. var _isNaN = isNaN,
  42. _isFinite = isFinite;
  43. // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
  44. var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
  45. var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
  46. 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
  47. // The largest integer that can be represented exactly.
  48. var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
  49. // Some functions take a variable number of arguments, or a few expected
  50. // arguments at the beginning and then a variable number of values to operate
  51. // on. This helper accumulates all remaining arguments past the function’s
  52. // argument length (or an explicit `startIndex`), into an array that becomes
  53. // the last argument. Similar to ES6’s "rest parameter".
  54. function restArguments(func, startIndex) {
  55. startIndex = startIndex == null ? func.length - 1 : +startIndex;
  56. return function() {
  57. var length = Math.max(arguments.length - startIndex, 0),
  58. rest = Array(length),
  59. index = 0;
  60. for (; index < length; index++) {
  61. rest[index] = arguments[index + startIndex];
  62. }
  63. switch (startIndex) {
  64. case 0: return func.call(this, rest);
  65. case 1: return func.call(this, arguments[0], rest);
  66. case 2: return func.call(this, arguments[0], arguments[1], rest);
  67. }
  68. var args = Array(startIndex + 1);
  69. for (index = 0; index < startIndex; index++) {
  70. args[index] = arguments[index];
  71. }
  72. args[startIndex] = rest;
  73. return func.apply(this, args);
  74. };
  75. }
  76. // Is a given variable an object?
  77. function isObject(obj) {
  78. var type = typeof obj;
  79. return type === 'function' || type === 'object' && !!obj;
  80. }
  81. // Is a given value equal to null?
  82. function isNull(obj) {
  83. return obj === null;
  84. }
  85. // Is a given variable undefined?
  86. function isUndefined(obj) {
  87. return obj === void 0;
  88. }
  89. // Is a given value a boolean?
  90. function isBoolean(obj) {
  91. return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
  92. }
  93. // Is a given value a DOM element?
  94. function isElement(obj) {
  95. return !!(obj && obj.nodeType === 1);
  96. }
  97. // Internal function for creating a `toString`-based type tester.
  98. function tagTester(name) {
  99. var tag = '[object ' + name + ']';
  100. return function(obj) {
  101. return toString.call(obj) === tag;
  102. };
  103. }
  104. var isString = tagTester('String');
  105. var isNumber = tagTester('Number');
  106. var isDate = tagTester('Date');
  107. var isRegExp = tagTester('RegExp');
  108. var isError = tagTester('Error');
  109. var isSymbol = tagTester('Symbol');
  110. var isArrayBuffer = tagTester('ArrayBuffer');
  111. var isFunction = tagTester('Function');
  112. // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old
  113. // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
  114. var nodelist = root.document && root.document.childNodes;
  115. if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
  116. isFunction = function(obj) {
  117. return typeof obj == 'function' || false;
  118. };
  119. }
  120. var isFunction$1 = isFunction;
  121. var hasObjectTag = tagTester('Object');
  122. // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.
  123. // In IE 11, the most common among them, this problem also applies to
  124. // `Map`, `WeakMap` and `Set`.
  125. var hasStringTagBug = (
  126. supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))
  127. ),
  128. isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));
  129. var isDataView = tagTester('DataView');
  130. // In IE 10 - Edge 13, we need a different heuristic
  131. // to determine whether an object is a `DataView`.
  132. function ie10IsDataView(obj) {
  133. return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
  134. }
  135. var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);
  136. // Is a given value an array?
  137. // Delegates to ECMA5's native `Array.isArray`.
  138. var isArray = nativeIsArray || tagTester('Array');
  139. // Internal function to check whether `key` is an own property name of `obj`.
  140. function has$1(obj, key) {
  141. return obj != null && hasOwnProperty.call(obj, key);
  142. }
  143. var isArguments = tagTester('Arguments');
  144. // Define a fallback version of the method in browsers (ahem, IE < 9), where
  145. // there isn't any inspectable "Arguments" type.
  146. (function() {
  147. if (!isArguments(arguments)) {
  148. isArguments = function(obj) {
  149. return has$1(obj, 'callee');
  150. };
  151. }
  152. }());
  153. var isArguments$1 = isArguments;
  154. // Is a given object a finite number?
  155. function isFinite$1(obj) {
  156. return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
  157. }
  158. // Is the given value `NaN`?
  159. function isNaN$1(obj) {
  160. return isNumber(obj) && _isNaN(obj);
  161. }
  162. // Predicate-generating function. Often useful outside of Underscore.
  163. function constant(value) {
  164. return function() {
  165. return value;
  166. };
  167. }
  168. // Common internal logic for `isArrayLike` and `isBufferLike`.
  169. function createSizePropertyCheck(getSizeProperty) {
  170. return function(collection) {
  171. var sizeProperty = getSizeProperty(collection);
  172. return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
  173. }
  174. }
  175. // Internal helper to generate a function to obtain property `key` from `obj`.
  176. function shallowProperty(key) {
  177. return function(obj) {
  178. return obj == null ? void 0 : obj[key];
  179. };
  180. }
  181. // Internal helper to obtain the `byteLength` property of an object.
  182. var getByteLength = shallowProperty('byteLength');
  183. // Internal helper to determine whether we should spend extensive checks against
  184. // `ArrayBuffer` et al.
  185. var isBufferLike = createSizePropertyCheck(getByteLength);
  186. // Is a given value a typed array?
  187. var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
  188. function isTypedArray(obj) {
  189. // `ArrayBuffer.isView` is the most future-proof, so use it when available.
  190. // Otherwise, fall back on the above regular expression.
  191. return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :
  192. isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
  193. }
  194. var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
  195. // Internal helper to obtain the `length` property of an object.
  196. var getLength = shallowProperty('length');
  197. // Internal helper to create a simple lookup structure.
  198. // `collectNonEnumProps` used to depend on `_.contains`, but this led to
  199. // circular imports. `emulatedSet` is a one-off solution that only works for
  200. // arrays of strings.
  201. function emulatedSet(keys) {
  202. var hash = {};
  203. for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;
  204. return {
  205. contains: function(key) { return hash[key]; },
  206. push: function(key) {
  207. hash[key] = true;
  208. return keys.push(key);
  209. }
  210. };
  211. }
  212. // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't
  213. // be iterated by `for key in ...` and thus missed. Extends `keys` in place if
  214. // needed.
  215. function collectNonEnumProps(obj, keys) {
  216. keys = emulatedSet(keys);
  217. var nonEnumIdx = nonEnumerableProps.length;
  218. var constructor = obj.constructor;
  219. var proto = isFunction$1(constructor) && constructor.prototype || ObjProto;
  220. // Constructor is a special case.
  221. var prop = 'constructor';
  222. if (has$1(obj, prop) && !keys.contains(prop)) keys.push(prop);
  223. while (nonEnumIdx--) {
  224. prop = nonEnumerableProps[nonEnumIdx];
  225. if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) {
  226. keys.push(prop);
  227. }
  228. }
  229. }
  230. // Retrieve the names of an object's own properties.
  231. // Delegates to **ECMAScript 5**'s native `Object.keys`.
  232. function keys(obj) {
  233. if (!isObject(obj)) return [];
  234. if (nativeKeys) return nativeKeys(obj);
  235. var keys = [];
  236. for (var key in obj) if (has$1(obj, key)) keys.push(key);
  237. // Ahem, IE < 9.
  238. if (hasEnumBug) collectNonEnumProps(obj, keys);
  239. return keys;
  240. }
  241. // Is a given array, string, or object empty?
  242. // An "empty" object has no enumerable own-properties.
  243. function isEmpty(obj) {
  244. if (obj == null) return true;
  245. // Skip the more expensive `toString`-based type checks if `obj` has no
  246. // `.length`.
  247. var length = getLength(obj);
  248. if (typeof length == 'number' && (
  249. isArray(obj) || isString(obj) || isArguments$1(obj)
  250. )) return length === 0;
  251. return getLength(keys(obj)) === 0;
  252. }
  253. // Returns whether an object has a given set of `key:value` pairs.
  254. function isMatch(object, attrs) {
  255. var _keys = keys(attrs), length = _keys.length;
  256. if (object == null) return !length;
  257. var obj = Object(object);
  258. for (var i = 0; i < length; i++) {
  259. var key = _keys[i];
  260. if (attrs[key] !== obj[key] || !(key in obj)) return false;
  261. }
  262. return true;
  263. }
  264. // If Underscore is called as a function, it returns a wrapped object that can
  265. // be used OO-style. This wrapper holds altered versions of all functions added
  266. // through `_.mixin`. Wrapped objects may be chained.
  267. function _$1(obj) {
  268. if (obj instanceof _$1) return obj;
  269. if (!(this instanceof _$1)) return new _$1(obj);
  270. this._wrapped = obj;
  271. }
  272. _$1.VERSION = VERSION;
  273. // Extracts the result from a wrapped and chained object.
  274. _$1.prototype.value = function() {
  275. return this._wrapped;
  276. };
  277. // Provide unwrapping proxies for some methods used in engine operations
  278. // such as arithmetic and JSON stringification.
  279. _$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
  280. _$1.prototype.toString = function() {
  281. return String(this._wrapped);
  282. };
  283. // Internal function to wrap or shallow-copy an ArrayBuffer,
  284. // typed array or DataView to a new view, reusing the buffer.
  285. function toBufferView(bufferSource) {
  286. return new Uint8Array(
  287. bufferSource.buffer || bufferSource,
  288. bufferSource.byteOffset || 0,
  289. getByteLength(bufferSource)
  290. );
  291. }
  292. // We use this string twice, so give it a name for minification.
  293. var tagDataView = '[object DataView]';
  294. // Internal recursive comparison function for `_.isEqual`.
  295. function eq(a, b, aStack, bStack) {
  296. // Identical objects are equal. `0 === -0`, but they aren't identical.
  297. // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).
  298. if (a === b) return a !== 0 || 1 / a === 1 / b;
  299. // `null` or `undefined` only equal to itself (strict comparison).
  300. if (a == null || b == null) return false;
  301. // `NaN`s are equivalent, but non-reflexive.
  302. if (a !== a) return b !== b;
  303. // Exhaust primitive checks
  304. var type = typeof a;
  305. if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
  306. return deepEq(a, b, aStack, bStack);
  307. }
  308. // Internal recursive comparison function for `_.isEqual`.
  309. function deepEq(a, b, aStack, bStack) {
  310. // Unwrap any wrapped objects.
  311. if (a instanceof _$1) a = a._wrapped;
  312. if (b instanceof _$1) b = b._wrapped;
  313. // Compare `[[Class]]` names.
  314. var className = toString.call(a);
  315. if (className !== toString.call(b)) return false;
  316. // Work around a bug in IE 10 - Edge 13.
  317. if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) {
  318. if (!isDataView$1(b)) return false;
  319. className = tagDataView;
  320. }
  321. switch (className) {
  322. // These types are compared by value.
  323. case '[object RegExp]':
  324. // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
  325. case '[object String]':
  326. // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
  327. // equivalent to `new String("5")`.
  328. return '' + a === '' + b;
  329. case '[object Number]':
  330. // `NaN`s are equivalent, but non-reflexive.
  331. // Object(NaN) is equivalent to NaN.
  332. if (+a !== +a) return +b !== +b;
  333. // An `egal` comparison is performed for other numeric values.
  334. return +a === 0 ? 1 / +a === 1 / b : +a === +b;
  335. case '[object Date]':
  336. case '[object Boolean]':
  337. // Coerce dates and booleans to numeric primitive values. Dates are compared by their
  338. // millisecond representations. Note that invalid dates with millisecond representations
  339. // of `NaN` are not equivalent.
  340. return +a === +b;
  341. case '[object Symbol]':
  342. return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
  343. case '[object ArrayBuffer]':
  344. case tagDataView:
  345. // Coerce to typed array so we can fall through.
  346. return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);
  347. }
  348. var areArrays = className === '[object Array]';
  349. if (!areArrays && isTypedArray$1(a)) {
  350. var byteLength = getByteLength(a);
  351. if (byteLength !== getByteLength(b)) return false;
  352. if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;
  353. areArrays = true;
  354. }
  355. if (!areArrays) {
  356. if (typeof a != 'object' || typeof b != 'object') return false;
  357. // Objects with different constructors are not equivalent, but `Object`s or `Array`s
  358. // from different frames are.
  359. var aCtor = a.constructor, bCtor = b.constructor;
  360. if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor &&
  361. isFunction$1(bCtor) && bCtor instanceof bCtor)
  362. && ('constructor' in a && 'constructor' in b)) {
  363. return false;
  364. }
  365. }
  366. // Assume equality for cyclic structures. The algorithm for detecting cyclic
  367. // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
  368. // Initializing stack of traversed objects.
  369. // It's done here since we only need them for objects and arrays comparison.
  370. aStack = aStack || [];
  371. bStack = bStack || [];
  372. var length = aStack.length;
  373. while (length--) {
  374. // Linear search. Performance is inversely proportional to the number of
  375. // unique nested structures.
  376. if (aStack[length] === a) return bStack[length] === b;
  377. }
  378. // Add the first object to the stack of traversed objects.
  379. aStack.push(a);
  380. bStack.push(b);
  381. // Recursively compare objects and arrays.
  382. if (areArrays) {
  383. // Compare array lengths to determine if a deep comparison is necessary.
  384. length = a.length;
  385. if (length !== b.length) return false;
  386. // Deep compare the contents, ignoring non-numeric properties.
  387. while (length--) {
  388. if (!eq(a[length], b[length], aStack, bStack)) return false;
  389. }
  390. } else {
  391. // Deep compare objects.
  392. var _keys = keys(a), key;
  393. length = _keys.length;
  394. // Ensure that both objects contain the same number of properties before comparing deep equality.
  395. if (keys(b).length !== length) return false;
  396. while (length--) {
  397. // Deep compare each member
  398. key = _keys[length];
  399. if (!(has$1(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
  400. }
  401. }
  402. // Remove the first object from the stack of traversed objects.
  403. aStack.pop();
  404. bStack.pop();
  405. return true;
  406. }
  407. // Perform a deep comparison to check if two objects are equal.
  408. function isEqual(a, b) {
  409. return eq(a, b);
  410. }
  411. // Retrieve all the enumerable property names of an object.
  412. function allKeys(obj) {
  413. if (!isObject(obj)) return [];
  414. var keys = [];
  415. for (var key in obj) keys.push(key);
  416. // Ahem, IE < 9.
  417. if (hasEnumBug) collectNonEnumProps(obj, keys);
  418. return keys;
  419. }
  420. // Since the regular `Object.prototype.toString` type tests don't work for
  421. // some types in IE 11, we use a fingerprinting heuristic instead, based
  422. // on the methods. It's not great, but it's the best we got.
  423. // The fingerprint method lists are defined below.
  424. function ie11fingerprint(methods) {
  425. var length = getLength(methods);
  426. return function(obj) {
  427. if (obj == null) return false;
  428. // `Map`, `WeakMap` and `Set` have no enumerable keys.
  429. var keys = allKeys(obj);
  430. if (getLength(keys)) return false;
  431. for (var i = 0; i < length; i++) {
  432. if (!isFunction$1(obj[methods[i]])) return false;
  433. }
  434. // If we are testing against `WeakMap`, we need to ensure that
  435. // `obj` doesn't have a `forEach` method in order to distinguish
  436. // it from a regular `Map`.
  437. return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);
  438. };
  439. }
  440. // In the interest of compact minification, we write
  441. // each string in the fingerprints only once.
  442. var forEachName = 'forEach',
  443. hasName = 'has',
  444. commonInit = ['clear', 'delete'],
  445. mapTail = ['get', hasName, 'set'];
  446. // `Map`, `WeakMap` and `Set` each have slightly different
  447. // combinations of the above sublists.
  448. var mapMethods = commonInit.concat(forEachName, mapTail),
  449. weakMapMethods = commonInit.concat(mapTail),
  450. setMethods = ['add'].concat(commonInit, forEachName, hasName);
  451. var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map');
  452. var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap');
  453. var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set');
  454. var isWeakSet = tagTester('WeakSet');
  455. // Retrieve the values of an object's properties.
  456. function values(obj) {
  457. var _keys = keys(obj);
  458. var length = _keys.length;
  459. var values = Array(length);
  460. for (var i = 0; i < length; i++) {
  461. values[i] = obj[_keys[i]];
  462. }
  463. return values;
  464. }
  465. // Convert an object into a list of `[key, value]` pairs.
  466. // The opposite of `_.object` with one argument.
  467. function pairs(obj) {
  468. var _keys = keys(obj);
  469. var length = _keys.length;
  470. var pairs = Array(length);
  471. for (var i = 0; i < length; i++) {
  472. pairs[i] = [_keys[i], obj[_keys[i]]];
  473. }
  474. return pairs;
  475. }
  476. // Invert the keys and values of an object. The values must be serializable.
  477. function invert(obj) {
  478. var result = {};
  479. var _keys = keys(obj);
  480. for (var i = 0, length = _keys.length; i < length; i++) {
  481. result[obj[_keys[i]]] = _keys[i];
  482. }
  483. return result;
  484. }
  485. // Return a sorted list of the function names available on the object.
  486. function functions(obj) {
  487. var names = [];
  488. for (var key in obj) {
  489. if (isFunction$1(obj[key])) names.push(key);
  490. }
  491. return names.sort();
  492. }
  493. // An internal function for creating assigner functions.
  494. function createAssigner(keysFunc, defaults) {
  495. return function(obj) {
  496. var length = arguments.length;
  497. if (defaults) obj = Object(obj);
  498. if (length < 2 || obj == null) return obj;
  499. for (var index = 1; index < length; index++) {
  500. var source = arguments[index],
  501. keys = keysFunc(source),
  502. l = keys.length;
  503. for (var i = 0; i < l; i++) {
  504. var key = keys[i];
  505. if (!defaults || obj[key] === void 0) obj[key] = source[key];
  506. }
  507. }
  508. return obj;
  509. };
  510. }
  511. // Extend a given object with all the properties in passed-in object(s).
  512. var extend = createAssigner(allKeys);
  513. // Assigns a given object with all the own properties in the passed-in
  514. // object(s).
  515. // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
  516. var extendOwn = createAssigner(keys);
  517. // Fill in a given object with default properties.
  518. var defaults = createAssigner(allKeys, true);
  519. // Create a naked function reference for surrogate-prototype-swapping.
  520. function ctor() {
  521. return function(){};
  522. }
  523. // An internal function for creating a new object that inherits from another.
  524. function baseCreate(prototype) {
  525. if (!isObject(prototype)) return {};
  526. if (nativeCreate) return nativeCreate(prototype);
  527. var Ctor = ctor();
  528. Ctor.prototype = prototype;
  529. var result = new Ctor;
  530. Ctor.prototype = null;
  531. return result;
  532. }
  533. // Creates an object that inherits from the given prototype object.
  534. // If additional properties are provided then they will be added to the
  535. // created object.
  536. function create(prototype, props) {
  537. var result = baseCreate(prototype);
  538. if (props) extendOwn(result, props);
  539. return result;
  540. }
  541. // Create a (shallow-cloned) duplicate of an object.
  542. function clone(obj) {
  543. if (!isObject(obj)) return obj;
  544. return isArray(obj) ? obj.slice() : extend({}, obj);
  545. }
  546. // Invokes `interceptor` with the `obj` and then returns `obj`.
  547. // The primary purpose of this method is to "tap into" a method chain, in
  548. // order to perform operations on intermediate results within the chain.
  549. function tap(obj, interceptor) {
  550. interceptor(obj);
  551. return obj;
  552. }
  553. // Normalize a (deep) property `path` to array.
  554. // Like `_.iteratee`, this function can be customized.
  555. function toPath$1(path) {
  556. return isArray(path) ? path : [path];
  557. }
  558. _$1.toPath = toPath$1;
  559. // Internal wrapper for `_.toPath` to enable minification.
  560. // Similar to `cb` for `_.iteratee`.
  561. function toPath(path) {
  562. return _$1.toPath(path);
  563. }
  564. // Internal function to obtain a nested property in `obj` along `path`.
  565. function deepGet(obj, path) {
  566. var length = path.length;
  567. for (var i = 0; i < length; i++) {
  568. if (obj == null) return void 0;
  569. obj = obj[path[i]];
  570. }
  571. return length ? obj : void 0;
  572. }
  573. // Get the value of the (deep) property on `path` from `object`.
  574. // If any property in `path` does not exist or if the value is
  575. // `undefined`, return `defaultValue` instead.
  576. // The `path` is normalized through `_.toPath`.
  577. function get(object, path, defaultValue) {
  578. var value = deepGet(object, toPath(path));
  579. return isUndefined(value) ? defaultValue : value;
  580. }
  581. // Shortcut function for checking if an object has a given property directly on
  582. // itself (in other words, not on a prototype). Unlike the internal `has`
  583. // function, this public version can also traverse nested properties.
  584. function has(obj, path) {
  585. path = toPath(path);
  586. var length = path.length;
  587. for (var i = 0; i < length; i++) {
  588. var key = path[i];
  589. if (!has$1(obj, key)) return false;
  590. obj = obj[key];
  591. }
  592. return !!length;
  593. }
  594. // Keep the identity function around for default iteratees.
  595. function identity(value) {
  596. return value;
  597. }
  598. // Returns a predicate for checking whether an object has a given set of
  599. // `key:value` pairs.
  600. function matcher(attrs) {
  601. attrs = extendOwn({}, attrs);
  602. return function(obj) {
  603. return isMatch(obj, attrs);
  604. };
  605. }
  606. // Creates a function that, when passed an object, will traverse that object’s
  607. // properties down the given `path`, specified as an array of keys or indices.
  608. function property(path) {
  609. path = toPath(path);
  610. return function(obj) {
  611. return deepGet(obj, path);
  612. };
  613. }
  614. // Internal function that returns an efficient (for current engines) version
  615. // of the passed-in callback, to be repeatedly applied in other Underscore
  616. // functions.
  617. function optimizeCb(func, context, argCount) {
  618. if (context === void 0) return func;
  619. switch (argCount == null ? 3 : argCount) {
  620. case 1: return function(value) {
  621. return func.call(context, value);
  622. };
  623. // The 2-argument case is omitted because we’re not using it.
  624. case 3: return function(value, index, collection) {
  625. return func.call(context, value, index, collection);
  626. };
  627. case 4: return function(accumulator, value, index, collection) {
  628. return func.call(context, accumulator, value, index, collection);
  629. };
  630. }
  631. return function() {
  632. return func.apply(context, arguments);
  633. };
  634. }
  635. // An internal function to generate callbacks that can be applied to each
  636. // element in a collection, returning the desired result — either `_.identity`,
  637. // an arbitrary callback, a property matcher, or a property accessor.
  638. function baseIteratee(value, context, argCount) {
  639. if (value == null) return identity;
  640. if (isFunction$1(value)) return optimizeCb(value, context, argCount);
  641. if (isObject(value) && !isArray(value)) return matcher(value);
  642. return property(value);
  643. }
  644. // External wrapper for our callback generator. Users may customize
  645. // `_.iteratee` if they want additional predicate/iteratee shorthand styles.
  646. // This abstraction hides the internal-only `argCount` argument.
  647. function iteratee(value, context) {
  648. return baseIteratee(value, context, Infinity);
  649. }
  650. _$1.iteratee = iteratee;
  651. // The function we call internally to generate a callback. It invokes
  652. // `_.iteratee` if overridden, otherwise `baseIteratee`.
  653. function cb(value, context, argCount) {
  654. if (_$1.iteratee !== iteratee) return _$1.iteratee(value, context);
  655. return baseIteratee(value, context, argCount);
  656. }
  657. // Returns the results of applying the `iteratee` to each element of `obj`.
  658. // In contrast to `_.map` it returns an object.
  659. function mapObject(obj, iteratee, context) {
  660. iteratee = cb(iteratee, context);
  661. var _keys = keys(obj),
  662. length = _keys.length,
  663. results = {};
  664. for (var index = 0; index < length; index++) {
  665. var currentKey = _keys[index];
  666. results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
  667. }
  668. return results;
  669. }
  670. // Predicate-generating function. Often useful outside of Underscore.
  671. function noop(){}
  672. // Generates a function for a given object that returns a given property.
  673. function propertyOf(obj) {
  674. if (obj == null) return noop;
  675. return function(path) {
  676. return get(obj, path);
  677. };
  678. }
  679. // Run a function **n** times.
  680. function times(n, iteratee, context) {
  681. var accum = Array(Math.max(0, n));
  682. iteratee = optimizeCb(iteratee, context, 1);
  683. for (var i = 0; i < n; i++) accum[i] = iteratee(i);
  684. return accum;
  685. }
  686. // Return a random integer between `min` and `max` (inclusive).
  687. function random(min, max) {
  688. if (max == null) {
  689. max = min;
  690. min = 0;
  691. }
  692. return min + Math.floor(Math.random() * (max - min + 1));
  693. }
  694. // A (possibly faster) way to get the current timestamp as an integer.
  695. var now = Date.now || function() {
  696. return new Date().getTime();
  697. };
  698. // Internal helper to generate functions for escaping and unescaping strings
  699. // to/from HTML interpolation.
  700. function createEscaper(map) {
  701. var escaper = function(match) {
  702. return map[match];
  703. };
  704. // Regexes for identifying a key that needs to be escaped.
  705. var source = '(?:' + keys(map).join('|') + ')';
  706. var testRegexp = RegExp(source);
  707. var replaceRegexp = RegExp(source, 'g');
  708. return function(string) {
  709. string = string == null ? '' : '' + string;
  710. return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
  711. };
  712. }
  713. // Internal list of HTML entities for escaping.
  714. var escapeMap = {
  715. '&': '&amp;',
  716. '<': '&lt;',
  717. '>': '&gt;',
  718. '"': '&quot;',
  719. "'": '&#x27;',
  720. '`': '&#x60;'
  721. };
  722. // Function for escaping strings to HTML interpolation.
  723. var _escape = createEscaper(escapeMap);
  724. // Internal list of HTML entities for unescaping.
  725. var unescapeMap = invert(escapeMap);
  726. // Function for unescaping strings from HTML interpolation.
  727. var _unescape = createEscaper(unescapeMap);
  728. // By default, Underscore uses ERB-style template delimiters. Change the
  729. // following template settings to use alternative delimiters.
  730. var templateSettings = _$1.templateSettings = {
  731. evaluate: /<%([\s\S]+?)%>/g,
  732. interpolate: /<%=([\s\S]+?)%>/g,
  733. escape: /<%-([\s\S]+?)%>/g
  734. };
  735. // When customizing `_.templateSettings`, if you don't want to define an
  736. // interpolation, evaluation or escaping regex, we need one that is
  737. // guaranteed not to match.
  738. var noMatch = /(.)^/;
  739. // Certain characters need to be escaped so that they can be put into a
  740. // string literal.
  741. var escapes = {
  742. "'": "'",
  743. '\\': '\\',
  744. '\r': 'r',
  745. '\n': 'n',
  746. '\u2028': 'u2028',
  747. '\u2029': 'u2029'
  748. };
  749. var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
  750. function escapeChar(match) {
  751. return '\\' + escapes[match];
  752. }
  753. // In order to prevent third-party code injection through
  754. // `_.templateSettings.variable`, we test it against the following regular
  755. // expression. It is intentionally a bit more liberal than just matching valid
  756. // identifiers, but still prevents possible loopholes through defaults or
  757. // destructuring assignment.
  758. var bareIdentifier = /^\s*(\w|\$)+\s*$/;
  759. // JavaScript micro-templating, similar to John Resig's implementation.
  760. // Underscore templating handles arbitrary delimiters, preserves whitespace,
  761. // and correctly escapes quotes within interpolated code.
  762. // NB: `oldSettings` only exists for backwards compatibility.
  763. function template(text, settings, oldSettings) {
  764. if (!settings && oldSettings) settings = oldSettings;
  765. settings = defaults({}, settings, _$1.templateSettings);
  766. // Combine delimiters into one regular expression via alternation.
  767. var matcher = RegExp([
  768. (settings.escape || noMatch).source,
  769. (settings.interpolate || noMatch).source,
  770. (settings.evaluate || noMatch).source
  771. ].join('|') + '|$', 'g');
  772. // Compile the template source, escaping string literals appropriately.
  773. var index = 0;
  774. var source = "__p+='";
  775. text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
  776. source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
  777. index = offset + match.length;
  778. if (escape) {
  779. source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
  780. } else if (interpolate) {
  781. source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
  782. } else if (evaluate) {
  783. source += "';\n" + evaluate + "\n__p+='";
  784. }
  785. // Adobe VMs need the match returned to produce the correct offset.
  786. return match;
  787. });
  788. source += "';\n";
  789. var argument = settings.variable;
  790. if (argument) {
  791. // Insure against third-party code injection. (CVE-2021-23358)
  792. if (!bareIdentifier.test(argument)) throw new Error(
  793. 'variable is not a bare identifier: ' + argument
  794. );
  795. } else {
  796. // If a variable is not specified, place data values in local scope.
  797. source = 'with(obj||{}){\n' + source + '}\n';
  798. argument = 'obj';
  799. }
  800. source = "var __t,__p='',__j=Array.prototype.join," +
  801. "print=function(){__p+=__j.call(arguments,'');};\n" +
  802. source + 'return __p;\n';
  803. var render;
  804. try {
  805. render = new Function(argument, '_', source);
  806. } catch (e) {
  807. e.source = source;
  808. throw e;
  809. }
  810. var template = function(data) {
  811. return render.call(this, data, _$1);
  812. };
  813. // Provide the compiled source as a convenience for precompilation.
  814. template.source = 'function(' + argument + '){\n' + source + '}';
  815. return template;
  816. }
  817. // Traverses the children of `obj` along `path`. If a child is a function, it
  818. // is invoked with its parent as context. Returns the value of the final
  819. // child, or `fallback` if any child is undefined.
  820. function result(obj, path, fallback) {
  821. path = toPath(path);
  822. var length = path.length;
  823. if (!length) {
  824. return isFunction$1(fallback) ? fallback.call(obj) : fallback;
  825. }
  826. for (var i = 0; i < length; i++) {
  827. var prop = obj == null ? void 0 : obj[path[i]];
  828. if (prop === void 0) {
  829. prop = fallback;
  830. i = length; // Ensure we don't continue iterating.
  831. }
  832. obj = isFunction$1(prop) ? prop.call(obj) : prop;
  833. }
  834. return obj;
  835. }
  836. // Generate a unique integer id (unique within the entire client session).
  837. // Useful for temporary DOM ids.
  838. var idCounter = 0;
  839. function uniqueId(prefix) {
  840. var id = ++idCounter + '';
  841. return prefix ? prefix + id : id;
  842. }
  843. // Start chaining a wrapped Underscore object.
  844. function chain(obj) {
  845. var instance = _$1(obj);
  846. instance._chain = true;
  847. return instance;
  848. }
  849. // Internal function to execute `sourceFunc` bound to `context` with optional
  850. // `args`. Determines whether to execute a function as a constructor or as a
  851. // normal function.
  852. function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
  853. if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
  854. var self = baseCreate(sourceFunc.prototype);
  855. var result = sourceFunc.apply(self, args);
  856. if (isObject(result)) return result;
  857. return self;
  858. }
  859. // Partially apply a function by creating a version that has had some of its
  860. // arguments pre-filled, without changing its dynamic `this` context. `_` acts
  861. // as a placeholder by default, allowing any combination of arguments to be
  862. // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
  863. var partial = restArguments(function(func, boundArgs) {
  864. var placeholder = partial.placeholder;
  865. var bound = function() {
  866. var position = 0, length = boundArgs.length;
  867. var args = Array(length);
  868. for (var i = 0; i < length; i++) {
  869. args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
  870. }
  871. while (position < arguments.length) args.push(arguments[position++]);
  872. return executeBound(func, bound, this, this, args);
  873. };
  874. return bound;
  875. });
  876. partial.placeholder = _$1;
  877. // Create a function bound to a given object (assigning `this`, and arguments,
  878. // optionally).
  879. var bind = restArguments(function(func, context, args) {
  880. if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');
  881. var bound = restArguments(function(callArgs) {
  882. return executeBound(func, bound, context, this, args.concat(callArgs));
  883. });
  884. return bound;
  885. });
  886. // Internal helper for collection methods to determine whether a collection
  887. // should be iterated as an array or as an object.
  888. // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
  889. // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
  890. var isArrayLike = createSizePropertyCheck(getLength);
  891. // Internal implementation of a recursive `flatten` function.
  892. function flatten$1(input, depth, strict, output) {
  893. output = output || [];
  894. if (!depth && depth !== 0) {
  895. depth = Infinity;
  896. } else if (depth <= 0) {
  897. return output.concat(input);
  898. }
  899. var idx = output.length;
  900. for (var i = 0, length = getLength(input); i < length; i++) {
  901. var value = input[i];
  902. if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
  903. // Flatten current level of array or arguments object.
  904. if (depth > 1) {
  905. flatten$1(value, depth - 1, strict, output);
  906. idx = output.length;
  907. } else {
  908. var j = 0, len = value.length;
  909. while (j < len) output[idx++] = value[j++];
  910. }
  911. } else if (!strict) {
  912. output[idx++] = value;
  913. }
  914. }
  915. return output;
  916. }
  917. // Bind a number of an object's methods to that object. Remaining arguments
  918. // are the method names to be bound. Useful for ensuring that all callbacks
  919. // defined on an object belong to it.
  920. var bindAll = restArguments(function(obj, keys) {
  921. keys = flatten$1(keys, false, false);
  922. var index = keys.length;
  923. if (index < 1) throw new Error('bindAll must be passed function names');
  924. while (index--) {
  925. var key = keys[index];
  926. obj[key] = bind(obj[key], obj);
  927. }
  928. return obj;
  929. });
  930. // Memoize an expensive function by storing its results.
  931. function memoize(func, hasher) {
  932. var memoize = function(key) {
  933. var cache = memoize.cache;
  934. var address = '' + (hasher ? hasher.apply(this, arguments) : key);
  935. if (!has$1(cache, address)) cache[address] = func.apply(this, arguments);
  936. return cache[address];
  937. };
  938. memoize.cache = {};
  939. return memoize;
  940. }
  941. // Delays a function for the given number of milliseconds, and then calls
  942. // it with the arguments supplied.
  943. var delay = restArguments(function(func, wait, args) {
  944. return setTimeout(function() {
  945. return func.apply(null, args);
  946. }, wait);
  947. });
  948. // Defers a function, scheduling it to run after the current call stack has
  949. // cleared.
  950. var defer = partial(delay, _$1, 1);
  951. // Returns a function, that, when invoked, will only be triggered at most once
  952. // during a given window of time. Normally, the throttled function will run
  953. // as much as it can, without ever going more than once per `wait` duration;
  954. // but if you'd like to disable the execution on the leading edge, pass
  955. // `{leading: false}`. To disable execution on the trailing edge, ditto.
  956. function throttle(func, wait, options) {
  957. var timeout, context, args, result;
  958. var previous = 0;
  959. if (!options) options = {};
  960. var later = function() {
  961. previous = options.leading === false ? 0 : now();
  962. timeout = null;
  963. result = func.apply(context, args);
  964. if (!timeout) context = args = null;
  965. };
  966. var throttled = function() {
  967. var _now = now();
  968. if (!previous && options.leading === false) previous = _now;
  969. var remaining = wait - (_now - previous);
  970. context = this;
  971. args = arguments;
  972. if (remaining <= 0 || remaining > wait) {
  973. if (timeout) {
  974. clearTimeout(timeout);
  975. timeout = null;
  976. }
  977. previous = _now;
  978. result = func.apply(context, args);
  979. if (!timeout) context = args = null;
  980. } else if (!timeout && options.trailing !== false) {
  981. timeout = setTimeout(later, remaining);
  982. }
  983. return result;
  984. };
  985. throttled.cancel = function() {
  986. clearTimeout(timeout);
  987. previous = 0;
  988. timeout = context = args = null;
  989. };
  990. return throttled;
  991. }
  992. // When a sequence of calls of the returned function ends, the argument
  993. // function is triggered. The end of a sequence is defined by the `wait`
  994. // parameter. If `immediate` is passed, the argument function will be
  995. // triggered at the beginning of the sequence instead of at the end.
  996. function debounce(func, wait, immediate) {
  997. var timeout, previous, args, result, context;
  998. var later = function() {
  999. var passed = now() - previous;
  1000. if (wait > passed) {
  1001. timeout = setTimeout(later, wait - passed);
  1002. } else {
  1003. timeout = null;
  1004. if (!immediate) result = func.apply(context, args);
  1005. // This check is needed because `func` can recursively invoke `debounced`.
  1006. if (!timeout) args = context = null;
  1007. }
  1008. };
  1009. var debounced = restArguments(function(_args) {
  1010. context = this;
  1011. args = _args;
  1012. previous = now();
  1013. if (!timeout) {
  1014. timeout = setTimeout(later, wait);
  1015. if (immediate) result = func.apply(context, args);
  1016. }
  1017. return result;
  1018. });
  1019. debounced.cancel = function() {
  1020. clearTimeout(timeout);
  1021. timeout = args = context = null;
  1022. };
  1023. return debounced;
  1024. }
  1025. // Returns the first function passed as an argument to the second,
  1026. // allowing you to adjust arguments, run code before and after, and
  1027. // conditionally execute the original function.
  1028. function wrap(func, wrapper) {
  1029. return partial(wrapper, func);
  1030. }
  1031. // Returns a negated version of the passed-in predicate.
  1032. function negate(predicate) {
  1033. return function() {
  1034. return !predicate.apply(this, arguments);
  1035. };
  1036. }
  1037. // Returns a function that is the composition of a list of functions, each
  1038. // consuming the return value of the function that follows.
  1039. function compose() {
  1040. var args = arguments;
  1041. var start = args.length - 1;
  1042. return function() {
  1043. var i = start;
  1044. var result = args[start].apply(this, arguments);
  1045. while (i--) result = args[i].call(this, result);
  1046. return result;
  1047. };
  1048. }
  1049. // Returns a function that will only be executed on and after the Nth call.
  1050. function after(times, func) {
  1051. return function() {
  1052. if (--times < 1) {
  1053. return func.apply(this, arguments);
  1054. }
  1055. };
  1056. }
  1057. // Returns a function that will only be executed up to (but not including) the
  1058. // Nth call.
  1059. function before(times, func) {
  1060. var memo;
  1061. return function() {
  1062. if (--times > 0) {
  1063. memo = func.apply(this, arguments);
  1064. }
  1065. if (times <= 1) func = null;
  1066. return memo;
  1067. };
  1068. }
  1069. // Returns a function that will be executed at most one time, no matter how
  1070. // often you call it. Useful for lazy initialization.
  1071. var once = partial(before, 2);
  1072. // Returns the first key on an object that passes a truth test.
  1073. function findKey(obj, predicate, context) {
  1074. predicate = cb(predicate, context);
  1075. var _keys = keys(obj), key;
  1076. for (var i = 0, length = _keys.length; i < length; i++) {
  1077. key = _keys[i];
  1078. if (predicate(obj[key], key, obj)) return key;
  1079. }
  1080. }
  1081. // Internal function to generate `_.findIndex` and `_.findLastIndex`.
  1082. function createPredicateIndexFinder(dir) {
  1083. return function(array, predicate, context) {
  1084. predicate = cb(predicate, context);
  1085. var length = getLength(array);
  1086. var index = dir > 0 ? 0 : length - 1;
  1087. for (; index >= 0 && index < length; index += dir) {
  1088. if (predicate(array[index], index, array)) return index;
  1089. }
  1090. return -1;
  1091. };
  1092. }
  1093. // Returns the first index on an array-like that passes a truth test.
  1094. var findIndex = createPredicateIndexFinder(1);
  1095. // Returns the last index on an array-like that passes a truth test.
  1096. var findLastIndex = createPredicateIndexFinder(-1);
  1097. // Use a comparator function to figure out the smallest index at which
  1098. // an object should be inserted so as to maintain order. Uses binary search.
  1099. function sortedIndex(array, obj, iteratee, context) {
  1100. iteratee = cb(iteratee, context, 1);
  1101. var value = iteratee(obj);
  1102. var low = 0, high = getLength(array);
  1103. while (low < high) {
  1104. var mid = Math.floor((low + high) / 2);
  1105. if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
  1106. }
  1107. return low;
  1108. }
  1109. // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
  1110. function createIndexFinder(dir, predicateFind, sortedIndex) {
  1111. return function(array, item, idx) {
  1112. var i = 0, length = getLength(array);
  1113. if (typeof idx == 'number') {
  1114. if (dir > 0) {
  1115. i = idx >= 0 ? idx : Math.max(idx + length, i);
  1116. } else {
  1117. length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
  1118. }
  1119. } else if (sortedIndex && idx && length) {
  1120. idx = sortedIndex(array, item);
  1121. return array[idx] === item ? idx : -1;
  1122. }
  1123. if (item !== item) {
  1124. idx = predicateFind(slice.call(array, i, length), isNaN$1);
  1125. return idx >= 0 ? idx + i : -1;
  1126. }
  1127. for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
  1128. if (array[idx] === item) return idx;
  1129. }
  1130. return -1;
  1131. };
  1132. }
  1133. // Return the position of the first occurrence of an item in an array,
  1134. // or -1 if the item is not included in the array.
  1135. // If the array is large and already in sort order, pass `true`
  1136. // for **isSorted** to use binary search.
  1137. var indexOf = createIndexFinder(1, findIndex, sortedIndex);
  1138. // Return the position of the last occurrence of an item in an array,
  1139. // or -1 if the item is not included in the array.
  1140. var lastIndexOf = createIndexFinder(-1, findLastIndex);
  1141. // Return the first value which passes a truth test.
  1142. function find(obj, predicate, context) {
  1143. var keyFinder = isArrayLike(obj) ? findIndex : findKey;
  1144. var key = keyFinder(obj, predicate, context);
  1145. if (key !== void 0 && key !== -1) return obj[key];
  1146. }
  1147. // Convenience version of a common use case of `_.find`: getting the first
  1148. // object containing specific `key:value` pairs.
  1149. function findWhere(obj, attrs) {
  1150. return find(obj, matcher(attrs));
  1151. }
  1152. // The cornerstone for collection functions, an `each`
  1153. // implementation, aka `forEach`.
  1154. // Handles raw objects in addition to array-likes. Treats all
  1155. // sparse array-likes as if they were dense.
  1156. function each(obj, iteratee, context) {
  1157. iteratee = optimizeCb(iteratee, context);
  1158. var i, length;
  1159. if (isArrayLike(obj)) {
  1160. for (i = 0, length = obj.length; i < length; i++) {
  1161. iteratee(obj[i], i, obj);
  1162. }
  1163. } else {
  1164. var _keys = keys(obj);
  1165. for (i = 0, length = _keys.length; i < length; i++) {
  1166. iteratee(obj[_keys[i]], _keys[i], obj);
  1167. }
  1168. }
  1169. return obj;
  1170. }
  1171. // Return the results of applying the iteratee to each element.
  1172. function map(obj, iteratee, context) {
  1173. iteratee = cb(iteratee, context);
  1174. var _keys = !isArrayLike(obj) && keys(obj),
  1175. length = (_keys || obj).length,
  1176. results = Array(length);
  1177. for (var index = 0; index < length; index++) {
  1178. var currentKey = _keys ? _keys[index] : index;
  1179. results[index] = iteratee(obj[currentKey], currentKey, obj);
  1180. }
  1181. return results;
  1182. }
  1183. // Internal helper to create a reducing function, iterating left or right.
  1184. function createReduce(dir) {
  1185. // Wrap code that reassigns argument variables in a separate function than
  1186. // the one that accesses `arguments.length` to avoid a perf hit. (#1991)
  1187. var reducer = function(obj, iteratee, memo, initial) {
  1188. var _keys = !isArrayLike(obj) && keys(obj),
  1189. length = (_keys || obj).length,
  1190. index = dir > 0 ? 0 : length - 1;
  1191. if (!initial) {
  1192. memo = obj[_keys ? _keys[index] : index];
  1193. index += dir;
  1194. }
  1195. for (; index >= 0 && index < length; index += dir) {
  1196. var currentKey = _keys ? _keys[index] : index;
  1197. memo = iteratee(memo, obj[currentKey], currentKey, obj);
  1198. }
  1199. return memo;
  1200. };
  1201. return function(obj, iteratee, memo, context) {
  1202. var initial = arguments.length >= 3;
  1203. return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
  1204. };
  1205. }
  1206. // **Reduce** builds up a single result from a list of values, aka `inject`,
  1207. // or `foldl`.
  1208. var reduce = createReduce(1);
  1209. // The right-associative version of reduce, also known as `foldr`.
  1210. var reduceRight = createReduce(-1);
  1211. // Return all the elements that pass a truth test.
  1212. function filter(obj, predicate, context) {
  1213. var results = [];
  1214. predicate = cb(predicate, context);
  1215. each(obj, function(value, index, list) {
  1216. if (predicate(value, index, list)) results.push(value);
  1217. });
  1218. return results;
  1219. }
  1220. // Return all the elements for which a truth test fails.
  1221. function reject(obj, predicate, context) {
  1222. return filter(obj, negate(cb(predicate)), context);
  1223. }
  1224. // Determine whether all of the elements pass a truth test.
  1225. function every(obj, predicate, context) {
  1226. predicate = cb(predicate, context);
  1227. var _keys = !isArrayLike(obj) && keys(obj),
  1228. length = (_keys || obj).length;
  1229. for (var index = 0; index < length; index++) {
  1230. var currentKey = _keys ? _keys[index] : index;
  1231. if (!predicate(obj[currentKey], currentKey, obj)) return false;
  1232. }
  1233. return true;
  1234. }
  1235. // Determine if at least one element in the object passes a truth test.
  1236. function some(obj, predicate, context) {
  1237. predicate = cb(predicate, context);
  1238. var _keys = !isArrayLike(obj) && keys(obj),
  1239. length = (_keys || obj).length;
  1240. for (var index = 0; index < length; index++) {
  1241. var currentKey = _keys ? _keys[index] : index;
  1242. if (predicate(obj[currentKey], currentKey, obj)) return true;
  1243. }
  1244. return false;
  1245. }
  1246. // Determine if the array or object contains a given item (using `===`).
  1247. function contains(obj, item, fromIndex, guard) {
  1248. if (!isArrayLike(obj)) obj = values(obj);
  1249. if (typeof fromIndex != 'number' || guard) fromIndex = 0;
  1250. return indexOf(obj, item, fromIndex) >= 0;
  1251. }
  1252. // Invoke a method (with arguments) on every item in a collection.
  1253. var invoke = restArguments(function(obj, path, args) {
  1254. var contextPath, func;
  1255. if (isFunction$1(path)) {
  1256. func = path;
  1257. } else {
  1258. path = toPath(path);
  1259. contextPath = path.slice(0, -1);
  1260. path = path[path.length - 1];
  1261. }
  1262. return map(obj, function(context) {
  1263. var method = func;
  1264. if (!method) {
  1265. if (contextPath && contextPath.length) {
  1266. context = deepGet(context, contextPath);
  1267. }
  1268. if (context == null) return void 0;
  1269. method = context[path];
  1270. }
  1271. return method == null ? method : method.apply(context, args);
  1272. });
  1273. });
  1274. // Convenience version of a common use case of `_.map`: fetching a property.
  1275. function pluck(obj, key) {
  1276. return map(obj, property(key));
  1277. }
  1278. // Convenience version of a common use case of `_.filter`: selecting only
  1279. // objects containing specific `key:value` pairs.
  1280. function where(obj, attrs) {
  1281. return filter(obj, matcher(attrs));
  1282. }
  1283. // Return the maximum element (or element-based computation).
  1284. function max(obj, iteratee, context) {
  1285. var result = -Infinity, lastComputed = -Infinity,
  1286. value, computed;
  1287. if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
  1288. obj = isArrayLike(obj) ? obj : values(obj);
  1289. for (var i = 0, length = obj.length; i < length; i++) {
  1290. value = obj[i];
  1291. if (value != null && value > result) {
  1292. result = value;
  1293. }
  1294. }
  1295. } else {
  1296. iteratee = cb(iteratee, context);
  1297. each(obj, function(v, index, list) {
  1298. computed = iteratee(v, index, list);
  1299. if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
  1300. result = v;
  1301. lastComputed = computed;
  1302. }
  1303. });
  1304. }
  1305. return result;
  1306. }
  1307. // Return the minimum element (or element-based computation).
  1308. function min(obj, iteratee, context) {
  1309. var result = Infinity, lastComputed = Infinity,
  1310. value, computed;
  1311. if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
  1312. obj = isArrayLike(obj) ? obj : values(obj);
  1313. for (var i = 0, length = obj.length; i < length; i++) {
  1314. value = obj[i];
  1315. if (value != null && value < result) {
  1316. result = value;
  1317. }
  1318. }
  1319. } else {
  1320. iteratee = cb(iteratee, context);
  1321. each(obj, function(v, index, list) {
  1322. computed = iteratee(v, index, list);
  1323. if (computed < lastComputed || computed === Infinity && result === Infinity) {
  1324. result = v;
  1325. lastComputed = computed;
  1326. }
  1327. });
  1328. }
  1329. return result;
  1330. }
  1331. // Sample **n** random values from a collection using the modern version of the
  1332. // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
  1333. // If **n** is not specified, returns a single random element.
  1334. // The internal `guard` argument allows it to work with `_.map`.
  1335. function sample(obj, n, guard) {
  1336. if (n == null || guard) {
  1337. if (!isArrayLike(obj)) obj = values(obj);
  1338. return obj[random(obj.length - 1)];
  1339. }
  1340. var sample = isArrayLike(obj) ? clone(obj) : values(obj);
  1341. var length = getLength(sample);
  1342. n = Math.max(Math.min(n, length), 0);
  1343. var last = length - 1;
  1344. for (var index = 0; index < n; index++) {
  1345. var rand = random(index, last);
  1346. var temp = sample[index];
  1347. sample[index] = sample[rand];
  1348. sample[rand] = temp;
  1349. }
  1350. return sample.slice(0, n);
  1351. }
  1352. // Shuffle a collection.
  1353. function shuffle(obj) {
  1354. return sample(obj, Infinity);
  1355. }
  1356. // Sort the object's values by a criterion produced by an iteratee.
  1357. function sortBy(obj, iteratee, context) {
  1358. var index = 0;
  1359. iteratee = cb(iteratee, context);
  1360. return pluck(map(obj, function(value, key, list) {
  1361. return {
  1362. value: value,
  1363. index: index++,
  1364. criteria: iteratee(value, key, list)
  1365. };
  1366. }).sort(function(left, right) {
  1367. var a = left.criteria;
  1368. var b = right.criteria;
  1369. if (a !== b) {
  1370. if (a > b || a === void 0) return 1;
  1371. if (a < b || b === void 0) return -1;
  1372. }
  1373. return left.index - right.index;
  1374. }), 'value');
  1375. }
  1376. // An internal function used for aggregate "group by" operations.
  1377. function group(behavior, partition) {
  1378. return function(obj, iteratee, context) {
  1379. var result = partition ? [[], []] : {};
  1380. iteratee = cb(iteratee, context);
  1381. each(obj, function(value, index) {
  1382. var key = iteratee(value, index, obj);
  1383. behavior(result, value, key);
  1384. });
  1385. return result;
  1386. };
  1387. }
  1388. // Groups the object's values by a criterion. Pass either a string attribute
  1389. // to group by, or a function that returns the criterion.
  1390. var groupBy = group(function(result, value, key) {
  1391. if (has$1(result, key)) result[key].push(value); else result[key] = [value];
  1392. });
  1393. // Indexes the object's values by a criterion, similar to `_.groupBy`, but for
  1394. // when you know that your index values will be unique.
  1395. var indexBy = group(function(result, value, key) {
  1396. result[key] = value;
  1397. });
  1398. // Counts instances of an object that group by a certain criterion. Pass
  1399. // either a string attribute to count by, or a function that returns the
  1400. // criterion.
  1401. var countBy = group(function(result, value, key) {
  1402. if (has$1(result, key)) result[key]++; else result[key] = 1;
  1403. });
  1404. // Split a collection into two arrays: one whose elements all pass the given
  1405. // truth test, and one whose elements all do not pass the truth test.
  1406. var partition = group(function(result, value, pass) {
  1407. result[pass ? 0 : 1].push(value);
  1408. }, true);
  1409. // Safely create a real, live array from anything iterable.
  1410. var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
  1411. function toArray(obj) {
  1412. if (!obj) return [];
  1413. if (isArray(obj)) return slice.call(obj);
  1414. if (isString(obj)) {
  1415. // Keep surrogate pair characters together.
  1416. return obj.match(reStrSymbol);
  1417. }
  1418. if (isArrayLike(obj)) return map(obj, identity);
  1419. return values(obj);
  1420. }
  1421. // Return the number of elements in a collection.
  1422. function size(obj) {
  1423. if (obj == null) return 0;
  1424. return isArrayLike(obj) ? obj.length : keys(obj).length;
  1425. }
  1426. // Internal `_.pick` helper function to determine whether `key` is an enumerable
  1427. // property name of `obj`.
  1428. function keyInObj(value, key, obj) {
  1429. return key in obj;
  1430. }
  1431. // Return a copy of the object only containing the allowed properties.
  1432. var pick = restArguments(function(obj, keys) {
  1433. var result = {}, iteratee = keys[0];
  1434. if (obj == null) return result;
  1435. if (isFunction$1(iteratee)) {
  1436. if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
  1437. keys = allKeys(obj);
  1438. } else {
  1439. iteratee = keyInObj;
  1440. keys = flatten$1(keys, false, false);
  1441. obj = Object(obj);
  1442. }
  1443. for (var i = 0, length = keys.length; i < length; i++) {
  1444. var key = keys[i];
  1445. var value = obj[key];
  1446. if (iteratee(value, key, obj)) result[key] = value;
  1447. }
  1448. return result;
  1449. });
  1450. // Return a copy of the object without the disallowed properties.
  1451. var omit = restArguments(function(obj, keys) {
  1452. var iteratee = keys[0], context;
  1453. if (isFunction$1(iteratee)) {
  1454. iteratee = negate(iteratee);
  1455. if (keys.length > 1) context = keys[1];
  1456. } else {
  1457. keys = map(flatten$1(keys, false, false), String);
  1458. iteratee = function(value, key) {
  1459. return !contains(keys, key);
  1460. };
  1461. }
  1462. return pick(obj, iteratee, context);
  1463. });
  1464. // Returns everything but the last entry of the array. Especially useful on
  1465. // the arguments object. Passing **n** will return all the values in
  1466. // the array, excluding the last N.
  1467. function initial(array, n, guard) {
  1468. return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
  1469. }
  1470. // Get the first element of an array. Passing **n** will return the first N
  1471. // values in the array. The **guard** check allows it to work with `_.map`.
  1472. function first(array, n, guard) {
  1473. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  1474. if (n == null || guard) return array[0];
  1475. return initial(array, array.length - n);
  1476. }
  1477. // Returns everything but the first entry of the `array`. Especially useful on
  1478. // the `arguments` object. Passing an **n** will return the rest N values in the
  1479. // `array`.
  1480. function rest(array, n, guard) {
  1481. return slice.call(array, n == null || guard ? 1 : n);
  1482. }
  1483. // Get the last element of an array. Passing **n** will return the last N
  1484. // values in the array.
  1485. function last(array, n, guard) {
  1486. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  1487. if (n == null || guard) return array[array.length - 1];
  1488. return rest(array, Math.max(0, array.length - n));
  1489. }
  1490. // Trim out all falsy values from an array.
  1491. function compact(array) {
  1492. return filter(array, Boolean);
  1493. }
  1494. // Flatten out an array, either recursively (by default), or up to `depth`.
  1495. // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
  1496. function flatten(array, depth) {
  1497. return flatten$1(array, depth, false);
  1498. }
  1499. // Take the difference between one array and a number of other arrays.
  1500. // Only the elements present in just the first array will remain.
  1501. var difference = restArguments(function(array, rest) {
  1502. rest = flatten$1(rest, true, true);
  1503. return filter(array, function(value){
  1504. return !contains(rest, value);
  1505. });
  1506. });
  1507. // Return a version of the array that does not contain the specified value(s).
  1508. var without = restArguments(function(array, otherArrays) {
  1509. return difference(array, otherArrays);
  1510. });
  1511. // Produce a duplicate-free version of the array. If the array has already
  1512. // been sorted, you have the option of using a faster algorithm.
  1513. // The faster algorithm will not work with an iteratee if the iteratee
  1514. // is not a one-to-one function, so providing an iteratee will disable
  1515. // the faster algorithm.
  1516. function uniq(array, isSorted, iteratee, context) {
  1517. if (!isBoolean(isSorted)) {
  1518. context = iteratee;
  1519. iteratee = isSorted;
  1520. isSorted = false;
  1521. }
  1522. if (iteratee != null) iteratee = cb(iteratee, context);
  1523. var result = [];
  1524. var seen = [];
  1525. for (var i = 0, length = getLength(array); i < length; i++) {
  1526. var value = array[i],
  1527. computed = iteratee ? iteratee(value, i, array) : value;
  1528. if (isSorted && !iteratee) {
  1529. if (!i || seen !== computed) result.push(value);
  1530. seen = computed;
  1531. } else if (iteratee) {
  1532. if (!contains(seen, computed)) {
  1533. seen.push(computed);
  1534. result.push(value);
  1535. }
  1536. } else if (!contains(result, value)) {
  1537. result.push(value);
  1538. }
  1539. }
  1540. return result;
  1541. }
  1542. // Produce an array that contains the union: each distinct element from all of
  1543. // the passed-in arrays.
  1544. var union = restArguments(function(arrays) {
  1545. return uniq(flatten$1(arrays, true, true));
  1546. });
  1547. // Produce an array that contains every item shared between all the
  1548. // passed-in arrays.
  1549. function intersection(array) {
  1550. var result = [];
  1551. var argsLength = arguments.length;
  1552. for (var i = 0, length = getLength(array); i < length; i++) {
  1553. var item = array[i];
  1554. if (contains(result, item)) continue;
  1555. var j;
  1556. for (j = 1; j < argsLength; j++) {
  1557. if (!contains(arguments[j], item)) break;
  1558. }
  1559. if (j === argsLength) result.push(item);
  1560. }
  1561. return result;
  1562. }
  1563. // Complement of zip. Unzip accepts an array of arrays and groups
  1564. // each array's elements on shared indices.
  1565. function unzip(array) {
  1566. var length = array && max(array, getLength).length || 0;
  1567. var result = Array(length);
  1568. for (var index = 0; index < length; index++) {
  1569. result[index] = pluck(array, index);
  1570. }
  1571. return result;
  1572. }
  1573. // Zip together multiple lists into a single array -- elements that share
  1574. // an index go together.
  1575. var zip = restArguments(unzip);
  1576. // Converts lists into objects. Pass either a single array of `[key, value]`
  1577. // pairs, or two parallel arrays of the same length -- one of keys, and one of
  1578. // the corresponding values. Passing by pairs is the reverse of `_.pairs`.
  1579. function object(list, values) {
  1580. var result = {};
  1581. for (var i = 0, length = getLength(list); i < length; i++) {
  1582. if (values) {
  1583. result[list[i]] = values[i];
  1584. } else {
  1585. result[list[i][0]] = list[i][1];
  1586. }
  1587. }
  1588. return result;
  1589. }
  1590. // Generate an integer Array containing an arithmetic progression. A port of
  1591. // the native Python `range()` function. See
  1592. // [the Python documentation](https://docs.python.org/library/functions.html#range).
  1593. function range(start, stop, step) {
  1594. if (stop == null) {
  1595. stop = start || 0;
  1596. start = 0;
  1597. }
  1598. if (!step) {
  1599. step = stop < start ? -1 : 1;
  1600. }
  1601. var length = Math.max(Math.ceil((stop - start) / step), 0);
  1602. var range = Array(length);
  1603. for (var idx = 0; idx < length; idx++, start += step) {
  1604. range[idx] = start;
  1605. }
  1606. return range;
  1607. }
  1608. // Chunk a single array into multiple arrays, each containing `count` or fewer
  1609. // items.
  1610. function chunk(array, count) {
  1611. if (count == null || count < 1) return [];
  1612. var result = [];
  1613. var i = 0, length = array.length;
  1614. while (i < length) {
  1615. result.push(slice.call(array, i, i += count));
  1616. }
  1617. return result;
  1618. }
  1619. // Helper function to continue chaining intermediate results.
  1620. function chainResult(instance, obj) {
  1621. return instance._chain ? _$1(obj).chain() : obj;
  1622. }
  1623. // Add your own custom functions to the Underscore object.
  1624. function mixin(obj) {
  1625. each(functions(obj), function(name) {
  1626. var func = _$1[name] = obj[name];
  1627. _$1.prototype[name] = function() {
  1628. var args = [this._wrapped];
  1629. push.apply(args, arguments);
  1630. return chainResult(this, func.apply(_$1, args));
  1631. };
  1632. });
  1633. return _$1;
  1634. }
  1635. // Add all mutator `Array` functions to the wrapper.
  1636. each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
  1637. var method = ArrayProto[name];
  1638. _$1.prototype[name] = function() {
  1639. var obj = this._wrapped;
  1640. if (obj != null) {
  1641. method.apply(obj, arguments);
  1642. if ((name === 'shift' || name === 'splice') && obj.length === 0) {
  1643. delete obj[0];
  1644. }
  1645. }
  1646. return chainResult(this, obj);
  1647. };
  1648. });
  1649. // Add all accessor `Array` functions to the wrapper.
  1650. each(['concat', 'join', 'slice'], function(name) {
  1651. var method = ArrayProto[name];
  1652. _$1.prototype[name] = function() {
  1653. var obj = this._wrapped;
  1654. if (obj != null) obj = method.apply(obj, arguments);
  1655. return chainResult(this, obj);
  1656. };
  1657. });
  1658. // Named Exports
  1659. var allExports = {
  1660. __proto__: null,
  1661. VERSION: VERSION,
  1662. restArguments: restArguments,
  1663. isObject: isObject,
  1664. isNull: isNull,
  1665. isUndefined: isUndefined,
  1666. isBoolean: isBoolean,
  1667. isElement: isElement,
  1668. isString: isString,
  1669. isNumber: isNumber,
  1670. isDate: isDate,
  1671. isRegExp: isRegExp,
  1672. isError: isError,
  1673. isSymbol: isSymbol,
  1674. isArrayBuffer: isArrayBuffer,
  1675. isDataView: isDataView$1,
  1676. isArray: isArray,
  1677. isFunction: isFunction$1,
  1678. isArguments: isArguments$1,
  1679. isFinite: isFinite$1,
  1680. isNaN: isNaN$1,
  1681. isTypedArray: isTypedArray$1,
  1682. isEmpty: isEmpty,
  1683. isMatch: isMatch,
  1684. isEqual: isEqual,
  1685. isMap: isMap,
  1686. isWeakMap: isWeakMap,
  1687. isSet: isSet,
  1688. isWeakSet: isWeakSet,
  1689. keys: keys,
  1690. allKeys: allKeys,
  1691. values: values,
  1692. pairs: pairs,
  1693. invert: invert,
  1694. functions: functions,
  1695. methods: functions,
  1696. extend: extend,
  1697. extendOwn: extendOwn,
  1698. assign: extendOwn,
  1699. defaults: defaults,
  1700. create: create,
  1701. clone: clone,
  1702. tap: tap,
  1703. get: get,
  1704. has: has,
  1705. mapObject: mapObject,
  1706. identity: identity,
  1707. constant: constant,
  1708. noop: noop,
  1709. toPath: toPath$1,
  1710. property: property,
  1711. propertyOf: propertyOf,
  1712. matcher: matcher,
  1713. matches: matcher,
  1714. times: times,
  1715. random: random,
  1716. now: now,
  1717. escape: _escape,
  1718. unescape: _unescape,
  1719. templateSettings: templateSettings,
  1720. template: template,
  1721. result: result,
  1722. uniqueId: uniqueId,
  1723. chain: chain,
  1724. iteratee: iteratee,
  1725. partial: partial,
  1726. bind: bind,
  1727. bindAll: bindAll,
  1728. memoize: memoize,
  1729. delay: delay,
  1730. defer: defer,
  1731. throttle: throttle,
  1732. debounce: debounce,
  1733. wrap: wrap,
  1734. negate: negate,
  1735. compose: compose,
  1736. after: after,
  1737. before: before,
  1738. once: once,
  1739. findKey: findKey,
  1740. findIndex: findIndex,
  1741. findLastIndex: findLastIndex,
  1742. sortedIndex: sortedIndex,
  1743. indexOf: indexOf,
  1744. lastIndexOf: lastIndexOf,
  1745. find: find,
  1746. detect: find,
  1747. findWhere: findWhere,
  1748. each: each,
  1749. forEach: each,
  1750. map: map,
  1751. collect: map,
  1752. reduce: reduce,
  1753. foldl: reduce,
  1754. inject: reduce,
  1755. reduceRight: reduceRight,
  1756. foldr: reduceRight,
  1757. filter: filter,
  1758. select: filter,
  1759. reject: reject,
  1760. every: every,
  1761. all: every,
  1762. some: some,
  1763. any: some,
  1764. contains: contains,
  1765. includes: contains,
  1766. include: contains,
  1767. invoke: invoke,
  1768. pluck: pluck,
  1769. where: where,
  1770. max: max,
  1771. min: min,
  1772. shuffle: shuffle,
  1773. sample: sample,
  1774. sortBy: sortBy,
  1775. groupBy: groupBy,
  1776. indexBy: indexBy,
  1777. countBy: countBy,
  1778. partition: partition,
  1779. toArray: toArray,
  1780. size: size,
  1781. pick: pick,
  1782. omit: omit,
  1783. first: first,
  1784. head: first,
  1785. take: first,
  1786. initial: initial,
  1787. last: last,
  1788. rest: rest,
  1789. tail: rest,
  1790. drop: rest,
  1791. compact: compact,
  1792. flatten: flatten,
  1793. without: without,
  1794. uniq: uniq,
  1795. unique: uniq,
  1796. union: union,
  1797. intersection: intersection,
  1798. difference: difference,
  1799. unzip: unzip,
  1800. transpose: unzip,
  1801. zip: zip,
  1802. object: object,
  1803. range: range,
  1804. chunk: chunk,
  1805. mixin: mixin,
  1806. 'default': _$1
  1807. };
  1808. // Default Export
  1809. // Add all of the Underscore functions to the wrapper object.
  1810. var _ = mixin(allExports);
  1811. // Legacy Node.js API.
  1812. _._ = _;
  1813. return _;
  1814. })));
  1815. //# sourceMappingURL=underscore-umd.js.map