| Download
Reference manual of the SageMath package kerrgeodesic_gw
Project: Sagittarius
Views: 7654License: GPL3
Image: ubuntu2004
(function (global, factory) {1typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :2typeof define === 'function' && define.amd ? define('underscore', factory) :3(global = global || self, (function () {4var current = global._;5var exports = global._ = factory();6exports.noConflict = function () { global._ = current; return exports; };7}()));8}(this, (function () {9// Underscore.js 1.12.010// https://underscorejs.org11// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors12// Underscore may be freely distributed under the MIT license.1314// Current version.15var VERSION = '1.12.0';1617// Establish the root object, `window` (`self`) in the browser, `global`18// on the server, or `this` in some virtual machines. We use `self`19// instead of `window` for `WebWorker` support.20var root = typeof self == 'object' && self.self === self && self ||21typeof global == 'object' && global.global === global && global ||22Function('return this')() ||23{};2425// Save bytes in the minified (but not gzipped) version:26var ArrayProto = Array.prototype, ObjProto = Object.prototype;27var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;2829// Create quick reference variables for speed access to core prototypes.30var push = ArrayProto.push,31slice = ArrayProto.slice,32toString = ObjProto.toString,33hasOwnProperty = ObjProto.hasOwnProperty;3435// Modern feature detection.36var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined',37supportsDataView = typeof DataView !== 'undefined';3839// All **ECMAScript 5+** native function implementations that we hope to use40// are declared here.41var nativeIsArray = Array.isArray,42nativeKeys = Object.keys,43nativeCreate = Object.create,44nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;4546// Create references to these builtin functions because we override them.47var _isNaN = isNaN,48_isFinite = isFinite;4950// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.51var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');52var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',53'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];5455// The largest integer that can be represented exactly.56var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;5758// Some functions take a variable number of arguments, or a few expected59// arguments at the beginning and then a variable number of values to operate60// on. This helper accumulates all remaining arguments past the function’s61// argument length (or an explicit `startIndex`), into an array that becomes62// the last argument. Similar to ES6’s "rest parameter".63function restArguments(func, startIndex) {64startIndex = startIndex == null ? func.length - 1 : +startIndex;65return function() {66var length = Math.max(arguments.length - startIndex, 0),67rest = Array(length),68index = 0;69for (; index < length; index++) {70rest[index] = arguments[index + startIndex];71}72switch (startIndex) {73case 0: return func.call(this, rest);74case 1: return func.call(this, arguments[0], rest);75case 2: return func.call(this, arguments[0], arguments[1], rest);76}77var args = Array(startIndex + 1);78for (index = 0; index < startIndex; index++) {79args[index] = arguments[index];80}81args[startIndex] = rest;82return func.apply(this, args);83};84}8586// Is a given variable an object?87function isObject(obj) {88var type = typeof obj;89return type === 'function' || type === 'object' && !!obj;90}9192// Is a given value equal to null?93function isNull(obj) {94return obj === null;95}9697// Is a given variable undefined?98function isUndefined(obj) {99return obj === void 0;100}101102// Is a given value a boolean?103function isBoolean(obj) {104return obj === true || obj === false || toString.call(obj) === '[object Boolean]';105}106107// Is a given value a DOM element?108function isElement(obj) {109return !!(obj && obj.nodeType === 1);110}111112// Internal function for creating a `toString`-based type tester.113function tagTester(name) {114var tag = '[object ' + name + ']';115return function(obj) {116return toString.call(obj) === tag;117};118}119120var isString = tagTester('String');121122var isNumber = tagTester('Number');123124var isDate = tagTester('Date');125126var isRegExp = tagTester('RegExp');127128var isError = tagTester('Error');129130var isSymbol = tagTester('Symbol');131132var isArrayBuffer = tagTester('ArrayBuffer');133134var isFunction = tagTester('Function');135136// Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old137// v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).138var nodelist = root.document && root.document.childNodes;139if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {140isFunction = function(obj) {141return typeof obj == 'function' || false;142};143}144145var isFunction$1 = isFunction;146147var hasObjectTag = tagTester('Object');148149// In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`.150// In IE 11, the most common among them, this problem also applies to151// `Map`, `WeakMap` and `Set`.152var hasStringTagBug = (153supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8)))154),155isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map));156157var isDataView = tagTester('DataView');158159// In IE 10 - Edge 13, we need a different heuristic160// to determine whether an object is a `DataView`.161function ie10IsDataView(obj) {162return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);163}164165var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView);166167// Is a given value an array?168// Delegates to ECMA5's native `Array.isArray`.169var isArray = nativeIsArray || tagTester('Array');170171// Internal function to check whether `key` is an own property name of `obj`.172function has(obj, key) {173return obj != null && hasOwnProperty.call(obj, key);174}175176var isArguments = tagTester('Arguments');177178// Define a fallback version of the method in browsers (ahem, IE < 9), where179// there isn't any inspectable "Arguments" type.180(function() {181if (!isArguments(arguments)) {182isArguments = function(obj) {183return has(obj, 'callee');184};185}186}());187188var isArguments$1 = isArguments;189190// Is a given object a finite number?191function isFinite$1(obj) {192return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));193}194195// Is the given value `NaN`?196function isNaN$1(obj) {197return isNumber(obj) && _isNaN(obj);198}199200// Predicate-generating function. Often useful outside of Underscore.201function constant(value) {202return function() {203return value;204};205}206207// Common internal logic for `isArrayLike` and `isBufferLike`.208function createSizePropertyCheck(getSizeProperty) {209return function(collection) {210var sizeProperty = getSizeProperty(collection);211return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;212}213}214215// Internal helper to generate a function to obtain property `key` from `obj`.216function shallowProperty(key) {217return function(obj) {218return obj == null ? void 0 : obj[key];219};220}221222// Internal helper to obtain the `byteLength` property of an object.223var getByteLength = shallowProperty('byteLength');224225// Internal helper to determine whether we should spend extensive checks against226// `ArrayBuffer` et al.227var isBufferLike = createSizePropertyCheck(getByteLength);228229// Is a given value a typed array?230var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;231function isTypedArray(obj) {232// `ArrayBuffer.isView` is the most future-proof, so use it when available.233// Otherwise, fall back on the above regular expression.234return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) :235isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));236}237238var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);239240// Internal helper to obtain the `length` property of an object.241var getLength = shallowProperty('length');242243// Internal helper to create a simple lookup structure.244// `collectNonEnumProps` used to depend on `_.contains`, but this led to245// circular imports. `emulatedSet` is a one-off solution that only works for246// arrays of strings.247function emulatedSet(keys) {248var hash = {};249for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true;250return {251contains: function(key) { return hash[key]; },252push: function(key) {253hash[key] = true;254return keys.push(key);255}256};257}258259// Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't260// be iterated by `for key in ...` and thus missed. Extends `keys` in place if261// needed.262function collectNonEnumProps(obj, keys) {263keys = emulatedSet(keys);264var nonEnumIdx = nonEnumerableProps.length;265var constructor = obj.constructor;266var proto = isFunction$1(constructor) && constructor.prototype || ObjProto;267268// Constructor is a special case.269var prop = 'constructor';270if (has(obj, prop) && !keys.contains(prop)) keys.push(prop);271272while (nonEnumIdx--) {273prop = nonEnumerableProps[nonEnumIdx];274if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) {275keys.push(prop);276}277}278}279280// Retrieve the names of an object's own properties.281// Delegates to **ECMAScript 5**'s native `Object.keys`.282function keys(obj) {283if (!isObject(obj)) return [];284if (nativeKeys) return nativeKeys(obj);285var keys = [];286for (var key in obj) if (has(obj, key)) keys.push(key);287// Ahem, IE < 9.288if (hasEnumBug) collectNonEnumProps(obj, keys);289return keys;290}291292// Is a given array, string, or object empty?293// An "empty" object has no enumerable own-properties.294function isEmpty(obj) {295if (obj == null) return true;296// Skip the more expensive `toString`-based type checks if `obj` has no297// `.length`.298var length = getLength(obj);299if (typeof length == 'number' && (300isArray(obj) || isString(obj) || isArguments$1(obj)301)) return length === 0;302return getLength(keys(obj)) === 0;303}304305// Returns whether an object has a given set of `key:value` pairs.306function isMatch(object, attrs) {307var _keys = keys(attrs), length = _keys.length;308if (object == null) return !length;309var obj = Object(object);310for (var i = 0; i < length; i++) {311var key = _keys[i];312if (attrs[key] !== obj[key] || !(key in obj)) return false;313}314return true;315}316317// If Underscore is called as a function, it returns a wrapped object that can318// be used OO-style. This wrapper holds altered versions of all functions added319// through `_.mixin`. Wrapped objects may be chained.320function _(obj) {321if (obj instanceof _) return obj;322if (!(this instanceof _)) return new _(obj);323this._wrapped = obj;324}325326_.VERSION = VERSION;327328// Extracts the result from a wrapped and chained object.329_.prototype.value = function() {330return this._wrapped;331};332333// Provide unwrapping proxies for some methods used in engine operations334// such as arithmetic and JSON stringification.335_.prototype.valueOf = _.prototype.toJSON = _.prototype.value;336337_.prototype.toString = function() {338return String(this._wrapped);339};340341// Internal function to wrap or shallow-copy an ArrayBuffer,342// typed array or DataView to a new view, reusing the buffer.343function toBufferView(bufferSource) {344return new Uint8Array(345bufferSource.buffer || bufferSource,346bufferSource.byteOffset || 0,347getByteLength(bufferSource)348);349}350351// We use this string twice, so give it a name for minification.352var tagDataView = '[object DataView]';353354// Internal recursive comparison function for `_.isEqual`.355function eq(a, b, aStack, bStack) {356// Identical objects are equal. `0 === -0`, but they aren't identical.357// See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal).358if (a === b) return a !== 0 || 1 / a === 1 / b;359// `null` or `undefined` only equal to itself (strict comparison).360if (a == null || b == null) return false;361// `NaN`s are equivalent, but non-reflexive.362if (a !== a) return b !== b;363// Exhaust primitive checks364var type = typeof a;365if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;366return deepEq(a, b, aStack, bStack);367}368369// Internal recursive comparison function for `_.isEqual`.370function deepEq(a, b, aStack, bStack) {371// Unwrap any wrapped objects.372if (a instanceof _) a = a._wrapped;373if (b instanceof _) b = b._wrapped;374// Compare `[[Class]]` names.375var className = toString.call(a);376if (className !== toString.call(b)) return false;377// Work around a bug in IE 10 - Edge 13.378if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) {379if (!isDataView$1(b)) return false;380className = tagDataView;381}382switch (className) {383// These types are compared by value.384case '[object RegExp]':385// RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')386case '[object String]':387// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is388// equivalent to `new String("5")`.389return '' + a === '' + b;390case '[object Number]':391// `NaN`s are equivalent, but non-reflexive.392// Object(NaN) is equivalent to NaN.393if (+a !== +a) return +b !== +b;394// An `egal` comparison is performed for other numeric values.395return +a === 0 ? 1 / +a === 1 / b : +a === +b;396case '[object Date]':397case '[object Boolean]':398// Coerce dates and booleans to numeric primitive values. Dates are compared by their399// millisecond representations. Note that invalid dates with millisecond representations400// of `NaN` are not equivalent.401return +a === +b;402case '[object Symbol]':403return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);404case '[object ArrayBuffer]':405case tagDataView:406// Coerce to typed array so we can fall through.407return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);408}409410var areArrays = className === '[object Array]';411if (!areArrays && isTypedArray$1(a)) {412var byteLength = getByteLength(a);413if (byteLength !== getByteLength(b)) return false;414if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true;415areArrays = true;416}417if (!areArrays) {418if (typeof a != 'object' || typeof b != 'object') return false;419420// Objects with different constructors are not equivalent, but `Object`s or `Array`s421// from different frames are.422var aCtor = a.constructor, bCtor = b.constructor;423if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor &&424isFunction$1(bCtor) && bCtor instanceof bCtor)425&& ('constructor' in a && 'constructor' in b)) {426return false;427}428}429// Assume equality for cyclic structures. The algorithm for detecting cyclic430// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.431432// Initializing stack of traversed objects.433// It's done here since we only need them for objects and arrays comparison.434aStack = aStack || [];435bStack = bStack || [];436var length = aStack.length;437while (length--) {438// Linear search. Performance is inversely proportional to the number of439// unique nested structures.440if (aStack[length] === a) return bStack[length] === b;441}442443// Add the first object to the stack of traversed objects.444aStack.push(a);445bStack.push(b);446447// Recursively compare objects and arrays.448if (areArrays) {449// Compare array lengths to determine if a deep comparison is necessary.450length = a.length;451if (length !== b.length) return false;452// Deep compare the contents, ignoring non-numeric properties.453while (length--) {454if (!eq(a[length], b[length], aStack, bStack)) return false;455}456} else {457// Deep compare objects.458var _keys = keys(a), key;459length = _keys.length;460// Ensure that both objects contain the same number of properties before comparing deep equality.461if (keys(b).length !== length) return false;462while (length--) {463// Deep compare each member464key = _keys[length];465if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;466}467}468// Remove the first object from the stack of traversed objects.469aStack.pop();470bStack.pop();471return true;472}473474// Perform a deep comparison to check if two objects are equal.475function isEqual(a, b) {476return eq(a, b);477}478479// Retrieve all the enumerable property names of an object.480function allKeys(obj) {481if (!isObject(obj)) return [];482var keys = [];483for (var key in obj) keys.push(key);484// Ahem, IE < 9.485if (hasEnumBug) collectNonEnumProps(obj, keys);486return keys;487}488489// Since the regular `Object.prototype.toString` type tests don't work for490// some types in IE 11, we use a fingerprinting heuristic instead, based491// on the methods. It's not great, but it's the best we got.492// The fingerprint method lists are defined below.493function ie11fingerprint(methods) {494var length = getLength(methods);495return function(obj) {496if (obj == null) return false;497// `Map`, `WeakMap` and `Set` have no enumerable keys.498var keys = allKeys(obj);499if (getLength(keys)) return false;500for (var i = 0; i < length; i++) {501if (!isFunction$1(obj[methods[i]])) return false;502}503// If we are testing against `WeakMap`, we need to ensure that504// `obj` doesn't have a `forEach` method in order to distinguish505// it from a regular `Map`.506return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);507};508}509510// In the interest of compact minification, we write511// each string in the fingerprints only once.512var forEachName = 'forEach',513hasName = 'has',514commonInit = ['clear', 'delete'],515mapTail = ['get', hasName, 'set'];516517// `Map`, `WeakMap` and `Set` each have slightly different518// combinations of the above sublists.519var mapMethods = commonInit.concat(forEachName, mapTail),520weakMapMethods = commonInit.concat(mapTail),521setMethods = ['add'].concat(commonInit, forEachName, hasName);522523var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map');524525var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap');526527var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set');528529var isWeakSet = tagTester('WeakSet');530531// Retrieve the values of an object's properties.532function values(obj) {533var _keys = keys(obj);534var length = _keys.length;535var values = Array(length);536for (var i = 0; i < length; i++) {537values[i] = obj[_keys[i]];538}539return values;540}541542// Convert an object into a list of `[key, value]` pairs.543// The opposite of `_.object` with one argument.544function pairs(obj) {545var _keys = keys(obj);546var length = _keys.length;547var pairs = Array(length);548for (var i = 0; i < length; i++) {549pairs[i] = [_keys[i], obj[_keys[i]]];550}551return pairs;552}553554// Invert the keys and values of an object. The values must be serializable.555function invert(obj) {556var result = {};557var _keys = keys(obj);558for (var i = 0, length = _keys.length; i < length; i++) {559result[obj[_keys[i]]] = _keys[i];560}561return result;562}563564// Return a sorted list of the function names available on the object.565function functions(obj) {566var names = [];567for (var key in obj) {568if (isFunction$1(obj[key])) names.push(key);569}570return names.sort();571}572573// An internal function for creating assigner functions.574function createAssigner(keysFunc, defaults) {575return function(obj) {576var length = arguments.length;577if (defaults) obj = Object(obj);578if (length < 2 || obj == null) return obj;579for (var index = 1; index < length; index++) {580var source = arguments[index],581keys = keysFunc(source),582l = keys.length;583for (var i = 0; i < l; i++) {584var key = keys[i];585if (!defaults || obj[key] === void 0) obj[key] = source[key];586}587}588return obj;589};590}591592// Extend a given object with all the properties in passed-in object(s).593var extend = createAssigner(allKeys);594595// Assigns a given object with all the own properties in the passed-in596// object(s).597// (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)598var extendOwn = createAssigner(keys);599600// Fill in a given object with default properties.601var defaults = createAssigner(allKeys, true);602603// Create a naked function reference for surrogate-prototype-swapping.604function ctor() {605return function(){};606}607608// An internal function for creating a new object that inherits from another.609function baseCreate(prototype) {610if (!isObject(prototype)) return {};611if (nativeCreate) return nativeCreate(prototype);612var Ctor = ctor();613Ctor.prototype = prototype;614var result = new Ctor;615Ctor.prototype = null;616return result;617}618619// Creates an object that inherits from the given prototype object.620// If additional properties are provided then they will be added to the621// created object.622function create(prototype, props) {623var result = baseCreate(prototype);624if (props) extendOwn(result, props);625return result;626}627628// Create a (shallow-cloned) duplicate of an object.629function clone(obj) {630if (!isObject(obj)) return obj;631return isArray(obj) ? obj.slice() : extend({}, obj);632}633634// Invokes `interceptor` with the `obj` and then returns `obj`.635// The primary purpose of this method is to "tap into" a method chain, in636// order to perform operations on intermediate results within the chain.637function tap(obj, interceptor) {638interceptor(obj);639return obj;640}641642// Normalize a (deep) property `path` to array.643// Like `_.iteratee`, this function can be customized.644function toPath(path) {645return isArray(path) ? path : [path];646}647_.toPath = toPath;648649// Internal wrapper for `_.toPath` to enable minification.650// Similar to `cb` for `_.iteratee`.651function toPath$1(path) {652return _.toPath(path);653}654655// Internal function to obtain a nested property in `obj` along `path`.656function deepGet(obj, path) {657var length = path.length;658for (var i = 0; i < length; i++) {659if (obj == null) return void 0;660obj = obj[path[i]];661}662return length ? obj : void 0;663}664665// Get the value of the (deep) property on `path` from `object`.666// If any property in `path` does not exist or if the value is667// `undefined`, return `defaultValue` instead.668// The `path` is normalized through `_.toPath`.669function get(object, path, defaultValue) {670var value = deepGet(object, toPath$1(path));671return isUndefined(value) ? defaultValue : value;672}673674// Shortcut function for checking if an object has a given property directly on675// itself (in other words, not on a prototype). Unlike the internal `has`676// function, this public version can also traverse nested properties.677function has$1(obj, path) {678path = toPath$1(path);679var length = path.length;680for (var i = 0; i < length; i++) {681var key = path[i];682if (!has(obj, key)) return false;683obj = obj[key];684}685return !!length;686}687688// Keep the identity function around for default iteratees.689function identity(value) {690return value;691}692693// Returns a predicate for checking whether an object has a given set of694// `key:value` pairs.695function matcher(attrs) {696attrs = extendOwn({}, attrs);697return function(obj) {698return isMatch(obj, attrs);699};700}701702// Creates a function that, when passed an object, will traverse that object’s703// properties down the given `path`, specified as an array of keys or indices.704function property(path) {705path = toPath$1(path);706return function(obj) {707return deepGet(obj, path);708};709}710711// Internal function that returns an efficient (for current engines) version712// of the passed-in callback, to be repeatedly applied in other Underscore713// functions.714function optimizeCb(func, context, argCount) {715if (context === void 0) return func;716switch (argCount == null ? 3 : argCount) {717case 1: return function(value) {718return func.call(context, value);719};720// The 2-argument case is omitted because we’re not using it.721case 3: return function(value, index, collection) {722return func.call(context, value, index, collection);723};724case 4: return function(accumulator, value, index, collection) {725return func.call(context, accumulator, value, index, collection);726};727}728return function() {729return func.apply(context, arguments);730};731}732733// An internal function to generate callbacks that can be applied to each734// element in a collection, returning the desired result — either `_.identity`,735// an arbitrary callback, a property matcher, or a property accessor.736function baseIteratee(value, context, argCount) {737if (value == null) return identity;738if (isFunction$1(value)) return optimizeCb(value, context, argCount);739if (isObject(value) && !isArray(value)) return matcher(value);740return property(value);741}742743// External wrapper for our callback generator. Users may customize744// `_.iteratee` if they want additional predicate/iteratee shorthand styles.745// This abstraction hides the internal-only `argCount` argument.746function iteratee(value, context) {747return baseIteratee(value, context, Infinity);748}749_.iteratee = iteratee;750751// The function we call internally to generate a callback. It invokes752// `_.iteratee` if overridden, otherwise `baseIteratee`.753function cb(value, context, argCount) {754if (_.iteratee !== iteratee) return _.iteratee(value, context);755return baseIteratee(value, context, argCount);756}757758// Returns the results of applying the `iteratee` to each element of `obj`.759// In contrast to `_.map` it returns an object.760function mapObject(obj, iteratee, context) {761iteratee = cb(iteratee, context);762var _keys = keys(obj),763length = _keys.length,764results = {};765for (var index = 0; index < length; index++) {766var currentKey = _keys[index];767results[currentKey] = iteratee(obj[currentKey], currentKey, obj);768}769return results;770}771772// Predicate-generating function. Often useful outside of Underscore.773function noop(){}774775// Generates a function for a given object that returns a given property.776function propertyOf(obj) {777if (obj == null) return noop;778return function(path) {779return get(obj, path);780};781}782783// Run a function **n** times.784function times(n, iteratee, context) {785var accum = Array(Math.max(0, n));786iteratee = optimizeCb(iteratee, context, 1);787for (var i = 0; i < n; i++) accum[i] = iteratee(i);788return accum;789}790791// Return a random integer between `min` and `max` (inclusive).792function random(min, max) {793if (max == null) {794max = min;795min = 0;796}797return min + Math.floor(Math.random() * (max - min + 1));798}799800// A (possibly faster) way to get the current timestamp as an integer.801var now = Date.now || function() {802return new Date().getTime();803};804805// Internal helper to generate functions for escaping and unescaping strings806// to/from HTML interpolation.807function createEscaper(map) {808var escaper = function(match) {809return map[match];810};811// Regexes for identifying a key that needs to be escaped.812var source = '(?:' + keys(map).join('|') + ')';813var testRegexp = RegExp(source);814var replaceRegexp = RegExp(source, 'g');815return function(string) {816string = string == null ? '' : '' + string;817return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;818};819}820821// Internal list of HTML entities for escaping.822var escapeMap = {823'&': '&',824'<': '<',825'>': '>',826'"': '"',827"'": ''',828'`': '`'829};830831// Function for escaping strings to HTML interpolation.832var _escape = createEscaper(escapeMap);833834// Internal list of HTML entities for unescaping.835var unescapeMap = invert(escapeMap);836837// Function for unescaping strings from HTML interpolation.838var _unescape = createEscaper(unescapeMap);839840// By default, Underscore uses ERB-style template delimiters. Change the841// following template settings to use alternative delimiters.842var templateSettings = _.templateSettings = {843evaluate: /<%([\s\S]+?)%>/g,844interpolate: /<%=([\s\S]+?)%>/g,845escape: /<%-([\s\S]+?)%>/g846};847848// When customizing `_.templateSettings`, if you don't want to define an849// interpolation, evaluation or escaping regex, we need one that is850// guaranteed not to match.851var noMatch = /(.)^/;852853// Certain characters need to be escaped so that they can be put into a854// string literal.855var escapes = {856"'": "'",857'\\': '\\',858'\r': 'r',859'\n': 'n',860'\u2028': 'u2028',861'\u2029': 'u2029'862};863864var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;865866function escapeChar(match) {867return '\\' + escapes[match];868}869870// JavaScript micro-templating, similar to John Resig's implementation.871// Underscore templating handles arbitrary delimiters, preserves whitespace,872// and correctly escapes quotes within interpolated code.873// NB: `oldSettings` only exists for backwards compatibility.874function template(text, settings, oldSettings) {875if (!settings && oldSettings) settings = oldSettings;876settings = defaults({}, settings, _.templateSettings);877878// Combine delimiters into one regular expression via alternation.879var matcher = RegExp([880(settings.escape || noMatch).source,881(settings.interpolate || noMatch).source,882(settings.evaluate || noMatch).source883].join('|') + '|$', 'g');884885// Compile the template source, escaping string literals appropriately.886var index = 0;887var source = "__p+='";888text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {889source += text.slice(index, offset).replace(escapeRegExp, escapeChar);890index = offset + match.length;891892if (escape) {893source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";894} else if (interpolate) {895source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";896} else if (evaluate) {897source += "';\n" + evaluate + "\n__p+='";898}899900// Adobe VMs need the match returned to produce the correct offset.901return match;902});903source += "';\n";904905// If a variable is not specified, place data values in local scope.906if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';907908source = "var __t,__p='',__j=Array.prototype.join," +909"print=function(){__p+=__j.call(arguments,'');};\n" +910source + 'return __p;\n';911912var render;913try {914render = new Function(settings.variable || 'obj', '_', source);915} catch (e) {916e.source = source;917throw e;918}919920var template = function(data) {921return render.call(this, data, _);922};923924// Provide the compiled source as a convenience for precompilation.925var argument = settings.variable || 'obj';926template.source = 'function(' + argument + '){\n' + source + '}';927928return template;929}930931// Traverses the children of `obj` along `path`. If a child is a function, it932// is invoked with its parent as context. Returns the value of the final933// child, or `fallback` if any child is undefined.934function result(obj, path, fallback) {935path = toPath$1(path);936var length = path.length;937if (!length) {938return isFunction$1(fallback) ? fallback.call(obj) : fallback;939}940for (var i = 0; i < length; i++) {941var prop = obj == null ? void 0 : obj[path[i]];942if (prop === void 0) {943prop = fallback;944i = length; // Ensure we don't continue iterating.945}946obj = isFunction$1(prop) ? prop.call(obj) : prop;947}948return obj;949}950951// Generate a unique integer id (unique within the entire client session).952// Useful for temporary DOM ids.953var idCounter = 0;954function uniqueId(prefix) {955var id = ++idCounter + '';956return prefix ? prefix + id : id;957}958959// Start chaining a wrapped Underscore object.960function chain(obj) {961var instance = _(obj);962instance._chain = true;963return instance;964}965966// Internal function to execute `sourceFunc` bound to `context` with optional967// `args`. Determines whether to execute a function as a constructor or as a968// normal function.969function executeBound(sourceFunc, boundFunc, context, callingContext, args) {970if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);971var self = baseCreate(sourceFunc.prototype);972var result = sourceFunc.apply(self, args);973if (isObject(result)) return result;974return self;975}976977// Partially apply a function by creating a version that has had some of its978// arguments pre-filled, without changing its dynamic `this` context. `_` acts979// as a placeholder by default, allowing any combination of arguments to be980// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.981var partial = restArguments(function(func, boundArgs) {982var placeholder = partial.placeholder;983var bound = function() {984var position = 0, length = boundArgs.length;985var args = Array(length);986for (var i = 0; i < length; i++) {987args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];988}989while (position < arguments.length) args.push(arguments[position++]);990return executeBound(func, bound, this, this, args);991};992return bound;993});994995partial.placeholder = _;996997// Create a function bound to a given object (assigning `this`, and arguments,998// optionally).999var bind = restArguments(function(func, context, args) {1000if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function');1001var bound = restArguments(function(callArgs) {1002return executeBound(func, bound, context, this, args.concat(callArgs));1003});1004return bound;1005});10061007// Internal helper for collection methods to determine whether a collection1008// should be iterated as an array or as an object.1009// Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength1010// Avoids a very nasty iOS 8 JIT bug on ARM-64. #20941011var isArrayLike = createSizePropertyCheck(getLength);10121013// Internal implementation of a recursive `flatten` function.1014function flatten(input, depth, strict, output) {1015output = output || [];1016if (!depth && depth !== 0) {1017depth = Infinity;1018} else if (depth <= 0) {1019return output.concat(input);1020}1021var idx = output.length;1022for (var i = 0, length = getLength(input); i < length; i++) {1023var value = input[i];1024if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) {1025// Flatten current level of array or arguments object.1026if (depth > 1) {1027flatten(value, depth - 1, strict, output);1028idx = output.length;1029} else {1030var j = 0, len = value.length;1031while (j < len) output[idx++] = value[j++];1032}1033} else if (!strict) {1034output[idx++] = value;1035}1036}1037return output;1038}10391040// Bind a number of an object's methods to that object. Remaining arguments1041// are the method names to be bound. Useful for ensuring that all callbacks1042// defined on an object belong to it.1043var bindAll = restArguments(function(obj, keys) {1044keys = flatten(keys, false, false);1045var index = keys.length;1046if (index < 1) throw new Error('bindAll must be passed function names');1047while (index--) {1048var key = keys[index];1049obj[key] = bind(obj[key], obj);1050}1051return obj;1052});10531054// Memoize an expensive function by storing its results.1055function memoize(func, hasher) {1056var memoize = function(key) {1057var cache = memoize.cache;1058var address = '' + (hasher ? hasher.apply(this, arguments) : key);1059if (!has(cache, address)) cache[address] = func.apply(this, arguments);1060return cache[address];1061};1062memoize.cache = {};1063return memoize;1064}10651066// Delays a function for the given number of milliseconds, and then calls1067// it with the arguments supplied.1068var delay = restArguments(function(func, wait, args) {1069return setTimeout(function() {1070return func.apply(null, args);1071}, wait);1072});10731074// Defers a function, scheduling it to run after the current call stack has1075// cleared.1076var defer = partial(delay, _, 1);10771078// Returns a function, that, when invoked, will only be triggered at most once1079// during a given window of time. Normally, the throttled function will run1080// as much as it can, without ever going more than once per `wait` duration;1081// but if you'd like to disable the execution on the leading edge, pass1082// `{leading: false}`. To disable execution on the trailing edge, ditto.1083function throttle(func, wait, options) {1084var timeout, context, args, result;1085var previous = 0;1086if (!options) options = {};10871088var later = function() {1089previous = options.leading === false ? 0 : now();1090timeout = null;1091result = func.apply(context, args);1092if (!timeout) context = args = null;1093};10941095var throttled = function() {1096var _now = now();1097if (!previous && options.leading === false) previous = _now;1098var remaining = wait - (_now - previous);1099context = this;1100args = arguments;1101if (remaining <= 0 || remaining > wait) {1102if (timeout) {1103clearTimeout(timeout);1104timeout = null;1105}1106previous = _now;1107result = func.apply(context, args);1108if (!timeout) context = args = null;1109} else if (!timeout && options.trailing !== false) {1110timeout = setTimeout(later, remaining);1111}1112return result;1113};11141115throttled.cancel = function() {1116clearTimeout(timeout);1117previous = 0;1118timeout = context = args = null;1119};11201121return throttled;1122}11231124// When a sequence of calls of the returned function ends, the argument1125// function is triggered. The end of a sequence is defined by the `wait`1126// parameter. If `immediate` is passed, the argument function will be1127// triggered at the beginning of the sequence instead of at the end.1128function debounce(func, wait, immediate) {1129var timeout, previous, args, result, context;11301131var later = function() {1132var passed = now() - previous;1133if (wait > passed) {1134timeout = setTimeout(later, wait - passed);1135} else {1136timeout = null;1137if (!immediate) result = func.apply(context, args);1138// This check is needed because `func` can recursively invoke `debounced`.1139if (!timeout) args = context = null;1140}1141};11421143var debounced = restArguments(function(_args) {1144context = this;1145args = _args;1146previous = now();1147if (!timeout) {1148timeout = setTimeout(later, wait);1149if (immediate) result = func.apply(context, args);1150}1151return result;1152});11531154debounced.cancel = function() {1155clearTimeout(timeout);1156timeout = args = context = null;1157};11581159return debounced;1160}11611162// Returns the first function passed as an argument to the second,1163// allowing you to adjust arguments, run code before and after, and1164// conditionally execute the original function.1165function wrap(func, wrapper) {1166return partial(wrapper, func);1167}11681169// Returns a negated version of the passed-in predicate.1170function negate(predicate) {1171return function() {1172return !predicate.apply(this, arguments);1173};1174}11751176// Returns a function that is the composition of a list of functions, each1177// consuming the return value of the function that follows.1178function compose() {1179var args = arguments;1180var start = args.length - 1;1181return function() {1182var i = start;1183var result = args[start].apply(this, arguments);1184while (i--) result = args[i].call(this, result);1185return result;1186};1187}11881189// Returns a function that will only be executed on and after the Nth call.1190function after(times, func) {1191return function() {1192if (--times < 1) {1193return func.apply(this, arguments);1194}1195};1196}11971198// Returns a function that will only be executed up to (but not including) the1199// Nth call.1200function before(times, func) {1201var memo;1202return function() {1203if (--times > 0) {1204memo = func.apply(this, arguments);1205}1206if (times <= 1) func = null;1207return memo;1208};1209}12101211// Returns a function that will be executed at most one time, no matter how1212// often you call it. Useful for lazy initialization.1213var once = partial(before, 2);12141215// Returns the first key on an object that passes a truth test.1216function findKey(obj, predicate, context) {1217predicate = cb(predicate, context);1218var _keys = keys(obj), key;1219for (var i = 0, length = _keys.length; i < length; i++) {1220key = _keys[i];1221if (predicate(obj[key], key, obj)) return key;1222}1223}12241225// Internal function to generate `_.findIndex` and `_.findLastIndex`.1226function createPredicateIndexFinder(dir) {1227return function(array, predicate, context) {1228predicate = cb(predicate, context);1229var length = getLength(array);1230var index = dir > 0 ? 0 : length - 1;1231for (; index >= 0 && index < length; index += dir) {1232if (predicate(array[index], index, array)) return index;1233}1234return -1;1235};1236}12371238// Returns the first index on an array-like that passes a truth test.1239var findIndex = createPredicateIndexFinder(1);12401241// Returns the last index on an array-like that passes a truth test.1242var findLastIndex = createPredicateIndexFinder(-1);12431244// Use a comparator function to figure out the smallest index at which1245// an object should be inserted so as to maintain order. Uses binary search.1246function sortedIndex(array, obj, iteratee, context) {1247iteratee = cb(iteratee, context, 1);1248var value = iteratee(obj);1249var low = 0, high = getLength(array);1250while (low < high) {1251var mid = Math.floor((low + high) / 2);1252if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;1253}1254return low;1255}12561257// Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.1258function createIndexFinder(dir, predicateFind, sortedIndex) {1259return function(array, item, idx) {1260var i = 0, length = getLength(array);1261if (typeof idx == 'number') {1262if (dir > 0) {1263i = idx >= 0 ? idx : Math.max(idx + length, i);1264} else {1265length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;1266}1267} else if (sortedIndex && idx && length) {1268idx = sortedIndex(array, item);1269return array[idx] === item ? idx : -1;1270}1271if (item !== item) {1272idx = predicateFind(slice.call(array, i, length), isNaN$1);1273return idx >= 0 ? idx + i : -1;1274}1275for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {1276if (array[idx] === item) return idx;1277}1278return -1;1279};1280}12811282// Return the position of the first occurrence of an item in an array,1283// or -1 if the item is not included in the array.1284// If the array is large and already in sort order, pass `true`1285// for **isSorted** to use binary search.1286var indexOf = createIndexFinder(1, findIndex, sortedIndex);12871288// Return the position of the last occurrence of an item in an array,1289// or -1 if the item is not included in the array.1290var lastIndexOf = createIndexFinder(-1, findLastIndex);12911292// Return the first value which passes a truth test.1293function find(obj, predicate, context) {1294var keyFinder = isArrayLike(obj) ? findIndex : findKey;1295var key = keyFinder(obj, predicate, context);1296if (key !== void 0 && key !== -1) return obj[key];1297}12981299// Convenience version of a common use case of `_.find`: getting the first1300// object containing specific `key:value` pairs.1301function findWhere(obj, attrs) {1302return find(obj, matcher(attrs));1303}13041305// The cornerstone for collection functions, an `each`1306// implementation, aka `forEach`.1307// Handles raw objects in addition to array-likes. Treats all1308// sparse array-likes as if they were dense.1309function each(obj, iteratee, context) {1310iteratee = optimizeCb(iteratee, context);1311var i, length;1312if (isArrayLike(obj)) {1313for (i = 0, length = obj.length; i < length; i++) {1314iteratee(obj[i], i, obj);1315}1316} else {1317var _keys = keys(obj);1318for (i = 0, length = _keys.length; i < length; i++) {1319iteratee(obj[_keys[i]], _keys[i], obj);1320}1321}1322return obj;1323}13241325// Return the results of applying the iteratee to each element.1326function map(obj, iteratee, context) {1327iteratee = cb(iteratee, context);1328var _keys = !isArrayLike(obj) && keys(obj),1329length = (_keys || obj).length,1330results = Array(length);1331for (var index = 0; index < length; index++) {1332var currentKey = _keys ? _keys[index] : index;1333results[index] = iteratee(obj[currentKey], currentKey, obj);1334}1335return results;1336}13371338// Internal helper to create a reducing function, iterating left or right.1339function createReduce(dir) {1340// Wrap code that reassigns argument variables in a separate function than1341// the one that accesses `arguments.length` to avoid a perf hit. (#1991)1342var reducer = function(obj, iteratee, memo, initial) {1343var _keys = !isArrayLike(obj) && keys(obj),1344length = (_keys || obj).length,1345index = dir > 0 ? 0 : length - 1;1346if (!initial) {1347memo = obj[_keys ? _keys[index] : index];1348index += dir;1349}1350for (; index >= 0 && index < length; index += dir) {1351var currentKey = _keys ? _keys[index] : index;1352memo = iteratee(memo, obj[currentKey], currentKey, obj);1353}1354return memo;1355};13561357return function(obj, iteratee, memo, context) {1358var initial = arguments.length >= 3;1359return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);1360};1361}13621363// **Reduce** builds up a single result from a list of values, aka `inject`,1364// or `foldl`.1365var reduce = createReduce(1);13661367// The right-associative version of reduce, also known as `foldr`.1368var reduceRight = createReduce(-1);13691370// Return all the elements that pass a truth test.1371function filter(obj, predicate, context) {1372var results = [];1373predicate = cb(predicate, context);1374each(obj, function(value, index, list) {1375if (predicate(value, index, list)) results.push(value);1376});1377return results;1378}13791380// Return all the elements for which a truth test fails.1381function reject(obj, predicate, context) {1382return filter(obj, negate(cb(predicate)), context);1383}13841385// Determine whether all of the elements pass a truth test.1386function every(obj, predicate, context) {1387predicate = cb(predicate, context);1388var _keys = !isArrayLike(obj) && keys(obj),1389length = (_keys || obj).length;1390for (var index = 0; index < length; index++) {1391var currentKey = _keys ? _keys[index] : index;1392if (!predicate(obj[currentKey], currentKey, obj)) return false;1393}1394return true;1395}13961397// Determine if at least one element in the object passes a truth test.1398function some(obj, predicate, context) {1399predicate = cb(predicate, context);1400var _keys = !isArrayLike(obj) && keys(obj),1401length = (_keys || obj).length;1402for (var index = 0; index < length; index++) {1403var currentKey = _keys ? _keys[index] : index;1404if (predicate(obj[currentKey], currentKey, obj)) return true;1405}1406return false;1407}14081409// Determine if the array or object contains a given item (using `===`).1410function contains(obj, item, fromIndex, guard) {1411if (!isArrayLike(obj)) obj = values(obj);1412if (typeof fromIndex != 'number' || guard) fromIndex = 0;1413return indexOf(obj, item, fromIndex) >= 0;1414}14151416// Invoke a method (with arguments) on every item in a collection.1417var invoke = restArguments(function(obj, path, args) {1418var contextPath, func;1419if (isFunction$1(path)) {1420func = path;1421} else {1422path = toPath$1(path);1423contextPath = path.slice(0, -1);1424path = path[path.length - 1];1425}1426return map(obj, function(context) {1427var method = func;1428if (!method) {1429if (contextPath && contextPath.length) {1430context = deepGet(context, contextPath);1431}1432if (context == null) return void 0;1433method = context[path];1434}1435return method == null ? method : method.apply(context, args);1436});1437});14381439// Convenience version of a common use case of `_.map`: fetching a property.1440function pluck(obj, key) {1441return map(obj, property(key));1442}14431444// Convenience version of a common use case of `_.filter`: selecting only1445// objects containing specific `key:value` pairs.1446function where(obj, attrs) {1447return filter(obj, matcher(attrs));1448}14491450// Return the maximum element (or element-based computation).1451function max(obj, iteratee, context) {1452var result = -Infinity, lastComputed = -Infinity,1453value, computed;1454if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {1455obj = isArrayLike(obj) ? obj : values(obj);1456for (var i = 0, length = obj.length; i < length; i++) {1457value = obj[i];1458if (value != null && value > result) {1459result = value;1460}1461}1462} else {1463iteratee = cb(iteratee, context);1464each(obj, function(v, index, list) {1465computed = iteratee(v, index, list);1466if (computed > lastComputed || computed === -Infinity && result === -Infinity) {1467result = v;1468lastComputed = computed;1469}1470});1471}1472return result;1473}14741475// Return the minimum element (or element-based computation).1476function min(obj, iteratee, context) {1477var result = Infinity, lastComputed = Infinity,1478value, computed;1479if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) {1480obj = isArrayLike(obj) ? obj : values(obj);1481for (var i = 0, length = obj.length; i < length; i++) {1482value = obj[i];1483if (value != null && value < result) {1484result = value;1485}1486}1487} else {1488iteratee = cb(iteratee, context);1489each(obj, function(v, index, list) {1490computed = iteratee(v, index, list);1491if (computed < lastComputed || computed === Infinity && result === Infinity) {1492result = v;1493lastComputed = computed;1494}1495});1496}1497return result;1498}14991500// Sample **n** random values from a collection using the modern version of the1501// [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).1502// If **n** is not specified, returns a single random element.1503// The internal `guard` argument allows it to work with `_.map`.1504function sample(obj, n, guard) {1505if (n == null || guard) {1506if (!isArrayLike(obj)) obj = values(obj);1507return obj[random(obj.length - 1)];1508}1509var sample = isArrayLike(obj) ? clone(obj) : values(obj);1510var length = getLength(sample);1511n = Math.max(Math.min(n, length), 0);1512var last = length - 1;1513for (var index = 0; index < n; index++) {1514var rand = random(index, last);1515var temp = sample[index];1516sample[index] = sample[rand];1517sample[rand] = temp;1518}1519return sample.slice(0, n);1520}15211522// Shuffle a collection.1523function shuffle(obj) {1524return sample(obj, Infinity);1525}15261527// Sort the object's values by a criterion produced by an iteratee.1528function sortBy(obj, iteratee, context) {1529var index = 0;1530iteratee = cb(iteratee, context);1531return pluck(map(obj, function(value, key, list) {1532return {1533value: value,1534index: index++,1535criteria: iteratee(value, key, list)1536};1537}).sort(function(left, right) {1538var a = left.criteria;1539var b = right.criteria;1540if (a !== b) {1541if (a > b || a === void 0) return 1;1542if (a < b || b === void 0) return -1;1543}1544return left.index - right.index;1545}), 'value');1546}15471548// An internal function used for aggregate "group by" operations.1549function group(behavior, partition) {1550return function(obj, iteratee, context) {1551var result = partition ? [[], []] : {};1552iteratee = cb(iteratee, context);1553each(obj, function(value, index) {1554var key = iteratee(value, index, obj);1555behavior(result, value, key);1556});1557return result;1558};1559}15601561// Groups the object's values by a criterion. Pass either a string attribute1562// to group by, or a function that returns the criterion.1563var groupBy = group(function(result, value, key) {1564if (has(result, key)) result[key].push(value); else result[key] = [value];1565});15661567// Indexes the object's values by a criterion, similar to `_.groupBy`, but for1568// when you know that your index values will be unique.1569var indexBy = group(function(result, value, key) {1570result[key] = value;1571});15721573// Counts instances of an object that group by a certain criterion. Pass1574// either a string attribute to count by, or a function that returns the1575// criterion.1576var countBy = group(function(result, value, key) {1577if (has(result, key)) result[key]++; else result[key] = 1;1578});15791580// Split a collection into two arrays: one whose elements all pass the given1581// truth test, and one whose elements all do not pass the truth test.1582var partition = group(function(result, value, pass) {1583result[pass ? 0 : 1].push(value);1584}, true);15851586// Safely create a real, live array from anything iterable.1587var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;1588function toArray(obj) {1589if (!obj) return [];1590if (isArray(obj)) return slice.call(obj);1591if (isString(obj)) {1592// Keep surrogate pair characters together.1593return obj.match(reStrSymbol);1594}1595if (isArrayLike(obj)) return map(obj, identity);1596return values(obj);1597}15981599// Return the number of elements in a collection.1600function size(obj) {1601if (obj == null) return 0;1602return isArrayLike(obj) ? obj.length : keys(obj).length;1603}16041605// Internal `_.pick` helper function to determine whether `key` is an enumerable1606// property name of `obj`.1607function keyInObj(value, key, obj) {1608return key in obj;1609}16101611// Return a copy of the object only containing the allowed properties.1612var pick = restArguments(function(obj, keys) {1613var result = {}, iteratee = keys[0];1614if (obj == null) return result;1615if (isFunction$1(iteratee)) {1616if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);1617keys = allKeys(obj);1618} else {1619iteratee = keyInObj;1620keys = flatten(keys, false, false);1621obj = Object(obj);1622}1623for (var i = 0, length = keys.length; i < length; i++) {1624var key = keys[i];1625var value = obj[key];1626if (iteratee(value, key, obj)) result[key] = value;1627}1628return result;1629});16301631// Return a copy of the object without the disallowed properties.1632var omit = restArguments(function(obj, keys) {1633var iteratee = keys[0], context;1634if (isFunction$1(iteratee)) {1635iteratee = negate(iteratee);1636if (keys.length > 1) context = keys[1];1637} else {1638keys = map(flatten(keys, false, false), String);1639iteratee = function(value, key) {1640return !contains(keys, key);1641};1642}1643return pick(obj, iteratee, context);1644});16451646// Returns everything but the last entry of the array. Especially useful on1647// the arguments object. Passing **n** will return all the values in1648// the array, excluding the last N.1649function initial(array, n, guard) {1650return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));1651}16521653// Get the first element of an array. Passing **n** will return the first N1654// values in the array. The **guard** check allows it to work with `_.map`.1655function first(array, n, guard) {1656if (array == null || array.length < 1) return n == null || guard ? void 0 : [];1657if (n == null || guard) return array[0];1658return initial(array, array.length - n);1659}16601661// Returns everything but the first entry of the `array`. Especially useful on1662// the `arguments` object. Passing an **n** will return the rest N values in the1663// `array`.1664function rest(array, n, guard) {1665return slice.call(array, n == null || guard ? 1 : n);1666}16671668// Get the last element of an array. Passing **n** will return the last N1669// values in the array.1670function last(array, n, guard) {1671if (array == null || array.length < 1) return n == null || guard ? void 0 : [];1672if (n == null || guard) return array[array.length - 1];1673return rest(array, Math.max(0, array.length - n));1674}16751676// Trim out all falsy values from an array.1677function compact(array) {1678return filter(array, Boolean);1679}16801681// Flatten out an array, either recursively (by default), or up to `depth`.1682// Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.1683function flatten$1(array, depth) {1684return flatten(array, depth, false);1685}16861687// Take the difference between one array and a number of other arrays.1688// Only the elements present in just the first array will remain.1689var difference = restArguments(function(array, rest) {1690rest = flatten(rest, true, true);1691return filter(array, function(value){1692return !contains(rest, value);1693});1694});16951696// Return a version of the array that does not contain the specified value(s).1697var without = restArguments(function(array, otherArrays) {1698return difference(array, otherArrays);1699});17001701// Produce a duplicate-free version of the array. If the array has already1702// been sorted, you have the option of using a faster algorithm.1703// The faster algorithm will not work with an iteratee if the iteratee1704// is not a one-to-one function, so providing an iteratee will disable1705// the faster algorithm.1706function uniq(array, isSorted, iteratee, context) {1707if (!isBoolean(isSorted)) {1708context = iteratee;1709iteratee = isSorted;1710isSorted = false;1711}1712if (iteratee != null) iteratee = cb(iteratee, context);1713var result = [];1714var seen = [];1715for (var i = 0, length = getLength(array); i < length; i++) {1716var value = array[i],1717computed = iteratee ? iteratee(value, i, array) : value;1718if (isSorted && !iteratee) {1719if (!i || seen !== computed) result.push(value);1720seen = computed;1721} else if (iteratee) {1722if (!contains(seen, computed)) {1723seen.push(computed);1724result.push(value);1725}1726} else if (!contains(result, value)) {1727result.push(value);1728}1729}1730return result;1731}17321733// Produce an array that contains the union: each distinct element from all of1734// the passed-in arrays.1735var union = restArguments(function(arrays) {1736return uniq(flatten(arrays, true, true));1737});17381739// Produce an array that contains every item shared between all the1740// passed-in arrays.1741function intersection(array) {1742var result = [];1743var argsLength = arguments.length;1744for (var i = 0, length = getLength(array); i < length; i++) {1745var item = array[i];1746if (contains(result, item)) continue;1747var j;1748for (j = 1; j < argsLength; j++) {1749if (!contains(arguments[j], item)) break;1750}1751if (j === argsLength) result.push(item);1752}1753return result;1754}17551756// Complement of zip. Unzip accepts an array of arrays and groups1757// each array's elements on shared indices.1758function unzip(array) {1759var length = array && max(array, getLength).length || 0;1760var result = Array(length);17611762for (var index = 0; index < length; index++) {1763result[index] = pluck(array, index);1764}1765return result;1766}17671768// Zip together multiple lists into a single array -- elements that share1769// an index go together.1770var zip = restArguments(unzip);17711772// Converts lists into objects. Pass either a single array of `[key, value]`1773// pairs, or two parallel arrays of the same length -- one of keys, and one of1774// the corresponding values. Passing by pairs is the reverse of `_.pairs`.1775function object(list, values) {1776var result = {};1777for (var i = 0, length = getLength(list); i < length; i++) {1778if (values) {1779result[list[i]] = values[i];1780} else {1781result[list[i][0]] = list[i][1];1782}1783}1784return result;1785}17861787// Generate an integer Array containing an arithmetic progression. A port of1788// the native Python `range()` function. See1789// [the Python documentation](https://docs.python.org/library/functions.html#range).1790function range(start, stop, step) {1791if (stop == null) {1792stop = start || 0;1793start = 0;1794}1795if (!step) {1796step = stop < start ? -1 : 1;1797}17981799var length = Math.max(Math.ceil((stop - start) / step), 0);1800var range = Array(length);18011802for (var idx = 0; idx < length; idx++, start += step) {1803range[idx] = start;1804}18051806return range;1807}18081809// Chunk a single array into multiple arrays, each containing `count` or fewer1810// items.1811function chunk(array, count) {1812if (count == null || count < 1) return [];1813var result = [];1814var i = 0, length = array.length;1815while (i < length) {1816result.push(slice.call(array, i, i += count));1817}1818return result;1819}18201821// Helper function to continue chaining intermediate results.1822function chainResult(instance, obj) {1823return instance._chain ? _(obj).chain() : obj;1824}18251826// Add your own custom functions to the Underscore object.1827function mixin(obj) {1828each(functions(obj), function(name) {1829var func = _[name] = obj[name];1830_.prototype[name] = function() {1831var args = [this._wrapped];1832push.apply(args, arguments);1833return chainResult(this, func.apply(_, args));1834};1835});1836return _;1837}18381839// Add all mutator `Array` functions to the wrapper.1840each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {1841var method = ArrayProto[name];1842_.prototype[name] = function() {1843var obj = this._wrapped;1844if (obj != null) {1845method.apply(obj, arguments);1846if ((name === 'shift' || name === 'splice') && obj.length === 0) {1847delete obj[0];1848}1849}1850return chainResult(this, obj);1851};1852});18531854// Add all accessor `Array` functions to the wrapper.1855each(['concat', 'join', 'slice'], function(name) {1856var method = ArrayProto[name];1857_.prototype[name] = function() {1858var obj = this._wrapped;1859if (obj != null) obj = method.apply(obj, arguments);1860return chainResult(this, obj);1861};1862});18631864// Named Exports18651866var allExports = {1867__proto__: null,1868VERSION: VERSION,1869restArguments: restArguments,1870isObject: isObject,1871isNull: isNull,1872isUndefined: isUndefined,1873isBoolean: isBoolean,1874isElement: isElement,1875isString: isString,1876isNumber: isNumber,1877isDate: isDate,1878isRegExp: isRegExp,1879isError: isError,1880isSymbol: isSymbol,1881isArrayBuffer: isArrayBuffer,1882isDataView: isDataView$1,1883isArray: isArray,1884isFunction: isFunction$1,1885isArguments: isArguments$1,1886isFinite: isFinite$1,1887isNaN: isNaN$1,1888isTypedArray: isTypedArray$1,1889isEmpty: isEmpty,1890isMatch: isMatch,1891isEqual: isEqual,1892isMap: isMap,1893isWeakMap: isWeakMap,1894isSet: isSet,1895isWeakSet: isWeakSet,1896keys: keys,1897allKeys: allKeys,1898values: values,1899pairs: pairs,1900invert: invert,1901functions: functions,1902methods: functions,1903extend: extend,1904extendOwn: extendOwn,1905assign: extendOwn,1906defaults: defaults,1907create: create,1908clone: clone,1909tap: tap,1910get: get,1911has: has$1,1912mapObject: mapObject,1913identity: identity,1914constant: constant,1915noop: noop,1916toPath: toPath,1917property: property,1918propertyOf: propertyOf,1919matcher: matcher,1920matches: matcher,1921times: times,1922random: random,1923now: now,1924escape: _escape,1925unescape: _unescape,1926templateSettings: templateSettings,1927template: template,1928result: result,1929uniqueId: uniqueId,1930chain: chain,1931iteratee: iteratee,1932partial: partial,1933bind: bind,1934bindAll: bindAll,1935memoize: memoize,1936delay: delay,1937defer: defer,1938throttle: throttle,1939debounce: debounce,1940wrap: wrap,1941negate: negate,1942compose: compose,1943after: after,1944before: before,1945once: once,1946findKey: findKey,1947findIndex: findIndex,1948findLastIndex: findLastIndex,1949sortedIndex: sortedIndex,1950indexOf: indexOf,1951lastIndexOf: lastIndexOf,1952find: find,1953detect: find,1954findWhere: findWhere,1955each: each,1956forEach: each,1957map: map,1958collect: map,1959reduce: reduce,1960foldl: reduce,1961inject: reduce,1962reduceRight: reduceRight,1963foldr: reduceRight,1964filter: filter,1965select: filter,1966reject: reject,1967every: every,1968all: every,1969some: some,1970any: some,1971contains: contains,1972includes: contains,1973include: contains,1974invoke: invoke,1975pluck: pluck,1976where: where,1977max: max,1978min: min,1979shuffle: shuffle,1980sample: sample,1981sortBy: sortBy,1982groupBy: groupBy,1983indexBy: indexBy,1984countBy: countBy,1985partition: partition,1986toArray: toArray,1987size: size,1988pick: pick,1989omit: omit,1990first: first,1991head: first,1992take: first,1993initial: initial,1994last: last,1995rest: rest,1996tail: rest,1997drop: rest,1998compact: compact,1999flatten: flatten$1,2000without: without,2001uniq: uniq,2002unique: uniq,2003union: union,2004intersection: intersection,2005difference: difference,2006unzip: unzip,2007transpose: unzip,2008zip: zip,2009object: object,2010range: range,2011chunk: chunk,2012mixin: mixin,2013'default': _2014};20152016// Default Export20172018// Add all of the Underscore functions to the wrapper object.2019var _$1 = mixin(allExports);2020// Legacy Node.js API.2021_$1._ = _$1;20222023return _$1;20242025})));2026//# sourceMappingURL=underscore.js.map202720282029