underscore.js 67 KB

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