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