6834 lines
693 KiB
JavaScript
6834 lines
693 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
var obsidian = require('obsidian');
|
||
|
|
||
|
/*! *****************************************************************************
|
||
|
Copyright (c) Microsoft Corporation.
|
||
|
|
||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||
|
purpose with or without fee is hereby granted.
|
||
|
|
||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||
|
PERFORMANCE OF THIS SOFTWARE.
|
||
|
***************************************************************************** */
|
||
|
/* global Reflect, Promise */
|
||
|
|
||
|
var extendStatics = function(d, b) {
|
||
|
extendStatics = Object.setPrototypeOf ||
|
||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||
|
return extendStatics(d, b);
|
||
|
};
|
||
|
|
||
|
function __extends(d, b) {
|
||
|
if (typeof b !== "function" && b !== null)
|
||
|
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||
|
extendStatics(d, b);
|
||
|
function __() { this.constructor = d; }
|
||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||
|
}
|
||
|
|
||
|
function __awaiter(thisArg, _arguments, P, generator) {
|
||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function __generator(thisArg, body) {
|
||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||
|
function step(op) {
|
||
|
if (f) throw new TypeError("Generator is already executing.");
|
||
|
while (_) try {
|
||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||
|
switch (op[0]) {
|
||
|
case 0: case 1: t = op; break;
|
||
|
case 4: _.label++; return { value: op[1], done: false };
|
||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||
|
default:
|
||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||
|
if (t[2]) _.ops.pop();
|
||
|
_.trys.pop(); continue;
|
||
|
}
|
||
|
op = body.call(thisArg, _);
|
||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||
|
|
||
|
function createCommonjsModule(fn, basedir, module) {
|
||
|
return module = {
|
||
|
path: basedir,
|
||
|
exports: {},
|
||
|
require: function (path, base) {
|
||
|
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
||
|
}
|
||
|
}, fn(module, module.exports), module.exports;
|
||
|
}
|
||
|
|
||
|
function commonjsRequire () {
|
||
|
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Removes all key-value entries from the list cache.
|
||
|
*
|
||
|
* @private
|
||
|
* @name clear
|
||
|
* @memberOf ListCache
|
||
|
*/
|
||
|
function listCacheClear() {
|
||
|
this.__data__ = [];
|
||
|
this.size = 0;
|
||
|
}
|
||
|
|
||
|
var _listCacheClear = listCacheClear;
|
||
|
|
||
|
/**
|
||
|
* Performs a
|
||
|
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
|
* comparison between two values to determine if they are equivalent.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to compare.
|
||
|
* @param {*} other The other value to compare.
|
||
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = { 'a': 1 };
|
||
|
* var other = { 'a': 1 };
|
||
|
*
|
||
|
* _.eq(object, object);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.eq(object, other);
|
||
|
* // => false
|
||
|
*
|
||
|
* _.eq('a', 'a');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.eq('a', Object('a'));
|
||
|
* // => false
|
||
|
*
|
||
|
* _.eq(NaN, NaN);
|
||
|
* // => true
|
||
|
*/
|
||
|
function eq(value, other) {
|
||
|
return value === other || (value !== value && other !== other);
|
||
|
}
|
||
|
|
||
|
var eq_1 = eq;
|
||
|
|
||
|
/**
|
||
|
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to inspect.
|
||
|
* @param {*} key The key to search for.
|
||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
|
*/
|
||
|
function assocIndexOf(array, key) {
|
||
|
var length = array.length;
|
||
|
while (length--) {
|
||
|
if (eq_1(array[length][0], key)) {
|
||
|
return length;
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
var _assocIndexOf = assocIndexOf;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var arrayProto = Array.prototype;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var splice = arrayProto.splice;
|
||
|
|
||
|
/**
|
||
|
* Removes `key` and its value from the list cache.
|
||
|
*
|
||
|
* @private
|
||
|
* @name delete
|
||
|
* @memberOf ListCache
|
||
|
* @param {string} key The key of the value to remove.
|
||
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
|
*/
|
||
|
function listCacheDelete(key) {
|
||
|
var data = this.__data__,
|
||
|
index = _assocIndexOf(data, key);
|
||
|
|
||
|
if (index < 0) {
|
||
|
return false;
|
||
|
}
|
||
|
var lastIndex = data.length - 1;
|
||
|
if (index == lastIndex) {
|
||
|
data.pop();
|
||
|
} else {
|
||
|
splice.call(data, index, 1);
|
||
|
}
|
||
|
--this.size;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
var _listCacheDelete = listCacheDelete;
|
||
|
|
||
|
/**
|
||
|
* Gets the list cache value for `key`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name get
|
||
|
* @memberOf ListCache
|
||
|
* @param {string} key The key of the value to get.
|
||
|
* @returns {*} Returns the entry value.
|
||
|
*/
|
||
|
function listCacheGet(key) {
|
||
|
var data = this.__data__,
|
||
|
index = _assocIndexOf(data, key);
|
||
|
|
||
|
return index < 0 ? undefined : data[index][1];
|
||
|
}
|
||
|
|
||
|
var _listCacheGet = listCacheGet;
|
||
|
|
||
|
/**
|
||
|
* Checks if a list cache value for `key` exists.
|
||
|
*
|
||
|
* @private
|
||
|
* @name has
|
||
|
* @memberOf ListCache
|
||
|
* @param {string} key The key of the entry to check.
|
||
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
|
*/
|
||
|
function listCacheHas(key) {
|
||
|
return _assocIndexOf(this.__data__, key) > -1;
|
||
|
}
|
||
|
|
||
|
var _listCacheHas = listCacheHas;
|
||
|
|
||
|
/**
|
||
|
* Sets the list cache `key` to `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name set
|
||
|
* @memberOf ListCache
|
||
|
* @param {string} key The key of the value to set.
|
||
|
* @param {*} value The value to set.
|
||
|
* @returns {Object} Returns the list cache instance.
|
||
|
*/
|
||
|
function listCacheSet(key, value) {
|
||
|
var data = this.__data__,
|
||
|
index = _assocIndexOf(data, key);
|
||
|
|
||
|
if (index < 0) {
|
||
|
++this.size;
|
||
|
data.push([key, value]);
|
||
|
} else {
|
||
|
data[index][1] = value;
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
var _listCacheSet = listCacheSet;
|
||
|
|
||
|
/**
|
||
|
* Creates an list cache object.
|
||
|
*
|
||
|
* @private
|
||
|
* @constructor
|
||
|
* @param {Array} [entries] The key-value pairs to cache.
|
||
|
*/
|
||
|
function ListCache(entries) {
|
||
|
var index = -1,
|
||
|
length = entries == null ? 0 : entries.length;
|
||
|
|
||
|
this.clear();
|
||
|
while (++index < length) {
|
||
|
var entry = entries[index];
|
||
|
this.set(entry[0], entry[1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Add methods to `ListCache`.
|
||
|
ListCache.prototype.clear = _listCacheClear;
|
||
|
ListCache.prototype['delete'] = _listCacheDelete;
|
||
|
ListCache.prototype.get = _listCacheGet;
|
||
|
ListCache.prototype.has = _listCacheHas;
|
||
|
ListCache.prototype.set = _listCacheSet;
|
||
|
|
||
|
var _ListCache = ListCache;
|
||
|
|
||
|
/**
|
||
|
* Removes all key-value entries from the stack.
|
||
|
*
|
||
|
* @private
|
||
|
* @name clear
|
||
|
* @memberOf Stack
|
||
|
*/
|
||
|
function stackClear() {
|
||
|
this.__data__ = new _ListCache;
|
||
|
this.size = 0;
|
||
|
}
|
||
|
|
||
|
var _stackClear = stackClear;
|
||
|
|
||
|
/**
|
||
|
* Removes `key` and its value from the stack.
|
||
|
*
|
||
|
* @private
|
||
|
* @name delete
|
||
|
* @memberOf Stack
|
||
|
* @param {string} key The key of the value to remove.
|
||
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
|
*/
|
||
|
function stackDelete(key) {
|
||
|
var data = this.__data__,
|
||
|
result = data['delete'](key);
|
||
|
|
||
|
this.size = data.size;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _stackDelete = stackDelete;
|
||
|
|
||
|
/**
|
||
|
* Gets the stack value for `key`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name get
|
||
|
* @memberOf Stack
|
||
|
* @param {string} key The key of the value to get.
|
||
|
* @returns {*} Returns the entry value.
|
||
|
*/
|
||
|
function stackGet(key) {
|
||
|
return this.__data__.get(key);
|
||
|
}
|
||
|
|
||
|
var _stackGet = stackGet;
|
||
|
|
||
|
/**
|
||
|
* Checks if a stack value for `key` exists.
|
||
|
*
|
||
|
* @private
|
||
|
* @name has
|
||
|
* @memberOf Stack
|
||
|
* @param {string} key The key of the entry to check.
|
||
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
|
*/
|
||
|
function stackHas(key) {
|
||
|
return this.__data__.has(key);
|
||
|
}
|
||
|
|
||
|
var _stackHas = stackHas;
|
||
|
|
||
|
/** Detect free variable `global` from Node.js. */
|
||
|
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
||
|
|
||
|
var _freeGlobal = freeGlobal;
|
||
|
|
||
|
/** Detect free variable `self`. */
|
||
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||
|
|
||
|
/** Used as a reference to the global object. */
|
||
|
var root = _freeGlobal || freeSelf || Function('return this')();
|
||
|
|
||
|
var _root = root;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var Symbol$1 = _root.Symbol;
|
||
|
|
||
|
var _Symbol = Symbol$1;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Used to resolve the
|
||
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||
|
* of values.
|
||
|
*/
|
||
|
var nativeObjectToString = objectProto.toString;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to query.
|
||
|
* @returns {string} Returns the raw `toStringTag`.
|
||
|
*/
|
||
|
function getRawTag(value) {
|
||
|
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
||
|
tag = value[symToStringTag];
|
||
|
|
||
|
try {
|
||
|
value[symToStringTag] = undefined;
|
||
|
var unmasked = true;
|
||
|
} catch (e) {}
|
||
|
|
||
|
var result = nativeObjectToString.call(value);
|
||
|
if (unmasked) {
|
||
|
if (isOwn) {
|
||
|
value[symToStringTag] = tag;
|
||
|
} else {
|
||
|
delete value[symToStringTag];
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _getRawTag = getRawTag;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$1 = Object.prototype;
|
||
|
|
||
|
/**
|
||
|
* Used to resolve the
|
||
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||
|
* of values.
|
||
|
*/
|
||
|
var nativeObjectToString$1 = objectProto$1.toString;
|
||
|
|
||
|
/**
|
||
|
* Converts `value` to a string using `Object.prototype.toString`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to convert.
|
||
|
* @returns {string} Returns the converted string.
|
||
|
*/
|
||
|
function objectToString(value) {
|
||
|
return nativeObjectToString$1.call(value);
|
||
|
}
|
||
|
|
||
|
var _objectToString = objectToString;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var nullTag = '[object Null]',
|
||
|
undefinedTag = '[object Undefined]';
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to query.
|
||
|
* @returns {string} Returns the `toStringTag`.
|
||
|
*/
|
||
|
function baseGetTag(value) {
|
||
|
if (value == null) {
|
||
|
return value === undefined ? undefinedTag : nullTag;
|
||
|
}
|
||
|
return (symToStringTag$1 && symToStringTag$1 in Object(value))
|
||
|
? _getRawTag(value)
|
||
|
: _objectToString(value);
|
||
|
}
|
||
|
|
||
|
var _baseGetTag = baseGetTag;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is the
|
||
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
||
|
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isObject({});
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isObject([1, 2, 3]);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isObject(_.noop);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isObject(null);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isObject(value) {
|
||
|
var type = typeof value;
|
||
|
return value != null && (type == 'object' || type == 'function');
|
||
|
}
|
||
|
|
||
|
var isObject_1 = isObject;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var asyncTag = '[object AsyncFunction]',
|
||
|
funcTag = '[object Function]',
|
||
|
genTag = '[object GeneratorFunction]',
|
||
|
proxyTag = '[object Proxy]';
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a `Function` object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isFunction(_);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isFunction(/abc/);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isFunction(value) {
|
||
|
if (!isObject_1(value)) {
|
||
|
return false;
|
||
|
}
|
||
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||
|
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
||
|
var tag = _baseGetTag(value);
|
||
|
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
||
|
}
|
||
|
|
||
|
var isFunction_1 = isFunction;
|
||
|
|
||
|
/** Used to detect overreaching core-js shims. */
|
||
|
var coreJsData = _root['__core-js_shared__'];
|
||
|
|
||
|
var _coreJsData = coreJsData;
|
||
|
|
||
|
/** Used to detect methods masquerading as native. */
|
||
|
var maskSrcKey = (function() {
|
||
|
var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
|
||
|
return uid ? ('Symbol(src)_1.' + uid) : '';
|
||
|
}());
|
||
|
|
||
|
/**
|
||
|
* Checks if `func` has its source masked.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to check.
|
||
|
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
||
|
*/
|
||
|
function isMasked(func) {
|
||
|
return !!maskSrcKey && (maskSrcKey in func);
|
||
|
}
|
||
|
|
||
|
var _isMasked = isMasked;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var funcProto = Function.prototype;
|
||
|
|
||
|
/** Used to resolve the decompiled source of functions. */
|
||
|
var funcToString = funcProto.toString;
|
||
|
|
||
|
/**
|
||
|
* Converts `func` to its source code.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to convert.
|
||
|
* @returns {string} Returns the source code.
|
||
|
*/
|
||
|
function toSource(func) {
|
||
|
if (func != null) {
|
||
|
try {
|
||
|
return funcToString.call(func);
|
||
|
} catch (e) {}
|
||
|
try {
|
||
|
return (func + '');
|
||
|
} catch (e) {}
|
||
|
}
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
var _toSource = toSource;
|
||
|
|
||
|
/**
|
||
|
* Used to match `RegExp`
|
||
|
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
||
|
*/
|
||
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||
|
|
||
|
/** Used to detect host constructors (Safari). */
|
||
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var funcProto$1 = Function.prototype,
|
||
|
objectProto$2 = Object.prototype;
|
||
|
|
||
|
/** Used to resolve the decompiled source of functions. */
|
||
|
var funcToString$1 = funcProto$1.toString;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
||
|
|
||
|
/** Used to detect if a method is native. */
|
||
|
var reIsNative = RegExp('^' +
|
||
|
funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
|
||
|
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isNative` without bad shim checks.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a native function,
|
||
|
* else `false`.
|
||
|
*/
|
||
|
function baseIsNative(value) {
|
||
|
if (!isObject_1(value) || _isMasked(value)) {
|
||
|
return false;
|
||
|
}
|
||
|
var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
|
||
|
return pattern.test(_toSource(value));
|
||
|
}
|
||
|
|
||
|
var _baseIsNative = baseIsNative;
|
||
|
|
||
|
/**
|
||
|
* Gets the value at `key` of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} [object] The object to query.
|
||
|
* @param {string} key The key of the property to get.
|
||
|
* @returns {*} Returns the property value.
|
||
|
*/
|
||
|
function getValue(object, key) {
|
||
|
return object == null ? undefined : object[key];
|
||
|
}
|
||
|
|
||
|
var _getValue = getValue;
|
||
|
|
||
|
/**
|
||
|
* Gets the native function at `key` of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {string} key The key of the method to get.
|
||
|
* @returns {*} Returns the function if it's native, else `undefined`.
|
||
|
*/
|
||
|
function getNative(object, key) {
|
||
|
var value = _getValue(object, key);
|
||
|
return _baseIsNative(value) ? value : undefined;
|
||
|
}
|
||
|
|
||
|
var _getNative = getNative;
|
||
|
|
||
|
/* Built-in method references that are verified to be native. */
|
||
|
var Map = _getNative(_root, 'Map');
|
||
|
|
||
|
var _Map = Map;
|
||
|
|
||
|
/* Built-in method references that are verified to be native. */
|
||
|
var nativeCreate = _getNative(Object, 'create');
|
||
|
|
||
|
var _nativeCreate = nativeCreate;
|
||
|
|
||
|
/**
|
||
|
* Removes all key-value entries from the hash.
|
||
|
*
|
||
|
* @private
|
||
|
* @name clear
|
||
|
* @memberOf Hash
|
||
|
*/
|
||
|
function hashClear() {
|
||
|
this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
|
||
|
this.size = 0;
|
||
|
}
|
||
|
|
||
|
var _hashClear = hashClear;
|
||
|
|
||
|
/**
|
||
|
* Removes `key` and its value from the hash.
|
||
|
*
|
||
|
* @private
|
||
|
* @name delete
|
||
|
* @memberOf Hash
|
||
|
* @param {Object} hash The hash to modify.
|
||
|
* @param {string} key The key of the value to remove.
|
||
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
|
*/
|
||
|
function hashDelete(key) {
|
||
|
var result = this.has(key) && delete this.__data__[key];
|
||
|
this.size -= result ? 1 : 0;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _hashDelete = hashDelete;
|
||
|
|
||
|
/** Used to stand-in for `undefined` hash values. */
|
||
|
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$3 = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Gets the hash value for `key`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name get
|
||
|
* @memberOf Hash
|
||
|
* @param {string} key The key of the value to get.
|
||
|
* @returns {*} Returns the entry value.
|
||
|
*/
|
||
|
function hashGet(key) {
|
||
|
var data = this.__data__;
|
||
|
if (_nativeCreate) {
|
||
|
var result = data[key];
|
||
|
return result === HASH_UNDEFINED ? undefined : result;
|
||
|
}
|
||
|
return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
|
||
|
}
|
||
|
|
||
|
var _hashGet = hashGet;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$4 = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Checks if a hash value for `key` exists.
|
||
|
*
|
||
|
* @private
|
||
|
* @name has
|
||
|
* @memberOf Hash
|
||
|
* @param {string} key The key of the entry to check.
|
||
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
|
*/
|
||
|
function hashHas(key) {
|
||
|
var data = this.__data__;
|
||
|
return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
|
||
|
}
|
||
|
|
||
|
var _hashHas = hashHas;
|
||
|
|
||
|
/** Used to stand-in for `undefined` hash values. */
|
||
|
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
||
|
|
||
|
/**
|
||
|
* Sets the hash `key` to `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name set
|
||
|
* @memberOf Hash
|
||
|
* @param {string} key The key of the value to set.
|
||
|
* @param {*} value The value to set.
|
||
|
* @returns {Object} Returns the hash instance.
|
||
|
*/
|
||
|
function hashSet(key, value) {
|
||
|
var data = this.__data__;
|
||
|
this.size += this.has(key) ? 0 : 1;
|
||
|
data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
var _hashSet = hashSet;
|
||
|
|
||
|
/**
|
||
|
* Creates a hash object.
|
||
|
*
|
||
|
* @private
|
||
|
* @constructor
|
||
|
* @param {Array} [entries] The key-value pairs to cache.
|
||
|
*/
|
||
|
function Hash(entries) {
|
||
|
var index = -1,
|
||
|
length = entries == null ? 0 : entries.length;
|
||
|
|
||
|
this.clear();
|
||
|
while (++index < length) {
|
||
|
var entry = entries[index];
|
||
|
this.set(entry[0], entry[1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Add methods to `Hash`.
|
||
|
Hash.prototype.clear = _hashClear;
|
||
|
Hash.prototype['delete'] = _hashDelete;
|
||
|
Hash.prototype.get = _hashGet;
|
||
|
Hash.prototype.has = _hashHas;
|
||
|
Hash.prototype.set = _hashSet;
|
||
|
|
||
|
var _Hash = Hash;
|
||
|
|
||
|
/**
|
||
|
* Removes all key-value entries from the map.
|
||
|
*
|
||
|
* @private
|
||
|
* @name clear
|
||
|
* @memberOf MapCache
|
||
|
*/
|
||
|
function mapCacheClear() {
|
||
|
this.size = 0;
|
||
|
this.__data__ = {
|
||
|
'hash': new _Hash,
|
||
|
'map': new (_Map || _ListCache),
|
||
|
'string': new _Hash
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _mapCacheClear = mapCacheClear;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is suitable for use as unique object key.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
||
|
*/
|
||
|
function isKeyable(value) {
|
||
|
var type = typeof value;
|
||
|
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||
|
? (value !== '__proto__')
|
||
|
: (value === null);
|
||
|
}
|
||
|
|
||
|
var _isKeyable = isKeyable;
|
||
|
|
||
|
/**
|
||
|
* Gets the data for `map`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} map The map to query.
|
||
|
* @param {string} key The reference key.
|
||
|
* @returns {*} Returns the map data.
|
||
|
*/
|
||
|
function getMapData(map, key) {
|
||
|
var data = map.__data__;
|
||
|
return _isKeyable(key)
|
||
|
? data[typeof key == 'string' ? 'string' : 'hash']
|
||
|
: data.map;
|
||
|
}
|
||
|
|
||
|
var _getMapData = getMapData;
|
||
|
|
||
|
/**
|
||
|
* Removes `key` and its value from the map.
|
||
|
*
|
||
|
* @private
|
||
|
* @name delete
|
||
|
* @memberOf MapCache
|
||
|
* @param {string} key The key of the value to remove.
|
||
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
|
*/
|
||
|
function mapCacheDelete(key) {
|
||
|
var result = _getMapData(this, key)['delete'](key);
|
||
|
this.size -= result ? 1 : 0;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _mapCacheDelete = mapCacheDelete;
|
||
|
|
||
|
/**
|
||
|
* Gets the map value for `key`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name get
|
||
|
* @memberOf MapCache
|
||
|
* @param {string} key The key of the value to get.
|
||
|
* @returns {*} Returns the entry value.
|
||
|
*/
|
||
|
function mapCacheGet(key) {
|
||
|
return _getMapData(this, key).get(key);
|
||
|
}
|
||
|
|
||
|
var _mapCacheGet = mapCacheGet;
|
||
|
|
||
|
/**
|
||
|
* Checks if a map value for `key` exists.
|
||
|
*
|
||
|
* @private
|
||
|
* @name has
|
||
|
* @memberOf MapCache
|
||
|
* @param {string} key The key of the entry to check.
|
||
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
|
*/
|
||
|
function mapCacheHas(key) {
|
||
|
return _getMapData(this, key).has(key);
|
||
|
}
|
||
|
|
||
|
var _mapCacheHas = mapCacheHas;
|
||
|
|
||
|
/**
|
||
|
* Sets the map `key` to `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name set
|
||
|
* @memberOf MapCache
|
||
|
* @param {string} key The key of the value to set.
|
||
|
* @param {*} value The value to set.
|
||
|
* @returns {Object} Returns the map cache instance.
|
||
|
*/
|
||
|
function mapCacheSet(key, value) {
|
||
|
var data = _getMapData(this, key),
|
||
|
size = data.size;
|
||
|
|
||
|
data.set(key, value);
|
||
|
this.size += data.size == size ? 0 : 1;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
var _mapCacheSet = mapCacheSet;
|
||
|
|
||
|
/**
|
||
|
* Creates a map cache object to store key-value pairs.
|
||
|
*
|
||
|
* @private
|
||
|
* @constructor
|
||
|
* @param {Array} [entries] The key-value pairs to cache.
|
||
|
*/
|
||
|
function MapCache(entries) {
|
||
|
var index = -1,
|
||
|
length = entries == null ? 0 : entries.length;
|
||
|
|
||
|
this.clear();
|
||
|
while (++index < length) {
|
||
|
var entry = entries[index];
|
||
|
this.set(entry[0], entry[1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Add methods to `MapCache`.
|
||
|
MapCache.prototype.clear = _mapCacheClear;
|
||
|
MapCache.prototype['delete'] = _mapCacheDelete;
|
||
|
MapCache.prototype.get = _mapCacheGet;
|
||
|
MapCache.prototype.has = _mapCacheHas;
|
||
|
MapCache.prototype.set = _mapCacheSet;
|
||
|
|
||
|
var _MapCache = MapCache;
|
||
|
|
||
|
/** Used as the size to enable large array optimizations. */
|
||
|
var LARGE_ARRAY_SIZE = 200;
|
||
|
|
||
|
/**
|
||
|
* Sets the stack `key` to `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @name set
|
||
|
* @memberOf Stack
|
||
|
* @param {string} key The key of the value to set.
|
||
|
* @param {*} value The value to set.
|
||
|
* @returns {Object} Returns the stack cache instance.
|
||
|
*/
|
||
|
function stackSet(key, value) {
|
||
|
var data = this.__data__;
|
||
|
if (data instanceof _ListCache) {
|
||
|
var pairs = data.__data__;
|
||
|
if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||
|
pairs.push([key, value]);
|
||
|
this.size = ++data.size;
|
||
|
return this;
|
||
|
}
|
||
|
data = this.__data__ = new _MapCache(pairs);
|
||
|
}
|
||
|
data.set(key, value);
|
||
|
this.size = data.size;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
var _stackSet = stackSet;
|
||
|
|
||
|
/**
|
||
|
* Creates a stack cache object to store key-value pairs.
|
||
|
*
|
||
|
* @private
|
||
|
* @constructor
|
||
|
* @param {Array} [entries] The key-value pairs to cache.
|
||
|
*/
|
||
|
function Stack(entries) {
|
||
|
var data = this.__data__ = new _ListCache(entries);
|
||
|
this.size = data.size;
|
||
|
}
|
||
|
|
||
|
// Add methods to `Stack`.
|
||
|
Stack.prototype.clear = _stackClear;
|
||
|
Stack.prototype['delete'] = _stackDelete;
|
||
|
Stack.prototype.get = _stackGet;
|
||
|
Stack.prototype.has = _stackHas;
|
||
|
Stack.prototype.set = _stackSet;
|
||
|
|
||
|
var _Stack = Stack;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.forEach` for arrays without support for
|
||
|
* iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @returns {Array} Returns `array`.
|
||
|
*/
|
||
|
function arrayEach(array, iteratee) {
|
||
|
var index = -1,
|
||
|
length = array == null ? 0 : array.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
if (iteratee(array[index], index, array) === false) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
|
||
|
var _arrayEach = arrayEach;
|
||
|
|
||
|
var defineProperty = (function() {
|
||
|
try {
|
||
|
var func = _getNative(Object, 'defineProperty');
|
||
|
func({}, '', {});
|
||
|
return func;
|
||
|
} catch (e) {}
|
||
|
}());
|
||
|
|
||
|
var _defineProperty = defineProperty;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `assignValue` and `assignMergeValue` without
|
||
|
* value checks.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to modify.
|
||
|
* @param {string} key The key of the property to assign.
|
||
|
* @param {*} value The value to assign.
|
||
|
*/
|
||
|
function baseAssignValue(object, key, value) {
|
||
|
if (key == '__proto__' && _defineProperty) {
|
||
|
_defineProperty(object, key, {
|
||
|
'configurable': true,
|
||
|
'enumerable': true,
|
||
|
'value': value,
|
||
|
'writable': true
|
||
|
});
|
||
|
} else {
|
||
|
object[key] = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var _baseAssignValue = baseAssignValue;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$5 = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
||
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
|
* for equality comparisons.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to modify.
|
||
|
* @param {string} key The key of the property to assign.
|
||
|
* @param {*} value The value to assign.
|
||
|
*/
|
||
|
function assignValue(object, key, value) {
|
||
|
var objValue = object[key];
|
||
|
if (!(hasOwnProperty$4.call(object, key) && eq_1(objValue, value)) ||
|
||
|
(value === undefined && !(key in object))) {
|
||
|
_baseAssignValue(object, key, value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var _assignValue = assignValue;
|
||
|
|
||
|
/**
|
||
|
* Copies properties of `source` to `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} source The object to copy properties from.
|
||
|
* @param {Array} props The property identifiers to copy.
|
||
|
* @param {Object} [object={}] The object to copy properties to.
|
||
|
* @param {Function} [customizer] The function to customize copied values.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function copyObject(source, props, object, customizer) {
|
||
|
var isNew = !object;
|
||
|
object || (object = {});
|
||
|
|
||
|
var index = -1,
|
||
|
length = props.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
var key = props[index];
|
||
|
|
||
|
var newValue = customizer
|
||
|
? customizer(object[key], source[key], key, object, source)
|
||
|
: undefined;
|
||
|
|
||
|
if (newValue === undefined) {
|
||
|
newValue = source[key];
|
||
|
}
|
||
|
if (isNew) {
|
||
|
_baseAssignValue(object, key, newValue);
|
||
|
} else {
|
||
|
_assignValue(object, key, newValue);
|
||
|
}
|
||
|
}
|
||
|
return object;
|
||
|
}
|
||
|
|
||
|
var _copyObject = copyObject;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.times` without support for iteratee shorthands
|
||
|
* or max array length checks.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {number} n The number of times to invoke `iteratee`.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @returns {Array} Returns the array of results.
|
||
|
*/
|
||
|
function baseTimes(n, iteratee) {
|
||
|
var index = -1,
|
||
|
result = Array(n);
|
||
|
|
||
|
while (++index < n) {
|
||
|
result[index] = iteratee(index);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseTimes = baseTimes;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
||
|
* and has a `typeof` result of "object".
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isObjectLike({});
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isObjectLike([1, 2, 3]);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isObjectLike(_.noop);
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isObjectLike(null);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isObjectLike(value) {
|
||
|
return value != null && typeof value == 'object';
|
||
|
}
|
||
|
|
||
|
var isObjectLike_1 = isObjectLike;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var argsTag = '[object Arguments]';
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isArguments`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||
|
*/
|
||
|
function baseIsArguments(value) {
|
||
|
return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
|
||
|
}
|
||
|
|
||
|
var _baseIsArguments = baseIsArguments;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$6 = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is likely an `arguments` object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||
|
* else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isArguments(function() { return arguments; }());
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArguments([1, 2, 3]);
|
||
|
* // => false
|
||
|
*/
|
||
|
var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
|
||
|
return isObjectLike_1(value) && hasOwnProperty$5.call(value, 'callee') &&
|
||
|
!propertyIsEnumerable.call(value, 'callee');
|
||
|
};
|
||
|
|
||
|
var isArguments_1 = isArguments;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as an `Array` object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isArray([1, 2, 3]);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArray(document.body.children);
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isArray('abc');
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isArray(_.noop);
|
||
|
* // => false
|
||
|
*/
|
||
|
var isArray = Array.isArray;
|
||
|
|
||
|
var isArray_1 = isArray;
|
||
|
|
||
|
/**
|
||
|
* This method returns `false`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.13.0
|
||
|
* @category Util
|
||
|
* @returns {boolean} Returns `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.times(2, _.stubFalse);
|
||
|
* // => [false, false]
|
||
|
*/
|
||
|
function stubFalse() {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var stubFalse_1 = stubFalse;
|
||
|
|
||
|
var isBuffer_1 = createCommonjsModule(function (module, exports) {
|
||
|
/** Detect free variable `exports`. */
|
||
|
var freeExports = exports && !exports.nodeType && exports;
|
||
|
|
||
|
/** Detect free variable `module`. */
|
||
|
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
||
|
|
||
|
/** Detect the popular CommonJS extension `module.exports`. */
|
||
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var Buffer = moduleExports ? _root.Buffer : undefined;
|
||
|
|
||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
|
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is a buffer.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.3.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isBuffer(new Buffer(2));
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isBuffer(new Uint8Array(2));
|
||
|
* // => false
|
||
|
*/
|
||
|
var isBuffer = nativeIsBuffer || stubFalse_1;
|
||
|
|
||
|
module.exports = isBuffer;
|
||
|
});
|
||
|
|
||
|
/** Used as references for various `Number` constants. */
|
||
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
|
||
|
/** Used to detect unsigned integer values. */
|
||
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is a valid array-like index.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
||
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||
|
*/
|
||
|
function isIndex(value, length) {
|
||
|
var type = typeof value;
|
||
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
||
|
|
||
|
return !!length &&
|
||
|
(type == 'number' ||
|
||
|
(type != 'symbol' && reIsUint.test(value))) &&
|
||
|
(value > -1 && value % 1 == 0 && value < length);
|
||
|
}
|
||
|
|
||
|
var _isIndex = isIndex;
|
||
|
|
||
|
/** Used as references for various `Number` constants. */
|
||
|
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is a valid array-like length.
|
||
|
*
|
||
|
* **Note:** This method is loosely based on
|
||
|
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isLength(3);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isLength(Number.MIN_VALUE);
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isLength(Infinity);
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isLength('3');
|
||
|
* // => false
|
||
|
*/
|
||
|
function isLength(value) {
|
||
|
return typeof value == 'number' &&
|
||
|
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
|
||
|
}
|
||
|
|
||
|
var isLength_1 = isLength;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var argsTag$1 = '[object Arguments]',
|
||
|
arrayTag = '[object Array]',
|
||
|
boolTag = '[object Boolean]',
|
||
|
dateTag = '[object Date]',
|
||
|
errorTag = '[object Error]',
|
||
|
funcTag$1 = '[object Function]',
|
||
|
mapTag = '[object Map]',
|
||
|
numberTag = '[object Number]',
|
||
|
objectTag = '[object Object]',
|
||
|
regexpTag = '[object RegExp]',
|
||
|
setTag = '[object Set]',
|
||
|
stringTag = '[object String]',
|
||
|
weakMapTag = '[object WeakMap]';
|
||
|
|
||
|
var arrayBufferTag = '[object ArrayBuffer]',
|
||
|
dataViewTag = '[object DataView]',
|
||
|
float32Tag = '[object Float32Array]',
|
||
|
float64Tag = '[object Float64Array]',
|
||
|
int8Tag = '[object Int8Array]',
|
||
|
int16Tag = '[object Int16Array]',
|
||
|
int32Tag = '[object Int32Array]',
|
||
|
uint8Tag = '[object Uint8Array]',
|
||
|
uint8ClampedTag = '[object Uint8ClampedArray]',
|
||
|
uint16Tag = '[object Uint16Array]',
|
||
|
uint32Tag = '[object Uint32Array]';
|
||
|
|
||
|
/** Used to identify `toStringTag` values of typed arrays. */
|
||
|
var typedArrayTags = {};
|
||
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
||
|
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
||
|
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
||
|
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
||
|
typedArrayTags[uint32Tag] = true;
|
||
|
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
|
||
|
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
||
|
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
||
|
typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
|
||
|
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
||
|
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
||
|
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
||
|
typedArrayTags[weakMapTag] = false;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
||
|
*/
|
||
|
function baseIsTypedArray(value) {
|
||
|
return isObjectLike_1(value) &&
|
||
|
isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
|
||
|
}
|
||
|
|
||
|
var _baseIsTypedArray = baseIsTypedArray;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.unary` without support for storing metadata.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to cap arguments for.
|
||
|
* @returns {Function} Returns the new capped function.
|
||
|
*/
|
||
|
function baseUnary(func) {
|
||
|
return function(value) {
|
||
|
return func(value);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _baseUnary = baseUnary;
|
||
|
|
||
|
var _nodeUtil = createCommonjsModule(function (module, exports) {
|
||
|
/** Detect free variable `exports`. */
|
||
|
var freeExports = exports && !exports.nodeType && exports;
|
||
|
|
||
|
/** Detect free variable `module`. */
|
||
|
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
||
|
|
||
|
/** Detect the popular CommonJS extension `module.exports`. */
|
||
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
|
||
|
/** Detect free variable `process` from Node.js. */
|
||
|
var freeProcess = moduleExports && _freeGlobal.process;
|
||
|
|
||
|
/** Used to access faster Node.js helpers. */
|
||
|
var nodeUtil = (function() {
|
||
|
try {
|
||
|
// Use `util.types` for Node.js 10+.
|
||
|
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
||
|
|
||
|
if (types) {
|
||
|
return types;
|
||
|
}
|
||
|
|
||
|
// Legacy `process.binding('util')` for Node.js < 10.
|
||
|
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
||
|
} catch (e) {}
|
||
|
}());
|
||
|
|
||
|
module.exports = nodeUtil;
|
||
|
});
|
||
|
|
||
|
/* Node.js helper references. */
|
||
|
var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a typed array.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 3.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isTypedArray(new Uint8Array);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isTypedArray([]);
|
||
|
* // => false
|
||
|
*/
|
||
|
var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
|
||
|
|
||
|
var isTypedArray_1 = isTypedArray;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$7 = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of the enumerable property names of the array-like `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to query.
|
||
|
* @param {boolean} inherited Specify returning inherited property names.
|
||
|
* @returns {Array} Returns the array of property names.
|
||
|
*/
|
||
|
function arrayLikeKeys(value, inherited) {
|
||
|
var isArr = isArray_1(value),
|
||
|
isArg = !isArr && isArguments_1(value),
|
||
|
isBuff = !isArr && !isArg && isBuffer_1(value),
|
||
|
isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
|
||
|
skipIndexes = isArr || isArg || isBuff || isType,
|
||
|
result = skipIndexes ? _baseTimes(value.length, String) : [],
|
||
|
length = result.length;
|
||
|
|
||
|
for (var key in value) {
|
||
|
if ((inherited || hasOwnProperty$6.call(value, key)) &&
|
||
|
!(skipIndexes && (
|
||
|
// Safari 9 has enumerable `arguments.length` in strict mode.
|
||
|
key == 'length' ||
|
||
|
// Node.js 0.10 has enumerable non-index properties on buffers.
|
||
|
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||
|
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
||
|
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||
|
// Skip index properties.
|
||
|
_isIndex(key, length)
|
||
|
))) {
|
||
|
result.push(key);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _arrayLikeKeys = arrayLikeKeys;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$8 = Object.prototype;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is likely a prototype object.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
||
|
*/
|
||
|
function isPrototype(value) {
|
||
|
var Ctor = value && value.constructor,
|
||
|
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
|
||
|
|
||
|
return value === proto;
|
||
|
}
|
||
|
|
||
|
var _isPrototype = isPrototype;
|
||
|
|
||
|
/**
|
||
|
* Creates a unary function that invokes `func` with its argument transformed.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to wrap.
|
||
|
* @param {Function} transform The argument transform.
|
||
|
* @returns {Function} Returns the new function.
|
||
|
*/
|
||
|
function overArg(func, transform) {
|
||
|
return function(arg) {
|
||
|
return func(transform(arg));
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _overArg = overArg;
|
||
|
|
||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
|
var nativeKeys = _overArg(Object.keys, Object);
|
||
|
|
||
|
var _nativeKeys = nativeKeys;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$9 = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names.
|
||
|
*/
|
||
|
function baseKeys(object) {
|
||
|
if (!_isPrototype(object)) {
|
||
|
return _nativeKeys(object);
|
||
|
}
|
||
|
var result = [];
|
||
|
for (var key in Object(object)) {
|
||
|
if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
|
||
|
result.push(key);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseKeys = baseKeys;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is array-like. A value is considered array-like if it's
|
||
|
* not a function and has a `value.length` that's an integer greater than or
|
||
|
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isArrayLike([1, 2, 3]);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArrayLike(document.body.children);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArrayLike('abc');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArrayLike(_.noop);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isArrayLike(value) {
|
||
|
return value != null && isLength_1(value.length) && !isFunction_1(value);
|
||
|
}
|
||
|
|
||
|
var isArrayLike_1 = isArrayLike;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of the own enumerable property names of `object`.
|
||
|
*
|
||
|
* **Note:** Non-object values are coerced to objects. See the
|
||
|
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||
|
* for more details.
|
||
|
*
|
||
|
* @static
|
||
|
* @since 0.1.0
|
||
|
* @memberOf _
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names.
|
||
|
* @example
|
||
|
*
|
||
|
* function Foo() {
|
||
|
* this.a = 1;
|
||
|
* this.b = 2;
|
||
|
* }
|
||
|
*
|
||
|
* Foo.prototype.c = 3;
|
||
|
*
|
||
|
* _.keys(new Foo);
|
||
|
* // => ['a', 'b'] (iteration order is not guaranteed)
|
||
|
*
|
||
|
* _.keys('hi');
|
||
|
* // => ['0', '1']
|
||
|
*/
|
||
|
function keys(object) {
|
||
|
return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
|
||
|
}
|
||
|
|
||
|
var keys_1 = keys;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.assign` without support for multiple sources
|
||
|
* or `customizer` functions.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The destination object.
|
||
|
* @param {Object} source The source object.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function baseAssign(object, source) {
|
||
|
return object && _copyObject(source, keys_1(source), object);
|
||
|
}
|
||
|
|
||
|
var _baseAssign = baseAssign;
|
||
|
|
||
|
/**
|
||
|
* This function is like
|
||
|
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||
|
* except that it includes inherited enumerable properties.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names.
|
||
|
*/
|
||
|
function nativeKeysIn(object) {
|
||
|
var result = [];
|
||
|
if (object != null) {
|
||
|
for (var key in Object(object)) {
|
||
|
result.push(key);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _nativeKeysIn = nativeKeysIn;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$a = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names.
|
||
|
*/
|
||
|
function baseKeysIn(object) {
|
||
|
if (!isObject_1(object)) {
|
||
|
return _nativeKeysIn(object);
|
||
|
}
|
||
|
var isProto = _isPrototype(object),
|
||
|
result = [];
|
||
|
|
||
|
for (var key in object) {
|
||
|
if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
|
||
|
result.push(key);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseKeysIn = baseKeysIn;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of the own and inherited enumerable property names of `object`.
|
||
|
*
|
||
|
* **Note:** Non-object values are coerced to objects.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 3.0.0
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names.
|
||
|
* @example
|
||
|
*
|
||
|
* function Foo() {
|
||
|
* this.a = 1;
|
||
|
* this.b = 2;
|
||
|
* }
|
||
|
*
|
||
|
* Foo.prototype.c = 3;
|
||
|
*
|
||
|
* _.keysIn(new Foo);
|
||
|
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
||
|
*/
|
||
|
function keysIn(object) {
|
||
|
return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
|
||
|
}
|
||
|
|
||
|
var keysIn_1 = keysIn;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.assignIn` without support for multiple sources
|
||
|
* or `customizer` functions.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The destination object.
|
||
|
* @param {Object} source The source object.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function baseAssignIn(object, source) {
|
||
|
return object && _copyObject(source, keysIn_1(source), object);
|
||
|
}
|
||
|
|
||
|
var _baseAssignIn = baseAssignIn;
|
||
|
|
||
|
var _cloneBuffer = createCommonjsModule(function (module, exports) {
|
||
|
/** Detect free variable `exports`. */
|
||
|
var freeExports = exports && !exports.nodeType && exports;
|
||
|
|
||
|
/** Detect free variable `module`. */
|
||
|
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
||
|
|
||
|
/** Detect the popular CommonJS extension `module.exports`. */
|
||
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var Buffer = moduleExports ? _root.Buffer : undefined,
|
||
|
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
||
|
|
||
|
/**
|
||
|
* Creates a clone of `buffer`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Buffer} buffer The buffer to clone.
|
||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||
|
* @returns {Buffer} Returns the cloned buffer.
|
||
|
*/
|
||
|
function cloneBuffer(buffer, isDeep) {
|
||
|
if (isDeep) {
|
||
|
return buffer.slice();
|
||
|
}
|
||
|
var length = buffer.length,
|
||
|
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||
|
|
||
|
buffer.copy(result);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
module.exports = cloneBuffer;
|
||
|
});
|
||
|
|
||
|
/**
|
||
|
* Copies the values of `source` to `array`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} source The array to copy values from.
|
||
|
* @param {Array} [array=[]] The array to copy values to.
|
||
|
* @returns {Array} Returns `array`.
|
||
|
*/
|
||
|
function copyArray(source, array) {
|
||
|
var index = -1,
|
||
|
length = source.length;
|
||
|
|
||
|
array || (array = Array(length));
|
||
|
while (++index < length) {
|
||
|
array[index] = source[index];
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
|
||
|
var _copyArray = copyArray;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.filter` for arrays without support for
|
||
|
* iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to iterate over.
|
||
|
* @param {Function} predicate The function invoked per iteration.
|
||
|
* @returns {Array} Returns the new filtered array.
|
||
|
*/
|
||
|
function arrayFilter(array, predicate) {
|
||
|
var index = -1,
|
||
|
length = array == null ? 0 : array.length,
|
||
|
resIndex = 0,
|
||
|
result = [];
|
||
|
|
||
|
while (++index < length) {
|
||
|
var value = array[index];
|
||
|
if (predicate(value, index, array)) {
|
||
|
result[resIndex++] = value;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _arrayFilter = arrayFilter;
|
||
|
|
||
|
/**
|
||
|
* This method returns a new empty array.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.13.0
|
||
|
* @category Util
|
||
|
* @returns {Array} Returns the new empty array.
|
||
|
* @example
|
||
|
*
|
||
|
* var arrays = _.times(2, _.stubArray);
|
||
|
*
|
||
|
* console.log(arrays);
|
||
|
* // => [[], []]
|
||
|
*
|
||
|
* console.log(arrays[0] === arrays[1]);
|
||
|
* // => false
|
||
|
*/
|
||
|
function stubArray() {
|
||
|
return [];
|
||
|
}
|
||
|
|
||
|
var stubArray_1 = stubArray;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$b = Object.prototype;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
|
||
|
|
||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
|
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of the own enumerable symbols of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of symbols.
|
||
|
*/
|
||
|
var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
|
||
|
if (object == null) {
|
||
|
return [];
|
||
|
}
|
||
|
object = Object(object);
|
||
|
return _arrayFilter(nativeGetSymbols(object), function(symbol) {
|
||
|
return propertyIsEnumerable$1.call(object, symbol);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var _getSymbols = getSymbols;
|
||
|
|
||
|
/**
|
||
|
* Copies own symbols of `source` to `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} source The object to copy symbols from.
|
||
|
* @param {Object} [object={}] The object to copy symbols to.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function copySymbols(source, object) {
|
||
|
return _copyObject(source, _getSymbols(source), object);
|
||
|
}
|
||
|
|
||
|
var _copySymbols = copySymbols;
|
||
|
|
||
|
/**
|
||
|
* Appends the elements of `values` to `array`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to modify.
|
||
|
* @param {Array} values The values to append.
|
||
|
* @returns {Array} Returns `array`.
|
||
|
*/
|
||
|
function arrayPush(array, values) {
|
||
|
var index = -1,
|
||
|
length = values.length,
|
||
|
offset = array.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
array[offset + index] = values[index];
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
|
||
|
var _arrayPush = arrayPush;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var getPrototype = _overArg(Object.getPrototypeOf, Object);
|
||
|
|
||
|
var _getPrototype = getPrototype;
|
||
|
|
||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
|
var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of the own and inherited enumerable symbols of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of symbols.
|
||
|
*/
|
||
|
var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
|
||
|
var result = [];
|
||
|
while (object) {
|
||
|
_arrayPush(result, _getSymbols(object));
|
||
|
object = _getPrototype(object);
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
|
||
|
var _getSymbolsIn = getSymbolsIn;
|
||
|
|
||
|
/**
|
||
|
* Copies own and inherited symbols of `source` to `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} source The object to copy symbols from.
|
||
|
* @param {Object} [object={}] The object to copy symbols to.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function copySymbolsIn(source, object) {
|
||
|
return _copyObject(source, _getSymbolsIn(source), object);
|
||
|
}
|
||
|
|
||
|
var _copySymbolsIn = copySymbolsIn;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
||
|
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
||
|
* symbols of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
||
|
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
||
|
* @returns {Array} Returns the array of property names and symbols.
|
||
|
*/
|
||
|
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
||
|
var result = keysFunc(object);
|
||
|
return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
|
||
|
}
|
||
|
|
||
|
var _baseGetAllKeys = baseGetAllKeys;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of own enumerable property names and symbols of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names and symbols.
|
||
|
*/
|
||
|
function getAllKeys(object) {
|
||
|
return _baseGetAllKeys(object, keys_1, _getSymbols);
|
||
|
}
|
||
|
|
||
|
var _getAllKeys = getAllKeys;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of own and inherited enumerable property names and
|
||
|
* symbols of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property names and symbols.
|
||
|
*/
|
||
|
function getAllKeysIn(object) {
|
||
|
return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
|
||
|
}
|
||
|
|
||
|
var _getAllKeysIn = getAllKeysIn;
|
||
|
|
||
|
/* Built-in method references that are verified to be native. */
|
||
|
var DataView = _getNative(_root, 'DataView');
|
||
|
|
||
|
var _DataView = DataView;
|
||
|
|
||
|
/* Built-in method references that are verified to be native. */
|
||
|
var Promise$1 = _getNative(_root, 'Promise');
|
||
|
|
||
|
var _Promise = Promise$1;
|
||
|
|
||
|
/* Built-in method references that are verified to be native. */
|
||
|
var Set = _getNative(_root, 'Set');
|
||
|
|
||
|
var _Set = Set;
|
||
|
|
||
|
/* Built-in method references that are verified to be native. */
|
||
|
var WeakMap = _getNative(_root, 'WeakMap');
|
||
|
|
||
|
var _WeakMap = WeakMap;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var mapTag$1 = '[object Map]',
|
||
|
objectTag$1 = '[object Object]',
|
||
|
promiseTag = '[object Promise]',
|
||
|
setTag$1 = '[object Set]',
|
||
|
weakMapTag$1 = '[object WeakMap]';
|
||
|
|
||
|
var dataViewTag$1 = '[object DataView]';
|
||
|
|
||
|
/** Used to detect maps, sets, and weakmaps. */
|
||
|
var dataViewCtorString = _toSource(_DataView),
|
||
|
mapCtorString = _toSource(_Map),
|
||
|
promiseCtorString = _toSource(_Promise),
|
||
|
setCtorString = _toSource(_Set),
|
||
|
weakMapCtorString = _toSource(_WeakMap);
|
||
|
|
||
|
/**
|
||
|
* Gets the `toStringTag` of `value`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to query.
|
||
|
* @returns {string} Returns the `toStringTag`.
|
||
|
*/
|
||
|
var getTag = _baseGetTag;
|
||
|
|
||
|
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
||
|
if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
|
||
|
(_Map && getTag(new _Map) != mapTag$1) ||
|
||
|
(_Promise && getTag(_Promise.resolve()) != promiseTag) ||
|
||
|
(_Set && getTag(new _Set) != setTag$1) ||
|
||
|
(_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
|
||
|
getTag = function(value) {
|
||
|
var result = _baseGetTag(value),
|
||
|
Ctor = result == objectTag$1 ? value.constructor : undefined,
|
||
|
ctorString = Ctor ? _toSource(Ctor) : '';
|
||
|
|
||
|
if (ctorString) {
|
||
|
switch (ctorString) {
|
||
|
case dataViewCtorString: return dataViewTag$1;
|
||
|
case mapCtorString: return mapTag$1;
|
||
|
case promiseCtorString: return promiseTag;
|
||
|
case setCtorString: return setTag$1;
|
||
|
case weakMapCtorString: return weakMapTag$1;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _getTag = getTag;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$c = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Initializes an array clone.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to clone.
|
||
|
* @returns {Array} Returns the initialized clone.
|
||
|
*/
|
||
|
function initCloneArray(array) {
|
||
|
var length = array.length,
|
||
|
result = new array.constructor(length);
|
||
|
|
||
|
// Add properties assigned by `RegExp#exec`.
|
||
|
if (length && typeof array[0] == 'string' && hasOwnProperty$9.call(array, 'index')) {
|
||
|
result.index = array.index;
|
||
|
result.input = array.input;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _initCloneArray = initCloneArray;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var Uint8Array = _root.Uint8Array;
|
||
|
|
||
|
var _Uint8Array = Uint8Array;
|
||
|
|
||
|
/**
|
||
|
* Creates a clone of `arrayBuffer`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
||
|
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||
|
*/
|
||
|
function cloneArrayBuffer(arrayBuffer) {
|
||
|
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||
|
new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _cloneArrayBuffer = cloneArrayBuffer;
|
||
|
|
||
|
/**
|
||
|
* Creates a clone of `dataView`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} dataView The data view to clone.
|
||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||
|
* @returns {Object} Returns the cloned data view.
|
||
|
*/
|
||
|
function cloneDataView(dataView, isDeep) {
|
||
|
var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
||
|
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
||
|
}
|
||
|
|
||
|
var _cloneDataView = cloneDataView;
|
||
|
|
||
|
/** Used to match `RegExp` flags from their coerced string values. */
|
||
|
var reFlags = /\w*$/;
|
||
|
|
||
|
/**
|
||
|
* Creates a clone of `regexp`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} regexp The regexp to clone.
|
||
|
* @returns {Object} Returns the cloned regexp.
|
||
|
*/
|
||
|
function cloneRegExp(regexp) {
|
||
|
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||
|
result.lastIndex = regexp.lastIndex;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _cloneRegExp = cloneRegExp;
|
||
|
|
||
|
/** Used to convert symbols to primitives and strings. */
|
||
|
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
||
|
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||
|
|
||
|
/**
|
||
|
* Creates a clone of the `symbol` object.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} symbol The symbol object to clone.
|
||
|
* @returns {Object} Returns the cloned symbol object.
|
||
|
*/
|
||
|
function cloneSymbol(symbol) {
|
||
|
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
||
|
}
|
||
|
|
||
|
var _cloneSymbol = cloneSymbol;
|
||
|
|
||
|
/**
|
||
|
* Creates a clone of `typedArray`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} typedArray The typed array to clone.
|
||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||
|
* @returns {Object} Returns the cloned typed array.
|
||
|
*/
|
||
|
function cloneTypedArray(typedArray, isDeep) {
|
||
|
var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||
|
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||
|
}
|
||
|
|
||
|
var _cloneTypedArray = cloneTypedArray;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var boolTag$1 = '[object Boolean]',
|
||
|
dateTag$1 = '[object Date]',
|
||
|
mapTag$2 = '[object Map]',
|
||
|
numberTag$1 = '[object Number]',
|
||
|
regexpTag$1 = '[object RegExp]',
|
||
|
setTag$2 = '[object Set]',
|
||
|
stringTag$1 = '[object String]',
|
||
|
symbolTag = '[object Symbol]';
|
||
|
|
||
|
var arrayBufferTag$1 = '[object ArrayBuffer]',
|
||
|
dataViewTag$2 = '[object DataView]',
|
||
|
float32Tag$1 = '[object Float32Array]',
|
||
|
float64Tag$1 = '[object Float64Array]',
|
||
|
int8Tag$1 = '[object Int8Array]',
|
||
|
int16Tag$1 = '[object Int16Array]',
|
||
|
int32Tag$1 = '[object Int32Array]',
|
||
|
uint8Tag$1 = '[object Uint8Array]',
|
||
|
uint8ClampedTag$1 = '[object Uint8ClampedArray]',
|
||
|
uint16Tag$1 = '[object Uint16Array]',
|
||
|
uint32Tag$1 = '[object Uint32Array]';
|
||
|
|
||
|
/**
|
||
|
* Initializes an object clone based on its `toStringTag`.
|
||
|
*
|
||
|
* **Note:** This function only supports cloning values with tags of
|
||
|
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to clone.
|
||
|
* @param {string} tag The `toStringTag` of the object to clone.
|
||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||
|
* @returns {Object} Returns the initialized clone.
|
||
|
*/
|
||
|
function initCloneByTag(object, tag, isDeep) {
|
||
|
var Ctor = object.constructor;
|
||
|
switch (tag) {
|
||
|
case arrayBufferTag$1:
|
||
|
return _cloneArrayBuffer(object);
|
||
|
|
||
|
case boolTag$1:
|
||
|
case dateTag$1:
|
||
|
return new Ctor(+object);
|
||
|
|
||
|
case dataViewTag$2:
|
||
|
return _cloneDataView(object, isDeep);
|
||
|
|
||
|
case float32Tag$1: case float64Tag$1:
|
||
|
case int8Tag$1: case int16Tag$1: case int32Tag$1:
|
||
|
case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
|
||
|
return _cloneTypedArray(object, isDeep);
|
||
|
|
||
|
case mapTag$2:
|
||
|
return new Ctor;
|
||
|
|
||
|
case numberTag$1:
|
||
|
case stringTag$1:
|
||
|
return new Ctor(object);
|
||
|
|
||
|
case regexpTag$1:
|
||
|
return _cloneRegExp(object);
|
||
|
|
||
|
case setTag$2:
|
||
|
return new Ctor;
|
||
|
|
||
|
case symbolTag:
|
||
|
return _cloneSymbol(object);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var _initCloneByTag = initCloneByTag;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var objectCreate = Object.create;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.create` without support for assigning
|
||
|
* properties to the created object.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} proto The object to inherit from.
|
||
|
* @returns {Object} Returns the new object.
|
||
|
*/
|
||
|
var baseCreate = (function() {
|
||
|
function object() {}
|
||
|
return function(proto) {
|
||
|
if (!isObject_1(proto)) {
|
||
|
return {};
|
||
|
}
|
||
|
if (objectCreate) {
|
||
|
return objectCreate(proto);
|
||
|
}
|
||
|
object.prototype = proto;
|
||
|
var result = new object;
|
||
|
object.prototype = undefined;
|
||
|
return result;
|
||
|
};
|
||
|
}());
|
||
|
|
||
|
var _baseCreate = baseCreate;
|
||
|
|
||
|
/**
|
||
|
* Initializes an object clone.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to clone.
|
||
|
* @returns {Object} Returns the initialized clone.
|
||
|
*/
|
||
|
function initCloneObject(object) {
|
||
|
return (typeof object.constructor == 'function' && !_isPrototype(object))
|
||
|
? _baseCreate(_getPrototype(object))
|
||
|
: {};
|
||
|
}
|
||
|
|
||
|
var _initCloneObject = initCloneObject;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var mapTag$3 = '[object Map]';
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isMap` without Node.js optimizations.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
|
||
|
*/
|
||
|
function baseIsMap(value) {
|
||
|
return isObjectLike_1(value) && _getTag(value) == mapTag$3;
|
||
|
}
|
||
|
|
||
|
var _baseIsMap = baseIsMap;
|
||
|
|
||
|
/* Node.js helper references. */
|
||
|
var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a `Map` object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.3.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isMap(new Map);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isMap(new WeakMap);
|
||
|
* // => false
|
||
|
*/
|
||
|
var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
|
||
|
|
||
|
var isMap_1 = isMap;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var setTag$3 = '[object Set]';
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isSet` without Node.js optimizations.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
|
||
|
*/
|
||
|
function baseIsSet(value) {
|
||
|
return isObjectLike_1(value) && _getTag(value) == setTag$3;
|
||
|
}
|
||
|
|
||
|
var _baseIsSet = baseIsSet;
|
||
|
|
||
|
/* Node.js helper references. */
|
||
|
var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a `Set` object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.3.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isSet(new Set);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isSet(new WeakSet);
|
||
|
* // => false
|
||
|
*/
|
||
|
var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
|
||
|
|
||
|
var isSet_1 = isSet;
|
||
|
|
||
|
/** Used to compose bitmasks for cloning. */
|
||
|
var CLONE_DEEP_FLAG = 1,
|
||
|
CLONE_FLAT_FLAG = 2,
|
||
|
CLONE_SYMBOLS_FLAG = 4;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var argsTag$2 = '[object Arguments]',
|
||
|
arrayTag$1 = '[object Array]',
|
||
|
boolTag$2 = '[object Boolean]',
|
||
|
dateTag$2 = '[object Date]',
|
||
|
errorTag$1 = '[object Error]',
|
||
|
funcTag$2 = '[object Function]',
|
||
|
genTag$1 = '[object GeneratorFunction]',
|
||
|
mapTag$4 = '[object Map]',
|
||
|
numberTag$2 = '[object Number]',
|
||
|
objectTag$2 = '[object Object]',
|
||
|
regexpTag$2 = '[object RegExp]',
|
||
|
setTag$4 = '[object Set]',
|
||
|
stringTag$2 = '[object String]',
|
||
|
symbolTag$1 = '[object Symbol]',
|
||
|
weakMapTag$2 = '[object WeakMap]';
|
||
|
|
||
|
var arrayBufferTag$2 = '[object ArrayBuffer]',
|
||
|
dataViewTag$3 = '[object DataView]',
|
||
|
float32Tag$2 = '[object Float32Array]',
|
||
|
float64Tag$2 = '[object Float64Array]',
|
||
|
int8Tag$2 = '[object Int8Array]',
|
||
|
int16Tag$2 = '[object Int16Array]',
|
||
|
int32Tag$2 = '[object Int32Array]',
|
||
|
uint8Tag$2 = '[object Uint8Array]',
|
||
|
uint8ClampedTag$2 = '[object Uint8ClampedArray]',
|
||
|
uint16Tag$2 = '[object Uint16Array]',
|
||
|
uint32Tag$2 = '[object Uint32Array]';
|
||
|
|
||
|
/** Used to identify `toStringTag` values supported by `_.clone`. */
|
||
|
var cloneableTags = {};
|
||
|
cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
|
||
|
cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
|
||
|
cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
|
||
|
cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
|
||
|
cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
|
||
|
cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
|
||
|
cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
|
||
|
cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
|
||
|
cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
|
||
|
cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
|
||
|
cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
|
||
|
cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
|
||
|
cloneableTags[weakMapTag$2] = false;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.clone` and `_.cloneDeep` which tracks
|
||
|
* traversed objects.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to clone.
|
||
|
* @param {boolean} bitmask The bitmask flags.
|
||
|
* 1 - Deep clone
|
||
|
* 2 - Flatten inherited properties
|
||
|
* 4 - Clone symbols
|
||
|
* @param {Function} [customizer] The function to customize cloning.
|
||
|
* @param {string} [key] The key of `value`.
|
||
|
* @param {Object} [object] The parent object of `value`.
|
||
|
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
|
||
|
* @returns {*} Returns the cloned value.
|
||
|
*/
|
||
|
function baseClone(value, bitmask, customizer, key, object, stack) {
|
||
|
var result,
|
||
|
isDeep = bitmask & CLONE_DEEP_FLAG,
|
||
|
isFlat = bitmask & CLONE_FLAT_FLAG,
|
||
|
isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
||
|
|
||
|
if (customizer) {
|
||
|
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||
|
}
|
||
|
if (result !== undefined) {
|
||
|
return result;
|
||
|
}
|
||
|
if (!isObject_1(value)) {
|
||
|
return value;
|
||
|
}
|
||
|
var isArr = isArray_1(value);
|
||
|
if (isArr) {
|
||
|
result = _initCloneArray(value);
|
||
|
if (!isDeep) {
|
||
|
return _copyArray(value, result);
|
||
|
}
|
||
|
} else {
|
||
|
var tag = _getTag(value),
|
||
|
isFunc = tag == funcTag$2 || tag == genTag$1;
|
||
|
|
||
|
if (isBuffer_1(value)) {
|
||
|
return _cloneBuffer(value, isDeep);
|
||
|
}
|
||
|
if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
|
||
|
result = (isFlat || isFunc) ? {} : _initCloneObject(value);
|
||
|
if (!isDeep) {
|
||
|
return isFlat
|
||
|
? _copySymbolsIn(value, _baseAssignIn(result, value))
|
||
|
: _copySymbols(value, _baseAssign(result, value));
|
||
|
}
|
||
|
} else {
|
||
|
if (!cloneableTags[tag]) {
|
||
|
return object ? value : {};
|
||
|
}
|
||
|
result = _initCloneByTag(value, tag, isDeep);
|
||
|
}
|
||
|
}
|
||
|
// Check for circular references and return its corresponding clone.
|
||
|
stack || (stack = new _Stack);
|
||
|
var stacked = stack.get(value);
|
||
|
if (stacked) {
|
||
|
return stacked;
|
||
|
}
|
||
|
stack.set(value, result);
|
||
|
|
||
|
if (isSet_1(value)) {
|
||
|
value.forEach(function(subValue) {
|
||
|
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
||
|
});
|
||
|
} else if (isMap_1(value)) {
|
||
|
value.forEach(function(subValue, key) {
|
||
|
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
var keysFunc = isFull
|
||
|
? (isFlat ? _getAllKeysIn : _getAllKeys)
|
||
|
: (isFlat ? keysIn_1 : keys_1);
|
||
|
|
||
|
var props = isArr ? undefined : keysFunc(value);
|
||
|
_arrayEach(props || value, function(subValue, key) {
|
||
|
if (props) {
|
||
|
key = subValue;
|
||
|
subValue = value[key];
|
||
|
}
|
||
|
// Recursively populate clone (susceptible to call stack limits).
|
||
|
_assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseClone = baseClone;
|
||
|
|
||
|
/** Used to compose bitmasks for cloning. */
|
||
|
var CLONE_SYMBOLS_FLAG$1 = 4;
|
||
|
|
||
|
/**
|
||
|
* Creates a shallow clone of `value`.
|
||
|
*
|
||
|
* **Note:** This method is loosely based on the
|
||
|
* [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
|
||
|
* and supports cloning arrays, array buffers, booleans, date objects, maps,
|
||
|
* numbers, `Object` objects, regexes, sets, strings, symbols, and typed
|
||
|
* arrays. The own enumerable properties of `arguments` objects are cloned
|
||
|
* as plain objects. An empty object is returned for uncloneable values such
|
||
|
* as error objects, functions, DOM nodes, and WeakMaps.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to clone.
|
||
|
* @returns {*} Returns the cloned value.
|
||
|
* @see _.cloneDeep
|
||
|
* @example
|
||
|
*
|
||
|
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||
|
*
|
||
|
* var shallow = _.clone(objects);
|
||
|
* console.log(shallow[0] === objects[0]);
|
||
|
* // => true
|
||
|
*/
|
||
|
function clone(value) {
|
||
|
return _baseClone(value, CLONE_SYMBOLS_FLAG$1);
|
||
|
}
|
||
|
|
||
|
var clone_1 = clone;
|
||
|
|
||
|
/**
|
||
|
* Creates a function that returns `value`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 2.4.0
|
||
|
* @category Util
|
||
|
* @param {*} value The value to return from the new function.
|
||
|
* @returns {Function} Returns the new constant function.
|
||
|
* @example
|
||
|
*
|
||
|
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
||
|
*
|
||
|
* console.log(objects);
|
||
|
* // => [{ 'a': 1 }, { 'a': 1 }]
|
||
|
*
|
||
|
* console.log(objects[0] === objects[1]);
|
||
|
* // => true
|
||
|
*/
|
||
|
function constant(value) {
|
||
|
return function() {
|
||
|
return value;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var constant_1 = constant;
|
||
|
|
||
|
/**
|
||
|
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||
|
* @returns {Function} Returns the new base function.
|
||
|
*/
|
||
|
function createBaseFor(fromRight) {
|
||
|
return function(object, iteratee, keysFunc) {
|
||
|
var index = -1,
|
||
|
iterable = Object(object),
|
||
|
props = keysFunc(object),
|
||
|
length = props.length;
|
||
|
|
||
|
while (length--) {
|
||
|
var key = props[fromRight ? length : ++index];
|
||
|
if (iteratee(iterable[key], key, iterable) === false) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return object;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _createBaseFor = createBaseFor;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `baseForOwn` which iterates over `object`
|
||
|
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
||
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
var baseFor = _createBaseFor();
|
||
|
|
||
|
var _baseFor = baseFor;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function baseForOwn(object, iteratee) {
|
||
|
return object && _baseFor(object, iteratee, keys_1);
|
||
|
}
|
||
|
|
||
|
var _baseForOwn = baseForOwn;
|
||
|
|
||
|
/**
|
||
|
* Creates a `baseEach` or `baseEachRight` function.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} eachFunc The function to iterate over a collection.
|
||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||
|
* @returns {Function} Returns the new base function.
|
||
|
*/
|
||
|
function createBaseEach(eachFunc, fromRight) {
|
||
|
return function(collection, iteratee) {
|
||
|
if (collection == null) {
|
||
|
return collection;
|
||
|
}
|
||
|
if (!isArrayLike_1(collection)) {
|
||
|
return eachFunc(collection, iteratee);
|
||
|
}
|
||
|
var length = collection.length,
|
||
|
index = fromRight ? length : -1,
|
||
|
iterable = Object(collection);
|
||
|
|
||
|
while ((fromRight ? index-- : ++index < length)) {
|
||
|
if (iteratee(iterable[index], index, iterable) === false) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return collection;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _createBaseEach = createBaseEach;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @returns {Array|Object} Returns `collection`.
|
||
|
*/
|
||
|
var baseEach = _createBaseEach(_baseForOwn);
|
||
|
|
||
|
var _baseEach = baseEach;
|
||
|
|
||
|
/**
|
||
|
* This method returns the first argument it receives.
|
||
|
*
|
||
|
* @static
|
||
|
* @since 0.1.0
|
||
|
* @memberOf _
|
||
|
* @category Util
|
||
|
* @param {*} value Any value.
|
||
|
* @returns {*} Returns `value`.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = { 'a': 1 };
|
||
|
*
|
||
|
* console.log(_.identity(object) === object);
|
||
|
* // => true
|
||
|
*/
|
||
|
function identity(value) {
|
||
|
return value;
|
||
|
}
|
||
|
|
||
|
var identity_1 = identity;
|
||
|
|
||
|
/**
|
||
|
* Casts `value` to `identity` if it's not a function.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to inspect.
|
||
|
* @returns {Function} Returns cast function.
|
||
|
*/
|
||
|
function castFunction(value) {
|
||
|
return typeof value == 'function' ? value : identity_1;
|
||
|
}
|
||
|
|
||
|
var _castFunction = castFunction;
|
||
|
|
||
|
/**
|
||
|
* Iterates over elements of `collection` and invokes `iteratee` for each element.
|
||
|
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
||
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||
|
*
|
||
|
* **Note:** As with other "Collections" methods, objects with a "length"
|
||
|
* property are iterated like arrays. To avoid this behavior use `_.forIn`
|
||
|
* or `_.forOwn` for object iteration.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @alias each
|
||
|
* @category Collection
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||
|
* @returns {Array|Object} Returns `collection`.
|
||
|
* @see _.forEachRight
|
||
|
* @example
|
||
|
*
|
||
|
* _.forEach([1, 2], function(value) {
|
||
|
* console.log(value);
|
||
|
* });
|
||
|
* // => Logs `1` then `2`.
|
||
|
*
|
||
|
* _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
|
||
|
* console.log(key);
|
||
|
* });
|
||
|
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
||
|
*/
|
||
|
function forEach(collection, iteratee) {
|
||
|
var func = isArray_1(collection) ? _arrayEach : _baseEach;
|
||
|
return func(collection, _castFunction(iteratee));
|
||
|
}
|
||
|
|
||
|
var forEach_1 = forEach;
|
||
|
|
||
|
var each = forEach_1;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.filter` without support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} predicate The function invoked per iteration.
|
||
|
* @returns {Array} Returns the new filtered array.
|
||
|
*/
|
||
|
function baseFilter(collection, predicate) {
|
||
|
var result = [];
|
||
|
_baseEach(collection, function(value, index, collection) {
|
||
|
if (predicate(value, index, collection)) {
|
||
|
result.push(value);
|
||
|
}
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseFilter = baseFilter;
|
||
|
|
||
|
/** Used to stand-in for `undefined` hash values. */
|
||
|
var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
|
||
|
|
||
|
/**
|
||
|
* Adds `value` to the array cache.
|
||
|
*
|
||
|
* @private
|
||
|
* @name add
|
||
|
* @memberOf SetCache
|
||
|
* @alias push
|
||
|
* @param {*} value The value to cache.
|
||
|
* @returns {Object} Returns the cache instance.
|
||
|
*/
|
||
|
function setCacheAdd(value) {
|
||
|
this.__data__.set(value, HASH_UNDEFINED$2);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
var _setCacheAdd = setCacheAdd;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is in the array cache.
|
||
|
*
|
||
|
* @private
|
||
|
* @name has
|
||
|
* @memberOf SetCache
|
||
|
* @param {*} value The value to search for.
|
||
|
* @returns {number} Returns `true` if `value` is found, else `false`.
|
||
|
*/
|
||
|
function setCacheHas(value) {
|
||
|
return this.__data__.has(value);
|
||
|
}
|
||
|
|
||
|
var _setCacheHas = setCacheHas;
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* Creates an array cache object to store unique values.
|
||
|
*
|
||
|
* @private
|
||
|
* @constructor
|
||
|
* @param {Array} [values] The values to cache.
|
||
|
*/
|
||
|
function SetCache(values) {
|
||
|
var index = -1,
|
||
|
length = values == null ? 0 : values.length;
|
||
|
|
||
|
this.__data__ = new _MapCache;
|
||
|
while (++index < length) {
|
||
|
this.add(values[index]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Add methods to `SetCache`.
|
||
|
SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
|
||
|
SetCache.prototype.has = _setCacheHas;
|
||
|
|
||
|
var _SetCache = SetCache;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.some` for arrays without support for iteratee
|
||
|
* shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to iterate over.
|
||
|
* @param {Function} predicate The function invoked per iteration.
|
||
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||
|
* else `false`.
|
||
|
*/
|
||
|
function arraySome(array, predicate) {
|
||
|
var index = -1,
|
||
|
length = array == null ? 0 : array.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
if (predicate(array[index], index, array)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var _arraySome = arraySome;
|
||
|
|
||
|
/**
|
||
|
* Checks if a `cache` value for `key` exists.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} cache The cache to query.
|
||
|
* @param {string} key The key of the entry to check.
|
||
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
|
*/
|
||
|
function cacheHas(cache, key) {
|
||
|
return cache.has(key);
|
||
|
}
|
||
|
|
||
|
var _cacheHas = cacheHas;
|
||
|
|
||
|
/** Used to compose bitmasks for value comparisons. */
|
||
|
var COMPARE_PARTIAL_FLAG = 1,
|
||
|
COMPARE_UNORDERED_FLAG = 2;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
||
|
* partial deep comparisons.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to compare.
|
||
|
* @param {Array} other The other array to compare.
|
||
|
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
|
* @param {Function} customizer The function to customize comparisons.
|
||
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
|
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
||
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||
|
*/
|
||
|
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
||
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
||
|
arrLength = array.length,
|
||
|
othLength = other.length;
|
||
|
|
||
|
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
||
|
return false;
|
||
|
}
|
||
|
// Check that cyclic values are equal.
|
||
|
var arrStacked = stack.get(array);
|
||
|
var othStacked = stack.get(other);
|
||
|
if (arrStacked && othStacked) {
|
||
|
return arrStacked == other && othStacked == array;
|
||
|
}
|
||
|
var index = -1,
|
||
|
result = true,
|
||
|
seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new _SetCache : undefined;
|
||
|
|
||
|
stack.set(array, other);
|
||
|
stack.set(other, array);
|
||
|
|
||
|
// Ignore non-index properties.
|
||
|
while (++index < arrLength) {
|
||
|
var arrValue = array[index],
|
||
|
othValue = other[index];
|
||
|
|
||
|
if (customizer) {
|
||
|
var compared = isPartial
|
||
|
? customizer(othValue, arrValue, index, other, array, stack)
|
||
|
: customizer(arrValue, othValue, index, array, other, stack);
|
||
|
}
|
||
|
if (compared !== undefined) {
|
||
|
if (compared) {
|
||
|
continue;
|
||
|
}
|
||
|
result = false;
|
||
|
break;
|
||
|
}
|
||
|
// Recursively compare arrays (susceptible to call stack limits).
|
||
|
if (seen) {
|
||
|
if (!_arraySome(other, function(othValue, othIndex) {
|
||
|
if (!_cacheHas(seen, othIndex) &&
|
||
|
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
||
|
return seen.push(othIndex);
|
||
|
}
|
||
|
})) {
|
||
|
result = false;
|
||
|
break;
|
||
|
}
|
||
|
} else if (!(
|
||
|
arrValue === othValue ||
|
||
|
equalFunc(arrValue, othValue, bitmask, customizer, stack)
|
||
|
)) {
|
||
|
result = false;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
stack['delete'](array);
|
||
|
stack['delete'](other);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _equalArrays = equalArrays;
|
||
|
|
||
|
/**
|
||
|
* Converts `map` to its key-value pairs.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} map The map to convert.
|
||
|
* @returns {Array} Returns the key-value pairs.
|
||
|
*/
|
||
|
function mapToArray(map) {
|
||
|
var index = -1,
|
||
|
result = Array(map.size);
|
||
|
|
||
|
map.forEach(function(value, key) {
|
||
|
result[++index] = [key, value];
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _mapToArray = mapToArray;
|
||
|
|
||
|
/**
|
||
|
* Converts `set` to an array of its values.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} set The set to convert.
|
||
|
* @returns {Array} Returns the values.
|
||
|
*/
|
||
|
function setToArray(set) {
|
||
|
var index = -1,
|
||
|
result = Array(set.size);
|
||
|
|
||
|
set.forEach(function(value) {
|
||
|
result[++index] = value;
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _setToArray = setToArray;
|
||
|
|
||
|
/** Used to compose bitmasks for value comparisons. */
|
||
|
var COMPARE_PARTIAL_FLAG$1 = 1,
|
||
|
COMPARE_UNORDERED_FLAG$1 = 2;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var boolTag$3 = '[object Boolean]',
|
||
|
dateTag$3 = '[object Date]',
|
||
|
errorTag$2 = '[object Error]',
|
||
|
mapTag$5 = '[object Map]',
|
||
|
numberTag$3 = '[object Number]',
|
||
|
regexpTag$3 = '[object RegExp]',
|
||
|
setTag$5 = '[object Set]',
|
||
|
stringTag$3 = '[object String]',
|
||
|
symbolTag$2 = '[object Symbol]';
|
||
|
|
||
|
var arrayBufferTag$3 = '[object ArrayBuffer]',
|
||
|
dataViewTag$4 = '[object DataView]';
|
||
|
|
||
|
/** Used to convert symbols to primitives and strings. */
|
||
|
var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
|
||
|
symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : undefined;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||
|
* the same `toStringTag`.
|
||
|
*
|
||
|
* **Note:** This function only supports comparing values with tags of
|
||
|
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to compare.
|
||
|
* @param {Object} other The other object to compare.
|
||
|
* @param {string} tag The `toStringTag` of the objects to compare.
|
||
|
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
|
* @param {Function} customizer The function to customize comparisons.
|
||
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
|
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||
|
*/
|
||
|
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
||
|
switch (tag) {
|
||
|
case dataViewTag$4:
|
||
|
if ((object.byteLength != other.byteLength) ||
|
||
|
(object.byteOffset != other.byteOffset)) {
|
||
|
return false;
|
||
|
}
|
||
|
object = object.buffer;
|
||
|
other = other.buffer;
|
||
|
|
||
|
case arrayBufferTag$3:
|
||
|
if ((object.byteLength != other.byteLength) ||
|
||
|
!equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
|
||
|
case boolTag$3:
|
||
|
case dateTag$3:
|
||
|
case numberTag$3:
|
||
|
// Coerce booleans to `1` or `0` and dates to milliseconds.
|
||
|
// Invalid dates are coerced to `NaN`.
|
||
|
return eq_1(+object, +other);
|
||
|
|
||
|
case errorTag$2:
|
||
|
return object.name == other.name && object.message == other.message;
|
||
|
|
||
|
case regexpTag$3:
|
||
|
case stringTag$3:
|
||
|
// Coerce regexes to strings and treat strings, primitives and objects,
|
||
|
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
||
|
// for more details.
|
||
|
return object == (other + '');
|
||
|
|
||
|
case mapTag$5:
|
||
|
var convert = _mapToArray;
|
||
|
|
||
|
case setTag$5:
|
||
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1;
|
||
|
convert || (convert = _setToArray);
|
||
|
|
||
|
if (object.size != other.size && !isPartial) {
|
||
|
return false;
|
||
|
}
|
||
|
// Assume cyclic values are equal.
|
||
|
var stacked = stack.get(object);
|
||
|
if (stacked) {
|
||
|
return stacked == other;
|
||
|
}
|
||
|
bitmask |= COMPARE_UNORDERED_FLAG$1;
|
||
|
|
||
|
// Recursively compare objects (susceptible to call stack limits).
|
||
|
stack.set(object, other);
|
||
|
var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
||
|
stack['delete'](object);
|
||
|
return result;
|
||
|
|
||
|
case symbolTag$2:
|
||
|
if (symbolValueOf$1) {
|
||
|
return symbolValueOf$1.call(object) == symbolValueOf$1.call(other);
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var _equalByTag = equalByTag;
|
||
|
|
||
|
/** Used to compose bitmasks for value comparisons. */
|
||
|
var COMPARE_PARTIAL_FLAG$2 = 1;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$d = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$a = objectProto$d.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseIsEqualDeep` for objects with support for
|
||
|
* partial deep comparisons.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to compare.
|
||
|
* @param {Object} other The other object to compare.
|
||
|
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
|
* @param {Function} customizer The function to customize comparisons.
|
||
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
|
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||
|
*/
|
||
|
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
||
|
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2,
|
||
|
objProps = _getAllKeys(object),
|
||
|
objLength = objProps.length,
|
||
|
othProps = _getAllKeys(other),
|
||
|
othLength = othProps.length;
|
||
|
|
||
|
if (objLength != othLength && !isPartial) {
|
||
|
return false;
|
||
|
}
|
||
|
var index = objLength;
|
||
|
while (index--) {
|
||
|
var key = objProps[index];
|
||
|
if (!(isPartial ? key in other : hasOwnProperty$a.call(other, key))) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
// Check that cyclic values are equal.
|
||
|
var objStacked = stack.get(object);
|
||
|
var othStacked = stack.get(other);
|
||
|
if (objStacked && othStacked) {
|
||
|
return objStacked == other && othStacked == object;
|
||
|
}
|
||
|
var result = true;
|
||
|
stack.set(object, other);
|
||
|
stack.set(other, object);
|
||
|
|
||
|
var skipCtor = isPartial;
|
||
|
while (++index < objLength) {
|
||
|
key = objProps[index];
|
||
|
var objValue = object[key],
|
||
|
othValue = other[key];
|
||
|
|
||
|
if (customizer) {
|
||
|
var compared = isPartial
|
||
|
? customizer(othValue, objValue, key, other, object, stack)
|
||
|
: customizer(objValue, othValue, key, object, other, stack);
|
||
|
}
|
||
|
// Recursively compare objects (susceptible to call stack limits).
|
||
|
if (!(compared === undefined
|
||
|
? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
|
||
|
: compared
|
||
|
)) {
|
||
|
result = false;
|
||
|
break;
|
||
|
}
|
||
|
skipCtor || (skipCtor = key == 'constructor');
|
||
|
}
|
||
|
if (result && !skipCtor) {
|
||
|
var objCtor = object.constructor,
|
||
|
othCtor = other.constructor;
|
||
|
|
||
|
// Non `Object` object instances with different constructors are not equal.
|
||
|
if (objCtor != othCtor &&
|
||
|
('constructor' in object && 'constructor' in other) &&
|
||
|
!(typeof objCtor == 'function' && objCtor instanceof objCtor &&
|
||
|
typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
||
|
result = false;
|
||
|
}
|
||
|
}
|
||
|
stack['delete'](object);
|
||
|
stack['delete'](other);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _equalObjects = equalObjects;
|
||
|
|
||
|
/** Used to compose bitmasks for value comparisons. */
|
||
|
var COMPARE_PARTIAL_FLAG$3 = 1;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var argsTag$3 = '[object Arguments]',
|
||
|
arrayTag$2 = '[object Array]',
|
||
|
objectTag$3 = '[object Object]';
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$e = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$b = objectProto$e.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
||
|
* deep comparisons and tracks traversed objects enabling objects with circular
|
||
|
* references to be compared.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to compare.
|
||
|
* @param {Object} other The other object to compare.
|
||
|
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
|
||
|
* @param {Function} customizer The function to customize comparisons.
|
||
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||
|
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
||
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||
|
*/
|
||
|
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
||
|
var objIsArr = isArray_1(object),
|
||
|
othIsArr = isArray_1(other),
|
||
|
objTag = objIsArr ? arrayTag$2 : _getTag(object),
|
||
|
othTag = othIsArr ? arrayTag$2 : _getTag(other);
|
||
|
|
||
|
objTag = objTag == argsTag$3 ? objectTag$3 : objTag;
|
||
|
othTag = othTag == argsTag$3 ? objectTag$3 : othTag;
|
||
|
|
||
|
var objIsObj = objTag == objectTag$3,
|
||
|
othIsObj = othTag == objectTag$3,
|
||
|
isSameTag = objTag == othTag;
|
||
|
|
||
|
if (isSameTag && isBuffer_1(object)) {
|
||
|
if (!isBuffer_1(other)) {
|
||
|
return false;
|
||
|
}
|
||
|
objIsArr = true;
|
||
|
objIsObj = false;
|
||
|
}
|
||
|
if (isSameTag && !objIsObj) {
|
||
|
stack || (stack = new _Stack);
|
||
|
return (objIsArr || isTypedArray_1(object))
|
||
|
? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
|
||
|
: _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
||
|
}
|
||
|
if (!(bitmask & COMPARE_PARTIAL_FLAG$3)) {
|
||
|
var objIsWrapped = objIsObj && hasOwnProperty$b.call(object, '__wrapped__'),
|
||
|
othIsWrapped = othIsObj && hasOwnProperty$b.call(other, '__wrapped__');
|
||
|
|
||
|
if (objIsWrapped || othIsWrapped) {
|
||
|
var objUnwrapped = objIsWrapped ? object.value() : object,
|
||
|
othUnwrapped = othIsWrapped ? other.value() : other;
|
||
|
|
||
|
stack || (stack = new _Stack);
|
||
|
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
||
|
}
|
||
|
}
|
||
|
if (!isSameTag) {
|
||
|
return false;
|
||
|
}
|
||
|
stack || (stack = new _Stack);
|
||
|
return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
||
|
}
|
||
|
|
||
|
var _baseIsEqualDeep = baseIsEqualDeep;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isEqual` which supports partial comparisons
|
||
|
* and tracks traversed objects.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to compare.
|
||
|
* @param {*} other The other value to compare.
|
||
|
* @param {boolean} bitmask The bitmask flags.
|
||
|
* 1 - Unordered comparison
|
||
|
* 2 - Partial comparison
|
||
|
* @param {Function} [customizer] The function to customize comparisons.
|
||
|
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
|
||
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||
|
*/
|
||
|
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
||
|
if (value === other) {
|
||
|
return true;
|
||
|
}
|
||
|
if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) {
|
||
|
return value !== value && other !== other;
|
||
|
}
|
||
|
return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
||
|
}
|
||
|
|
||
|
var _baseIsEqual = baseIsEqual;
|
||
|
|
||
|
/** Used to compose bitmasks for value comparisons. */
|
||
|
var COMPARE_PARTIAL_FLAG$4 = 1,
|
||
|
COMPARE_UNORDERED_FLAG$2 = 2;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isMatch` without support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to inspect.
|
||
|
* @param {Object} source The object of property values to match.
|
||
|
* @param {Array} matchData The property names, values, and compare flags to match.
|
||
|
* @param {Function} [customizer] The function to customize comparisons.
|
||
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
||
|
*/
|
||
|
function baseIsMatch(object, source, matchData, customizer) {
|
||
|
var index = matchData.length,
|
||
|
length = index,
|
||
|
noCustomizer = !customizer;
|
||
|
|
||
|
if (object == null) {
|
||
|
return !length;
|
||
|
}
|
||
|
object = Object(object);
|
||
|
while (index--) {
|
||
|
var data = matchData[index];
|
||
|
if ((noCustomizer && data[2])
|
||
|
? data[1] !== object[data[0]]
|
||
|
: !(data[0] in object)
|
||
|
) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
while (++index < length) {
|
||
|
data = matchData[index];
|
||
|
var key = data[0],
|
||
|
objValue = object[key],
|
||
|
srcValue = data[1];
|
||
|
|
||
|
if (noCustomizer && data[2]) {
|
||
|
if (objValue === undefined && !(key in object)) {
|
||
|
return false;
|
||
|
}
|
||
|
} else {
|
||
|
var stack = new _Stack;
|
||
|
if (customizer) {
|
||
|
var result = customizer(objValue, srcValue, key, object, source, stack);
|
||
|
}
|
||
|
if (!(result === undefined
|
||
|
? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$4 | COMPARE_UNORDERED_FLAG$2, customizer, stack)
|
||
|
: result
|
||
|
)) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
var _baseIsMatch = baseIsMatch;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
||
|
* equality comparisons, else `false`.
|
||
|
*/
|
||
|
function isStrictComparable(value) {
|
||
|
return value === value && !isObject_1(value);
|
||
|
}
|
||
|
|
||
|
var _isStrictComparable = isStrictComparable;
|
||
|
|
||
|
/**
|
||
|
* Gets the property names, values, and compare flags of `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the match data of `object`.
|
||
|
*/
|
||
|
function getMatchData(object) {
|
||
|
var result = keys_1(object),
|
||
|
length = result.length;
|
||
|
|
||
|
while (length--) {
|
||
|
var key = result[length],
|
||
|
value = object[key];
|
||
|
|
||
|
result[length] = [key, value, _isStrictComparable(value)];
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _getMatchData = getMatchData;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `matchesProperty` for source values suitable
|
||
|
* for strict equality comparisons, i.e. `===`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} key The key of the property to get.
|
||
|
* @param {*} srcValue The value to match.
|
||
|
* @returns {Function} Returns the new spec function.
|
||
|
*/
|
||
|
function matchesStrictComparable(key, srcValue) {
|
||
|
return function(object) {
|
||
|
if (object == null) {
|
||
|
return false;
|
||
|
}
|
||
|
return object[key] === srcValue &&
|
||
|
(srcValue !== undefined || (key in Object(object)));
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _matchesStrictComparable = matchesStrictComparable;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.matches` which doesn't clone `source`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} source The object of property values to match.
|
||
|
* @returns {Function} Returns the new spec function.
|
||
|
*/
|
||
|
function baseMatches(source) {
|
||
|
var matchData = _getMatchData(source);
|
||
|
if (matchData.length == 1 && matchData[0][2]) {
|
||
|
return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
||
|
}
|
||
|
return function(object) {
|
||
|
return object === source || _baseIsMatch(object, source, matchData);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _baseMatches = baseMatches;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var symbolTag$3 = '[object Symbol]';
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a `Symbol` primitive or object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isSymbol(Symbol.iterator);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isSymbol('abc');
|
||
|
* // => false
|
||
|
*/
|
||
|
function isSymbol(value) {
|
||
|
return typeof value == 'symbol' ||
|
||
|
(isObjectLike_1(value) && _baseGetTag(value) == symbolTag$3);
|
||
|
}
|
||
|
|
||
|
var isSymbol_1 = isSymbol;
|
||
|
|
||
|
/** Used to match property names within property paths. */
|
||
|
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
||
|
reIsPlainProp = /^\w*$/;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is a property name and not a property path.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @param {Object} [object] The object to query keys on.
|
||
|
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||
|
*/
|
||
|
function isKey(value, object) {
|
||
|
if (isArray_1(value)) {
|
||
|
return false;
|
||
|
}
|
||
|
var type = typeof value;
|
||
|
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
||
|
value == null || isSymbol_1(value)) {
|
||
|
return true;
|
||
|
}
|
||
|
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||
|
(object != null && value in Object(object));
|
||
|
}
|
||
|
|
||
|
var _isKey = isKey;
|
||
|
|
||
|
/** Error message constants. */
|
||
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||
|
|
||
|
/**
|
||
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||
|
* provided, it determines the cache key for storing the result based on the
|
||
|
* arguments provided to the memoized function. By default, the first argument
|
||
|
* provided to the memoized function is used as the map cache key. The `func`
|
||
|
* is invoked with the `this` binding of the memoized function.
|
||
|
*
|
||
|
* **Note:** The cache is exposed as the `cache` property on the memoized
|
||
|
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
||
|
* constructor with one whose instances implement the
|
||
|
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
||
|
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Function
|
||
|
* @param {Function} func The function to have its output memoized.
|
||
|
* @param {Function} [resolver] The function to resolve the cache key.
|
||
|
* @returns {Function} Returns the new memoized function.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = { 'a': 1, 'b': 2 };
|
||
|
* var other = { 'c': 3, 'd': 4 };
|
||
|
*
|
||
|
* var values = _.memoize(_.values);
|
||
|
* values(object);
|
||
|
* // => [1, 2]
|
||
|
*
|
||
|
* values(other);
|
||
|
* // => [3, 4]
|
||
|
*
|
||
|
* object.a = 2;
|
||
|
* values(object);
|
||
|
* // => [1, 2]
|
||
|
*
|
||
|
* // Modify the result cache.
|
||
|
* values.cache.set(object, ['a', 'b']);
|
||
|
* values(object);
|
||
|
* // => ['a', 'b']
|
||
|
*
|
||
|
* // Replace `_.memoize.Cache`.
|
||
|
* _.memoize.Cache = WeakMap;
|
||
|
*/
|
||
|
function memoize(func, resolver) {
|
||
|
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
||
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||
|
}
|
||
|
var memoized = function() {
|
||
|
var args = arguments,
|
||
|
key = resolver ? resolver.apply(this, args) : args[0],
|
||
|
cache = memoized.cache;
|
||
|
|
||
|
if (cache.has(key)) {
|
||
|
return cache.get(key);
|
||
|
}
|
||
|
var result = func.apply(this, args);
|
||
|
memoized.cache = cache.set(key, result) || cache;
|
||
|
return result;
|
||
|
};
|
||
|
memoized.cache = new (memoize.Cache || _MapCache);
|
||
|
return memoized;
|
||
|
}
|
||
|
|
||
|
// Expose `MapCache`.
|
||
|
memoize.Cache = _MapCache;
|
||
|
|
||
|
var memoize_1 = memoize;
|
||
|
|
||
|
/** Used as the maximum memoize cache size. */
|
||
|
var MAX_MEMOIZE_SIZE = 500;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.memoize` which clears the memoized function's
|
||
|
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to have its output memoized.
|
||
|
* @returns {Function} Returns the new memoized function.
|
||
|
*/
|
||
|
function memoizeCapped(func) {
|
||
|
var result = memoize_1(func, function(key) {
|
||
|
if (cache.size === MAX_MEMOIZE_SIZE) {
|
||
|
cache.clear();
|
||
|
}
|
||
|
return key;
|
||
|
});
|
||
|
|
||
|
var cache = result.cache;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _memoizeCapped = memoizeCapped;
|
||
|
|
||
|
/** Used to match property names within property paths. */
|
||
|
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||
|
|
||
|
/** Used to match backslashes in property paths. */
|
||
|
var reEscapeChar = /\\(\\)?/g;
|
||
|
|
||
|
/**
|
||
|
* Converts `string` to a property path array.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} string The string to convert.
|
||
|
* @returns {Array} Returns the property path array.
|
||
|
*/
|
||
|
var stringToPath = _memoizeCapped(function(string) {
|
||
|
var result = [];
|
||
|
if (string.charCodeAt(0) === 46 /* . */) {
|
||
|
result.push('');
|
||
|
}
|
||
|
string.replace(rePropName, function(match, number, quote, subString) {
|
||
|
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
||
|
});
|
||
|
return result;
|
||
|
});
|
||
|
|
||
|
var _stringToPath = stringToPath;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.map` for arrays without support for iteratee
|
||
|
* shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @returns {Array} Returns the new mapped array.
|
||
|
*/
|
||
|
function arrayMap(array, iteratee) {
|
||
|
var index = -1,
|
||
|
length = array == null ? 0 : array.length,
|
||
|
result = Array(length);
|
||
|
|
||
|
while (++index < length) {
|
||
|
result[index] = iteratee(array[index], index, array);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _arrayMap = arrayMap;
|
||
|
|
||
|
/** Used as references for various `Number` constants. */
|
||
|
var INFINITY = 1 / 0;
|
||
|
|
||
|
/** Used to convert symbols to primitives and strings. */
|
||
|
var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined,
|
||
|
symbolToString = symbolProto$2 ? symbolProto$2.toString : undefined;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.toString` which doesn't convert nullish
|
||
|
* values to empty strings.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to process.
|
||
|
* @returns {string} Returns the string.
|
||
|
*/
|
||
|
function baseToString(value) {
|
||
|
// Exit early for strings to avoid a performance hit in some environments.
|
||
|
if (typeof value == 'string') {
|
||
|
return value;
|
||
|
}
|
||
|
if (isArray_1(value)) {
|
||
|
// Recursively convert values (susceptible to call stack limits).
|
||
|
return _arrayMap(value, baseToString) + '';
|
||
|
}
|
||
|
if (isSymbol_1(value)) {
|
||
|
return symbolToString ? symbolToString.call(value) : '';
|
||
|
}
|
||
|
var result = (value + '');
|
||
|
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||
|
}
|
||
|
|
||
|
var _baseToString = baseToString;
|
||
|
|
||
|
/**
|
||
|
* Converts `value` to a string. An empty string is returned for `null`
|
||
|
* and `undefined` values. The sign of `-0` is preserved.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to convert.
|
||
|
* @returns {string} Returns the converted string.
|
||
|
* @example
|
||
|
*
|
||
|
* _.toString(null);
|
||
|
* // => ''
|
||
|
*
|
||
|
* _.toString(-0);
|
||
|
* // => '-0'
|
||
|
*
|
||
|
* _.toString([1, 2, 3]);
|
||
|
* // => '1,2,3'
|
||
|
*/
|
||
|
function toString(value) {
|
||
|
return value == null ? '' : _baseToString(value);
|
||
|
}
|
||
|
|
||
|
var toString_1 = toString;
|
||
|
|
||
|
/**
|
||
|
* Casts `value` to a path array if it's not one.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to inspect.
|
||
|
* @param {Object} [object] The object to query keys on.
|
||
|
* @returns {Array} Returns the cast property path array.
|
||
|
*/
|
||
|
function castPath(value, object) {
|
||
|
if (isArray_1(value)) {
|
||
|
return value;
|
||
|
}
|
||
|
return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
|
||
|
}
|
||
|
|
||
|
var _castPath = castPath;
|
||
|
|
||
|
/** Used as references for various `Number` constants. */
|
||
|
var INFINITY$1 = 1 / 0;
|
||
|
|
||
|
/**
|
||
|
* Converts `value` to a string key if it's not a string or symbol.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to inspect.
|
||
|
* @returns {string|symbol} Returns the key.
|
||
|
*/
|
||
|
function toKey(value) {
|
||
|
if (typeof value == 'string' || isSymbol_1(value)) {
|
||
|
return value;
|
||
|
}
|
||
|
var result = (value + '');
|
||
|
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
||
|
}
|
||
|
|
||
|
var _toKey = toKey;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.get` without support for default values.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Array|string} path The path of the property to get.
|
||
|
* @returns {*} Returns the resolved value.
|
||
|
*/
|
||
|
function baseGet(object, path) {
|
||
|
path = _castPath(path, object);
|
||
|
|
||
|
var index = 0,
|
||
|
length = path.length;
|
||
|
|
||
|
while (object != null && index < length) {
|
||
|
object = object[_toKey(path[index++])];
|
||
|
}
|
||
|
return (index && index == length) ? object : undefined;
|
||
|
}
|
||
|
|
||
|
var _baseGet = baseGet;
|
||
|
|
||
|
/**
|
||
|
* Gets the value at `path` of `object`. If the resolved value is
|
||
|
* `undefined`, the `defaultValue` is returned in its place.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 3.7.0
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Array|string} path The path of the property to get.
|
||
|
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
||
|
* @returns {*} Returns the resolved value.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||
|
*
|
||
|
* _.get(object, 'a[0].b.c');
|
||
|
* // => 3
|
||
|
*
|
||
|
* _.get(object, ['a', '0', 'b', 'c']);
|
||
|
* // => 3
|
||
|
*
|
||
|
* _.get(object, 'a.b.c', 'default');
|
||
|
* // => 'default'
|
||
|
*/
|
||
|
function get(object, path, defaultValue) {
|
||
|
var result = object == null ? undefined : _baseGet(object, path);
|
||
|
return result === undefined ? defaultValue : result;
|
||
|
}
|
||
|
|
||
|
var get_1 = get;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.hasIn` without support for deep paths.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} [object] The object to query.
|
||
|
* @param {Array|string} key The key to check.
|
||
|
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
||
|
*/
|
||
|
function baseHasIn(object, key) {
|
||
|
return object != null && key in Object(object);
|
||
|
}
|
||
|
|
||
|
var _baseHasIn = baseHasIn;
|
||
|
|
||
|
/**
|
||
|
* Checks if `path` exists on `object`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Array|string} path The path to check.
|
||
|
* @param {Function} hasFunc The function to check properties.
|
||
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||
|
*/
|
||
|
function hasPath(object, path, hasFunc) {
|
||
|
path = _castPath(path, object);
|
||
|
|
||
|
var index = -1,
|
||
|
length = path.length,
|
||
|
result = false;
|
||
|
|
||
|
while (++index < length) {
|
||
|
var key = _toKey(path[index]);
|
||
|
if (!(result = object != null && hasFunc(object, key))) {
|
||
|
break;
|
||
|
}
|
||
|
object = object[key];
|
||
|
}
|
||
|
if (result || ++index != length) {
|
||
|
return result;
|
||
|
}
|
||
|
length = object == null ? 0 : object.length;
|
||
|
return !!length && isLength_1(length) && _isIndex(key, length) &&
|
||
|
(isArray_1(object) || isArguments_1(object));
|
||
|
}
|
||
|
|
||
|
var _hasPath = hasPath;
|
||
|
|
||
|
/**
|
||
|
* Checks if `path` is a direct or inherited property of `object`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Array|string} path The path to check.
|
||
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
||
|
*
|
||
|
* _.hasIn(object, 'a');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.hasIn(object, 'a.b');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.hasIn(object, ['a', 'b']);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.hasIn(object, 'b');
|
||
|
* // => false
|
||
|
*/
|
||
|
function hasIn(object, path) {
|
||
|
return object != null && _hasPath(object, path, _baseHasIn);
|
||
|
}
|
||
|
|
||
|
var hasIn_1 = hasIn;
|
||
|
|
||
|
/** Used to compose bitmasks for value comparisons. */
|
||
|
var COMPARE_PARTIAL_FLAG$5 = 1,
|
||
|
COMPARE_UNORDERED_FLAG$3 = 2;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} path The path of the property to get.
|
||
|
* @param {*} srcValue The value to match.
|
||
|
* @returns {Function} Returns the new spec function.
|
||
|
*/
|
||
|
function baseMatchesProperty(path, srcValue) {
|
||
|
if (_isKey(path) && _isStrictComparable(srcValue)) {
|
||
|
return _matchesStrictComparable(_toKey(path), srcValue);
|
||
|
}
|
||
|
return function(object) {
|
||
|
var objValue = get_1(object, path);
|
||
|
return (objValue === undefined && objValue === srcValue)
|
||
|
? hasIn_1(object, path)
|
||
|
: _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _baseMatchesProperty = baseMatchesProperty;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.property` without support for deep paths.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} key The key of the property to get.
|
||
|
* @returns {Function} Returns the new accessor function.
|
||
|
*/
|
||
|
function baseProperty(key) {
|
||
|
return function(object) {
|
||
|
return object == null ? undefined : object[key];
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _baseProperty = baseProperty;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseProperty` which supports deep paths.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array|string} path The path of the property to get.
|
||
|
* @returns {Function} Returns the new accessor function.
|
||
|
*/
|
||
|
function basePropertyDeep(path) {
|
||
|
return function(object) {
|
||
|
return _baseGet(object, path);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _basePropertyDeep = basePropertyDeep;
|
||
|
|
||
|
/**
|
||
|
* Creates a function that returns the value at `path` of a given object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 2.4.0
|
||
|
* @category Util
|
||
|
* @param {Array|string} path The path of the property to get.
|
||
|
* @returns {Function} Returns the new accessor function.
|
||
|
* @example
|
||
|
*
|
||
|
* var objects = [
|
||
|
* { 'a': { 'b': 2 } },
|
||
|
* { 'a': { 'b': 1 } }
|
||
|
* ];
|
||
|
*
|
||
|
* _.map(objects, _.property('a.b'));
|
||
|
* // => [2, 1]
|
||
|
*
|
||
|
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
|
||
|
* // => [1, 2]
|
||
|
*/
|
||
|
function property(path) {
|
||
|
return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
|
||
|
}
|
||
|
|
||
|
var property_1 = property;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.iteratee`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} [value=_.identity] The value to convert to an iteratee.
|
||
|
* @returns {Function} Returns the iteratee.
|
||
|
*/
|
||
|
function baseIteratee(value) {
|
||
|
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
||
|
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
||
|
if (typeof value == 'function') {
|
||
|
return value;
|
||
|
}
|
||
|
if (value == null) {
|
||
|
return identity_1;
|
||
|
}
|
||
|
if (typeof value == 'object') {
|
||
|
return isArray_1(value)
|
||
|
? _baseMatchesProperty(value[0], value[1])
|
||
|
: _baseMatches(value);
|
||
|
}
|
||
|
return property_1(value);
|
||
|
}
|
||
|
|
||
|
var _baseIteratee = baseIteratee;
|
||
|
|
||
|
/**
|
||
|
* Iterates over elements of `collection`, returning an array of all elements
|
||
|
* `predicate` returns truthy for. The predicate is invoked with three
|
||
|
* arguments: (value, index|key, collection).
|
||
|
*
|
||
|
* **Note:** Unlike `_.remove`, this method returns a new array.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Collection
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||
|
* @returns {Array} Returns the new filtered array.
|
||
|
* @see _.reject
|
||
|
* @example
|
||
|
*
|
||
|
* var users = [
|
||
|
* { 'user': 'barney', 'age': 36, 'active': true },
|
||
|
* { 'user': 'fred', 'age': 40, 'active': false }
|
||
|
* ];
|
||
|
*
|
||
|
* _.filter(users, function(o) { return !o.active; });
|
||
|
* // => objects for ['fred']
|
||
|
*
|
||
|
* // The `_.matches` iteratee shorthand.
|
||
|
* _.filter(users, { 'age': 36, 'active': true });
|
||
|
* // => objects for ['barney']
|
||
|
*
|
||
|
* // The `_.matchesProperty` iteratee shorthand.
|
||
|
* _.filter(users, ['active', false]);
|
||
|
* // => objects for ['fred']
|
||
|
*
|
||
|
* // The `_.property` iteratee shorthand.
|
||
|
* _.filter(users, 'active');
|
||
|
* // => objects for ['barney']
|
||
|
*
|
||
|
* // Combining several predicates using `_.overEvery` or `_.overSome`.
|
||
|
* _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
|
||
|
* // => objects for ['fred', 'barney']
|
||
|
*/
|
||
|
function filter(collection, predicate) {
|
||
|
var func = isArray_1(collection) ? _arrayFilter : _baseFilter;
|
||
|
return func(collection, _baseIteratee(predicate));
|
||
|
}
|
||
|
|
||
|
var filter_1 = filter;
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$f = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$c = objectProto$f.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.has` without support for deep paths.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} [object] The object to query.
|
||
|
* @param {Array|string} key The key to check.
|
||
|
* @returns {boolean} Returns `true` if `key` exists, else `false`.
|
||
|
*/
|
||
|
function baseHas(object, key) {
|
||
|
return object != null && hasOwnProperty$c.call(object, key);
|
||
|
}
|
||
|
|
||
|
var _baseHas = baseHas;
|
||
|
|
||
|
/**
|
||
|
* Checks if `path` is a direct property of `object`.
|
||
|
*
|
||
|
* @static
|
||
|
* @since 0.1.0
|
||
|
* @memberOf _
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Array|string} path The path to check.
|
||
|
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = { 'a': { 'b': 2 } };
|
||
|
* var other = _.create({ 'a': _.create({ 'b': 2 }) });
|
||
|
*
|
||
|
* _.has(object, 'a');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.has(object, 'a.b');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.has(object, ['a', 'b']);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.has(other, 'a');
|
||
|
* // => false
|
||
|
*/
|
||
|
function has(object, path) {
|
||
|
return object != null && _hasPath(object, path, _baseHas);
|
||
|
}
|
||
|
|
||
|
var has_1 = has;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var mapTag$6 = '[object Map]',
|
||
|
setTag$6 = '[object Set]';
|
||
|
|
||
|
/** Used for built-in method references. */
|
||
|
var objectProto$g = Object.prototype;
|
||
|
|
||
|
/** Used to check objects for own properties. */
|
||
|
var hasOwnProperty$d = objectProto$g.hasOwnProperty;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is an empty object, collection, map, or set.
|
||
|
*
|
||
|
* Objects are considered empty if they have no own enumerable string keyed
|
||
|
* properties.
|
||
|
*
|
||
|
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
||
|
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
||
|
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isEmpty(null);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isEmpty(true);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isEmpty(1);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isEmpty([1, 2, 3]);
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isEmpty({ 'a': 1 });
|
||
|
* // => false
|
||
|
*/
|
||
|
function isEmpty(value) {
|
||
|
if (value == null) {
|
||
|
return true;
|
||
|
}
|
||
|
if (isArrayLike_1(value) &&
|
||
|
(isArray_1(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
||
|
isBuffer_1(value) || isTypedArray_1(value) || isArguments_1(value))) {
|
||
|
return !value.length;
|
||
|
}
|
||
|
var tag = _getTag(value);
|
||
|
if (tag == mapTag$6 || tag == setTag$6) {
|
||
|
return !value.size;
|
||
|
}
|
||
|
if (_isPrototype(value)) {
|
||
|
return !_baseKeys(value).length;
|
||
|
}
|
||
|
for (var key in value) {
|
||
|
if (hasOwnProperty$d.call(value, key)) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
var isEmpty_1 = isEmpty;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is `undefined`.
|
||
|
*
|
||
|
* @static
|
||
|
* @since 0.1.0
|
||
|
* @memberOf _
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isUndefined(void 0);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isUndefined(null);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isUndefined(value) {
|
||
|
return value === undefined;
|
||
|
}
|
||
|
|
||
|
var isUndefined_1 = isUndefined;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.map` without support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @returns {Array} Returns the new mapped array.
|
||
|
*/
|
||
|
function baseMap(collection, iteratee) {
|
||
|
var index = -1,
|
||
|
result = isArrayLike_1(collection) ? Array(collection.length) : [];
|
||
|
|
||
|
_baseEach(collection, function(value, key, collection) {
|
||
|
result[++index] = iteratee(value, key, collection);
|
||
|
});
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseMap = baseMap;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of values by running each element in `collection` thru
|
||
|
* `iteratee`. The iteratee is invoked with three arguments:
|
||
|
* (value, index|key, collection).
|
||
|
*
|
||
|
* Many lodash methods are guarded to work as iteratees for methods like
|
||
|
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
|
||
|
*
|
||
|
* The guarded methods are:
|
||
|
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
|
||
|
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
|
||
|
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
|
||
|
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Collection
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||
|
* @returns {Array} Returns the new mapped array.
|
||
|
* @example
|
||
|
*
|
||
|
* function square(n) {
|
||
|
* return n * n;
|
||
|
* }
|
||
|
*
|
||
|
* _.map([4, 8], square);
|
||
|
* // => [16, 64]
|
||
|
*
|
||
|
* _.map({ 'a': 4, 'b': 8 }, square);
|
||
|
* // => [16, 64] (iteration order is not guaranteed)
|
||
|
*
|
||
|
* var users = [
|
||
|
* { 'user': 'barney' },
|
||
|
* { 'user': 'fred' }
|
||
|
* ];
|
||
|
*
|
||
|
* // The `_.property` iteratee shorthand.
|
||
|
* _.map(users, 'user');
|
||
|
* // => ['barney', 'fred']
|
||
|
*/
|
||
|
function map(collection, iteratee) {
|
||
|
var func = isArray_1(collection) ? _arrayMap : _baseMap;
|
||
|
return func(collection, _baseIteratee(iteratee));
|
||
|
}
|
||
|
|
||
|
var map_1 = map;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.reduce` for arrays without support for
|
||
|
* iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @param {*} [accumulator] The initial value.
|
||
|
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
||
|
* the initial value.
|
||
|
* @returns {*} Returns the accumulated value.
|
||
|
*/
|
||
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
||
|
var index = -1,
|
||
|
length = array == null ? 0 : array.length;
|
||
|
|
||
|
if (initAccum && length) {
|
||
|
accumulator = array[++index];
|
||
|
}
|
||
|
while (++index < length) {
|
||
|
accumulator = iteratee(accumulator, array[index], index, array);
|
||
|
}
|
||
|
return accumulator;
|
||
|
}
|
||
|
|
||
|
var _arrayReduce = arrayReduce;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
||
|
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} iteratee The function invoked per iteration.
|
||
|
* @param {*} accumulator The initial value.
|
||
|
* @param {boolean} initAccum Specify using the first or last element of
|
||
|
* `collection` as the initial value.
|
||
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
||
|
* @returns {*} Returns the accumulated value.
|
||
|
*/
|
||
|
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
||
|
eachFunc(collection, function(value, index, collection) {
|
||
|
accumulator = initAccum
|
||
|
? (initAccum = false, value)
|
||
|
: iteratee(accumulator, value, index, collection);
|
||
|
});
|
||
|
return accumulator;
|
||
|
}
|
||
|
|
||
|
var _baseReduce = baseReduce;
|
||
|
|
||
|
/**
|
||
|
* Reduces `collection` to a value which is the accumulated result of running
|
||
|
* each element in `collection` thru `iteratee`, where each successive
|
||
|
* invocation is supplied the return value of the previous. If `accumulator`
|
||
|
* is not given, the first element of `collection` is used as the initial
|
||
|
* value. The iteratee is invoked with four arguments:
|
||
|
* (accumulator, value, index|key, collection).
|
||
|
*
|
||
|
* Many lodash methods are guarded to work as iteratees for methods like
|
||
|
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
||
|
*
|
||
|
* The guarded methods are:
|
||
|
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
|
||
|
* and `sortBy`
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Collection
|
||
|
* @param {Array|Object} collection The collection to iterate over.
|
||
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||
|
* @param {*} [accumulator] The initial value.
|
||
|
* @returns {*} Returns the accumulated value.
|
||
|
* @see _.reduceRight
|
||
|
* @example
|
||
|
*
|
||
|
* _.reduce([1, 2], function(sum, n) {
|
||
|
* return sum + n;
|
||
|
* }, 0);
|
||
|
* // => 3
|
||
|
*
|
||
|
* _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
||
|
* (result[value] || (result[value] = [])).push(key);
|
||
|
* return result;
|
||
|
* }, {});
|
||
|
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
|
||
|
*/
|
||
|
function reduce(collection, iteratee, accumulator) {
|
||
|
var func = isArray_1(collection) ? _arrayReduce : _baseReduce,
|
||
|
initAccum = arguments.length < 3;
|
||
|
|
||
|
return func(collection, _baseIteratee(iteratee), accumulator, initAccum, _baseEach);
|
||
|
}
|
||
|
|
||
|
var reduce_1 = reduce;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var stringTag$4 = '[object String]';
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a `String` primitive or object.
|
||
|
*
|
||
|
* @static
|
||
|
* @since 0.1.0
|
||
|
* @memberOf _
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isString('abc');
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isString(1);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isString(value) {
|
||
|
return typeof value == 'string' ||
|
||
|
(!isArray_1(value) && isObjectLike_1(value) && _baseGetTag(value) == stringTag$4);
|
||
|
}
|
||
|
|
||
|
var isString_1 = isString;
|
||
|
|
||
|
/**
|
||
|
* Gets the size of an ASCII `string`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} string The string inspect.
|
||
|
* @returns {number} Returns the string size.
|
||
|
*/
|
||
|
var asciiSize = _baseProperty('length');
|
||
|
|
||
|
var _asciiSize = asciiSize;
|
||
|
|
||
|
/** Used to compose unicode character classes. */
|
||
|
var rsAstralRange = '\\ud800-\\udfff',
|
||
|
rsComboMarksRange = '\\u0300-\\u036f',
|
||
|
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||
|
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||
|
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
||
|
rsVarRange = '\\ufe0e\\ufe0f';
|
||
|
|
||
|
/** Used to compose unicode capture groups. */
|
||
|
var rsZWJ = '\\u200d';
|
||
|
|
||
|
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||
|
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
|
||
|
|
||
|
/**
|
||
|
* Checks if `string` contains Unicode symbols.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} string The string to inspect.
|
||
|
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
||
|
*/
|
||
|
function hasUnicode(string) {
|
||
|
return reHasUnicode.test(string);
|
||
|
}
|
||
|
|
||
|
var _hasUnicode = hasUnicode;
|
||
|
|
||
|
/** Used to compose unicode character classes. */
|
||
|
var rsAstralRange$1 = '\\ud800-\\udfff',
|
||
|
rsComboMarksRange$1 = '\\u0300-\\u036f',
|
||
|
reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
|
||
|
rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
|
||
|
rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
|
||
|
rsVarRange$1 = '\\ufe0e\\ufe0f';
|
||
|
|
||
|
/** Used to compose unicode capture groups. */
|
||
|
var rsAstral = '[' + rsAstralRange$1 + ']',
|
||
|
rsCombo = '[' + rsComboRange$1 + ']',
|
||
|
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||
|
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||
|
rsNonAstral = '[^' + rsAstralRange$1 + ']',
|
||
|
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||
|
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||
|
rsZWJ$1 = '\\u200d';
|
||
|
|
||
|
/** Used to compose unicode regexes. */
|
||
|
var reOptMod = rsModifier + '?',
|
||
|
rsOptVar = '[' + rsVarRange$1 + ']?',
|
||
|
rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||
|
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||
|
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||
|
|
||
|
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||
|
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||
|
|
||
|
/**
|
||
|
* Gets the size of a Unicode `string`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} string The string inspect.
|
||
|
* @returns {number} Returns the string size.
|
||
|
*/
|
||
|
function unicodeSize(string) {
|
||
|
var result = reUnicode.lastIndex = 0;
|
||
|
while (reUnicode.test(string)) {
|
||
|
++result;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _unicodeSize = unicodeSize;
|
||
|
|
||
|
/**
|
||
|
* Gets the number of symbols in `string`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} string The string to inspect.
|
||
|
* @returns {number} Returns the string size.
|
||
|
*/
|
||
|
function stringSize(string) {
|
||
|
return _hasUnicode(string)
|
||
|
? _unicodeSize(string)
|
||
|
: _asciiSize(string);
|
||
|
}
|
||
|
|
||
|
var _stringSize = stringSize;
|
||
|
|
||
|
/** `Object#toString` result references. */
|
||
|
var mapTag$7 = '[object Map]',
|
||
|
setTag$7 = '[object Set]';
|
||
|
|
||
|
/**
|
||
|
* Gets the size of `collection` by returning its length for array-like
|
||
|
* values or the number of own enumerable string keyed properties for objects.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Collection
|
||
|
* @param {Array|Object|string} collection The collection to inspect.
|
||
|
* @returns {number} Returns the collection size.
|
||
|
* @example
|
||
|
*
|
||
|
* _.size([1, 2, 3]);
|
||
|
* // => 3
|
||
|
*
|
||
|
* _.size({ 'a': 1, 'b': 2 });
|
||
|
* // => 2
|
||
|
*
|
||
|
* _.size('pebbles');
|
||
|
* // => 7
|
||
|
*/
|
||
|
function size(collection) {
|
||
|
if (collection == null) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (isArrayLike_1(collection)) {
|
||
|
return isString_1(collection) ? _stringSize(collection) : collection.length;
|
||
|
}
|
||
|
var tag = _getTag(collection);
|
||
|
if (tag == mapTag$7 || tag == setTag$7) {
|
||
|
return collection.size;
|
||
|
}
|
||
|
return _baseKeys(collection).length;
|
||
|
}
|
||
|
|
||
|
var size_1 = size;
|
||
|
|
||
|
/**
|
||
|
* An alternative to `_.reduce`; this method transforms `object` to a new
|
||
|
* `accumulator` object which is the result of running each of its own
|
||
|
* enumerable string keyed properties thru `iteratee`, with each invocation
|
||
|
* potentially mutating the `accumulator` object. If `accumulator` is not
|
||
|
* provided, a new object with the same `[[Prototype]]` will be used. The
|
||
|
* iteratee is invoked with four arguments: (accumulator, value, key, object).
|
||
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 1.3.0
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to iterate over.
|
||
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||
|
* @param {*} [accumulator] The custom accumulator value.
|
||
|
* @returns {*} Returns the accumulated value.
|
||
|
* @example
|
||
|
*
|
||
|
* _.transform([2, 3, 4], function(result, n) {
|
||
|
* result.push(n *= n);
|
||
|
* return n % 2 == 0;
|
||
|
* }, []);
|
||
|
* // => [4, 9]
|
||
|
*
|
||
|
* _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
||
|
* (result[value] || (result[value] = [])).push(key);
|
||
|
* }, {});
|
||
|
* // => { '1': ['a', 'c'], '2': ['b'] }
|
||
|
*/
|
||
|
function transform(object, iteratee, accumulator) {
|
||
|
var isArr = isArray_1(object),
|
||
|
isArrLike = isArr || isBuffer_1(object) || isTypedArray_1(object);
|
||
|
|
||
|
iteratee = _baseIteratee(iteratee);
|
||
|
if (accumulator == null) {
|
||
|
var Ctor = object && object.constructor;
|
||
|
if (isArrLike) {
|
||
|
accumulator = isArr ? new Ctor : [];
|
||
|
}
|
||
|
else if (isObject_1(object)) {
|
||
|
accumulator = isFunction_1(Ctor) ? _baseCreate(_getPrototype(object)) : {};
|
||
|
}
|
||
|
else {
|
||
|
accumulator = {};
|
||
|
}
|
||
|
}
|
||
|
(isArrLike ? _arrayEach : _baseForOwn)(object, function(value, index, object) {
|
||
|
return iteratee(accumulator, value, index, object);
|
||
|
});
|
||
|
return accumulator;
|
||
|
}
|
||
|
|
||
|
var transform_1 = transform;
|
||
|
|
||
|
/** Built-in value references. */
|
||
|
var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is a flattenable `arguments` object or array.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
||
|
*/
|
||
|
function isFlattenable(value) {
|
||
|
return isArray_1(value) || isArguments_1(value) ||
|
||
|
!!(spreadableSymbol && value && value[spreadableSymbol]);
|
||
|
}
|
||
|
|
||
|
var _isFlattenable = isFlattenable;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.flatten` with support for restricting flattening.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to flatten.
|
||
|
* @param {number} depth The maximum recursion depth.
|
||
|
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
||
|
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
||
|
* @param {Array} [result=[]] The initial result value.
|
||
|
* @returns {Array} Returns the new flattened array.
|
||
|
*/
|
||
|
function baseFlatten(array, depth, predicate, isStrict, result) {
|
||
|
var index = -1,
|
||
|
length = array.length;
|
||
|
|
||
|
predicate || (predicate = _isFlattenable);
|
||
|
result || (result = []);
|
||
|
|
||
|
while (++index < length) {
|
||
|
var value = array[index];
|
||
|
if (depth > 0 && predicate(value)) {
|
||
|
if (depth > 1) {
|
||
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||
|
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
||
|
} else {
|
||
|
_arrayPush(result, value);
|
||
|
}
|
||
|
} else if (!isStrict) {
|
||
|
result[result.length] = value;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseFlatten = baseFlatten;
|
||
|
|
||
|
/**
|
||
|
* A faster alternative to `Function#apply`, this function invokes `func`
|
||
|
* with the `this` binding of `thisArg` and the arguments of `args`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to invoke.
|
||
|
* @param {*} thisArg The `this` binding of `func`.
|
||
|
* @param {Array} args The arguments to invoke `func` with.
|
||
|
* @returns {*} Returns the result of `func`.
|
||
|
*/
|
||
|
function apply(func, thisArg, args) {
|
||
|
switch (args.length) {
|
||
|
case 0: return func.call(thisArg);
|
||
|
case 1: return func.call(thisArg, args[0]);
|
||
|
case 2: return func.call(thisArg, args[0], args[1]);
|
||
|
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
||
|
}
|
||
|
return func.apply(thisArg, args);
|
||
|
}
|
||
|
|
||
|
var _apply = apply;
|
||
|
|
||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
|
var nativeMax = Math.max;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `baseRest` which transforms the rest array.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to apply a rest parameter to.
|
||
|
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||
|
* @param {Function} transform The rest array transform.
|
||
|
* @returns {Function} Returns the new function.
|
||
|
*/
|
||
|
function overRest(func, start, transform) {
|
||
|
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||
|
return function() {
|
||
|
var args = arguments,
|
||
|
index = -1,
|
||
|
length = nativeMax(args.length - start, 0),
|
||
|
array = Array(length);
|
||
|
|
||
|
while (++index < length) {
|
||
|
array[index] = args[start + index];
|
||
|
}
|
||
|
index = -1;
|
||
|
var otherArgs = Array(start + 1);
|
||
|
while (++index < start) {
|
||
|
otherArgs[index] = args[index];
|
||
|
}
|
||
|
otherArgs[start] = transform(array);
|
||
|
return _apply(func, this, otherArgs);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _overRest = overRest;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `setToString` without support for hot loop shorting.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to modify.
|
||
|
* @param {Function} string The `toString` result.
|
||
|
* @returns {Function} Returns `func`.
|
||
|
*/
|
||
|
var baseSetToString = !_defineProperty ? identity_1 : function(func, string) {
|
||
|
return _defineProperty(func, 'toString', {
|
||
|
'configurable': true,
|
||
|
'enumerable': false,
|
||
|
'value': constant_1(string),
|
||
|
'writable': true
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var _baseSetToString = baseSetToString;
|
||
|
|
||
|
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
||
|
var HOT_COUNT = 800,
|
||
|
HOT_SPAN = 16;
|
||
|
|
||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
|
var nativeNow = Date.now;
|
||
|
|
||
|
/**
|
||
|
* Creates a function that'll short out and invoke `identity` instead
|
||
|
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
||
|
* milliseconds.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to restrict.
|
||
|
* @returns {Function} Returns the new shortable function.
|
||
|
*/
|
||
|
function shortOut(func) {
|
||
|
var count = 0,
|
||
|
lastCalled = 0;
|
||
|
|
||
|
return function() {
|
||
|
var stamp = nativeNow(),
|
||
|
remaining = HOT_SPAN - (stamp - lastCalled);
|
||
|
|
||
|
lastCalled = stamp;
|
||
|
if (remaining > 0) {
|
||
|
if (++count >= HOT_COUNT) {
|
||
|
return arguments[0];
|
||
|
}
|
||
|
} else {
|
||
|
count = 0;
|
||
|
}
|
||
|
return func.apply(undefined, arguments);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var _shortOut = shortOut;
|
||
|
|
||
|
/**
|
||
|
* Sets the `toString` method of `func` to return `string`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to modify.
|
||
|
* @param {Function} string The `toString` result.
|
||
|
* @returns {Function} Returns `func`.
|
||
|
*/
|
||
|
var setToString = _shortOut(_baseSetToString);
|
||
|
|
||
|
var _setToString = setToString;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} func The function to apply a rest parameter to.
|
||
|
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||
|
* @returns {Function} Returns the new function.
|
||
|
*/
|
||
|
function baseRest(func, start) {
|
||
|
return _setToString(_overRest(func, start, identity_1), func + '');
|
||
|
}
|
||
|
|
||
|
var _baseRest = baseRest;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
||
|
* support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to inspect.
|
||
|
* @param {Function} predicate The function invoked per iteration.
|
||
|
* @param {number} fromIndex The index to search from.
|
||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
|
*/
|
||
|
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
||
|
var length = array.length,
|
||
|
index = fromIndex + (fromRight ? 1 : -1);
|
||
|
|
||
|
while ((fromRight ? index-- : ++index < length)) {
|
||
|
if (predicate(array[index], index, array)) {
|
||
|
return index;
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
var _baseFindIndex = baseFindIndex;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.isNaN` without support for number objects.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
||
|
*/
|
||
|
function baseIsNaN(value) {
|
||
|
return value !== value;
|
||
|
}
|
||
|
|
||
|
var _baseIsNaN = baseIsNaN;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.indexOf` which performs strict equality
|
||
|
* comparisons of values, i.e. `===`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to inspect.
|
||
|
* @param {*} value The value to search for.
|
||
|
* @param {number} fromIndex The index to search from.
|
||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
|
*/
|
||
|
function strictIndexOf(array, value, fromIndex) {
|
||
|
var index = fromIndex - 1,
|
||
|
length = array.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
if (array[index] === value) {
|
||
|
return index;
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
var _strictIndexOf = strictIndexOf;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to inspect.
|
||
|
* @param {*} value The value to search for.
|
||
|
* @param {number} fromIndex The index to search from.
|
||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
|
*/
|
||
|
function baseIndexOf(array, value, fromIndex) {
|
||
|
return value === value
|
||
|
? _strictIndexOf(array, value, fromIndex)
|
||
|
: _baseFindIndex(array, _baseIsNaN, fromIndex);
|
||
|
}
|
||
|
|
||
|
var _baseIndexOf = baseIndexOf;
|
||
|
|
||
|
/**
|
||
|
* A specialized version of `_.includes` for arrays without support for
|
||
|
* specifying an index to search from.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to inspect.
|
||
|
* @param {*} target The value to search for.
|
||
|
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
||
|
*/
|
||
|
function arrayIncludes(array, value) {
|
||
|
var length = array == null ? 0 : array.length;
|
||
|
return !!length && _baseIndexOf(array, value, 0) > -1;
|
||
|
}
|
||
|
|
||
|
var _arrayIncludes = arrayIncludes;
|
||
|
|
||
|
/**
|
||
|
* This function is like `arrayIncludes` except that it accepts a comparator.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} [array] The array to inspect.
|
||
|
* @param {*} target The value to search for.
|
||
|
* @param {Function} comparator The comparator invoked per element.
|
||
|
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
||
|
*/
|
||
|
function arrayIncludesWith(array, value, comparator) {
|
||
|
var index = -1,
|
||
|
length = array == null ? 0 : array.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
if (comparator(value, array[index])) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var _arrayIncludesWith = arrayIncludesWith;
|
||
|
|
||
|
/**
|
||
|
* This method returns `undefined`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 2.3.0
|
||
|
* @category Util
|
||
|
* @example
|
||
|
*
|
||
|
* _.times(2, _.noop);
|
||
|
* // => [undefined, undefined]
|
||
|
*/
|
||
|
function noop() {
|
||
|
// No operation performed.
|
||
|
}
|
||
|
|
||
|
var noop_1 = noop;
|
||
|
|
||
|
/** Used as references for various `Number` constants. */
|
||
|
var INFINITY$2 = 1 / 0;
|
||
|
|
||
|
/**
|
||
|
* Creates a set object of `values`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} values The values to add to the set.
|
||
|
* @returns {Object} Returns the new set.
|
||
|
*/
|
||
|
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY$2) ? noop_1 : function(values) {
|
||
|
return new _Set(values);
|
||
|
};
|
||
|
|
||
|
var _createSet = createSet;
|
||
|
|
||
|
/** Used as the size to enable large array optimizations. */
|
||
|
var LARGE_ARRAY_SIZE$1 = 200;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to inspect.
|
||
|
* @param {Function} [iteratee] The iteratee invoked per element.
|
||
|
* @param {Function} [comparator] The comparator invoked per element.
|
||
|
* @returns {Array} Returns the new duplicate free array.
|
||
|
*/
|
||
|
function baseUniq(array, iteratee, comparator) {
|
||
|
var index = -1,
|
||
|
includes = _arrayIncludes,
|
||
|
length = array.length,
|
||
|
isCommon = true,
|
||
|
result = [],
|
||
|
seen = result;
|
||
|
|
||
|
if (comparator) {
|
||
|
isCommon = false;
|
||
|
includes = _arrayIncludesWith;
|
||
|
}
|
||
|
else if (length >= LARGE_ARRAY_SIZE$1) {
|
||
|
var set = iteratee ? null : _createSet(array);
|
||
|
if (set) {
|
||
|
return _setToArray(set);
|
||
|
}
|
||
|
isCommon = false;
|
||
|
includes = _cacheHas;
|
||
|
seen = new _SetCache;
|
||
|
}
|
||
|
else {
|
||
|
seen = iteratee ? [] : result;
|
||
|
}
|
||
|
outer:
|
||
|
while (++index < length) {
|
||
|
var value = array[index],
|
||
|
computed = iteratee ? iteratee(value) : value;
|
||
|
|
||
|
value = (comparator || value !== 0) ? value : 0;
|
||
|
if (isCommon && computed === computed) {
|
||
|
var seenIndex = seen.length;
|
||
|
while (seenIndex--) {
|
||
|
if (seen[seenIndex] === computed) {
|
||
|
continue outer;
|
||
|
}
|
||
|
}
|
||
|
if (iteratee) {
|
||
|
seen.push(computed);
|
||
|
}
|
||
|
result.push(value);
|
||
|
}
|
||
|
else if (!includes(seen, computed, comparator)) {
|
||
|
if (seen !== result) {
|
||
|
seen.push(computed);
|
||
|
}
|
||
|
result.push(value);
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var _baseUniq = baseUniq;
|
||
|
|
||
|
/**
|
||
|
* This method is like `_.isArrayLike` except that it also checks if `value`
|
||
|
* is an object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 4.0.0
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
||
|
* else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isArrayLikeObject([1, 2, 3]);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArrayLikeObject(document.body.children);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isArrayLikeObject('abc');
|
||
|
* // => false
|
||
|
*
|
||
|
* _.isArrayLikeObject(_.noop);
|
||
|
* // => false
|
||
|
*/
|
||
|
function isArrayLikeObject(value) {
|
||
|
return isObjectLike_1(value) && isArrayLike_1(value);
|
||
|
}
|
||
|
|
||
|
var isArrayLikeObject_1 = isArrayLikeObject;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of unique values, in order, from all given arrays using
|
||
|
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
|
* for equality comparisons.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 0.1.0
|
||
|
* @category Array
|
||
|
* @param {...Array} [arrays] The arrays to inspect.
|
||
|
* @returns {Array} Returns the new array of combined values.
|
||
|
* @example
|
||
|
*
|
||
|
* _.union([2], [1, 2]);
|
||
|
* // => [2, 1]
|
||
|
*/
|
||
|
var union = _baseRest(function(arrays) {
|
||
|
return _baseUniq(_baseFlatten(arrays, 1, isArrayLikeObject_1, true));
|
||
|
});
|
||
|
|
||
|
var union_1 = union;
|
||
|
|
||
|
/**
|
||
|
* The base implementation of `_.values` and `_.valuesIn` which creates an
|
||
|
* array of `object` property values corresponding to the property names
|
||
|
* of `props`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} object The object to query.
|
||
|
* @param {Array} props The property names to get values for.
|
||
|
* @returns {Object} Returns the array of property values.
|
||
|
*/
|
||
|
function baseValues(object, props) {
|
||
|
return _arrayMap(props, function(key) {
|
||
|
return object[key];
|
||
|
});
|
||
|
}
|
||
|
|
||
|
var _baseValues = baseValues;
|
||
|
|
||
|
/**
|
||
|
* Creates an array of the own enumerable string keyed property values of `object`.
|
||
|
*
|
||
|
* **Note:** Non-object values are coerced to objects.
|
||
|
*
|
||
|
* @static
|
||
|
* @since 0.1.0
|
||
|
* @memberOf _
|
||
|
* @category Object
|
||
|
* @param {Object} object The object to query.
|
||
|
* @returns {Array} Returns the array of property values.
|
||
|
* @example
|
||
|
*
|
||
|
* function Foo() {
|
||
|
* this.a = 1;
|
||
|
* this.b = 2;
|
||
|
* }
|
||
|
*
|
||
|
* Foo.prototype.c = 3;
|
||
|
*
|
||
|
* _.values(new Foo);
|
||
|
* // => [1, 2] (iteration order is not guaranteed)
|
||
|
*
|
||
|
* _.values('hi');
|
||
|
* // => ['h', 'i']
|
||
|
*/
|
||
|
function values(object) {
|
||
|
return object == null ? [] : _baseValues(object, keys_1(object));
|
||
|
}
|
||
|
|
||
|
var values_1 = values;
|
||
|
|
||
|
/* global window */
|
||
|
|
||
|
var lodash;
|
||
|
|
||
|
if (typeof commonjsRequire === "function") {
|
||
|
try {
|
||
|
lodash = {
|
||
|
clone: clone_1,
|
||
|
constant: constant_1,
|
||
|
each: each,
|
||
|
filter: filter_1,
|
||
|
has: has_1,
|
||
|
isArray: isArray_1,
|
||
|
isEmpty: isEmpty_1,
|
||
|
isFunction: isFunction_1,
|
||
|
isUndefined: isUndefined_1,
|
||
|
keys: keys_1,
|
||
|
map: map_1,
|
||
|
reduce: reduce_1,
|
||
|
size: size_1,
|
||
|
transform: transform_1,
|
||
|
union: union_1,
|
||
|
values: values_1
|
||
|
};
|
||
|
} catch (e) {
|
||
|
// continue regardless of error
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!lodash) {
|
||
|
lodash = window._;
|
||
|
}
|
||
|
|
||
|
var lodash_1 = lodash;
|
||
|
|
||
|
var graph = Graph;
|
||
|
|
||
|
var DEFAULT_EDGE_NAME = "\x00";
|
||
|
var GRAPH_NODE = "\x00";
|
||
|
var EDGE_KEY_DELIM = "\x01";
|
||
|
|
||
|
// Implementation notes:
|
||
|
//
|
||
|
// * Node id query functions should return string ids for the nodes
|
||
|
// * Edge id query functions should return an "edgeObj", edge object, that is
|
||
|
// composed of enough information to uniquely identify an edge: {v, w, name}.
|
||
|
// * Internally we use an "edgeId", a stringified form of the edgeObj, to
|
||
|
// reference edges. This is because we need a performant way to look these
|
||
|
// edges up and, object properties, which have string keys, are the closest
|
||
|
// we're going to get to a performant hashtable in JavaScript.
|
||
|
|
||
|
function Graph(opts) {
|
||
|
this._isDirected = lodash_1.has(opts, "directed") ? opts.directed : true;
|
||
|
this._isMultigraph = lodash_1.has(opts, "multigraph") ? opts.multigraph : false;
|
||
|
this._isCompound = lodash_1.has(opts, "compound") ? opts.compound : false;
|
||
|
|
||
|
// Label for the graph itself
|
||
|
this._label = undefined;
|
||
|
|
||
|
// Defaults to be set when creating a new node
|
||
|
this._defaultNodeLabelFn = lodash_1.constant(undefined);
|
||
|
|
||
|
// Defaults to be set when creating a new edge
|
||
|
this._defaultEdgeLabelFn = lodash_1.constant(undefined);
|
||
|
|
||
|
// v -> label
|
||
|
this._nodes = {};
|
||
|
|
||
|
if (this._isCompound) {
|
||
|
// v -> parent
|
||
|
this._parent = {};
|
||
|
|
||
|
// v -> children
|
||
|
this._children = {};
|
||
|
this._children[GRAPH_NODE] = {};
|
||
|
}
|
||
|
|
||
|
// v -> edgeObj
|
||
|
this._in = {};
|
||
|
|
||
|
// u -> v -> Number
|
||
|
this._preds = {};
|
||
|
|
||
|
// v -> edgeObj
|
||
|
this._out = {};
|
||
|
|
||
|
// v -> w -> Number
|
||
|
this._sucs = {};
|
||
|
|
||
|
// e -> edgeObj
|
||
|
this._edgeObjs = {};
|
||
|
|
||
|
// e -> label
|
||
|
this._edgeLabels = {};
|
||
|
}
|
||
|
|
||
|
/* Number of nodes in the graph. Should only be changed by the implementation. */
|
||
|
Graph.prototype._nodeCount = 0;
|
||
|
|
||
|
/* Number of edges in the graph. Should only be changed by the implementation. */
|
||
|
Graph.prototype._edgeCount = 0;
|
||
|
|
||
|
|
||
|
/* === Graph functions ========= */
|
||
|
|
||
|
Graph.prototype.isDirected = function() {
|
||
|
return this._isDirected;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.isMultigraph = function() {
|
||
|
return this._isMultigraph;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.isCompound = function() {
|
||
|
return this._isCompound;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.setGraph = function(label) {
|
||
|
this._label = label;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.graph = function() {
|
||
|
return this._label;
|
||
|
};
|
||
|
|
||
|
|
||
|
/* === Node functions ========== */
|
||
|
|
||
|
Graph.prototype.setDefaultNodeLabel = function(newDefault) {
|
||
|
if (!lodash_1.isFunction(newDefault)) {
|
||
|
newDefault = lodash_1.constant(newDefault);
|
||
|
}
|
||
|
this._defaultNodeLabelFn = newDefault;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.nodeCount = function() {
|
||
|
return this._nodeCount;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.nodes = function() {
|
||
|
return lodash_1.keys(this._nodes);
|
||
|
};
|
||
|
|
||
|
Graph.prototype.sources = function() {
|
||
|
var self = this;
|
||
|
return lodash_1.filter(this.nodes(), function(v) {
|
||
|
return lodash_1.isEmpty(self._in[v]);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
Graph.prototype.sinks = function() {
|
||
|
var self = this;
|
||
|
return lodash_1.filter(this.nodes(), function(v) {
|
||
|
return lodash_1.isEmpty(self._out[v]);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
Graph.prototype.setNodes = function(vs, value) {
|
||
|
var args = arguments;
|
||
|
var self = this;
|
||
|
lodash_1.each(vs, function(v) {
|
||
|
if (args.length > 1) {
|
||
|
self.setNode(v, value);
|
||
|
} else {
|
||
|
self.setNode(v);
|
||
|
}
|
||
|
});
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.setNode = function(v, value) {
|
||
|
if (lodash_1.has(this._nodes, v)) {
|
||
|
if (arguments.length > 1) {
|
||
|
this._nodes[v] = value;
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
|
||
|
if (this._isCompound) {
|
||
|
this._parent[v] = GRAPH_NODE;
|
||
|
this._children[v] = {};
|
||
|
this._children[GRAPH_NODE][v] = true;
|
||
|
}
|
||
|
this._in[v] = {};
|
||
|
this._preds[v] = {};
|
||
|
this._out[v] = {};
|
||
|
this._sucs[v] = {};
|
||
|
++this._nodeCount;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.node = function(v) {
|
||
|
return this._nodes[v];
|
||
|
};
|
||
|
|
||
|
Graph.prototype.hasNode = function(v) {
|
||
|
return lodash_1.has(this._nodes, v);
|
||
|
};
|
||
|
|
||
|
Graph.prototype.removeNode = function(v) {
|
||
|
var self = this;
|
||
|
if (lodash_1.has(this._nodes, v)) {
|
||
|
var removeEdge = function(e) { self.removeEdge(self._edgeObjs[e]); };
|
||
|
delete this._nodes[v];
|
||
|
if (this._isCompound) {
|
||
|
this._removeFromParentsChildList(v);
|
||
|
delete this._parent[v];
|
||
|
lodash_1.each(this.children(v), function(child) {
|
||
|
self.setParent(child);
|
||
|
});
|
||
|
delete this._children[v];
|
||
|
}
|
||
|
lodash_1.each(lodash_1.keys(this._in[v]), removeEdge);
|
||
|
delete this._in[v];
|
||
|
delete this._preds[v];
|
||
|
lodash_1.each(lodash_1.keys(this._out[v]), removeEdge);
|
||
|
delete this._out[v];
|
||
|
delete this._sucs[v];
|
||
|
--this._nodeCount;
|
||
|
}
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.setParent = function(v, parent) {
|
||
|
if (!this._isCompound) {
|
||
|
throw new Error("Cannot set parent in a non-compound graph");
|
||
|
}
|
||
|
|
||
|
if (lodash_1.isUndefined(parent)) {
|
||
|
parent = GRAPH_NODE;
|
||
|
} else {
|
||
|
// Coerce parent to string
|
||
|
parent += "";
|
||
|
for (var ancestor = parent;
|
||
|
!lodash_1.isUndefined(ancestor);
|
||
|
ancestor = this.parent(ancestor)) {
|
||
|
if (ancestor === v) {
|
||
|
throw new Error("Setting " + parent+ " as parent of " + v +
|
||
|
" would create a cycle");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.setNode(parent);
|
||
|
}
|
||
|
|
||
|
this.setNode(v);
|
||
|
this._removeFromParentsChildList(v);
|
||
|
this._parent[v] = parent;
|
||
|
this._children[parent][v] = true;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype._removeFromParentsChildList = function(v) {
|
||
|
delete this._children[this._parent[v]][v];
|
||
|
};
|
||
|
|
||
|
Graph.prototype.parent = function(v) {
|
||
|
if (this._isCompound) {
|
||
|
var parent = this._parent[v];
|
||
|
if (parent !== GRAPH_NODE) {
|
||
|
return parent;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.children = function(v) {
|
||
|
if (lodash_1.isUndefined(v)) {
|
||
|
v = GRAPH_NODE;
|
||
|
}
|
||
|
|
||
|
if (this._isCompound) {
|
||
|
var children = this._children[v];
|
||
|
if (children) {
|
||
|
return lodash_1.keys(children);
|
||
|
}
|
||
|
} else if (v === GRAPH_NODE) {
|
||
|
return this.nodes();
|
||
|
} else if (this.hasNode(v)) {
|
||
|
return [];
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.predecessors = function(v) {
|
||
|
var predsV = this._preds[v];
|
||
|
if (predsV) {
|
||
|
return lodash_1.keys(predsV);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.successors = function(v) {
|
||
|
var sucsV = this._sucs[v];
|
||
|
if (sucsV) {
|
||
|
return lodash_1.keys(sucsV);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.neighbors = function(v) {
|
||
|
var preds = this.predecessors(v);
|
||
|
if (preds) {
|
||
|
return lodash_1.union(preds, this.successors(v));
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.isLeaf = function (v) {
|
||
|
var neighbors;
|
||
|
if (this.isDirected()) {
|
||
|
neighbors = this.successors(v);
|
||
|
} else {
|
||
|
neighbors = this.neighbors(v);
|
||
|
}
|
||
|
return neighbors.length === 0;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.filterNodes = function(filter) {
|
||
|
var copy = new this.constructor({
|
||
|
directed: this._isDirected,
|
||
|
multigraph: this._isMultigraph,
|
||
|
compound: this._isCompound
|
||
|
});
|
||
|
|
||
|
copy.setGraph(this.graph());
|
||
|
|
||
|
var self = this;
|
||
|
lodash_1.each(this._nodes, function(value, v) {
|
||
|
if (filter(v)) {
|
||
|
copy.setNode(v, value);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
lodash_1.each(this._edgeObjs, function(e) {
|
||
|
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
|
||
|
copy.setEdge(e, self.edge(e));
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var parents = {};
|
||
|
function findParent(v) {
|
||
|
var parent = self.parent(v);
|
||
|
if (parent === undefined || copy.hasNode(parent)) {
|
||
|
parents[v] = parent;
|
||
|
return parent;
|
||
|
} else if (parent in parents) {
|
||
|
return parents[parent];
|
||
|
} else {
|
||
|
return findParent(parent);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (this._isCompound) {
|
||
|
lodash_1.each(copy.nodes(), function(v) {
|
||
|
copy.setParent(v, findParent(v));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return copy;
|
||
|
};
|
||
|
|
||
|
/* === Edge functions ========== */
|
||
|
|
||
|
Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
|
||
|
if (!lodash_1.isFunction(newDefault)) {
|
||
|
newDefault = lodash_1.constant(newDefault);
|
||
|
}
|
||
|
this._defaultEdgeLabelFn = newDefault;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.edgeCount = function() {
|
||
|
return this._edgeCount;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.edges = function() {
|
||
|
return lodash_1.values(this._edgeObjs);
|
||
|
};
|
||
|
|
||
|
Graph.prototype.setPath = function(vs, value) {
|
||
|
var self = this;
|
||
|
var args = arguments;
|
||
|
lodash_1.reduce(vs, function(v, w) {
|
||
|
if (args.length > 1) {
|
||
|
self.setEdge(v, w, value);
|
||
|
} else {
|
||
|
self.setEdge(v, w);
|
||
|
}
|
||
|
return w;
|
||
|
});
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
* setEdge(v, w, [value, [name]])
|
||
|
* setEdge({ v, w, [name] }, [value])
|
||
|
*/
|
||
|
Graph.prototype.setEdge = function() {
|
||
|
var v, w, name, value;
|
||
|
var valueSpecified = false;
|
||
|
var arg0 = arguments[0];
|
||
|
|
||
|
if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
|
||
|
v = arg0.v;
|
||
|
w = arg0.w;
|
||
|
name = arg0.name;
|
||
|
if (arguments.length === 2) {
|
||
|
value = arguments[1];
|
||
|
valueSpecified = true;
|
||
|
}
|
||
|
} else {
|
||
|
v = arg0;
|
||
|
w = arguments[1];
|
||
|
name = arguments[3];
|
||
|
if (arguments.length > 2) {
|
||
|
value = arguments[2];
|
||
|
valueSpecified = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
v = "" + v;
|
||
|
w = "" + w;
|
||
|
if (!lodash_1.isUndefined(name)) {
|
||
|
name = "" + name;
|
||
|
}
|
||
|
|
||
|
var e = edgeArgsToId(this._isDirected, v, w, name);
|
||
|
if (lodash_1.has(this._edgeLabels, e)) {
|
||
|
if (valueSpecified) {
|
||
|
this._edgeLabels[e] = value;
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
if (!lodash_1.isUndefined(name) && !this._isMultigraph) {
|
||
|
throw new Error("Cannot set a named edge when isMultigraph = false");
|
||
|
}
|
||
|
|
||
|
// It didn't exist, so we need to create it.
|
||
|
// First ensure the nodes exist.
|
||
|
this.setNode(v);
|
||
|
this.setNode(w);
|
||
|
|
||
|
this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
|
||
|
|
||
|
var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
|
||
|
// Ensure we add undirected edges in a consistent way.
|
||
|
v = edgeObj.v;
|
||
|
w = edgeObj.w;
|
||
|
|
||
|
Object.freeze(edgeObj);
|
||
|
this._edgeObjs[e] = edgeObj;
|
||
|
incrementOrInitEntry(this._preds[w], v);
|
||
|
incrementOrInitEntry(this._sucs[v], w);
|
||
|
this._in[w][e] = edgeObj;
|
||
|
this._out[v][e] = edgeObj;
|
||
|
this._edgeCount++;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.edge = function(v, w, name) {
|
||
|
var e = (arguments.length === 1
|
||
|
? edgeObjToId(this._isDirected, arguments[0])
|
||
|
: edgeArgsToId(this._isDirected, v, w, name));
|
||
|
return this._edgeLabels[e];
|
||
|
};
|
||
|
|
||
|
Graph.prototype.hasEdge = function(v, w, name) {
|
||
|
var e = (arguments.length === 1
|
||
|
? edgeObjToId(this._isDirected, arguments[0])
|
||
|
: edgeArgsToId(this._isDirected, v, w, name));
|
||
|
return lodash_1.has(this._edgeLabels, e);
|
||
|
};
|
||
|
|
||
|
Graph.prototype.removeEdge = function(v, w, name) {
|
||
|
var e = (arguments.length === 1
|
||
|
? edgeObjToId(this._isDirected, arguments[0])
|
||
|
: edgeArgsToId(this._isDirected, v, w, name));
|
||
|
var edge = this._edgeObjs[e];
|
||
|
if (edge) {
|
||
|
v = edge.v;
|
||
|
w = edge.w;
|
||
|
delete this._edgeLabels[e];
|
||
|
delete this._edgeObjs[e];
|
||
|
decrementOrRemoveEntry(this._preds[w], v);
|
||
|
decrementOrRemoveEntry(this._sucs[v], w);
|
||
|
delete this._in[w][e];
|
||
|
delete this._out[v][e];
|
||
|
this._edgeCount--;
|
||
|
}
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
Graph.prototype.inEdges = function(v, u) {
|
||
|
var inV = this._in[v];
|
||
|
if (inV) {
|
||
|
var edges = lodash_1.values(inV);
|
||
|
if (!u) {
|
||
|
return edges;
|
||
|
}
|
||
|
return lodash_1.filter(edges, function(edge) { return edge.v === u; });
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.outEdges = function(v, w) {
|
||
|
var outV = this._out[v];
|
||
|
if (outV) {
|
||
|
var edges = lodash_1.values(outV);
|
||
|
if (!w) {
|
||
|
return edges;
|
||
|
}
|
||
|
return lodash_1.filter(edges, function(edge) { return edge.w === w; });
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Graph.prototype.nodeEdges = function(v, w) {
|
||
|
var inEdges = this.inEdges(v, w);
|
||
|
if (inEdges) {
|
||
|
return inEdges.concat(this.outEdges(v, w));
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function incrementOrInitEntry(map, k) {
|
||
|
if (map[k]) {
|
||
|
map[k]++;
|
||
|
} else {
|
||
|
map[k] = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function decrementOrRemoveEntry(map, k) {
|
||
|
if (!--map[k]) { delete map[k]; }
|
||
|
}
|
||
|
|
||
|
function edgeArgsToId(isDirected, v_, w_, name) {
|
||
|
var v = "" + v_;
|
||
|
var w = "" + w_;
|
||
|
if (!isDirected && v > w) {
|
||
|
var tmp = v;
|
||
|
v = w;
|
||
|
w = tmp;
|
||
|
}
|
||
|
return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +
|
||
|
(lodash_1.isUndefined(name) ? DEFAULT_EDGE_NAME : name);
|
||
|
}
|
||
|
|
||
|
function edgeArgsToObj(isDirected, v_, w_, name) {
|
||
|
var v = "" + v_;
|
||
|
var w = "" + w_;
|
||
|
if (!isDirected && v > w) {
|
||
|
var tmp = v;
|
||
|
v = w;
|
||
|
w = tmp;
|
||
|
}
|
||
|
var edgeObj = { v: v, w: w };
|
||
|
if (name) {
|
||
|
edgeObj.name = name;
|
||
|
}
|
||
|
return edgeObj;
|
||
|
}
|
||
|
|
||
|
function edgeObjToId(isDirected, edgeObj) {
|
||
|
return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
|
||
|
}
|
||
|
|
||
|
var version = '2.1.8';
|
||
|
|
||
|
// Includes only the "core" of graphlib
|
||
|
var lib = {
|
||
|
Graph: graph,
|
||
|
version: version
|
||
|
};
|
||
|
|
||
|
var json = {
|
||
|
write: write,
|
||
|
read: read
|
||
|
};
|
||
|
|
||
|
function write(g) {
|
||
|
var json = {
|
||
|
options: {
|
||
|
directed: g.isDirected(),
|
||
|
multigraph: g.isMultigraph(),
|
||
|
compound: g.isCompound()
|
||
|
},
|
||
|
nodes: writeNodes(g),
|
||
|
edges: writeEdges(g)
|
||
|
};
|
||
|
if (!lodash_1.isUndefined(g.graph())) {
|
||
|
json.value = lodash_1.clone(g.graph());
|
||
|
}
|
||
|
return json;
|
||
|
}
|
||
|
|
||
|
function writeNodes(g) {
|
||
|
return lodash_1.map(g.nodes(), function(v) {
|
||
|
var nodeValue = g.node(v);
|
||
|
var parent = g.parent(v);
|
||
|
var node = { v: v };
|
||
|
if (!lodash_1.isUndefined(nodeValue)) {
|
||
|
node.value = nodeValue;
|
||
|
}
|
||
|
if (!lodash_1.isUndefined(parent)) {
|
||
|
node.parent = parent;
|
||
|
}
|
||
|
return node;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function writeEdges(g) {
|
||
|
return lodash_1.map(g.edges(), function(e) {
|
||
|
var edgeValue = g.edge(e);
|
||
|
var edge = { v: e.v, w: e.w };
|
||
|
if (!lodash_1.isUndefined(e.name)) {
|
||
|
edge.name = e.name;
|
||
|
}
|
||
|
if (!lodash_1.isUndefined(edgeValue)) {
|
||
|
edge.value = edgeValue;
|
||
|
}
|
||
|
return edge;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function read(json) {
|
||
|
var g = new graph(json.options).setGraph(json.value);
|
||
|
lodash_1.each(json.nodes, function(entry) {
|
||
|
g.setNode(entry.v, entry.value);
|
||
|
if (entry.parent) {
|
||
|
g.setParent(entry.v, entry.parent);
|
||
|
}
|
||
|
});
|
||
|
lodash_1.each(json.edges, function(entry) {
|
||
|
g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value);
|
||
|
});
|
||
|
return g;
|
||
|
}
|
||
|
|
||
|
var components_1 = components;
|
||
|
|
||
|
function components(g) {
|
||
|
var visited = {};
|
||
|
var cmpts = [];
|
||
|
var cmpt;
|
||
|
|
||
|
function dfs(v) {
|
||
|
if (lodash_1.has(visited, v)) return;
|
||
|
visited[v] = true;
|
||
|
cmpt.push(v);
|
||
|
lodash_1.each(g.successors(v), dfs);
|
||
|
lodash_1.each(g.predecessors(v), dfs);
|
||
|
}
|
||
|
|
||
|
lodash_1.each(g.nodes(), function(v) {
|
||
|
cmpt = [];
|
||
|
dfs(v);
|
||
|
if (cmpt.length) {
|
||
|
cmpts.push(cmpt);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return cmpts;
|
||
|
}
|
||
|
|
||
|
var priorityQueue = PriorityQueue;
|
||
|
|
||
|
/**
|
||
|
* A min-priority queue data structure. This algorithm is derived from Cormen,
|
||
|
* et al., "Introduction to Algorithms". The basic idea of a min-priority
|
||
|
* queue is that you can efficiently (in O(1) time) get the smallest key in
|
||
|
* the queue. Adding and removing elements takes O(log n) time. A key can
|
||
|
* have its priority decreased in O(log n) time.
|
||
|
*/
|
||
|
function PriorityQueue() {
|
||
|
this._arr = [];
|
||
|
this._keyIndices = {};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the number of elements in the queue. Takes `O(1)` time.
|
||
|
*/
|
||
|
PriorityQueue.prototype.size = function() {
|
||
|
return this._arr.length;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Returns the keys that are in the queue. Takes `O(n)` time.
|
||
|
*/
|
||
|
PriorityQueue.prototype.keys = function() {
|
||
|
return this._arr.map(function(x) { return x.key; });
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Returns `true` if **key** is in the queue and `false` if not.
|
||
|
*/
|
||
|
PriorityQueue.prototype.has = function(key) {
|
||
|
return lodash_1.has(this._keyIndices, key);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Returns the priority for **key**. If **key** is not present in the queue
|
||
|
* then this function returns `undefined`. Takes `O(1)` time.
|
||
|
*
|
||
|
* @param {Object} key
|
||
|
*/
|
||
|
PriorityQueue.prototype.priority = function(key) {
|
||
|
var index = this._keyIndices[key];
|
||
|
if (index !== undefined) {
|
||
|
return this._arr[index].priority;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Returns the key for the minimum element in this queue. If the queue is
|
||
|
* empty this function throws an Error. Takes `O(1)` time.
|
||
|
*/
|
||
|
PriorityQueue.prototype.min = function() {
|
||
|
if (this.size() === 0) {
|
||
|
throw new Error("Queue underflow");
|
||
|
}
|
||
|
return this._arr[0].key;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Inserts a new key into the priority queue. If the key already exists in
|
||
|
* the queue this function returns `false`; otherwise it will return `true`.
|
||
|
* Takes `O(n)` time.
|
||
|
*
|
||
|
* @param {Object} key the key to add
|
||
|
* @param {Number} priority the initial priority for the key
|
||
|
*/
|
||
|
PriorityQueue.prototype.add = function(key, priority) {
|
||
|
var keyIndices = this._keyIndices;
|
||
|
key = String(key);
|
||
|
if (!lodash_1.has(keyIndices, key)) {
|
||
|
var arr = this._arr;
|
||
|
var index = arr.length;
|
||
|
keyIndices[key] = index;
|
||
|
arr.push({key: key, priority: priority});
|
||
|
this._decrease(index);
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Removes and returns the smallest key in the queue. Takes `O(log n)` time.
|
||
|
*/
|
||
|
PriorityQueue.prototype.removeMin = function() {
|
||
|
this._swap(0, this._arr.length - 1);
|
||
|
var min = this._arr.pop();
|
||
|
delete this._keyIndices[min.key];
|
||
|
this._heapify(0);
|
||
|
return min.key;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Decreases the priority for **key** to **priority**. If the new priority is
|
||
|
* greater than the previous priority, this function will throw an Error.
|
||
|
*
|
||
|
* @param {Object} key the key for which to raise priority
|
||
|
* @param {Number} priority the new priority for the key
|
||
|
*/
|
||
|
PriorityQueue.prototype.decrease = function(key, priority) {
|
||
|
var index = this._keyIndices[key];
|
||
|
if (priority > this._arr[index].priority) {
|
||
|
throw new Error("New priority is greater than current priority. " +
|
||
|
"Key: " + key + " Old: " + this._arr[index].priority + " New: " + priority);
|
||
|
}
|
||
|
this._arr[index].priority = priority;
|
||
|
this._decrease(index);
|
||
|
};
|
||
|
|
||
|
PriorityQueue.prototype._heapify = function(i) {
|
||
|
var arr = this._arr;
|
||
|
var l = 2 * i;
|
||
|
var r = l + 1;
|
||
|
var largest = i;
|
||
|
if (l < arr.length) {
|
||
|
largest = arr[l].priority < arr[largest].priority ? l : largest;
|
||
|
if (r < arr.length) {
|
||
|
largest = arr[r].priority < arr[largest].priority ? r : largest;
|
||
|
}
|
||
|
if (largest !== i) {
|
||
|
this._swap(i, largest);
|
||
|
this._heapify(largest);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
PriorityQueue.prototype._decrease = function(index) {
|
||
|
var arr = this._arr;
|
||
|
var priority = arr[index].priority;
|
||
|
var parent;
|
||
|
while (index !== 0) {
|
||
|
parent = index >> 1;
|
||
|
if (arr[parent].priority < priority) {
|
||
|
break;
|
||
|
}
|
||
|
this._swap(index, parent);
|
||
|
index = parent;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
PriorityQueue.prototype._swap = function(i, j) {
|
||
|
var arr = this._arr;
|
||
|
var keyIndices = this._keyIndices;
|
||
|
var origArrI = arr[i];
|
||
|
var origArrJ = arr[j];
|
||
|
arr[i] = origArrJ;
|
||
|
arr[j] = origArrI;
|
||
|
keyIndices[origArrJ.key] = i;
|
||
|
keyIndices[origArrI.key] = j;
|
||
|
};
|
||
|
|
||
|
var dijkstra_1 = dijkstra;
|
||
|
|
||
|
var DEFAULT_WEIGHT_FUNC = lodash_1.constant(1);
|
||
|
|
||
|
function dijkstra(g, source, weightFn, edgeFn) {
|
||
|
return runDijkstra(g, String(source),
|
||
|
weightFn || DEFAULT_WEIGHT_FUNC,
|
||
|
edgeFn || function(v) { return g.outEdges(v); });
|
||
|
}
|
||
|
|
||
|
function runDijkstra(g, source, weightFn, edgeFn) {
|
||
|
var results = {};
|
||
|
var pq = new priorityQueue();
|
||
|
var v, vEntry;
|
||
|
|
||
|
var updateNeighbors = function(edge) {
|
||
|
var w = edge.v !== v ? edge.v : edge.w;
|
||
|
var wEntry = results[w];
|
||
|
var weight = weightFn(edge);
|
||
|
var distance = vEntry.distance + weight;
|
||
|
|
||
|
if (weight < 0) {
|
||
|
throw new Error("dijkstra does not allow negative edge weights. " +
|
||
|
"Bad edge: " + edge + " Weight: " + weight);
|
||
|
}
|
||
|
|
||
|
if (distance < wEntry.distance) {
|
||
|
wEntry.distance = distance;
|
||
|
wEntry.predecessor = v;
|
||
|
pq.decrease(w, distance);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
g.nodes().forEach(function(v) {
|
||
|
var distance = v === source ? 0 : Number.POSITIVE_INFINITY;
|
||
|
results[v] = { distance: distance };
|
||
|
pq.add(v, distance);
|
||
|
});
|
||
|
|
||
|
while (pq.size() > 0) {
|
||
|
v = pq.removeMin();
|
||
|
vEntry = results[v];
|
||
|
if (vEntry.distance === Number.POSITIVE_INFINITY) {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
edgeFn(v).forEach(updateNeighbors);
|
||
|
}
|
||
|
|
||
|
return results;
|
||
|
}
|
||
|
|
||
|
var dijkstraAll_1 = dijkstraAll;
|
||
|
|
||
|
function dijkstraAll(g, weightFunc, edgeFunc) {
|
||
|
return lodash_1.transform(g.nodes(), function(acc, v) {
|
||
|
acc[v] = dijkstra_1(g, v, weightFunc, edgeFunc);
|
||
|
}, {});
|
||
|
}
|
||
|
|
||
|
var tarjan_1 = tarjan;
|
||
|
|
||
|
function tarjan(g) {
|
||
|
var index = 0;
|
||
|
var stack = [];
|
||
|
var visited = {}; // node id -> { onStack, lowlink, index }
|
||
|
var results = [];
|
||
|
|
||
|
function dfs(v) {
|
||
|
var entry = visited[v] = {
|
||
|
onStack: true,
|
||
|
lowlink: index,
|
||
|
index: index++
|
||
|
};
|
||
|
stack.push(v);
|
||
|
|
||
|
g.successors(v).forEach(function(w) {
|
||
|
if (!lodash_1.has(visited, w)) {
|
||
|
dfs(w);
|
||
|
entry.lowlink = Math.min(entry.lowlink, visited[w].lowlink);
|
||
|
} else if (visited[w].onStack) {
|
||
|
entry.lowlink = Math.min(entry.lowlink, visited[w].index);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (entry.lowlink === entry.index) {
|
||
|
var cmpt = [];
|
||
|
var w;
|
||
|
do {
|
||
|
w = stack.pop();
|
||
|
visited[w].onStack = false;
|
||
|
cmpt.push(w);
|
||
|
} while (v !== w);
|
||
|
results.push(cmpt);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
g.nodes().forEach(function(v) {
|
||
|
if (!lodash_1.has(visited, v)) {
|
||
|
dfs(v);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return results;
|
||
|
}
|
||
|
|
||
|
var findCycles_1 = findCycles;
|
||
|
|
||
|
function findCycles(g) {
|
||
|
return lodash_1.filter(tarjan_1(g), function(cmpt) {
|
||
|
return cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0]));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
var floydWarshall_1 = floydWarshall;
|
||
|
|
||
|
var DEFAULT_WEIGHT_FUNC$1 = lodash_1.constant(1);
|
||
|
|
||
|
function floydWarshall(g, weightFn, edgeFn) {
|
||
|
return runFloydWarshall(g,
|
||
|
weightFn || DEFAULT_WEIGHT_FUNC$1,
|
||
|
edgeFn || function(v) { return g.outEdges(v); });
|
||
|
}
|
||
|
|
||
|
function runFloydWarshall(g, weightFn, edgeFn) {
|
||
|
var results = {};
|
||
|
var nodes = g.nodes();
|
||
|
|
||
|
nodes.forEach(function(v) {
|
||
|
results[v] = {};
|
||
|
results[v][v] = { distance: 0 };
|
||
|
nodes.forEach(function(w) {
|
||
|
if (v !== w) {
|
||
|
results[v][w] = { distance: Number.POSITIVE_INFINITY };
|
||
|
}
|
||
|
});
|
||
|
edgeFn(v).forEach(function(edge) {
|
||
|
var w = edge.v === v ? edge.w : edge.v;
|
||
|
var d = weightFn(edge);
|
||
|
results[v][w] = { distance: d, predecessor: v };
|
||
|
});
|
||
|
});
|
||
|
|
||
|
nodes.forEach(function(k) {
|
||
|
var rowK = results[k];
|
||
|
nodes.forEach(function(i) {
|
||
|
var rowI = results[i];
|
||
|
nodes.forEach(function(j) {
|
||
|
var ik = rowI[k];
|
||
|
var kj = rowK[j];
|
||
|
var ij = rowI[j];
|
||
|
var altDistance = ik.distance + kj.distance;
|
||
|
if (altDistance < ij.distance) {
|
||
|
ij.distance = altDistance;
|
||
|
ij.predecessor = kj.predecessor;
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
return results;
|
||
|
}
|
||
|
|
||
|
var topsort_1 = topsort;
|
||
|
topsort.CycleException = CycleException;
|
||
|
|
||
|
function topsort(g) {
|
||
|
var visited = {};
|
||
|
var stack = {};
|
||
|
var results = [];
|
||
|
|
||
|
function visit(node) {
|
||
|
if (lodash_1.has(stack, node)) {
|
||
|
throw new CycleException();
|
||
|
}
|
||
|
|
||
|
if (!lodash_1.has(visited, node)) {
|
||
|
stack[node] = true;
|
||
|
visited[node] = true;
|
||
|
lodash_1.each(g.predecessors(node), visit);
|
||
|
delete stack[node];
|
||
|
results.push(node);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
lodash_1.each(g.sinks(), visit);
|
||
|
|
||
|
if (lodash_1.size(visited) !== g.nodeCount()) {
|
||
|
throw new CycleException();
|
||
|
}
|
||
|
|
||
|
return results;
|
||
|
}
|
||
|
|
||
|
function CycleException() {}
|
||
|
CycleException.prototype = new Error(); // must be an instance of Error to pass testing
|
||
|
|
||
|
var isAcyclic_1 = isAcyclic;
|
||
|
|
||
|
function isAcyclic(g) {
|
||
|
try {
|
||
|
topsort_1(g);
|
||
|
} catch (e) {
|
||
|
if (e instanceof topsort_1.CycleException) {
|
||
|
return false;
|
||
|
}
|
||
|
throw e;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
var dfs_1 = dfs;
|
||
|
|
||
|
/*
|
||
|
* A helper that preforms a pre- or post-order traversal on the input graph
|
||
|
* and returns the nodes in the order they were visited. If the graph is
|
||
|
* undirected then this algorithm will navigate using neighbors. If the graph
|
||
|
* is directed then this algorithm will navigate using successors.
|
||
|
*
|
||
|
* Order must be one of "pre" or "post".
|
||
|
*/
|
||
|
function dfs(g, vs, order) {
|
||
|
if (!lodash_1.isArray(vs)) {
|
||
|
vs = [vs];
|
||
|
}
|
||
|
|
||
|
var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);
|
||
|
|
||
|
var acc = [];
|
||
|
var visited = {};
|
||
|
lodash_1.each(vs, function(v) {
|
||
|
if (!g.hasNode(v)) {
|
||
|
throw new Error("Graph does not have node: " + v);
|
||
|
}
|
||
|
|
||
|
doDfs(g, v, order === "post", visited, navigation, acc);
|
||
|
});
|
||
|
return acc;
|
||
|
}
|
||
|
|
||
|
function doDfs(g, v, postorder, visited, navigation, acc) {
|
||
|
if (!lodash_1.has(visited, v)) {
|
||
|
visited[v] = true;
|
||
|
|
||
|
if (!postorder) { acc.push(v); }
|
||
|
lodash_1.each(navigation(v), function(w) {
|
||
|
doDfs(g, w, postorder, visited, navigation, acc);
|
||
|
});
|
||
|
if (postorder) { acc.push(v); }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var postorder_1 = postorder;
|
||
|
|
||
|
function postorder(g, vs) {
|
||
|
return dfs_1(g, vs, "post");
|
||
|
}
|
||
|
|
||
|
var preorder_1 = preorder;
|
||
|
|
||
|
function preorder(g, vs) {
|
||
|
return dfs_1(g, vs, "pre");
|
||
|
}
|
||
|
|
||
|
var prim_1 = prim;
|
||
|
|
||
|
function prim(g, weightFunc) {
|
||
|
var result = new graph();
|
||
|
var parents = {};
|
||
|
var pq = new priorityQueue();
|
||
|
var v;
|
||
|
|
||
|
function updateNeighbors(edge) {
|
||
|
var w = edge.v === v ? edge.w : edge.v;
|
||
|
var pri = pq.priority(w);
|
||
|
if (pri !== undefined) {
|
||
|
var edgeWeight = weightFunc(edge);
|
||
|
if (edgeWeight < pri) {
|
||
|
parents[w] = v;
|
||
|
pq.decrease(w, edgeWeight);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (g.nodeCount() === 0) {
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
lodash_1.each(g.nodes(), function(v) {
|
||
|
pq.add(v, Number.POSITIVE_INFINITY);
|
||
|
result.setNode(v);
|
||
|
});
|
||
|
|
||
|
// Start from an arbitrary node
|
||
|
pq.decrease(g.nodes()[0], 0);
|
||
|
|
||
|
var init = false;
|
||
|
while (pq.size() > 0) {
|
||
|
v = pq.removeMin();
|
||
|
if (lodash_1.has(parents, v)) {
|
||
|
result.setEdge(v, parents[v]);
|
||
|
} else if (init) {
|
||
|
throw new Error("Input graph is not connected: " + g);
|
||
|
} else {
|
||
|
init = true;
|
||
|
}
|
||
|
|
||
|
g.nodeEdges(v).forEach(updateNeighbors);
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
var alg = {
|
||
|
components: components_1,
|
||
|
dijkstra: dijkstra_1,
|
||
|
dijkstraAll: dijkstraAll_1,
|
||
|
findCycles: findCycles_1,
|
||
|
floydWarshall: floydWarshall_1,
|
||
|
isAcyclic: isAcyclic_1,
|
||
|
postorder: postorder_1,
|
||
|
preorder: preorder_1,
|
||
|
prim: prim_1,
|
||
|
tarjan: tarjan_1,
|
||
|
topsort: topsort_1
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Copyright (c) 2014, Chris Pettitt
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* Redistribution and use in source and binary forms, with or without
|
||
|
* modification, are permitted provided that the following conditions are met:
|
||
|
*
|
||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||
|
* list of conditions and the following disclaimer.
|
||
|
*
|
||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||
|
* this list of conditions and the following disclaimer in the documentation
|
||
|
* and/or other materials provided with the distribution.
|
||
|
*
|
||
|
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||
|
* may be used to endorse or promote products derived from this software without
|
||
|
* specific prior written permission.
|
||
|
*
|
||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
var graphlib = {
|
||
|
Graph: lib.Graph,
|
||
|
json: json,
|
||
|
alg: alg,
|
||
|
version: lib.version
|
||
|
};
|
||
|
|
||
|
obsidian.addIcon('journey', '<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">\n' +
|
||
|
'<g clip-path="url(#clip0)">\n' +
|
||
|
'<path d="M50 92.75C44.0004 87.6326 38.4394 82.0223 33.375 75.9778C25.775 66.9005 16.75 53.382 16.75 40.5C16.7433 27.0459 24.8452 14.9137 37.2751 9.76469C49.705 4.61573 64.0128 7.46495 73.522 16.9828C79.7752 23.2082 83.2781 31.6764 83.2502 40.5C83.2502 53.382 74.225 66.9005 66.625 75.9778C61.5606 82.0223 55.9996 87.6326 50 92.75ZM50 16.7501C36.8898 16.7658 26.2657 27.3898 26.25 40.5C26.25 46.0385 28.7533 55.6288 40.6663 69.8835C43.6024 73.3893 46.7178 76.7409 50 79.925C53.2825 76.7447 56.3994 73.3979 59.3385 69.8978C71.2468 55.624 73.75 46.0338 73.75 40.5C73.7343 27.3898 63.1103 16.7658 50 16.7501ZM50 54.75C42.13 54.75 35.75 48.3701 35.75 40.5C35.75 32.63 42.13 26.2501 50 26.2501C57.8701 26.2501 64.25 32.63 64.25 40.5C64.25 44.2794 62.7487 47.9039 60.0763 50.5763C57.4039 53.2487 53.7794 54.75 50 54.75Z" fill="#777777"/>\n' +
|
||
|
'</g>\n' +
|
||
|
'<defs>\n' +
|
||
|
'<clipPath id="clip0">\n' +
|
||
|
'<rect width="100" height="100" fill="white"/>\n' +
|
||
|
'</clipPath>\n' +
|
||
|
'</defs>\n' +
|
||
|
'</svg>');
|
||
|
var JourneyPlugin = /** @class */ (function (_super) {
|
||
|
__extends(JourneyPlugin, _super);
|
||
|
function JourneyPlugin() {
|
||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||
|
}
|
||
|
JourneyPlugin.prototype.onload = function () {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var _this = this;
|
||
|
return __generator(this, function (_a) {
|
||
|
this.loadSettings();
|
||
|
this.addSettingTab(new JourneyPluginSettingsTab(this.app, this));
|
||
|
this.addRibbonIcon('journey', 'Find Journey', function () {
|
||
|
_this.startSearch();
|
||
|
});
|
||
|
return [2 /*return*/];
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
JourneyPlugin.prototype.findShortestPath = function (start, end) {
|
||
|
return __awaiter(this, void 0, void 0, function () {
|
||
|
var startBasename, endBasename, resolvedLinks, g, _a, _b, _i, key, filePath, nodeBasename, clean, i, valueMap, outboundLinkCounter, linkKey, linkKey, target, targetClean, clean, i, text, result, ts, i, tag, searchResult, finalList, step;
|
||
|
return __generator(this, function (_c) {
|
||
|
switch (_c.label) {
|
||
|
case 0:
|
||
|
startBasename = start;
|
||
|
endBasename = end;
|
||
|
resolvedLinks = this.app.metadataCache.resolvedLinks;
|
||
|
g = new graphlib.Graph({});
|
||
|
_a = [];
|
||
|
for (_b in resolvedLinks)
|
||
|
_a.push(_b);
|
||
|
_i = 0;
|
||
|
_c.label = 1;
|
||
|
case 1:
|
||
|
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
||
|
key = _a[_i];
|
||
|
filePath = key;
|
||
|
nodeBasename = filePath // filePath.replace(".md", "");
|
||
|
;
|
||
|
// skipping/excluding node creation based on folders
|
||
|
if (this.settings.skipFoldersList().length > 0) {
|
||
|
clean = true;
|
||
|
for (i = 0; i <= this.settings.skipFoldersList().length; i++) {
|
||
|
if (nodeBasename.contains(this.settings.skipFoldersList()[i])) {
|
||
|
// console.log("Skipping adding " + nodeBasename + " as node");
|
||
|
clean = false;
|
||
|
}
|
||
|
}
|
||
|
// skip this loop
|
||
|
if (!clean) {
|
||
|
return [3 /*break*/, 3];
|
||
|
}
|
||
|
}
|
||
|
g.setNode(nodeBasename);
|
||
|
valueMap = resolvedLinks[key];
|
||
|
outboundLinkCounter = 0;
|
||
|
if (this.settings.skipMOCs) {
|
||
|
for (linkKey in valueMap) {
|
||
|
outboundLinkCounter++;
|
||
|
}
|
||
|
}
|
||
|
if (!this.settings.skipMOCs || !(outboundLinkCounter > this.settings.MOCMaxLinks)) {
|
||
|
// look at each link
|
||
|
for (linkKey in valueMap) {
|
||
|
target = linkKey;
|
||
|
targetClean = target;
|
||
|
// exclude/skip folders forward/backward link
|
||
|
if (this.settings.skipFoldersList().length > 0) {
|
||
|
clean = true;
|
||
|
for (i = 0; i <= this.settings.skipFoldersList().length; i++) {
|
||
|
if (targetClean.contains(this.settings.skipFoldersList()[i])) {
|
||
|
clean = false;
|
||
|
}
|
||
|
}
|
||
|
if (!clean) {
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
if (this.settings.useForwardLinks) {
|
||
|
// console.log(" Adding FORWARDLINK edge " + nodeBasename + " -> " + target);
|
||
|
g.setEdge(nodeBasename, targetClean);
|
||
|
}
|
||
|
// allow backlinks
|
||
|
if (this.settings.useBackLinks) {
|
||
|
// console.log(" Adding BACKLINK edge " + target + " -> " + nodeBasename);
|
||
|
g.setEdge(targetClean, nodeBasename);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (!this.settings.useTags) return [3 /*break*/, 3];
|
||
|
return [4 /*yield*/, this.app.vault.adapter.read(filePath)];
|
||
|
case 2:
|
||
|
text = _c.sent();
|
||
|
result = text.matchAll(/\#[\w|äÄöÖüÜß\/\-\_]+/gmi);
|
||
|
ts = Array.from(result);
|
||
|
for (i = 0; i < ts.length; i++) {
|
||
|
tag = String(ts[i]);
|
||
|
// @ts-ignore
|
||
|
tag = tag.trim();
|
||
|
if (!g.hasNode(tag)) {
|
||
|
// console.log("Adding Tag node" + tag)
|
||
|
g.setNode(tag);
|
||
|
}
|
||
|
if (!g.hasEdge(nodeBasename, tag)) {
|
||
|
// console.log("Adding edge " + nodeBasename + " -> " + tag);
|
||
|
g.setEdge(nodeBasename, tag);
|
||
|
}
|
||
|
if (!g.hasEdge(tag, nodeBasename)) {
|
||
|
// console.log("Adding edge " + tag + " -> " + nodeBasename);
|
||
|
g.setEdge(tag, nodeBasename);
|
||
|
}
|
||
|
}
|
||
|
_c.label = 3;
|
||
|
case 3:
|
||
|
_i++;
|
||
|
return [3 /*break*/, 1];
|
||
|
case 4:
|
||
|
searchResult = graphlib.alg.dijkstra(g, startBasename);
|
||
|
finalList = new Array();
|
||
|
// console.log(searchResult);
|
||
|
if (searchResult[endBasename] !== undefined && searchResult[endBasename].distance !== Infinity) {
|
||
|
step = searchResult[endBasename];
|
||
|
finalList.push(endBasename);
|
||
|
while (step.distance != 0) {
|
||
|
finalList.push(step.predecessor);
|
||
|
step = searchResult[step.predecessor];
|
||
|
}
|
||
|
}
|
||
|
this.searchModal.close();
|
||
|
this.searchModal = new SearchModal(this.app, this);
|
||
|
this.resultsModal = new ResultsModal(this.app, this);
|
||
|
this.resultsModal.results = finalList;
|
||
|
this.resultsModal.startBasename = startBasename;
|
||
|
this.resultsModal.endBasename = endBasename;
|
||
|
this.resultsModal.open();
|
||
|
return [2 /*return*/];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
JourneyPlugin.prototype.startSearch = function () {
|
||
|
this.searchModal = new SearchModal(this.app, this);
|
||
|
this.searchModal.open();
|
||
|
};
|
||
|
JourneyPlugin.prototype.loadSettings = function () {
|
||
|
var _this = this;
|
||
|
this.settings = new JourneyPluginSettings();
|
||
|
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||
|
var loadedSettings;
|
||
|
return __generator(this, function (_a) {
|
||
|
switch (_a.label) {
|
||
|
case 0: return [4 /*yield*/, this.loadData()];
|
||
|
case 1:
|
||
|
loadedSettings = _a.sent();
|
||
|
if (loadedSettings) {
|
||
|
this.settings.useForwardLinks = loadedSettings.useForwardLinks;
|
||
|
this.settings.useBackLinks = loadedSettings.useBackLinks;
|
||
|
this.settings.useTags = loadedSettings.useTags;
|
||
|
this.settings.skipMOCs = loadedSettings.skipMOCs;
|
||
|
this.settings.MOCMaxLinks = loadedSettings.MOCMaxLinks;
|
||
|
this.settings.enableHighContrast = loadedSettings.enableHighContrast;
|
||
|
this.settings.skipFolders = loadedSettings.skipFolders;
|
||
|
this.settings.enableLinks = loadedSettings.enableLinks;
|
||
|
this.settings.enableTransclusion = loadedSettings.enableTransclusion;
|
||
|
}
|
||
|
else {
|
||
|
this.saveData(this.settings);
|
||
|
}
|
||
|
return [2 /*return*/];
|
||
|
}
|
||
|
});
|
||
|
}); })();
|
||
|
};
|
||
|
return JourneyPlugin;
|
||
|
}(obsidian.Plugin));
|
||
|
var SearchModal = /** @class */ (function (_super) {
|
||
|
__extends(SearchModal, _super);
|
||
|
function SearchModal(app, plugin) {
|
||
|
var _this = _super.call(this, app) || this;
|
||
|
_this.plugin = plugin;
|
||
|
return _this;
|
||
|
}
|
||
|
SearchModal.prototype.onOpen = function () {
|
||
|
var contentEl = this.contentEl;
|
||
|
contentEl.createEl("h2", { text: "Find the Story Between Two Notes" });
|
||
|
this.formDiv = contentEl.createDiv({ cls: 'journey-search-form' });
|
||
|
this.setupFileList();
|
||
|
this.addStartSearchComponent();
|
||
|
this.addEndSearchComponent();
|
||
|
this.addSearchButton(contentEl);
|
||
|
this.addLuckyButton();
|
||
|
this.addSearchSettingsDisplay();
|
||
|
};
|
||
|
SearchModal.prototype.findRandomNoteBasename = function () {
|
||
|
// console.log(this.filePathList);
|
||
|
var rand = Math.floor(Math.random() * this.filePathList.length) + 1;
|
||
|
return this.filePathList[rand];
|
||
|
};
|
||
|
SearchModal.prototype.setupFileList = function () {
|
||
|
var resolvedLinks = this.app.metadataCache.resolvedLinks;
|
||
|
this.filePathList = [];
|
||
|
// console.log(this.plugin.settings.skipFoldersList());
|
||
|
for (var key in resolvedLinks) {
|
||
|
var filePath = key;
|
||
|
// exclude folders if set
|
||
|
if (this.plugin.settings.skipFoldersList().length > 0) {
|
||
|
var clean = true;
|
||
|
for (var i = 0; i < this.plugin.settings.skipFoldersList().length; i++) {
|
||
|
if (filePath.contains(this.plugin.settings.skipFoldersList()[i])) {
|
||
|
clean = false;
|
||
|
// console.log("Skipping adding " + filePath + " as search option because " + this.plugin.settings.skipFoldersList()[i]);
|
||
|
}
|
||
|
}
|
||
|
// if it's still clean...
|
||
|
if (clean) {
|
||
|
this.filePathList.push(filePath);
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
this.filePathList.push(filePath);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
SearchModal.prototype.addSearchSettingsDisplay = function () {
|
||
|
// add showing which settings are on
|
||
|
this.formDiv.createEl("br");
|
||
|
var via = "Settings: ";
|
||
|
if (this.plugin.settings.useForwardLinks) {
|
||
|
via += "✔ Forwardlinks ";
|
||
|
}
|
||
|
if (this.plugin.settings.useBackLinks) {
|
||
|
via += "✔ Backlinks ";
|
||
|
}
|
||
|
if (this.plugin.settings.useTags) {
|
||
|
via += "✔ Tags";
|
||
|
}
|
||
|
var avoid = "";
|
||
|
if (this.plugin.settings.skipMOCs) {
|
||
|
avoid = "✔ Avoid notes with " + this.plugin.settings.MOCMaxLinks + " or more links ";
|
||
|
}
|
||
|
var visual = "";
|
||
|
if (this.plugin.settings.enableHighContrast) {
|
||
|
visual = "✔ High-Contrast ";
|
||
|
}
|
||
|
var excludeSkip = "";
|
||
|
if (this.plugin.settings.skipFoldersList().length > 0) {
|
||
|
excludeSkip = "✔ Skipping " + this.plugin.settings.skipFolders + " ";
|
||
|
}
|
||
|
this.formDiv.createEl("p", { text: via + " " + avoid + " " + visual + " " + excludeSkip, cls: 'discovery-settings' });
|
||
|
};
|
||
|
SearchModal.prototype.addLuckyButton = function () {
|
||
|
var lucky = this.formDiv.createEl('p', { cls: 'journey-search-lucky', text: 'I feel lucky' });
|
||
|
var luckyFunction = (function () {
|
||
|
this.searchStart.setValue(this.findRandomNoteBasename());
|
||
|
this.searchEnd.setValue(this.findRandomNoteBasename());
|
||
|
}).bind(this);
|
||
|
lucky.onclick = luckyFunction;
|
||
|
};
|
||
|
SearchModal.prototype.addSearchButton = function (contentEl) {
|
||
|
var button = this.formDiv.createEl('input', {
|
||
|
type: 'submit',
|
||
|
cls: 'journey-input-button',
|
||
|
value: 'Find Journey'
|
||
|
});
|
||
|
var searchFunction = (function () {
|
||
|
contentEl.replaceWith(contentEl.createEl("h2", { text: "Searching..." }));
|
||
|
this.plugin.findShortestPath(this.searchStart.getValue(), this.searchEnd.getValue());
|
||
|
}).bind(this);
|
||
|
button.onclick = searchFunction;
|
||
|
};
|
||
|
SearchModal.prototype.addEndSearchComponent = function () {
|
||
|
var _this = this;
|
||
|
this.searchEnd = new obsidian.TextComponent(this.formDiv);
|
||
|
this.searchEnd.setPlaceholder("Your Ending Note Title");
|
||
|
var autocompleteResultEnd = this.formDiv.createDiv({ cls: 'journey-search-autocomplete-results-container hide-me' });
|
||
|
this.searchEnd.onChange(function (value) {
|
||
|
_this.autocomplete(value, autocompleteResultEnd, _this.searchEnd);
|
||
|
});
|
||
|
};
|
||
|
SearchModal.prototype.addStartSearchComponent = function () {
|
||
|
var _this = this;
|
||
|
this.searchStart = new obsidian.TextComponent(this.formDiv);
|
||
|
this.searchStart.setPlaceholder("Your Starting Note Title");
|
||
|
var autocompleteResultStart = this.formDiv.createDiv({ cls: 'journey-search-autocomplete-results-container hide-me' });
|
||
|
this.searchStart.onChange(function (value) {
|
||
|
_this.autocomplete(value, autocompleteResultStart, _this.searchStart);
|
||
|
});
|
||
|
};
|
||
|
SearchModal.prototype.autocomplete = function (value, autocompleteResult, targetElement) {
|
||
|
autocompleteResult.innerHTML = "";
|
||
|
var autocompleteResultContent = createDiv({ cls: 'journey-search-autocomplete-results-content' });
|
||
|
autocompleteResult.appendChild(autocompleteResultContent);
|
||
|
// console.log("Searching for:" + value);
|
||
|
if (!(value.length > 3)) {
|
||
|
autocompleteResult.addClass("hide-me");
|
||
|
return;
|
||
|
}
|
||
|
// console.log("Here are the files for auto-complete:");
|
||
|
// console.log(this.filePathList);
|
||
|
var searchResults = [];
|
||
|
for (var i = 0; i < this.filePathList.length; i++) {
|
||
|
if (this.filePathList[i].toUpperCase().includes(value.toUpperCase())) {
|
||
|
// console.log("Found: " + this.markdownFiles[i].basename);
|
||
|
searchResults.push(this.filePathList[i]);
|
||
|
}
|
||
|
}
|
||
|
var limit = searchResults.length;
|
||
|
if (limit > 5) {
|
||
|
limit = 5;
|
||
|
}
|
||
|
autocompleteResultContent.innerHTML = "";
|
||
|
var _loop_1 = function () {
|
||
|
var li = createDiv({ text: searchResults[i], cls: 'journey-search-autocomplete-results-content-item' });
|
||
|
li.addEventListener("click", function () {
|
||
|
var text = li.getText();
|
||
|
targetElement.setValue(text);
|
||
|
autocompleteResult.removeClass("show-me");
|
||
|
autocompleteResult.addClass("hide-me");
|
||
|
}.bind(this_1));
|
||
|
autocompleteResultContent.appendChild(li);
|
||
|
};
|
||
|
var this_1 = this;
|
||
|
for (var i = 0; i < limit; i++) {
|
||
|
_loop_1();
|
||
|
}
|
||
|
autocompleteResult.removeClass("hide-me");
|
||
|
autocompleteResult.addClass("show-me");
|
||
|
};
|
||
|
SearchModal.prototype.onClose = function () {
|
||
|
var contentEl = this.contentEl;
|
||
|
contentEl.empty();
|
||
|
};
|
||
|
return SearchModal;
|
||
|
}(obsidian.Modal));
|
||
|
var ResultsModal = /** @class */ (function (_super) {
|
||
|
__extends(ResultsModal, _super);
|
||
|
function ResultsModal(app, plugin) {
|
||
|
var _this = _super.call(this, app) || this;
|
||
|
_this.plugin = plugin;
|
||
|
return _this;
|
||
|
}
|
||
|
ResultsModal.prototype.onOpen = function () {
|
||
|
// console.log(this.results);
|
||
|
var contentEl = this.contentEl;
|
||
|
var anotherSearch = contentEl.createEl("p", { text: "Start another search", cls: 'journey-result-list-reset-link' });
|
||
|
var boundFunctionAnotherSearch = (function () {
|
||
|
this.close();
|
||
|
this.plugin.startSearch();
|
||
|
}).bind(this);
|
||
|
anotherSearch.onclick = boundFunctionAnotherSearch;
|
||
|
if (this.results.length <= 0) {
|
||
|
var noSearchResult = createDiv();
|
||
|
noSearchResult.appendChild(createEl("h2", { text: "No Journey Found between " + this.startBasename + " and " + this.endBasename }));
|
||
|
noSearchResult.appendChild(createEl("p", { text: "Here are some possible reasons why:" }));
|
||
|
var explanationList = createEl('ul');
|
||
|
if (!this.plugin.settings.useForwardLinks) {
|
||
|
explanationList.createEl('li', { text: 'You currently have forward-links disabled in your settings' });
|
||
|
}
|
||
|
if (!this.plugin.settings.useBackLinks) {
|
||
|
explanationList.createEl('li', { text: 'You currently have back-links disabled in your settings' });
|
||
|
}
|
||
|
if (!this.plugin.settings.useTags) {
|
||
|
explanationList.createEl('li', { text: 'You currently have tags disabled in your settings' });
|
||
|
}
|
||
|
if (this.plugin.settings.skipMOCs) {
|
||
|
explanationList.createEl('li', { text: 'You currently have skipping MOCs with more than ' + this.plugin.settings.MOCMaxLinks + ' outbound links enabled' });
|
||
|
}
|
||
|
if (this.plugin.settings.skipFolders) {
|
||
|
explanationList.createEl('li', { text: 'You currently have skipping folders enabled' });
|
||
|
}
|
||
|
explanationList.createEl('li', { text: 'The two notes may not be in the same network.' });
|
||
|
noSearchResult.appendChild(explanationList);
|
||
|
noSearchResult.appendChild(anotherSearch);
|
||
|
contentEl.replaceWith(noSearchResult);
|
||
|
}
|
||
|
else {
|
||
|
var listClass = 'journey-result-list';
|
||
|
if (this.plugin.settings.enableHighContrast) {
|
||
|
listClass = 'journey-result-list-high-contrast';
|
||
|
}
|
||
|
var list = createDiv({ cls: listClass });
|
||
|
var reversedResults = this.results.reverse();
|
||
|
for (var i = 0; i < reversedResults.length; i++) {
|
||
|
var text = reversedResults[i];
|
||
|
var cls = "journey-result-list-item-note";
|
||
|
if (i == 0)
|
||
|
cls = "journey-result-list-item-start";
|
||
|
if (i == reversedResults.length - 1)
|
||
|
cls = "journey-result-list-item-end";
|
||
|
if (text.match(/^\#\w+/))
|
||
|
cls = "journey-result-list-item-tag";
|
||
|
list.appendChild(createDiv({ text: text, cls: cls }));
|
||
|
}
|
||
|
contentEl.appendChild(list);
|
||
|
var button = contentEl.createEl('input', { type: 'submit', cls: 'journey-input-button', value: 'Copy to Clipboard' });
|
||
|
var boundFunctionButton = (function () {
|
||
|
this.saveToClipboard();
|
||
|
}).bind(this);
|
||
|
button.onclick = boundFunctionButton;
|
||
|
contentEl.appendChild(contentEl.createEl("hr"));
|
||
|
contentEl.appendChild(button);
|
||
|
contentEl.appendChild(anotherSearch);
|
||
|
}
|
||
|
};
|
||
|
ResultsModal.prototype.onClose = function () {
|
||
|
var contentEl = this.contentEl;
|
||
|
contentEl.empty();
|
||
|
};
|
||
|
ResultsModal.prototype.saveToClipboard = function () {
|
||
|
if (this.results.length > 0) {
|
||
|
navigator.clipboard.writeText(this.createClipboardContent());
|
||
|
new obsidian.Notice("Journey copied to clipboard!");
|
||
|
}
|
||
|
};
|
||
|
ResultsModal.prototype.createClipboardContent = function () {
|
||
|
var result = "## The Journey Between " + this.results.first().replace(".md", "") + " and " + this.results.last().replace(".md", "") + "\n";
|
||
|
for (var i = 0; i < this.results.length; i++) {
|
||
|
var noteTitle = this.results[i].replace(".md", "");
|
||
|
if (this.plugin.settings.enableLinks && !(noteTitle.startsWith("#"))) {
|
||
|
noteTitle = "[[" + noteTitle + "]]";
|
||
|
}
|
||
|
if (this.plugin.settings.enableLinks && this.plugin.settings.enableTransclusion) {
|
||
|
if (!(noteTitle.startsWith("#"))) {
|
||
|
result += "!" + noteTitle + "\n";
|
||
|
}
|
||
|
else {
|
||
|
result += noteTitle + "\n";
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
result += "- " + noteTitle + "\n";
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
};
|
||
|
return ResultsModal;
|
||
|
}(obsidian.Modal));
|
||
|
var JourneyPluginSettings = /** @class */ (function () {
|
||
|
function JourneyPluginSettings() {
|
||
|
this.useForwardLinks = true;
|
||
|
this.useBackLinks = true;
|
||
|
this.useTags = true;
|
||
|
this.skipMOCs = false;
|
||
|
this.MOCMaxLinks = 30;
|
||
|
this.enableHighContrast = false;
|
||
|
this.skipFolders = "";
|
||
|
this.enableLinks = false;
|
||
|
this.enableTransclusion = false;
|
||
|
}
|
||
|
JourneyPluginSettings.prototype.skipFoldersList = function () {
|
||
|
if (this.skipFolders == undefined || this.skipFolders == "")
|
||
|
return [];
|
||
|
return this.skipFolders.split(",").map(function (item) {
|
||
|
return item.trim();
|
||
|
});
|
||
|
};
|
||
|
return JourneyPluginSettings;
|
||
|
}());
|
||
|
var JourneyPluginSettingsTab = /** @class */ (function (_super) {
|
||
|
__extends(JourneyPluginSettingsTab, _super);
|
||
|
function JourneyPluginSettingsTab(app, plugin) {
|
||
|
var _this = _super.call(this, app, plugin) || this;
|
||
|
_this.plugin = plugin;
|
||
|
return _this;
|
||
|
}
|
||
|
JourneyPluginSettingsTab.prototype.display = function () {
|
||
|
var _this = this;
|
||
|
var containerEl = this.containerEl;
|
||
|
containerEl.empty();
|
||
|
containerEl.createEl("h2", { text: "Journey Plugin Settings" });
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Use Forward-links")
|
||
|
.setDesc("If set, allows to travel using forward-links. If you have a graph like this: A -> B -> C and you ask about the story between A and C, it will give you 'A, B, C' since A forward-links to B and B forward-links to C")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.useForwardLinks).onChange(function (value) {
|
||
|
_this.plugin.settings.useForwardLinks = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Use Back-links")
|
||
|
.setDesc("If set, allows to travel using back-links. If you have a graph like this: A -> B -> C and you ask about the story between C and A, it will give you 'C, B, A' since C has a back-link from B and B has a back-link from A")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.useBackLinks).onChange(function (value) {
|
||
|
_this.plugin.settings.useBackLinks = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
containerEl.createEl("h3", { text: "Include Tags" });
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Use Tags")
|
||
|
.setDesc("If set, allows to travel using tags. ")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.useTags).onChange(function (value) {
|
||
|
_this.plugin.settings.useTags = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
containerEl.createEl("h3", { text: "Avoid traveling via certain notes and folders" });
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Take the scenic route")
|
||
|
.setDesc("If set, will skip 'hub' notes with too many links (MOCs). Configure exactly how many links make a MOC below.")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.skipMOCs).onChange(function (value) {
|
||
|
_this.plugin.settings.skipMOCs = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("How many links make a MOC?")
|
||
|
.setDesc("Configure at which point to skip a note because it contains too many out-bound links. Applies only if 'Take the scenic route' above is set.")
|
||
|
.addSlider(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.MOCMaxLinks).onChange(function (value) {
|
||
|
_this.MOCMaxLinksCounter.setText("Max link count: " + String(value));
|
||
|
_this.plugin.settings.MOCMaxLinks = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
this.MOCMaxLinksCounter = containerEl.createDiv({ cls: 'moc-max-links-counter', text: "Max link count: " + this.plugin.settings.MOCMaxLinks });
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Exclude folders")
|
||
|
.setDesc("If set, will note include notes from the specified folders in your search. Please use comma to deliminate several folders")
|
||
|
.addText(function (text) {
|
||
|
return text
|
||
|
.setPlaceholder("Daily Notes/, Attachments/")
|
||
|
.setValue(_this.plugin.settings.skipFolders)
|
||
|
.onChange(function (value) {
|
||
|
_this.plugin.settings.skipFolders = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
containerEl.createEl("h3", { text: "Clipboard Settings" });
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Enable Automatic Linking")
|
||
|
.setDesc("If set, will turn titles in the list into links to their respective note")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.enableLinks).onChange(function (value) {
|
||
|
_this.plugin.settings.enableLinks = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Enable Automatic Transclusion")
|
||
|
.setDesc("If set, will automatically create transcluding links for you ('![[note]]' instead of '- [[note]]')")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.enableTransclusion).onChange(function (value) {
|
||
|
_this.plugin.settings.enableTransclusion = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
containerEl.createEl("h3", { text: "Accessibility Settings" });
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName("Enable High Contrast")
|
||
|
.setDesc("If set, will increase the contrast to make the result-list easier to read.")
|
||
|
.addToggle(function (toggle) {
|
||
|
return toggle.setValue(_this.plugin.settings.enableHighContrast).onChange(function (value) {
|
||
|
_this.plugin.settings.enableHighContrast = value;
|
||
|
_this.plugin.saveData(_this.plugin.settings);
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
return JourneyPluginSettingsTab;
|
||
|
}(obsidian.PluginSettingTab));
|
||
|
|
||
|
module.exports = JourneyPlugin;
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibm9kZV9tb2R1bGVzL3RzbGliL3RzbGliLmVzNi5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2xpc3RDYWNoZUNsZWFyLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9lcS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2Fzc29jSW5kZXhPZi5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2xpc3RDYWNoZURlbGV0ZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2xpc3RDYWNoZUdldC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2xpc3RDYWNoZUhhcy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2xpc3RDYWNoZVNldC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX0xpc3RDYWNoZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX3N0YWNrQ2xlYXIuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19zdGFja0RlbGV0ZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX3N0YWNrR2V0LmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fc3RhY2tIYXMuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19mcmVlR2xvYmFsLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fcm9vdC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX1N5bWJvbC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2dldFJhd1RhZy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX29iamVjdFRvU3RyaW5nLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fYmFzZUdldFRhZy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaXNPYmplY3QuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL2lzRnVuY3Rpb24uanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19jb3JlSnNEYXRhLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9faXNNYXNrZWQuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL190b1NvdXJjZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2Jhc2VJc05hdGl2ZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2dldFZhbHVlLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fZ2V0TmF0aXZlLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fTWFwLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fbmF0aXZlQ3JlYXRlLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9faGFzaENsZWFyLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9faGFzaERlbGV0ZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2hhc2hHZXQuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19oYXNoSGFzLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9faGFzaFNldC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX0hhc2guanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19tYXBDYWNoZUNsZWFyLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9faXNLZXlhYmxlLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fZ2V0TWFwRGF0YS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX21hcENhY2hlRGVsZXRlLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fbWFwQ2FjaGVHZXQuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19tYXBDYWNoZUhhcy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX21hcENhY2hlU2V0LmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fTWFwQ2FjaGUuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19zdGFja1NldC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX1N0YWNrLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fYXJyYXlFYWNoLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fZGVmaW5lUHJvcGVydHkuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19iYXNlQXNzaWduVmFsdWUuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19hc3NpZ25WYWx1ZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2NvcHlPYmplY3QuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19iYXNlVGltZXMuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL2lzT2JqZWN0TGlrZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2Jhc2VJc0FyZ3VtZW50cy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaXNBcmd1bWVudHMuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL2lzQXJyYXkuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL3N0dWJGYWxzZS5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaXNCdWZmZXIuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19pc0luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9pc0xlbmd0aC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2Jhc2VJc1R5cGVkQXJyYXkuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19iYXNlVW5hcnkuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19ub2RlVXRpbC5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaXNUeXBlZEFycmF5LmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fYXJyYXlMaWtlS2V5cy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2lzUHJvdG90eXBlLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fb3ZlckFyZy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX25hdGl2ZUtleXMuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19iYXNlS2V5cy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaXNBcnJheUxpa2UuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL2tleXMuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19iYXNlQXNzaWduLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fbmF0aXZlS2V5c0luLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fYmFzZUtleXNJbi5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gva2V5c0luLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fYmFzZUFzc2lnbkluLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fY2xvbmVCdWZmZXIuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19jb3B5QXJyYXkuanMiLCJub2RlX21vZHVsZXMvbG9kYXNoL19hcnJheUZpbHRlci5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvc3R1YkFycmF5LmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fZ2V0U3ltYm9scy5qcyIsIm5vZGVfbW9kdWxlcy9sb2Rhc2gvX2NvcHlTeW1ib2xzLmpzIiwibm9kZV9tb2R1bGVzL2xvZGFzaC9fYXJyYXl
|