underscore-min.js 74 KB

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