underscore-node-f.cjs 66 KB

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