underscore.js 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034
  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 = 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.12.1
  11. // https://underscorejs.org
  12. // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  13. // Underscore may be freely distributed under the MIT license.
  14. // Current version.
  15. var VERSION = '1.12.1';
  16. // Establish the root object, `window` (`self`) in the browser, `global`
  17. // on the server, or `this` in some virtual machines. We use `self`
  18. // instead of `window` for `WebWorker` support.
  19. var root = typeof self == 'object' && self.self === self && self ||
  20. typeof global == 'object' && global.global === global && global ||
  21. Function('return this')() ||
  22. {};
  23. // Save bytes in the minified (but not gzipped) version:
  24. var ArrayProto = Array.prototype, ObjProto = Object.prototype;
  25. var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
  26. // Create quick reference variables for speed access to core prototypes.
  27. var push = ArrayProto.push,
  28. slice = ArrayProto.slice,
  29. toString = ObjProto.toString,
  30. hasOwnProperty = ObjProto.hasOwnProperty;
  31. // Modern feature detection.
  32. var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',
  33. supportsDataView = typeof DataView !== 'undefined';
  34. // All **ECMAScript 5+** native function implementations that we hope to use
  35. // are declared here.
  36. var nativeIsArray = Array.isArray,
  37. nativeKeys = Object.keys,
  38. nativeCreate = Object.create,
  39. nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
  40. // Create references to these builtin functions because we override them.
  41. var _isNaN = isNaN,
  42. _isFinite = isFinite;
  43. // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
  44. var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
  45. var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
  46. 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
  47. // The largest integer that can be represented exactly.
  48. var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
  49. // Some functions take a variable number of arguments, or a few expected
  50. // arguments at the beginning and then a variable number of values to operate
  51. // on. This helper accumulates all remaining arguments past the function’s
  52. // argument length (or an explicit `startIndex`), into an array that becomes
  53. // the last argument. Similar to ES6’s "rest parameter".
  54. function restArguments(func, startIndex) {
  55. startIndex = startIndex == null ? func.length - 1 : +startIndex;
  56. return function() {
  57. var length = Math.max(arguments.length - startIndex, 0),
  58. rest = Array(length),
  59. index = 0;
  60. for (; index < length; index++) {
  61. rest[index] = arguments[index + startIndex];
  62. }
  63. switch (startIndex) {
  64. case 0: return func.call(this, rest);
  65. case 1: return func.call(this, arguments[0], rest);
  66. case 2: return func.call(this, arguments[0], arguments[1], rest);
  67. }
  68. var args = Array(startIndex + 1);
  69. for (index = 0; index < startIndex; index++) {
  70. args[index] = arguments[index];
  71. }
  72. args[startIndex] = rest;
  73. return func.apply(this, args);
  74. };
  75. }
  76. // Is a given variable an object?
  77. function isObject(obj) {
  78. var type = typeof obj;
  79. return type === 'function' || type === 'object' && !!obj;
  80. }
  81. // Is a given value equal to null?
  82. function isNull(obj) {
  83. return obj === null;
  84. }
  85. // Is a given variable undefined?
  86. function isUndefined(obj) {
  87. return obj === void 0;
  88. }
  89. // Is a given value a boolean?
  90. function isBoolean(obj) {
  91. return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
  92. }
  93. // Is a given value a DOM element?
  94. function isElement(obj) {
  95. return !!(obj && obj.nodeType === 1);
  96. }
  97. // Internal function for creating a `toString`-based type tester.
  98. function tagTester(name) {
  99. var tag = '[object ' + name + ']';
  100. return function(obj) {
  101. return toString.call(obj) === tag;
  102. };
  103. }
  104. var isString = tagTester('String');
  105. var isNumber = tagTester('Number');
  106. var isDate = tagTester('Date');
  107. var isRegExp = tagTester('RegExp');
  108. var isError = tagTester('Error');
  109. var isSymbol = tagTester('Symbol');
  110. var isArrayBuffer = tagTester('ArrayBuffer');
  111. var isFunction = tagTester('Function');
  112. // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old
  113. // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
  114. var nodelist = root.document && root.document.childNodes;
  115. if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
  116. isFunction = function(obj) {
  117. return typeof obj == 'function' || false;
  118. };
  119. }
  120. var isFunction$1 = isFunction;
  121. var hasObjectTag = tagTester('Object');
  122. // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.
  123. // In IE 11, the most common among them, this problem also applies to
  124. // `Map`, `WeakMap` and `Set`.
  125. var hasStringTagBug = (
  126. supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))
  127. ),
  128. isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));
  129. var isDataView = tagTester('DataView');
  130. // In IE 10 - Edge 13, we need a different heuristic
  131. // to determine whether an object is a `DataView`.
  132. function ie10IsDataView(obj) {
  133. return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
  134. }
  135. var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);
  136. // Is a given value an array?
  137. // Delegates to ECMA5's native `Array.isArray`.
  138. var isArray = nativeIsArray || tagTester('Array');
  139. // Internal function to check whether `key` is an own property name of `obj`.
  140. function has(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(obj, 'callee');
  150. };
  151. }
  152. }());
  153. var isArguments$1 = isArguments;
  154. // Is a given object a finite number?
  155. function isFinite$1(obj) {
  156. return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
  157. }
  158. // Is the given value `NaN`?
  159. function isNaN$1(obj) {
  160. return isNumber(obj) && _isNaN(obj);
  161. }
  162. // Predicate-generating function. Often useful outside of Underscore.
  163. function constant(value) {
  164. return function() {
  165. return value;
  166. };
  167. }
  168. // Common internal logic for `isArrayLike` and `isBufferLike`.
  169. function createSizePropertyCheck(getSizeProperty) {
  170. return function(collection) {
  171. var sizeProperty = getSizeProperty(collection);
  172. return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
  173. }
  174. }
  175. // Internal helper to generate a function to obtain property `key` from `obj`.
  176. function shallowProperty(key) {
  177. return function(obj) {
  178. return obj == null ? void 0 : obj[key];
  179. };
  180. }
  181. // Internal helper to obtain the `byteLength` property of an object.
  182. var getByteLength = shallowProperty('byteLength');
  183. // Internal helper to determine whether we should spend extensive checks against
  184. // `ArrayBuffer` et al.
  185. var isBufferLike = createSizePropertyCheck(getByteLength);
  186. // Is a given value a typed array?
  187. var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
  188. function isTypedArray(obj) {
  189. // `ArrayBuffer.isView` is the most future-proof, so use it when available.
  190. // Otherwise, fall back on the above regular expression.
  191. return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :
  192. isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
  193. }
  194. var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
  195. // Internal helper to obtain the `length` property of an object.
  196. var getLength = shallowProperty('length');
  197. // Internal helper to create a simple lookup structure.
  198. // `collectNonEnumProps` used to depend on `_.contains`, but this led to
  199. // circular imports. `emulatedSet` is a one-off solution that only works for
  200. // arrays of strings.
  201. function emulatedSet(keys) {
  202. var hash = {};
  203. for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;
  204. return {
  205. contains: function(key) { return hash[key]; },
  206. push: function(key) {
  207. hash[key] = true;
  208. return keys.push(key);
  209. }
  210. };
  211. }
  212. // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't
  213. // be iterated by `for key in ...` and thus missed. Extends `keys` in place if
  214. // needed.
  215. function collectNonEnumProps(obj, keys) {
  216. keys = emulatedSet(keys);
  217. var nonEnumIdx = nonEnumerableProps.length;
  218. var constructor = obj.constructor;
  219. var proto = isFunction$1(constructor) && constructor.prototype || ObjProto;
  220. // Constructor is a special case.
  221. var prop = 'constructor';
  222. if (has(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(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 _(obj) {
  268. if (obj instanceof _) return obj;
  269. if (!(this instanceof _)) return new _(obj);
  270. this._wrapped = obj;
  271. }
  272. _.VERSION = VERSION;
  273. // Extracts the result from a wrapped and chained object.
  274. _.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. _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
  280. _.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 _) a = a._wrapped;
  312. if (b instanceof _) 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(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(path) {
  556. return isArray(path) ? path : [path];
  557. }
  558. _.toPath = toPath;
  559. // Internal wrapper for `_.toPath` to enable minification.
  560. // Similar to `cb` for `_.iteratee`.
  561. function toPath$1(path) {
  562. return _.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$1(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$1(obj, path) {
  585. path = toPath$1(path);
  586. var length = path.length;
  587. for (var i = 0; i < length; i++) {
  588. var key = path[i];
  589. if (!has(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$1(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. _.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 (_.iteratee !== iteratee) return _.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 = _.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. var bareIdentifier = /^\s*(\w|\$)+\s*$/;
  754. // JavaScript micro-templating, similar to John Resig's implementation.
  755. // Underscore templating handles arbitrary delimiters, preserves whitespace,
  756. // and correctly escapes quotes within interpolated code.
  757. // NB: `oldSettings` only exists for backwards compatibility.
  758. function template(text, settings, oldSettings) {
  759. if (!settings && oldSettings) settings = oldSettings;
  760. settings = defaults({}, settings, _.templateSettings);
  761. // Combine delimiters into one regular expression via alternation.
  762. var matcher = RegExp([
  763. (settings.escape || noMatch).source,
  764. (settings.interpolate || noMatch).source,
  765. (settings.evaluate || noMatch).source
  766. ].join('|') + '|$', 'g');
  767. // Compile the template source, escaping string literals appropriately.
  768. var index = 0;
  769. var source = "__p+='";
  770. text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
  771. source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
  772. index = offset + match.length;
  773. if (escape) {
  774. source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
  775. } else if (interpolate) {
  776. source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
  777. } else if (evaluate) {
  778. source += "';\n" + evaluate + "\n__p+='";
  779. }
  780. // Adobe VMs need the match returned to produce the correct offset.
  781. return match;
  782. });
  783. source += "';\n";
  784. var argument = settings.variable;
  785. if (argument) {
  786. if (!bareIdentifier.test(argument)) throw new Error(argument);
  787. } else {
  788. // If a variable is not specified, place data values in local scope.
  789. source = 'with(obj||{}){\n' + source + '}\n';
  790. argument = 'obj';
  791. }
  792. source = "var __t,__p='',__j=Array.prototype.join," +
  793. "print=function(){__p+=__j.call(arguments,'');};\n" +
  794. source + 'return __p;\n';
  795. var render;
  796. try {
  797. render = new Function(argument, '_', source);
  798. } catch (e) {
  799. e.source = source;
  800. throw e;
  801. }
  802. var template = function(data) {
  803. return render.call(this, data, _);
  804. };
  805. // Provide the compiled source as a convenience for precompilation.
  806. template.source = 'function(' + argument + '){\n' + source + '}';
  807. return template;
  808. }
  809. // Traverses the children of `obj` along `path`. If a child is a function, it
  810. // is invoked with its parent as context. Returns the value of the final
  811. // child, or `fallback` if any child is undefined.
  812. function result(obj, path, fallback) {
  813. path = toPath$1(path);
  814. var length = path.length;
  815. if (!length) {
  816. return isFunction$1(fallback) ? fallback.call(obj) : fallback;
  817. }
  818. for (var i = 0; i < length; i++) {
  819. var prop = obj == null ? void 0 : obj[path[i]];
  820. if (prop === void 0) {
  821. prop = fallback;
  822. i = length; // Ensure we don't continue iterating.
  823. }
  824. obj = isFunction$1(prop) ? prop.call(obj) : prop;
  825. }
  826. return obj;
  827. }
  828. // Generate a unique integer id (unique within the entire client session).
  829. // Useful for temporary DOM ids.
  830. var idCounter = 0;
  831. function uniqueId(prefix) {
  832. var id = ++idCounter + '';
  833. return prefix ? prefix + id : id;
  834. }
  835. // Start chaining a wrapped Underscore object.
  836. function chain(obj) {
  837. var instance = _(obj);
  838. instance._chain = true;
  839. return instance;
  840. }
  841. // Internal function to execute `sourceFunc` bound to `context` with optional
  842. // `args`. Determines whether to execute a function as a constructor or as a
  843. // normal function.
  844. function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
  845. if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
  846. var self = baseCreate(sourceFunc.prototype);
  847. var result = sourceFunc.apply(self, args);
  848. if (isObject(result)) return result;
  849. return self;
  850. }
  851. // Partially apply a function by creating a version that has had some of its
  852. // arguments pre-filled, without changing its dynamic `this` context. `_` acts
  853. // as a placeholder by default, allowing any combination of arguments to be
  854. // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
  855. var partial = restArguments(function(func, boundArgs) {
  856. var placeholder = partial.placeholder;
  857. var bound = function() {
  858. var position = 0, length = boundArgs.length;
  859. var args = Array(length);
  860. for (var i = 0; i < length; i++) {
  861. args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
  862. }
  863. while (position < arguments.length) args.push(arguments[position++]);
  864. return executeBound(func, bound, this, this, args);
  865. };
  866. return bound;
  867. });
  868. partial.placeholder = _;
  869. // Create a function bound to a given object (assigning `this`, and arguments,
  870. // optionally).
  871. var bind = restArguments(function(func, context, args) {
  872. if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');
  873. var bound = restArguments(function(callArgs) {
  874. return executeBound(func, bound, context, this, args.concat(callArgs));
  875. });
  876. return bound;
  877. });
  878. // Internal helper for collection methods to determine whether a collection
  879. // should be iterated as an array or as an object.
  880. // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
  881. // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
  882. var isArrayLike = createSizePropertyCheck(getLength);
  883. // Internal implementation of a recursive `flatten` function.
  884. function flatten(input, depth, strict, output) {
  885. output = output || [];
  886. if (!depth && depth !== 0) {
  887. depth = Infinity;
  888. } else if (depth <= 0) {
  889. return output.concat(input);
  890. }
  891. var idx = output.length;
  892. for (var i = 0, length = getLength(input); i < length; i++) {
  893. var value = input[i];
  894. if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {
  895. // Flatten current level of array or arguments object.
  896. if (depth > 1) {
  897. flatten(value, depth - 1, strict, output);
  898. idx = output.length;
  899. } else {
  900. var j = 0, len = value.length;
  901. while (j < len) output[idx++] = value[j++];
  902. }
  903. } else if (!strict) {
  904. output[idx++] = value;
  905. }
  906. }
  907. return output;
  908. }
  909. // Bind a number of an object's methods to that object. Remaining arguments
  910. // are the method names to be bound. Useful for ensuring that all callbacks
  911. // defined on an object belong to it.
  912. var bindAll = restArguments(function(obj, keys) {
  913. keys = flatten(keys, false, false);
  914. var index = keys.length;
  915. if (index < 1) throw new Error('bindAll must be passed function names');
  916. while (index--) {
  917. var key = keys[index];
  918. obj[key] = bind(obj[key], obj);
  919. }
  920. return obj;
  921. });
  922. // Memoize an expensive function by storing its results.
  923. function memoize(func, hasher) {
  924. var memoize = function(key) {
  925. var cache = memoize.cache;
  926. var address = '' + (hasher ? hasher.apply(this, arguments) : key);
  927. if (!has(cache, address)) cache[address] = func.apply(this, arguments);
  928. return cache[address];
  929. };
  930. memoize.cache = {};
  931. return memoize;
  932. }
  933. // Delays a function for the given number of milliseconds, and then calls
  934. // it with the arguments supplied.
  935. var delay = restArguments(function(func, wait, args) {
  936. return setTimeout(function() {
  937. return func.apply(null, args);
  938. }, wait);
  939. });
  940. // Defers a function, scheduling it to run after the current call stack has
  941. // cleared.
  942. var defer = partial(delay, _, 1);
  943. // Returns a function, that, when invoked, will only be triggered at most once
  944. // during a given window of time. Normally, the throttled function will run
  945. // as much as it can, without ever going more than once per `wait` duration;
  946. // but if you'd like to disable the execution on the leading edge, pass
  947. // `{leading: false}`. To disable execution on the trailing edge, ditto.
  948. function throttle(func, wait, options) {
  949. var timeout, context, args, result;
  950. var previous = 0;
  951. if (!options) options = {};
  952. var later = function() {
  953. previous = options.leading === false ? 0 : now();
  954. timeout = null;
  955. result = func.apply(context, args);
  956. if (!timeout) context = args = null;
  957. };
  958. var throttled = function() {
  959. var _now = now();
  960. if (!previous && options.leading === false) previous = _now;
  961. var remaining = wait - (_now - previous);
  962. context = this;
  963. args = arguments;
  964. if (remaining <= 0 || remaining > wait) {
  965. if (timeout) {
  966. clearTimeout(timeout);
  967. timeout = null;
  968. }
  969. previous = _now;
  970. result = func.apply(context, args);
  971. if (!timeout) context = args = null;
  972. } else if (!timeout && options.trailing !== false) {
  973. timeout = setTimeout(later, remaining);
  974. }
  975. return result;
  976. };
  977. throttled.cancel = function() {
  978. clearTimeout(timeout);
  979. previous = 0;
  980. timeout = context = args = null;
  981. };
  982. return throttled;
  983. }
  984. // When a sequence of calls of the returned function ends, the argument
  985. // function is triggered. The end of a sequence is defined by the `wait`
  986. // parameter. If `immediate` is passed, the argument function will be
  987. // triggered at the beginning of the sequence instead of at the end.
  988. function debounce(func, wait, immediate) {
  989. var timeout, previous, args, result, context;
  990. var later = function() {
  991. var passed = now() - previous;
  992. if (wait > passed) {
  993. timeout = setTimeout(later, wait - passed);
  994. } else {
  995. timeout = null;
  996. if (!immediate) result = func.apply(context, args);
  997. // This check is needed because `func` can recursively invoke `debounced`.
  998. if (!timeout) args = context = null;
  999. }
  1000. };
  1001. var debounced = restArguments(function(_args) {
  1002. context = this;
  1003. args = _args;
  1004. previous = now();
  1005. if (!timeout) {
  1006. timeout = setTimeout(later, wait);
  1007. if (immediate) result = func.apply(context, args);
  1008. }
  1009. return result;
  1010. });
  1011. debounced.cancel = function() {
  1012. clearTimeout(timeout);
  1013. timeout = args = context = null;
  1014. };
  1015. return debounced;
  1016. }
  1017. // Returns the first function passed as an argument to the second,
  1018. // allowing you to adjust arguments, run code before and after, and
  1019. // conditionally execute the original function.
  1020. function wrap(func, wrapper) {
  1021. return partial(wrapper, func);
  1022. }
  1023. // Returns a negated version of the passed-in predicate.
  1024. function negate(predicate) {
  1025. return function() {
  1026. return !predicate.apply(this, arguments);
  1027. };
  1028. }
  1029. // Returns a function that is the composition of a list of functions, each
  1030. // consuming the return value of the function that follows.
  1031. function compose() {
  1032. var args = arguments;
  1033. var start = args.length - 1;
  1034. return function() {
  1035. var i = start;
  1036. var result = args[start].apply(this, arguments);
  1037. while (i--) result = args[i].call(this, result);
  1038. return result;
  1039. };
  1040. }
  1041. // Returns a function that will only be executed on and after the Nth call.
  1042. function after(times, func) {
  1043. return function() {
  1044. if (--times < 1) {
  1045. return func.apply(this, arguments);
  1046. }
  1047. };
  1048. }
  1049. // Returns a function that will only be executed up to (but not including) the
  1050. // Nth call.
  1051. function before(times, func) {
  1052. var memo;
  1053. return function() {
  1054. if (--times > 0) {
  1055. memo = func.apply(this, arguments);
  1056. }
  1057. if (times <= 1) func = null;
  1058. return memo;
  1059. };
  1060. }
  1061. // Returns a function that will be executed at most one time, no matter how
  1062. // often you call it. Useful for lazy initialization.
  1063. var once = partial(before, 2);
  1064. // Returns the first key on an object that passes a truth test.
  1065. function findKey(obj, predicate, context) {
  1066. predicate = cb(predicate, context);
  1067. var _keys = keys(obj), key;
  1068. for (var i = 0, length = _keys.length; i < length; i++) {
  1069. key = _keys[i];
  1070. if (predicate(obj[key], key, obj)) return key;
  1071. }
  1072. }
  1073. // Internal function to generate `_.findIndex` and `_.findLastIndex`.
  1074. function createPredicateIndexFinder(dir) {
  1075. return function(array, predicate, context) {
  1076. predicate = cb(predicate, context);
  1077. var length = getLength(array);
  1078. var index = dir > 0 ? 0 : length - 1;
  1079. for (; index >= 0 && index < length; index += dir) {
  1080. if (predicate(array[index], index, array)) return index;
  1081. }
  1082. return -1;
  1083. };
  1084. }
  1085. // Returns the first index on an array-like that passes a truth test.
  1086. var findIndex = createPredicateIndexFinder(1);
  1087. // Returns the last index on an array-like that passes a truth test.
  1088. var findLastIndex = createPredicateIndexFinder(-1);
  1089. // Use a comparator function to figure out the smallest index at which
  1090. // an object should be inserted so as to maintain order. Uses binary search.
  1091. function sortedIndex(array, obj, iteratee, context) {
  1092. iteratee = cb(iteratee, context, 1);
  1093. var value = iteratee(obj);
  1094. var low = 0, high = getLength(array);
  1095. while (low < high) {
  1096. var mid = Math.floor((low + high) / 2);
  1097. if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
  1098. }
  1099. return low;
  1100. }
  1101. // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
  1102. function createIndexFinder(dir, predicateFind, sortedIndex) {
  1103. return function(array, item, idx) {
  1104. var i = 0, length = getLength(array);
  1105. if (typeof idx == 'number') {
  1106. if (dir > 0) {
  1107. i = idx >= 0 ? idx : Math.max(idx + length, i);
  1108. } else {
  1109. length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
  1110. }
  1111. } else if (sortedIndex && idx && length) {
  1112. idx = sortedIndex(array, item);
  1113. return array[idx] === item ? idx : -1;
  1114. }
  1115. if (item !== item) {
  1116. idx = predicateFind(slice.call(array, i, length), isNaN$1);
  1117. return idx >= 0 ? idx + i : -1;
  1118. }
  1119. for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
  1120. if (array[idx] === item) return idx;
  1121. }
  1122. return -1;
  1123. };
  1124. }
  1125. // Return the position of the first occurrence of an item in an array,
  1126. // or -1 if the item is not included in the array.
  1127. // If the array is large and already in sort order, pass `true`
  1128. // for **isSorted** to use binary search.
  1129. var indexOf = createIndexFinder(1, findIndex, sortedIndex);
  1130. // Return the position of the last occurrence of an item in an array,
  1131. // or -1 if the item is not included in the array.
  1132. var lastIndexOf = createIndexFinder(-1, findLastIndex);
  1133. // Return the first value which passes a truth test.
  1134. function find(obj, predicate, context) {
  1135. var keyFinder = isArrayLike(obj) ? findIndex : findKey;
  1136. var key = keyFinder(obj, predicate, context);
  1137. if (key !== void 0 && key !== -1) return obj[key];
  1138. }
  1139. // Convenience version of a common use case of `_.find`: getting the first
  1140. // object containing specific `key:value` pairs.
  1141. function findWhere(obj, attrs) {
  1142. return find(obj, matcher(attrs));
  1143. }
  1144. // The cornerstone for collection functions, an `each`
  1145. // implementation, aka `forEach`.
  1146. // Handles raw objects in addition to array-likes. Treats all
  1147. // sparse array-likes as if they were dense.
  1148. function each(obj, iteratee, context) {
  1149. iteratee = optimizeCb(iteratee, context);
  1150. var i, length;
  1151. if (isArrayLike(obj)) {
  1152. for (i = 0, length = obj.length; i < length; i++) {
  1153. iteratee(obj[i], i, obj);
  1154. }
  1155. } else {
  1156. var _keys = keys(obj);
  1157. for (i = 0, length = _keys.length; i < length; i++) {
  1158. iteratee(obj[_keys[i]], _keys[i], obj);
  1159. }
  1160. }
  1161. return obj;
  1162. }
  1163. // Return the results of applying the iteratee to each element.
  1164. function map(obj, iteratee, context) {
  1165. iteratee = cb(iteratee, context);
  1166. var _keys = !isArrayLike(obj) && keys(obj),
  1167. length = (_keys || obj).length,
  1168. results = Array(length);
  1169. for (var index = 0; index < length; index++) {
  1170. var currentKey = _keys ? _keys[index] : index;
  1171. results[index] = iteratee(obj[currentKey], currentKey, obj);
  1172. }
  1173. return results;
  1174. }
  1175. // Internal helper to create a reducing function, iterating left or right.
  1176. function createReduce(dir) {
  1177. // Wrap code that reassigns argument variables in a separate function than
  1178. // the one that accesses `arguments.length` to avoid a perf hit. (#1991)
  1179. var reducer = function(obj, iteratee, memo, initial) {
  1180. var _keys = !isArrayLike(obj) && keys(obj),
  1181. length = (_keys || obj).length,
  1182. index = dir > 0 ? 0 : length - 1;
  1183. if (!initial) {
  1184. memo = obj[_keys ? _keys[index] : index];
  1185. index += dir;
  1186. }
  1187. for (; index >= 0 && index < length; index += dir) {
  1188. var currentKey = _keys ? _keys[index] : index;
  1189. memo = iteratee(memo, obj[currentKey], currentKey, obj);
  1190. }
  1191. return memo;
  1192. };
  1193. return function(obj, iteratee, memo, context) {
  1194. var initial = arguments.length >= 3;
  1195. return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
  1196. };
  1197. }
  1198. // **Reduce** builds up a single result from a list of values, aka `inject`,
  1199. // or `foldl`.
  1200. var reduce = createReduce(1);
  1201. // The right-associative version of reduce, also known as `foldr`.
  1202. var reduceRight = createReduce(-1);
  1203. // Return all the elements that pass a truth test.
  1204. function filter(obj, predicate, context) {
  1205. var results = [];
  1206. predicate = cb(predicate, context);
  1207. each(obj, function(value, index, list) {
  1208. if (predicate(value, index, list)) results.push(value);
  1209. });
  1210. return results;
  1211. }
  1212. // Return all the elements for which a truth test fails.
  1213. function reject(obj, predicate, context) {
  1214. return filter(obj, negate(cb(predicate)), context);
  1215. }
  1216. // Determine whether all of the elements pass a truth test.
  1217. function every(obj, predicate, context) {
  1218. predicate = cb(predicate, context);
  1219. var _keys = !isArrayLike(obj) && keys(obj),
  1220. length = (_keys || obj).length;
  1221. for (var index = 0; index < length; index++) {
  1222. var currentKey = _keys ? _keys[index] : index;
  1223. if (!predicate(obj[currentKey], currentKey, obj)) return false;
  1224. }
  1225. return true;
  1226. }
  1227. // Determine if at least one element in the object passes a truth test.
  1228. function some(obj, predicate, context) {
  1229. predicate = cb(predicate, context);
  1230. var _keys = !isArrayLike(obj) && keys(obj),
  1231. length = (_keys || obj).length;
  1232. for (var index = 0; index < length; index++) {
  1233. var currentKey = _keys ? _keys[index] : index;
  1234. if (predicate(obj[currentKey], currentKey, obj)) return true;
  1235. }
  1236. return false;
  1237. }
  1238. // Determine if the array or object contains a given item (using `===`).
  1239. function contains(obj, item, fromIndex, guard) {
  1240. if (!isArrayLike(obj)) obj = values(obj);
  1241. if (typeof fromIndex != 'number' || guard) fromIndex = 0;
  1242. return indexOf(obj, item, fromIndex) >= 0;
  1243. }
  1244. // Invoke a method (with arguments) on every item in a collection.
  1245. var invoke = restArguments(function(obj, path, args) {
  1246. var contextPath, func;
  1247. if (isFunction$1(path)) {
  1248. func = path;
  1249. } else {
  1250. path = toPath$1(path);
  1251. contextPath = path.slice(0, -1);
  1252. path = path[path.length - 1];
  1253. }
  1254. return map(obj, function(context) {
  1255. var method = func;
  1256. if (!method) {
  1257. if (contextPath && contextPath.length) {
  1258. context = deepGet(context, contextPath);
  1259. }
  1260. if (context == null) return void 0;
  1261. method = context[path];
  1262. }
  1263. return method == null ? method : method.apply(context, args);
  1264. });
  1265. });
  1266. // Convenience version of a common use case of `_.map`: fetching a property.
  1267. function pluck(obj, key) {
  1268. return map(obj, property(key));
  1269. }
  1270. // Convenience version of a common use case of `_.filter`: selecting only
  1271. // objects containing specific `key:value` pairs.
  1272. function where(obj, attrs) {
  1273. return filter(obj, matcher(attrs));
  1274. }
  1275. // Return the maximum element (or element-based computation).
  1276. function max(obj, iteratee, context) {
  1277. var result = -Infinity, lastComputed = -Infinity,
  1278. value, computed;
  1279. if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
  1280. obj = isArrayLike(obj) ? obj : values(obj);
  1281. for (var i = 0, length = obj.length; i < length; i++) {
  1282. value = obj[i];
  1283. if (value != null && value > result) {
  1284. result = value;
  1285. }
  1286. }
  1287. } else {
  1288. iteratee = cb(iteratee, context);
  1289. each(obj, function(v, index, list) {
  1290. computed = iteratee(v, index, list);
  1291. if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
  1292. result = v;
  1293. lastComputed = computed;
  1294. }
  1295. });
  1296. }
  1297. return result;
  1298. }
  1299. // Return the minimum element (or element-based computation).
  1300. function min(obj, iteratee, context) {
  1301. var result = Infinity, lastComputed = Infinity,
  1302. value, computed;
  1303. if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {
  1304. obj = isArrayLike(obj) ? obj : values(obj);
  1305. for (var i = 0, length = obj.length; i < length; i++) {
  1306. value = obj[i];
  1307. if (value != null && value < result) {
  1308. result = value;
  1309. }
  1310. }
  1311. } else {
  1312. iteratee = cb(iteratee, context);
  1313. each(obj, function(v, index, list) {
  1314. computed = iteratee(v, index, list);
  1315. if (computed < lastComputed || computed === Infinity && result === Infinity) {
  1316. result = v;
  1317. lastComputed = computed;
  1318. }
  1319. });
  1320. }
  1321. return result;
  1322. }
  1323. // Sample **n** random values from a collection using the modern version of the
  1324. // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
  1325. // If **n** is not specified, returns a single random element.
  1326. // The internal `guard` argument allows it to work with `_.map`.
  1327. function sample(obj, n, guard) {
  1328. if (n == null || guard) {
  1329. if (!isArrayLike(obj)) obj = values(obj);
  1330. return obj[random(obj.length - 1)];
  1331. }
  1332. var sample = isArrayLike(obj) ? clone(obj) : values(obj);
  1333. var length = getLength(sample);
  1334. n = Math.max(Math.min(n, length), 0);
  1335. var last = length - 1;
  1336. for (var index = 0; index < n; index++) {
  1337. var rand = random(index, last);
  1338. var temp = sample[index];
  1339. sample[index] = sample[rand];
  1340. sample[rand] = temp;
  1341. }
  1342. return sample.slice(0, n);
  1343. }
  1344. // Shuffle a collection.
  1345. function shuffle(obj) {
  1346. return sample(obj, Infinity);
  1347. }
  1348. // Sort the object's values by a criterion produced by an iteratee.
  1349. function sortBy(obj, iteratee, context) {
  1350. var index = 0;
  1351. iteratee = cb(iteratee, context);
  1352. return pluck(map(obj, function(value, key, list) {
  1353. return {
  1354. value: value,
  1355. index: index++,
  1356. criteria: iteratee(value, key, list)
  1357. };
  1358. }).sort(function(left, right) {
  1359. var a = left.criteria;
  1360. var b = right.criteria;
  1361. if (a !== b) {
  1362. if (a > b || a === void 0) return 1;
  1363. if (a < b || b === void 0) return -1;
  1364. }
  1365. return left.index - right.index;
  1366. }), 'value');
  1367. }
  1368. // An internal function used for aggregate "group by" operations.
  1369. function group(behavior, partition) {
  1370. return function(obj, iteratee, context) {
  1371. var result = partition ? [[], []] : {};
  1372. iteratee = cb(iteratee, context);
  1373. each(obj, function(value, index) {
  1374. var key = iteratee(value, index, obj);
  1375. behavior(result, value, key);
  1376. });
  1377. return result;
  1378. };
  1379. }
  1380. // Groups the object's values by a criterion. Pass either a string attribute
  1381. // to group by, or a function that returns the criterion.
  1382. var groupBy = group(function(result, value, key) {
  1383. if (has(result, key)) result[key].push(value); else result[key] = [value];
  1384. });
  1385. // Indexes the object's values by a criterion, similar to `_.groupBy`, but for
  1386. // when you know that your index values will be unique.
  1387. var indexBy = group(function(result, value, key) {
  1388. result[key] = value;
  1389. });
  1390. // Counts instances of an object that group by a certain criterion. Pass
  1391. // either a string attribute to count by, or a function that returns the
  1392. // criterion.
  1393. var countBy = group(function(result, value, key) {
  1394. if (has(result, key)) result[key]++; else result[key] = 1;
  1395. });
  1396. // Split a collection into two arrays: one whose elements all pass the given
  1397. // truth test, and one whose elements all do not pass the truth test.
  1398. var partition = group(function(result, value, pass) {
  1399. result[pass ? 0 : 1].push(value);
  1400. }, true);
  1401. // Safely create a real, live array from anything iterable.
  1402. var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
  1403. function toArray(obj) {
  1404. if (!obj) return [];
  1405. if (isArray(obj)) return slice.call(obj);
  1406. if (isString(obj)) {
  1407. // Keep surrogate pair characters together.
  1408. return obj.match(reStrSymbol);
  1409. }
  1410. if (isArrayLike(obj)) return map(obj, identity);
  1411. return values(obj);
  1412. }
  1413. // Return the number of elements in a collection.
  1414. function size(obj) {
  1415. if (obj == null) return 0;
  1416. return isArrayLike(obj) ? obj.length : keys(obj).length;
  1417. }
  1418. // Internal `_.pick` helper function to determine whether `key` is an enumerable
  1419. // property name of `obj`.
  1420. function keyInObj(value, key, obj) {
  1421. return key in obj;
  1422. }
  1423. // Return a copy of the object only containing the allowed properties.
  1424. var pick = restArguments(function(obj, keys) {
  1425. var result = {}, iteratee = keys[0];
  1426. if (obj == null) return result;
  1427. if (isFunction$1(iteratee)) {
  1428. if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
  1429. keys = allKeys(obj);
  1430. } else {
  1431. iteratee = keyInObj;
  1432. keys = flatten(keys, false, false);
  1433. obj = Object(obj);
  1434. }
  1435. for (var i = 0, length = keys.length; i < length; i++) {
  1436. var key = keys[i];
  1437. var value = obj[key];
  1438. if (iteratee(value, key, obj)) result[key] = value;
  1439. }
  1440. return result;
  1441. });
  1442. // Return a copy of the object without the disallowed properties.
  1443. var omit = restArguments(function(obj, keys) {
  1444. var iteratee = keys[0], context;
  1445. if (isFunction$1(iteratee)) {
  1446. iteratee = negate(iteratee);
  1447. if (keys.length > 1) context = keys[1];
  1448. } else {
  1449. keys = map(flatten(keys, false, false), String);
  1450. iteratee = function(value, key) {
  1451. return !contains(keys, key);
  1452. };
  1453. }
  1454. return pick(obj, iteratee, context);
  1455. });
  1456. // Returns everything but the last entry of the array. Especially useful on
  1457. // the arguments object. Passing **n** will return all the values in
  1458. // the array, excluding the last N.
  1459. function initial(array, n, guard) {
  1460. return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
  1461. }
  1462. // Get the first element of an array. Passing **n** will return the first N
  1463. // values in the array. The **guard** check allows it to work with `_.map`.
  1464. function first(array, n, guard) {
  1465. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  1466. if (n == null || guard) return array[0];
  1467. return initial(array, array.length - n);
  1468. }
  1469. // Returns everything but the first entry of the `array`. Especially useful on
  1470. // the `arguments` object. Passing an **n** will return the rest N values in the
  1471. // `array`.
  1472. function rest(array, n, guard) {
  1473. return slice.call(array, n == null || guard ? 1 : n);
  1474. }
  1475. // Get the last element of an array. Passing **n** will return the last N
  1476. // values in the array.
  1477. function last(array, n, guard) {
  1478. if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
  1479. if (n == null || guard) return array[array.length - 1];
  1480. return rest(array, Math.max(0, array.length - n));
  1481. }
  1482. // Trim out all falsy values from an array.
  1483. function compact(array) {
  1484. return filter(array, Boolean);
  1485. }
  1486. // Flatten out an array, either recursively (by default), or up to `depth`.
  1487. // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
  1488. function flatten$1(array, depth) {
  1489. return flatten(array, depth, false);
  1490. }
  1491. // Take the difference between one array and a number of other arrays.
  1492. // Only the elements present in just the first array will remain.
  1493. var difference = restArguments(function(array, rest) {
  1494. rest = flatten(rest, true, true);
  1495. return filter(array, function(value){
  1496. return !contains(rest, value);
  1497. });
  1498. });
  1499. // Return a version of the array that does not contain the specified value(s).
  1500. var without = restArguments(function(array, otherArrays) {
  1501. return difference(array, otherArrays);
  1502. });
  1503. // Produce a duplicate-free version of the array. If the array has already
  1504. // been sorted, you have the option of using a faster algorithm.
  1505. // The faster algorithm will not work with an iteratee if the iteratee
  1506. // is not a one-to-one function, so providing an iteratee will disable
  1507. // the faster algorithm.
  1508. function uniq(array, isSorted, iteratee, context) {
  1509. if (!isBoolean(isSorted)) {
  1510. context = iteratee;
  1511. iteratee = isSorted;
  1512. isSorted = false;
  1513. }
  1514. if (iteratee != null) iteratee = cb(iteratee, context);
  1515. var result = [];
  1516. var seen = [];
  1517. for (var i = 0, length = getLength(array); i < length; i++) {
  1518. var value = array[i],
  1519. computed = iteratee ? iteratee(value, i, array) : value;
  1520. if (isSorted && !iteratee) {
  1521. if (!i || seen !== computed) result.push(value);
  1522. seen = computed;
  1523. } else if (iteratee) {
  1524. if (!contains(seen, computed)) {
  1525. seen.push(computed);
  1526. result.push(value);
  1527. }
  1528. } else if (!contains(result, value)) {
  1529. result.push(value);
  1530. }
  1531. }
  1532. return result;
  1533. }
  1534. // Produce an array that contains the union: each distinct element from all of
  1535. // the passed-in arrays.
  1536. var union = restArguments(function(arrays) {
  1537. return uniq(flatten(arrays, true, true));
  1538. });
  1539. // Produce an array that contains every item shared between all the
  1540. // passed-in arrays.
  1541. function intersection(array) {
  1542. var result = [];
  1543. var argsLength = arguments.length;
  1544. for (var i = 0, length = getLength(array); i < length; i++) {
  1545. var item = array[i];
  1546. if (contains(result, item)) continue;
  1547. var j;
  1548. for (j = 1; j < argsLength; j++) {
  1549. if (!contains(arguments[j], item)) break;
  1550. }
  1551. if (j === argsLength) result.push(item);
  1552. }
  1553. return result;
  1554. }
  1555. // Complement of zip. Unzip accepts an array of arrays and groups
  1556. // each array's elements on shared indices.
  1557. function unzip(array) {
  1558. var length = array && max(array, getLength).length || 0;
  1559. var result = Array(length);
  1560. for (var index = 0; index < length; index++) {
  1561. result[index] = pluck(array, index);
  1562. }
  1563. return result;
  1564. }
  1565. // Zip together multiple lists into a single array -- elements that share
  1566. // an index go together.
  1567. var zip = restArguments(unzip);
  1568. // Converts lists into objects. Pass either a single array of `[key, value]`
  1569. // pairs, or two parallel arrays of the same length -- one of keys, and one of
  1570. // the corresponding values. Passing by pairs is the reverse of `_.pairs`.
  1571. function object(list, values) {
  1572. var result = {};
  1573. for (var i = 0, length = getLength(list); i < length; i++) {
  1574. if (values) {
  1575. result[list[i]] = values[i];
  1576. } else {
  1577. result[list[i][0]] = list[i][1];
  1578. }
  1579. }
  1580. return result;
  1581. }
  1582. // Generate an integer Array containing an arithmetic progression. A port of
  1583. // the native Python `range()` function. See
  1584. // [the Python documentation](https://docs.python.org/library/functions.html#range).
  1585. function range(start, stop, step) {
  1586. if (stop == null) {
  1587. stop = start || 0;
  1588. start = 0;
  1589. }
  1590. if (!step) {
  1591. step = stop < start ? -1 : 1;
  1592. }
  1593. var length = Math.max(Math.ceil((stop - start) / step), 0);
  1594. var range = Array(length);
  1595. for (var idx = 0; idx < length; idx++, start += step) {
  1596. range[idx] = start;
  1597. }
  1598. return range;
  1599. }
  1600. // Chunk a single array into multiple arrays, each containing `count` or fewer
  1601. // items.
  1602. function chunk(array, count) {
  1603. if (count == null || count < 1) return [];
  1604. var result = [];
  1605. var i = 0, length = array.length;
  1606. while (i < length) {
  1607. result.push(slice.call(array, i, i += count));
  1608. }
  1609. return result;
  1610. }
  1611. // Helper function to continue chaining intermediate results.
  1612. function chainResult(instance, obj) {
  1613. return instance._chain ? _(obj).chain() : obj;
  1614. }
  1615. // Add your own custom functions to the Underscore object.
  1616. function mixin(obj) {
  1617. each(functions(obj), function(name) {
  1618. var func = _[name] = obj[name];
  1619. _.prototype[name] = function() {
  1620. var args = [this._wrapped];
  1621. push.apply(args, arguments);
  1622. return chainResult(this, func.apply(_, args));
  1623. };
  1624. });
  1625. return _;
  1626. }
  1627. // Add all mutator `Array` functions to the wrapper.
  1628. each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
  1629. var method = ArrayProto[name];
  1630. _.prototype[name] = function() {
  1631. var obj = this._wrapped;
  1632. if (obj != null) {
  1633. method.apply(obj, arguments);
  1634. if ((name === 'shift' || name === 'splice') && obj.length === 0) {
  1635. delete obj[0];
  1636. }
  1637. }
  1638. return chainResult(this, obj);
  1639. };
  1640. });
  1641. // Add all accessor `Array` functions to the wrapper.
  1642. each(['concat', 'join', 'slice'], function(name) {
  1643. var method = ArrayProto[name];
  1644. _.prototype[name] = function() {
  1645. var obj = this._wrapped;
  1646. if (obj != null) obj = method.apply(obj, arguments);
  1647. return chainResult(this, obj);
  1648. };
  1649. });
  1650. // Named Exports
  1651. var allExports = {
  1652. __proto__: null,
  1653. VERSION: VERSION,
  1654. restArguments: restArguments,
  1655. isObject: isObject,
  1656. isNull: isNull,
  1657. isUndefined: isUndefined,
  1658. isBoolean: isBoolean,
  1659. isElement: isElement,
  1660. isString: isString,
  1661. isNumber: isNumber,
  1662. isDate: isDate,
  1663. isRegExp: isRegExp,
  1664. isError: isError,
  1665. isSymbol: isSymbol,
  1666. isArrayBuffer: isArrayBuffer,
  1667. isDataView: isDataView$1,
  1668. isArray: isArray,
  1669. isFunction: isFunction$1,
  1670. isArguments: isArguments$1,
  1671. isFinite: isFinite$1,
  1672. isNaN: isNaN$1,
  1673. isTypedArray: isTypedArray$1,
  1674. isEmpty: isEmpty,
  1675. isMatch: isMatch,
  1676. isEqual: isEqual,
  1677. isMap: isMap,
  1678. isWeakMap: isWeakMap,
  1679. isSet: isSet,
  1680. isWeakSet: isWeakSet,
  1681. keys: keys,
  1682. allKeys: allKeys,
  1683. values: values,
  1684. pairs: pairs,
  1685. invert: invert,
  1686. functions: functions,
  1687. methods: functions,
  1688. extend: extend,
  1689. extendOwn: extendOwn,
  1690. assign: extendOwn,
  1691. defaults: defaults,
  1692. create: create,
  1693. clone: clone,
  1694. tap: tap,
  1695. get: get,
  1696. has: has$1,
  1697. mapObject: mapObject,
  1698. identity: identity,
  1699. constant: constant,
  1700. noop: noop,
  1701. toPath: toPath,
  1702. property: property,
  1703. propertyOf: propertyOf,
  1704. matcher: matcher,
  1705. matches: matcher,
  1706. times: times,
  1707. random: random,
  1708. now: now,
  1709. escape: _escape,
  1710. unescape: _unescape,
  1711. templateSettings: templateSettings,
  1712. template: template,
  1713. result: result,
  1714. uniqueId: uniqueId,
  1715. chain: chain,
  1716. iteratee: iteratee,
  1717. partial: partial,
  1718. bind: bind,
  1719. bindAll: bindAll,
  1720. memoize: memoize,
  1721. delay: delay,
  1722. defer: defer,
  1723. throttle: throttle,
  1724. debounce: debounce,
  1725. wrap: wrap,
  1726. negate: negate,
  1727. compose: compose,
  1728. after: after,
  1729. before: before,
  1730. once: once,
  1731. findKey: findKey,
  1732. findIndex: findIndex,
  1733. findLastIndex: findLastIndex,
  1734. sortedIndex: sortedIndex,
  1735. indexOf: indexOf,
  1736. lastIndexOf: lastIndexOf,
  1737. find: find,
  1738. detect: find,
  1739. findWhere: findWhere,
  1740. each: each,
  1741. forEach: each,
  1742. map: map,
  1743. collect: map,
  1744. reduce: reduce,
  1745. foldl: reduce,
  1746. inject: reduce,
  1747. reduceRight: reduceRight,
  1748. foldr: reduceRight,
  1749. filter: filter,
  1750. select: filter,
  1751. reject: reject,
  1752. every: every,
  1753. all: every,
  1754. some: some,
  1755. any: some,
  1756. contains: contains,
  1757. includes: contains,
  1758. include: contains,
  1759. invoke: invoke,
  1760. pluck: pluck,
  1761. where: where,
  1762. max: max,
  1763. min: min,
  1764. shuffle: shuffle,
  1765. sample: sample,
  1766. sortBy: sortBy,
  1767. groupBy: groupBy,
  1768. indexBy: indexBy,
  1769. countBy: countBy,
  1770. partition: partition,
  1771. toArray: toArray,
  1772. size: size,
  1773. pick: pick,
  1774. omit: omit,
  1775. first: first,
  1776. head: first,
  1777. take: first,
  1778. initial: initial,
  1779. last: last,
  1780. rest: rest,
  1781. tail: rest,
  1782. drop: rest,
  1783. compact: compact,
  1784. flatten: flatten$1,
  1785. without: without,
  1786. uniq: uniq,
  1787. unique: uniq,
  1788. union: union,
  1789. intersection: intersection,
  1790. difference: difference,
  1791. unzip: unzip,
  1792. transpose: unzip,
  1793. zip: zip,
  1794. object: object,
  1795. range: range,
  1796. chunk: chunk,
  1797. mixin: mixin,
  1798. 'default': _
  1799. };
  1800. // Default Export
  1801. // Add all of the Underscore functions to the wrapper object.
  1802. var _$1 = mixin(allExports);
  1803. // Legacy Node.js API.
  1804. _$1._ = _$1;
  1805. return _$1;
  1806. })));
  1807. //# sourceMappingURL=underscore.js.map