underscore-node-f.cjs 66 KB

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