Move internal modules to “internal” folder.

This commit is contained in:
John-David Dalton
2017-01-10 00:44:25 -08:00
parent 2b05673125
commit 26ea38dcf4
500 changed files with 726 additions and 726 deletions

34
.internal/Hash.js Normal file
View File

@@ -0,0 +1,34 @@
import hashClear from './.internal/hashClear.js';
import hashDelete from './.internal/hashDelete.js';
import hashGet from './.internal/hashGet.js';
import hashHas from './.internal/hashHas.js';
import hashSet from './.internal/hashSet.js';
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
class Hash {
constructor(entries) {
let index = -1;
const length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
const 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;
export default Hash;

34
.internal/ListCache.js Normal file
View File

@@ -0,0 +1,34 @@
import listCacheClear from './.internal/listCacheClear.js';
import listCacheDelete from './.internal/listCacheDelete.js';
import listCacheGet from './.internal/listCacheGet.js';
import listCacheHas from './.internal/listCacheHas.js';
import listCacheSet from './.internal/listCacheSet.js';
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
class ListCache {
constructor(entries) {
let index = -1;
const length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
const 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;
export default ListCache;

34
.internal/MapCache.js Normal file
View File

@@ -0,0 +1,34 @@
import mapCacheClear from './.internal/mapCacheClear.js';
import mapCacheDelete from './.internal/mapCacheDelete.js';
import mapCacheGet from './.internal/mapCacheGet.js';
import mapCacheHas from './.internal/mapCacheHas.js';
import mapCacheSet from './.internal/mapCacheSet.js';
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
class MapCache {
constructor(entries) {
let index = -1;
const length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
const 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;
export default MapCache;

29
.internal/SetCache.js Normal file
View File

@@ -0,0 +1,29 @@
import MapCache from './.internal/MapCache.js';
import setCacheAdd from './.internal/setCacheAdd.js';
import setCacheHas from './.internal/setCacheHas.js';
/**
*
* Creates an array cache object to store unique values.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
class SetCache {
constructor(values) {
let index = -1;
const 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;
export default SetCache;

29
.internal/Stack.js Normal file
View File

@@ -0,0 +1,29 @@
import ListCache from './.internal/ListCache.js';
import stackClear from './.internal/stackClear.js';
import stackDelete from './.internal/stackDelete.js';
import stackGet from './.internal/stackGet.js';
import stackHas from './.internal/stackHas.js';
import stackSet from './.internal/stackSet.js';
/**
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
class Stack {
constructor(entries) {
const 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;
export default Stack;

15
.internal/addMapEntry.js Normal file
View File

@@ -0,0 +1,15 @@
/**
* Adds the key-value `pair` to `map`.
*
* @private
* @param {Object} map The map to modify.
* @param {Array} pair The key-value pair to add.
* @returns {Object} Returns `map`.
*/
function addMapEntry(map, pair) {
// Don't return `map.set` because it's not chainable in IE 11.
map.set(pair[0], pair[1]);
return map;
}
export default addMapEntry;

15
.internal/addSetEntry.js Normal file
View File

@@ -0,0 +1,15 @@
/**
* Adds `value` to `set`.
*
* @private
* @param {Object} set The set to modify.
* @param {*} value The value to add.
* @returns {Object} Returns `set`.
*/
function addSetEntry(set, value) {
// Don't return `set.add` because it's not chainable in IE 11.
set.add(value);
return set;
}
export default addSetEntry;

21
.internal/apply.js Normal file
View File

@@ -0,0 +1,21 @@
/**
* 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);
}
export default apply;

View File

@@ -0,0 +1,22 @@
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
let index = -1;
const length = array == null ? 0 : array.length;
while (++index < length) {
const value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
export default arrayAggregator;

21
.internal/arrayEach.js Normal file
View File

@@ -0,0 +1,21 @@
/**
* A specialized version of `forEach` for arrays.
*
* @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) {
let index = -1;
const length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
}
export default arrayEach;

View File

@@ -0,0 +1,20 @@
/**
* A specialized version of `forEachRight` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEachRight(array, iteratee) {
let length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
}
export default arrayEachRight;

22
.internal/arrayEvery.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* A specialized version of `every` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
*/
function arrayEvery(array, predicate) {
let index = -1;
const length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
return false;
}
}
return true;
}
export default arrayEvery;

24
.internal/arrayFilter.js Normal file
View File

@@ -0,0 +1,24 @@
/**
* A specialized version of `filter` for arrays.
*
* @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) {
let index = -1;
let resIndex = 0;
const length = array == null ? 0 : array.length;
const result = [];
while (++index < length) {
const value = array[index];
if (predicate(value, index, array)) {
result[resIndex++] = value;
}
}
return result;
}
export default arrayFilter;

View File

@@ -0,0 +1,17 @@
import baseIndexOf from './.internal/baseIndexOf.js';
/**
* 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) {
const length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
export default arrayIncludes;

View File

@@ -0,0 +1,22 @@
/**
* 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) {
let index = -1;
const length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
export default arrayIncludesWith;

View File

@@ -0,0 +1,44 @@
import baseTimes from './.internal/baseTimes.js';
import isArguments from './isArguments.js';
import isBuffer from './isBuffer.js';
import isIndex from './.internal/isIndex.js';
import isTypedArray from './isTypedArray.js';
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.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) {
const isArr = Array.isArray(value);
const isArg = !isArr && isArguments(value);
const isBuff = !isArr && !isArg && isBuffer(value);
const isType = !isArr && !isArg && !isBuff && isTypedArray(value);
const skipIndexes = isArr || isArg || isBuff || isType;
const result = skipIndexes ? baseTimes(value.length, String) : [];
const length = result.length;
for (const key in value) {
if ((inherited || hasOwnProperty.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;
}
export default arrayLikeKeys;

20
.internal/arrayMap.js Normal file
View File

@@ -0,0 +1,20 @@
/**
* A specialized version of `map` for arrays.
*
* @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) {
let index = -1;
const length = array == null ? 0 : array.length;
const result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
export default arrayMap;

20
.internal/arrayPush.js Normal file
View File

@@ -0,0 +1,20 @@
/**
* 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) {
let index = -1;
const length = values.length;
const offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
export default arrayPush;

25
.internal/arrayReduce.js Normal file
View File

@@ -0,0 +1,25 @@
/**
* A specialized version of `reduce` for arrays.
*
* @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) {
let index = -1;
const length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
export default arrayReduce;

View File

@@ -0,0 +1,23 @@
/**
* A specialized version of `reduceRight` for arrays.
*
* @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 last element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
let length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[--length];
}
while (length--) {
accumulator = iteratee(accumulator, array[length], length, array);
}
return accumulator;
}
export default arrayReduceRight;

15
.internal/arraySample.js Normal file
View File

@@ -0,0 +1,15 @@
import baseRandom from './.internal/baseRandom.js';
/**
* A specialized version of `sample` for arrays.
*
* @private
* @param {Array} array The array to sample.
* @returns {*} Returns the random element.
*/
function arraySample(array) {
const length = array.length;
return length ? array[baseRandom(0, length - 1)] : undefined;
}
export default arraySample;

View File

@@ -0,0 +1,17 @@
import baseClamp from './.internal/baseClamp.js';
import copyArray from './.internal/copyArray.js';
import shuffleSelf from './.internal/shuffleSelf.js';
/**
* A specialized version of `sampleSize` for arrays.
*
* @private
* @param {Array} array The array to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function arraySampleSize(array, n) {
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
}
export default arraySampleSize;

15
.internal/arrayShuffle.js Normal file
View File

@@ -0,0 +1,15 @@
import copyArray from './.internal/copyArray.js';
import shuffleSelf from './.internal/shuffleSelf.js';
/**
* A specialized version of `shuffle` for arrays.
*
* @private
* @param {Array} array The array to shuffle.
* @returns {Array} Returns the new shuffled array.
*/
function arrayShuffle(array) {
return shuffleSelf(copyArray(array));
}
export default arrayShuffle;

22
.internal/arraySome.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* A specialized version of `some` for arrays.
*
* @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) {
let index = -1;
const length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
return true;
}
}
return false;
}
export default arraySome;

12
.internal/asciiSize.js Normal file
View File

@@ -0,0 +1,12 @@
import baseProperty from './.internal/baseProperty.js';
/**
* Gets the size of an ASCII `string`.
*
* @private
* @param {string} string The string inspect.
* @returns {number} Returns the string size.
*/
const asciiSize = baseProperty('length');
export default asciiSize;

12
.internal/asciiToArray.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* Converts an ASCII `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function asciiToArray(string) {
return string.split('');
}
export default asciiToArray;

15
.internal/asciiWords.js Normal file
View File

@@ -0,0 +1,15 @@
/** Used to match words composed of alphanumeric characters. */
const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/**
* Splits an ASCII `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function asciiWords(string) {
return string.match(reAsciiWord) || [];
}
export default asciiWords;

View File

@@ -0,0 +1,20 @@
import baseAssignValue from './.internal/baseAssignValue.js';
import eq from './eq.js';
/**
* This function is like `assignValue` except that it doesn't assign
* `undefined` values.
*
* @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 assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
export default assignMergeValue;

25
.internal/assignValue.js Normal file
View File

@@ -0,0 +1,25 @@
import baseAssignValue from './.internal/baseAssignValue.js';
import eq from './eq.js';
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.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) {
const objValue = object[key];
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
export default assignValue;

21
.internal/assocIndexOf.js Normal file
View File

@@ -0,0 +1,21 @@
import eq from './eq.js';
/**
* 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) {
let length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
export default assocIndexOf;

View File

@@ -0,0 +1,21 @@
import baseEach from './.internal/baseEach.js';
/**
* Aggregates elements of `collection` on `accumulator` with keys transformed
* by `iteratee` and values set by `setter`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function baseAggregator(collection, setter, iteratee, accumulator) {
baseEach(collection, (value, key, collection) => {
setter(accumulator, value, iteratee(value), collection);
});
return accumulator;
}
export default baseAggregator;

17
.internal/baseAssign.js Normal file
View File

@@ -0,0 +1,17 @@
import copyObject from './.internal/copyObject.js';
import keys from './keys.js';
/**
* 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(source), object);
}
export default baseAssign;

17
.internal/baseAssignIn.js Normal file
View File

@@ -0,0 +1,17 @@
import copyObject from './.internal/copyObject.js';
import keysIn from './keysIn.js';
/**
* 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(source), object);
}
export default baseAssignIn;

View File

@@ -0,0 +1,23 @@
/**
* 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__') {
Object.defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
});
} else {
object[key] = value;
}
}
export default baseAssignValue;

23
.internal/baseAt.js Normal file
View File

@@ -0,0 +1,23 @@
import get from './get.js';
/**
* The base implementation of `at` without support for individual paths.
*
* @private
* @param {Object} object The object to iterate over.
* @param {string[]} paths The property paths to pick.
* @returns {Array} Returns the picked elements.
*/
function baseAt(object, paths) {
let index = -1;
const length = paths.length;
const result = Array(length);
const skip = object == null;
while (++index < length) {
result[index] = skip ? undefined : get(object, paths[index]);
}
return result;
}
export default baseAt;

22
.internal/baseClamp.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* The base implementation of `clamp` which doesn't coerce arguments.
*
* @private
* @param {number} number The number to clamp.
* @param {number} [lower] The lower bound.
* @param {number} upper The upper bound.
* @returns {number} Returns the clamped number.
*/
function baseClamp(number, lower, upper) {
if (number === number) {
if (upper !== undefined) {
number = number <= upper ? number : upper;
}
if (lower !== undefined) {
number = number >= lower ? number : lower;
}
}
return number;
}
export default baseClamp;

152
.internal/baseClone.js Normal file
View File

@@ -0,0 +1,152 @@
import Stack from './.internal/Stack.js';
import arrayEach from './.internal/arrayEach.js';
import assignValue from './.internal/assignValue.js';
import baseAssign from './.internal/baseAssign.js';
import baseAssignIn from './.internal/baseAssignIn.js';
import cloneBuffer from './.internal/cloneBuffer.js';
import copyArray from './.internal/copyArray.js';
import copySymbols from './.internal/copySymbols.js';
import copySymbolsIn from './.internal/copySymbolsIn.js';
import getAllKeys from './.internal/getAllKeys.js';
import getAllKeysIn from './.internal/getAllKeysIn.js';
import getTag from './.internal/getTag.js';
import initCloneArray from './.internal/initCloneArray.js';
import initCloneByTag from './.internal/initCloneByTag.js';
import initCloneObject from './.internal/initCloneObject.js';
import isBuffer from './isBuffer.js';
import isObject from './isObject.js';
import keys from './keys.js';
/** Used to compose bitmasks for cloning. */
const CLONE_DEEP_FLAG = 1;
const CLONE_FLAT_FLAG = 2;
const CLONE_SYMBOLS_FLAG = 4;
/** `Object#toString` result references. */
const argsTag = '[object Arguments]';
const arrayTag = '[object Array]';
const boolTag = '[object Boolean]';
const dateTag = '[object Date]';
const errorTag = '[object Error]';
const funcTag = '[object Function]';
const genTag = '[object GeneratorFunction]';
const mapTag = '[object Map]';
const numberTag = '[object Number]';
const objectTag = '[object Object]';
const regexpTag = '[object RegExp]';
const setTag = '[object Set]';
const stringTag = '[object String]';
const symbolTag = '[object Symbol]';
const weakMapTag = '[object WeakMap]';
const arrayBufferTag = '[object ArrayBuffer]';
const dataViewTag = '[object DataView]';
const float32Tag = '[object Float32Array]';
const float64Tag = '[object Float64Array]';
const int8Tag = '[object Int8Array]';
const int16Tag = '[object Int16Array]';
const int32Tag = '[object Int32Array]';
const uint8Tag = '[object Uint8Array]';
const uint8ClampedTag = '[object Uint8ClampedArray]';
const uint16Tag = '[object Uint16Array]';
const uint32Tag = '[object Uint32Array]';
/** Used to identify `toStringTag` values supported by `clone`. */
const cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] =
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
cloneableTags[boolTag] = cloneableTags[dateTag] =
cloneableTags[float32Tag] = cloneableTags[float64Tag] =
cloneableTags[int8Tag] = cloneableTags[int16Tag] =
cloneableTags[int32Tag] = cloneableTags[mapTag] =
cloneableTags[numberTag] = cloneableTags[objectTag] =
cloneableTags[regexpTag] = cloneableTags[setTag] =
cloneableTags[stringTag] = cloneableTags[symbolTag] =
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] =
cloneableTags[weakMapTag] = 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) {
let result;
const isDeep = bitmask & CLONE_DEEP_FLAG;
const isFlat = bitmask & CLONE_FLAT_FLAG;
const isFull = bitmask & CLONE_SYMBOLS_FLAG;
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
}
if (result !== undefined) {
return result;
}
if (!isObject(value)) {
return value;
}
const isArr = Array.isArray(value);
if (isArr) {
result = initCloneArray(value);
if (!isDeep) {
return copyArray(value, result);
}
} else {
const tag = getTag(value);
const isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) {
return cloneBuffer(value, isDeep);
}
if (tag == objectTag || tag == argsTag || (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, baseClone, isDeep);
}
}
// Check for circular references and return its corresponding clone.
stack || (stack = new Stack);
const stacked = stack.get(value);
if (stacked) {
return stacked;
}
stack.set(value, result);
const keysFunc = isFull
? (isFlat ? getAllKeysIn : getAllKeys)
: (isFlat ? keysIn : keys);
const props = isArr ? undefined : keysFunc(value);
arrayEach(props || value, (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;
}
export default baseClone;

16
.internal/baseConforms.js Normal file
View File

@@ -0,0 +1,16 @@
import baseConformsTo from './.internal/baseConformsTo.js';
import keys from './keys.js';
/**
* The base implementation of `conforms` which doesn't clone `source`.
*
* @private
* @param {Object} source The object of property predicates to conform to.
* @returns {Function} Returns the new spec function.
*/
function baseConforms(source) {
const props = keys(source);
return object => baseConformsTo(object, source, props);
}
export default baseConforms;

View File

@@ -0,0 +1,27 @@
/**
* The base implementation of `conformsTo` which accepts `props` to check.
*
* @private
* @param {Object} object The object to inspect.
* @param {Object} source The object of property predicates to conform to.
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
*/
function baseConformsTo(object, source, props) {
let length = props.length;
if (object == null) {
return !length;
}
object = Object(object);
while (length--) {
const key = props[length];
const predicate = source[key];
const value = object[key];
if ((value === undefined && !(key in object)) || !predicate(value)) {
return false;
}
}
return true;
}
export default baseConformsTo;

30
.internal/baseCreate.js Normal file
View File

@@ -0,0 +1,30 @@
import isObject from './isObject.js';
/** Built-in value references. */
const 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.
*/
const baseCreate = (() => {
function object() {}
return proto => {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
const result = new object;
object.prototype = undefined;
return result;
};
})();
export default baseCreate;

18
.internal/baseDelay.js Normal file
View File

@@ -0,0 +1,18 @@
/**
* The base implementation of `delay` and `defer` which accepts `args`
* to provide to `func`.
*
* @private
* @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation.
* @param {Array} args The arguments to provide to `func`.
* @returns {number|Object} Returns the timer id or timeout object.
*/
function baseDelay(func, wait, args) {
if (typeof func != 'function') {
throw new TypeError('Expected a function');
}
return setTimeout(() => func(...args), wait);
}
export default baseDelay;

View File

@@ -0,0 +1,66 @@
import SetCache from './.internal/SetCache.js';
import arrayIncludes from './.internal/arrayIncludes.js';
import arrayIncludesWith from './.internal/arrayIncludesWith.js';
import arrayMap from './.internal/arrayMap.js';
import cacheHas from './.internal/cacheHas.js';
/** Used as the size to enable large array optimizations. */
const LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of methods like `difference` without support
* for excluding multiple arrays.
*
* @private
* @param {Array} array The array to inspect.
* @param {Array} values The values to exclude.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of filtered values.
*/
function baseDifference(array, values, iteratee, comparator) {
let index = -1;
let includes = arrayIncludes;
let isCommon = true;
const length = array.length;
const result = [];
const valuesLength = values.length;
if (!length) {
return result;
}
if (iteratee) {
values = arrayMap(values, value => iteratee(value));
}
if (comparator) {
includes = arrayIncludesWith;
isCommon = false;
}
else if (values.length >= LARGE_ARRAY_SIZE) {
includes = cacheHas;
isCommon = false;
values = new SetCache(values);
}
outer:
while (++index < length) {
let value = array[index];
const computed = iteratee == null ? value : iteratee(value);
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {
let valuesIndex = valuesLength;
while (valuesIndex--) {
if (values[valuesIndex] === computed) {
continue outer;
}
}
result.push(value);
}
else if (!includes(values, computed, comparator)) {
result.push(value);
}
}
return result;
}
export default baseDifference;

14
.internal/baseEach.js Normal file
View File

@@ -0,0 +1,14 @@
import baseForOwn from './.internal/baseForOwn.js';
import createBaseEach from './.internal/createBaseEach.js';
/**
* The base implementation of `forEach`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
*/
const baseEach = createBaseEach(baseForOwn);
export default baseEach;

View File

@@ -0,0 +1,14 @@
import baseForOwnRight from './.internal/baseForOwnRight.js';
import createBaseEach from './.internal/createBaseEach.js';
/**
* The base implementation of `forEachRight`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
*/
const baseEachRight = createBaseEach(baseForOwnRight, true);
export default baseEachRight;

21
.internal/baseEvery.js Normal file
View File

@@ -0,0 +1,21 @@
import baseEach from './.internal/baseEach.js';
/**
* The base implementation of `every`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`
*/
function baseEvery(collection, predicate) {
let result = true;
baseEach(collection, (value, index, collection) => {
result = !!predicate(value, index, collection);
return result;
});
return result;
}
export default baseEvery;

34
.internal/baseExtremum.js Normal file
View File

@@ -0,0 +1,34 @@
import isSymbol from './isSymbol.js';
/**
* The base implementation of methods like `max` and `min` which accepts a
* `comparator` to determine the extremum value.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The iteratee invoked per iteration.
* @param {Function} comparator The comparator used to compare values.
* @returns {*} Returns the extremum value.
*/
function baseExtremum(array, iteratee, comparator) {
let result;
let index = -1;
const length = array.length;
while (++index < length) {
let computed;
const value = array[index];
const current = iteratee(value);
if (current != null && (computed === undefined
? (current === current && !isSymbol(current))
: comparator(current, computed)
)) {
computed = current;
result = value;
}
}
return result;
}
export default baseExtremum;

32
.internal/baseFill.js Normal file
View File

@@ -0,0 +1,32 @@
import toInteger from './toInteger.js';
import toLength from './toLength.js';
/**
* The base implementation of `fill` without an iteratee call guard.
*
* @private
* @param {Array} array The array to fill.
* @param {*} value The value to fill `array` with.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns `array`.
*/
function baseFill(array, value, start, end) {
const length = array.length;
start = toInteger(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : toInteger(end);
if (end < 0) {
end += length;
}
end = start > end ? 0 : toLength(end);
while (start < end) {
array[start++] = value;
}
return array;
}
export default baseFill;

21
.internal/baseFilter.js Normal file
View File

@@ -0,0 +1,21 @@
import baseEach from './.internal/baseEach.js';
/**
* The base implementation of `filter`.
*
* @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) {
const result = [];
baseEach(collection, (value, index, collection) => {
if (predicate(value, index, collection)) {
result.push(value);
}
});
return result;
}
export default baseFilter;

View File

@@ -0,0 +1,23 @@
/**
* The base implementation of `findIndex` and `findLastIndex`.
*
* @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) {
const length = array.length;
let index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
export default baseFindIndex;

22
.internal/baseFindKey.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* The base implementation of methods like `findKey` and `findLastKey`
* which iterates over `collection` using `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the found element or its key, else `undefined`.
*/
function baseFindKey(collection, predicate, eachFunc) {
let result;
eachFunc(collection, (value, key, collection) => {
if (predicate(value, key, collection)) {
result = key;
return false;
}
});
return result;
}
export default baseFindKey;

38
.internal/baseFlatten.js Normal file
View File

@@ -0,0 +1,38 @@
import arrayPush from './.internal/arrayPush.js';
import isFlattenable from './.internal/isFlattenable.js';
/**
* 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) {
let index = -1;
const length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
const 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;
}
export default baseFlatten;

16
.internal/baseFor.js Normal file
View File

@@ -0,0 +1,16 @@
import createBaseFor from './.internal/createBaseFor.js';
/**
* 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`.
*/
const baseFor = createBaseFor();
export default baseFor;

16
.internal/baseForOwn.js Normal file
View File

@@ -0,0 +1,16 @@
import baseFor from './.internal/baseFor.js';
import keys from './keys.js';
/**
* The base implementation of `forOwn`.
*
* @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);
}
export default baseForOwn;

View File

@@ -0,0 +1,16 @@
import baseForRight from './.internal/baseForRight.js';
import keys from './keys.js';
/**
* The base implementation of `forOwnRight`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns `object`.
*/
function baseForOwnRight(object, iteratee) {
return object && baseForRight(object, iteratee, keys);
}
export default baseForOwnRight;

15
.internal/baseForRight.js Normal file
View File

@@ -0,0 +1,15 @@
import createBaseFor from './.internal/createBaseFor.js';
/**
* This function is like `baseFor` except that it iterates over properties
* in the opposite order.
*
* @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`.
*/
const baseForRight = createBaseFor(true);
export default baseForRight;

View File

@@ -0,0 +1,17 @@
import arrayFilter from './.internal/arrayFilter.js';
import isFunction from './isFunction.js';
/**
* The base implementation of `functions` which creates an array of
* `object` function property names filtered from `props`.
*
* @private
* @param {Object} object The object to inspect.
* @param {Array} props The property names to filter.
* @returns {Array} Returns the function names.
*/
function baseFunctions(object, props) {
return arrayFilter(props, key => isFunction(object[key]));
}
export default baseFunctions;

24
.internal/baseGet.js Normal file
View File

@@ -0,0 +1,24 @@
import castPath from './.internal/castPath.js';
import toKey from './.internal/toKey.js';
/**
* 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);
let index = 0;
const length = path.length;
while (object != null && index < length) {
object = object[toKey(path[index++])];
}
return (index && index == length) ? object : undefined;
}
export default baseGet;

View File

@@ -0,0 +1,19 @@
import arrayPush from './.internal/arrayPush.js';
/**
* 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) {
const result = keysFunc(object);
return Array.isArray(object) ? result : arrayPush(result, symbolsFunc(object));
}
export default baseGetAllKeys;

27
.internal/baseGetTag.js Normal file
View File

@@ -0,0 +1,27 @@
import getRawTag from './.internal/getRawTag.js';
import objectToString from './.internal/objectToString.js';
/** `Object#toString` result references. */
const nullTag = '[object Null]';
const undefinedTag = '[object Undefined]';
/** Built-in value references. */
const symToStringTag = 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 && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
export default baseGetTag;

14
.internal/baseGt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `gt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
*/
function baseGt(value, other) {
return value > other;
}
export default baseGt;

16
.internal/baseHas.js Normal file
View File

@@ -0,0 +1,16 @@
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.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.call(object, key);
}
export default baseHas;

13
.internal/baseHasIn.js Normal file
View File

@@ -0,0 +1,13 @@
/**
* 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);
}
export default baseHasIn;

18
.internal/baseInRange.js Normal file
View File

@@ -0,0 +1,18 @@
/* Built-in method references for those with the same name as other `lodash` methods. */
const nativeMax = Math.max;
const nativeMin = Math.min;
/**
* The base implementation of `inRange` which doesn't coerce arguments.
*
* @private
* @param {number} number The number to check.
* @param {number} start The start of the range.
* @param {number} end The end of the range.
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
*/
function baseInRange(number, start, end) {
return number >= nativeMin(start, end) && number < nativeMax(start, end);
}
export default baseInRange;

20
.internal/baseIndexOf.js Normal file
View File

@@ -0,0 +1,20 @@
import baseFindIndex from './.internal/baseFindIndex.js';
import baseIsNaN from './.internal/baseIsNaN.js';
import strictIndexOf from './.internal/strictIndexOf.js';
/**
* 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);
}
export default baseIndexOf;

View File

@@ -0,0 +1,23 @@
/**
* This function is like `baseIndexOf` except that it accepts a comparator.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @param {Function} comparator The comparator invoked per element.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOfWith(array, value, fromIndex, comparator) {
let index = fromIndex - 1;
const length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
}
export default baseIndexOfWith;

View File

@@ -0,0 +1,75 @@
import SetCache from './.internal/SetCache.js';
import arrayIncludes from './.internal/arrayIncludes.js';
import arrayIncludesWith from './.internal/arrayIncludesWith.js';
import arrayMap from './.internal/arrayMap.js';
import cacheHas from './.internal/cacheHas.js';
/* Built-in method references for those with the same name as other `lodash` methods. */
const nativeMin = Math.min;
/**
* The base implementation of methods like `intersection` that accepts an
* array of arrays to inspect.
*
* @private
* @param {Array} arrays The arrays to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of shared values.
*/
function baseIntersection(arrays, iteratee, comparator) {
const includes = comparator ? arrayIncludesWith : arrayIncludes;
const length = arrays[0].length;
const othLength = arrays.length;
const caches = Array(othLength);
const result = [];
let array;
let maxLength = Infinity;
let othIndex = othLength;
while (othIndex--) {
array = arrays[othIndex];
if (othIndex && iteratee) {
array = arrayMap(array, valye => iteratee(value));
}
maxLength = nativeMin(array.length, maxLength);
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new SetCache(othIndex && array)
: undefined;
}
array = arrays[0];
let index = -1;
const seen = caches[0];
outer:
while (++index < length && result.length < maxLength) {
let value = array[index];
const computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (!(seen
? cacheHas(seen, computed)
: includes(result, computed, comparator)
)) {
othIndex = othLength;
while (--othIndex) {
const cache = caches[othIndex];
if (!(cache
? cacheHas(cache, computed)
: includes(arrays[othIndex], computed, comparator))
) {
continue outer;
}
}
if (seen) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
export default baseIntersection;

21
.internal/baseInverter.js Normal file
View File

@@ -0,0 +1,21 @@
import baseForOwn from './.internal/baseForOwn.js';
/**
* The base implementation of `invert` and `invertBy` which inverts
* `object` with values transformed by `iteratee` and set by `setter`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform values.
* @param {Object} accumulator The initial inverted object.
* @returns {Function} Returns `accumulator`.
*/
function baseInverter(object, setter, iteratee, accumulator) {
baseForOwn(object, (value, key, object) => {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
}
export default baseInverter;

24
.internal/baseInvoke.js Normal file
View File

@@ -0,0 +1,24 @@
import apply from './.internal/apply.js';
import castPath from './.internal/castPath.js';
import last from './last.js';
import parent from './.internal/parent.js';
import toKey from './.internal/toKey.js';
/**
* The base implementation of `invoke` without support for individual
* method arguments.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.
* @param {Array} args The arguments to invoke the method with.
* @returns {*} Returns the result of the invoked method.
*/
function baseInvoke(object, path, args) {
path = castPath(path, object);
object = parent(object, path);
const func = object == null ? object : object[toKey(last(path))];
return func == null ? undefined : apply(func, object, args);
}
export default baseInvoke;

View File

@@ -0,0 +1,17 @@
import baseGetTag from './.internal/baseGetTag.js';
import isObjectLike from './isObjectLike.js';
const arrayBufferTag = '[object ArrayBuffer]';
/**
* The base implementation of `isArrayBuffer` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
*/
function baseIsArrayBuffer(value) {
return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
}
export default baseIsArrayBuffer;

18
.internal/baseIsDate.js Normal file
View File

@@ -0,0 +1,18 @@
import baseGetTag from './.internal/baseGetTag.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
const dateTag = '[object Date]';
/**
* The base implementation of `isDate` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
*/
function baseIsDate(value) {
return isObjectLike(value) && baseGetTag(value) == dateTag;
}
export default baseIsDate;

28
.internal/baseIsEqual.js Normal file
View File

@@ -0,0 +1,28 @@
import baseIsEqualDeep from './.internal/baseIsEqualDeep.js';
import isObjectLike from './isObjectLike.js';
/**
* 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(value) && !isObjectLike(other))) {
return value !== value && other !== other;
}
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
}
export default baseIsEqual;

View File

@@ -0,0 +1,79 @@
import Stack from './.internal/Stack.js';
import equalArrays from './.internal/equalArrays.js';
import equalByTag from './.internal/equalByTag.js';
import equalObjects from './.internal/equalObjects.js';
import getTag from './.internal/getTag.js';
import isBuffer from './isBuffer.js';
import isTypedArray from './isTypedArray.js';
/** Used to compose bitmasks for value comparisons. */
const COMPARE_PARTIAL_FLAG = 1;
/** `Object#toString` result references. */
const argsTag = '[object Arguments]';
const arrayTag = '[object Array]';
const objectTag = '[object Object]';
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.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) {
let objIsArr = Array.isArray(object);
const othIsArr = Array.isArray(other);
let objTag = objIsArr ? arrayTag : getTag(object);
let othTag = othIsArr ? arrayTag : getTag(other);
objTag = objTag == argsTag ? objectTag : objTag;
othTag = othTag == argsTag ? objectTag : othTag;
let objIsObj = objTag == objectTag;
const othIsObj = othTag == objectTag;
const isSameTag = objTag == othTag;
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {
return false;
}
objIsArr = true;
objIsObj = false;
}
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
: equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
}
if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__');
const othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
if (objIsWrapped || othIsWrapped) {
const objUnwrapped = objIsWrapped ? object.value() : object;
const 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);
}
export default baseIsEqualDeep;

18
.internal/baseIsMap.js Normal file
View File

@@ -0,0 +1,18 @@
import getTag from './.internal/getTag.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
const mapTag = '[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(value) && getTag(value) == mapTag;
}
export default baseIsMap;

64
.internal/baseIsMatch.js Normal file
View File

@@ -0,0 +1,64 @@
import Stack from './.internal/Stack.js';
import baseIsEqual from './.internal/baseIsEqual.js';
/** Used to compose bitmasks for value comparisons. */
const COMPARE_PARTIAL_FLAG = 1;
const COMPARE_UNORDERED_FLAG = 2;
/**
* The base implementation of `isMatch`.
*
* @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) {
let index = matchData.length;
const length = index;
const noCustomizer = !customizer;
if (object == null) {
return !length;
}
let data;
let result;
object = Object(object);
while (index--) {
data = matchData[index];
if ((noCustomizer && data[2])
? data[1] !== object[data[0]]
: !(data[0] in object)
) {
return false;
}
}
while (++index < length) {
data = matchData[index];
const key = data[0];
const objValue = object[key];
const srcValue = data[1];
if (noCustomizer && data[2]) {
if (objValue === undefined && !(key in object)) {
return false;
}
} else {
const stack = new Stack;
if (customizer) {
result = customizer(objValue, srcValue, key, object, source, stack);
}
if (!(result === undefined
? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
: result
)) {
return false;
}
}
}
return true;
}
export default baseIsMatch;

12
.internal/baseIsNaN.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* 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;
}
export default baseIsNaN;

18
.internal/baseIsRegExp.js Normal file
View File

@@ -0,0 +1,18 @@
import baseGetTag from './.internal/baseGetTag.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
const regexpTag = '[object RegExp]';
/**
* The base implementation of `isRegExp` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
*/
function baseIsRegExp(value) {
return isObjectLike(value) && baseGetTag(value) == regexpTag;
}
export default baseIsRegExp;

18
.internal/baseIsSet.js Normal file
View File

@@ -0,0 +1,18 @@
import getTag from './.internal/getTag.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
const setTag = '[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(value) && getTag(value) == setTag;
}
export default baseIsSet;

View File

@@ -0,0 +1,60 @@
import baseGetTag from './.internal/baseGetTag.js';
import isLength from './isLength.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
const argsTag = '[object Arguments]';
const arrayTag = '[object Array]';
const boolTag = '[object Boolean]';
const dateTag = '[object Date]';
const errorTag = '[object Error]';
const funcTag = '[object Function]';
const mapTag = '[object Map]';
const numberTag = '[object Number]';
const objectTag = '[object Object]';
const regexpTag = '[object RegExp]';
const setTag = '[object Set]';
const stringTag = '[object String]';
const weakMapTag = '[object WeakMap]';
const arrayBufferTag = '[object ArrayBuffer]';
const dataViewTag = '[object DataView]';
const float32Tag = '[object Float32Array]';
const float64Tag = '[object Float64Array]';
const int8Tag = '[object Int8Array]';
const int16Tag = '[object Int16Array]';
const int32Tag = '[object Int32Array]';
const uint8Tag = '[object Uint8Array]';
const uint8ClampedTag = '[object Uint8ClampedArray]';
const uint16Tag = '[object Uint16Array]';
const uint32Tag = '[object Uint32Array]';
/** Used to identify `toStringTag` values of typed arrays. */
const typedArrayTags = {};
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
typedArrayTags[uint32Tag] = true;
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
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(value) &&
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
export default baseIsTypedArray;

27
.internal/baseKeys.js Normal file
View File

@@ -0,0 +1,27 @@
import isPrototype from './.internal/isPrototype.js';
import nativeKeys from './.internal/nativeKeys.js';
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.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);
}
const result = [];
for (const key in Object(object)) {
if (hasOwnProperty.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
export default baseKeys;

30
.internal/baseKeysIn.js Normal file
View File

@@ -0,0 +1,30 @@
import isObject from './isObject.js';
import isPrototype from './.internal/isPrototype.js';
import nativeKeysIn from './.internal/nativeKeysIn.js';
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.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(object)) {
return nativeKeysIn(object);
}
const isProto = isPrototype(object);
const result = [];
for (const key in object) {
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
result.push(key);
}
}
return result;
}
export default baseKeysIn;

10
.internal/baseLodash.js Normal file
View File

@@ -0,0 +1,10 @@
/**
* The function whose prototype chain sequence wrappers inherit from.
*
* @private
*/
function baseLodash() {
// No operation performed.
}
export default baseLodash;

14
.internal/baseLt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `lt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
*/
function baseLt(value, other) {
return value < other;
}
export default baseLt;

22
.internal/baseMap.js Normal file
View File

@@ -0,0 +1,22 @@
import baseEach from './.internal/baseEach.js';
import isArrayLike from './isArrayLike.js';
/**
* The base implementation of `map`.
*
* @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) {
let index = -1;
const result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, (value, key, collection) => {
result[++index] = iteratee(value, key, collection);
});
return result;
}
export default baseMap;

20
.internal/baseMatches.js Normal file
View File

@@ -0,0 +1,20 @@
import baseIsMatch from './.internal/baseIsMatch.js';
import getMatchData from './.internal/getMatchData.js';
import matchesStrictComparable from './.internal/matchesStrictComparable.js';
/**
* 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) {
const matchData = getMatchData(source);
if (matchData.length == 1 && matchData[0][2]) {
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
}
return object => object === source || baseIsMatch(object, source, matchData);
}
export default baseMatches;

View File

@@ -0,0 +1,33 @@
import baseIsEqual from './.internal/baseIsEqual.js';
import get from './get.js';
import hasIn from './hasIn.js';
import isKey from './.internal/isKey.js';
import isStrictComparable from './.internal/isStrictComparable.js';
import matchesStrictComparable from './.internal/matchesStrictComparable.js';
import toKey from './.internal/toKey.js';
/** Used to compose bitmasks for value comparisons. */
const COMPARE_PARTIAL_FLAG = 1;
const COMPARE_UNORDERED_FLAG = 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 object => {
const objValue = get(object, path);
return (objValue === undefined && objValue === srcValue)
? hasIn(object, path)
: baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
};
}
export default baseMatchesProperty;

41
.internal/baseMerge.js Normal file
View File

@@ -0,0 +1,41 @@
import Stack from './.internal/Stack.js';
import assignMergeValue from './.internal/assignMergeValue.js';
import baseFor from './.internal/baseFor.js';
import baseMergeDeep from './.internal/baseMergeDeep.js';
import isObject from './isObject.js';
import keysIn from './keysIn.js';
/**
* The base implementation of `merge` without support for multiple sources.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {number} srcIndex The index of `source`.
* @param {Function} [customizer] The function to customize merged values.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/
function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) {
return;
}
baseFor(source, (srcValue, key) => {
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
const newValue = customizer
? customizer(object[key], srcValue, `${ key }`, object, source, stack)
: undefined;
if (newValue === undefined) {
newValue = srcValue;
}
assignMergeValue(object, key, newValue);
}
}, keysIn);
}
export default baseMerge;

View File

@@ -0,0 +1,92 @@
import assignMergeValue from './.internal/assignMergeValue.js';
import cloneBuffer from './.internal/cloneBuffer.js';
import cloneTypedArray from './.internal/cloneTypedArray.js';
import copyArray from './.internal/copyArray.js';
import initCloneObject from './.internal/initCloneObject.js';
import isArguments from './isArguments.js';
import isArrayLikeObject from './isArrayLikeObject.js';
import isBuffer from './isBuffer.js';
import isFunction from './isFunction.js';
import isObject from './isObject.js';
import isPlainObject from './isPlainObject.js';
import isTypedArray from './isTypedArray.js';
import toPlainObject from './toPlainObject.js';
/**
* A specialized version of `baseMerge` for arrays and objects which performs
* deep merges and tracks traversed objects enabling objects with circular
* references to be merged.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {string} key The key of the value to merge.
* @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize assigned values.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
const objValue = object[key];
const srcValue = source[key];
const stacked = stack.get(srcValue);
if (stacked) {
assignMergeValue(object, key, stacked);
return;
}
let newValue = customizer
? customizer(objValue, srcValue, `${ key }`, object, source, stack)
: undefined;
let isCommon = newValue === undefined;
if (isCommon) {
const isArr = Array.isArray(srcValue);
const isBuff = !isArr && isBuffer(srcValue);
const isTyped = !isArr && !isBuff && isTypedArray(srcValue);
newValue = srcValue;
if (isArr || isBuff || isTyped) {
if (Array.isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else if (isBuff) {
isCommon = false;
newValue = cloneBuffer(srcValue, true);
}
else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray(srcValue, true);
}
else {
newValue = [];
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
newValue = initCloneObject(srcValue);
}
}
else {
isCommon = false;
}
}
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, newValue);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
stack['delete'](srcValue);
}
assignMergeValue(object, key, newValue);
}
export default baseMergeDeep;

20
.internal/baseNth.js Normal file
View File

@@ -0,0 +1,20 @@
import isIndex from './.internal/isIndex.js';
/**
* The base implementation of `nth` which doesn't coerce arguments.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
const length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
export default baseNth;

28
.internal/baseOrderBy.js Normal file
View File

@@ -0,0 +1,28 @@
import arrayMap from './.internal/arrayMap.js';
import baseMap from './.internal/baseMap.js';
import baseSortBy from './.internal/baseSortBy.js';
import compareMultiple from './.internal/compareMultiple.js';
import identity from './identity.js';
/**
* The base implementation of `orderBy` without param guards.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
* @param {string[]} orders The sort orders of `iteratees`.
* @returns {Array} Returns the new sorted array.
*/
function baseOrderBy(collection, iteratees, orders) {
let index = -1;
iteratees = iteratees.length ? iteratees : [identity];
const result = baseMap(collection, (value, key, collection) => {
const criteria = arrayMap(iteratees, iteratee => iteratee(value));
return { 'criteria': criteria, 'index': ++index, 'value': value };
});
return baseSortBy(result, (object, other) => compareMultiple(object, other, orders));
}
export default baseOrderBy;

17
.internal/basePick.js Normal file
View File

@@ -0,0 +1,17 @@
import basePickBy from './.internal/basePickBy.js';
import hasIn from './hasIn.js';
/**
* The base implementation of `pick` without support for individual
* property identifiers.
*
* @private
* @param {Object} object The source object.
* @param {string[]} paths The property paths to pick.
* @returns {Object} Returns the new object.
*/
function basePick(object, paths) {
return basePickBy(object, paths, (value, path) => hasIn(object, path));
}
export default basePick;

29
.internal/basePickBy.js Normal file
View File

@@ -0,0 +1,29 @@
import baseGet from './.internal/baseGet.js';
import baseSet from './.internal/baseSet.js';
import castPath from './.internal/castPath.js';
/**
* The base implementation of `pickBy`.
*
* @private
* @param {Object} object The source object.
* @param {string[]} paths The property paths to pick.
* @param {Function} predicate The function invoked per property.
* @returns {Object} Returns the new object.
*/
function basePickBy(object, paths, predicate) {
let index = -1;
const length = paths.length;
const result = {};
while (++index < length) {
const path = paths[index];
const value = baseGet(object, path);
if (predicate(value, path)) {
baseSet(result, castPath(path, object), value);
}
}
return result;
}
export default basePickBy;

12
.internal/baseProperty.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* 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 object => object == null ? undefined : object[key];
}
export default baseProperty;

View File

@@ -0,0 +1,14 @@
import baseGet from './.internal/baseGet.js';
/**
* 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 object => baseGet(object, path);
}
export default basePropertyDeep;

View File

@@ -0,0 +1,12 @@
/**
* The base implementation of `propertyOf` without support for deep paths.
*
* @private
* @param {Object} object The object to query.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyOf(object) {
return key => object == null ? undefined : object[key];
}
export default basePropertyOf;

47
.internal/basePullAll.js Normal file
View File

@@ -0,0 +1,47 @@
import arrayMap from './.internal/arrayMap.js';
import baseIndexOf from './.internal/baseIndexOf.js';
import baseIndexOfWith from './.internal/baseIndexOfWith.js';
import copyArray from './.internal/copyArray.js';
/** Built-in value references. */
const splice = Array.prototype.splice;
/**
* The base implementation of `pullAllBy`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`.
*/
function basePullAll(array, values, iteratee, comparator) {
const indexOf = comparator ? baseIndexOfWith : baseIndexOf;
const length = values.length;
let index = -1;
let seen = array;
if (array === values) {
values = copyArray(values);
}
if (iteratee) {
seen = arrayMap(array, value => iteratee(value));
}
while (++index < length) {
let fromIndex = 0;
const value = values[index];
const computed = iteratee ? iteratee(value) : value;
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
}
export default basePullAll;

35
.internal/basePullAt.js Normal file
View File

@@ -0,0 +1,35 @@
import baseUnset from './.internal/baseUnset.js';
import isIndex from './.internal/isIndex.js';
/** Built-in value references. */
const splice = Array.prototype.splice;
/**
* The base implementation of `pullAt` without support for individual
* indexes or capturing the removed elements.
*
* @private
* @param {Array} array The array to modify.
* @param {number[]} indexes The indexes of elements to remove.
* @returns {Array} Returns `array`.
*/
function basePullAt(array, indexes) {
let length = array ? indexes.length : 0;
const lastIndex = length - 1;
while (length--) {
let previous;
const index = indexes[length];
if (length == lastIndex || index !== previous) {
previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
} else {
baseUnset(array, index);
}
}
}
return array;
}
export default basePullAt;

18
.internal/baseRandom.js Normal file
View File

@@ -0,0 +1,18 @@
/* Built-in method references for those with the same name as other `lodash` methods. */
const nativeFloor = Math.floor;
const nativeRandom = Math.random;
/**
* The base implementation of `random` without support for returning
* floating-point numbers.
*
* @private
* @param {number} lower The lower bound.
* @param {number} upper The upper bound.
* @returns {number} Returns the random number.
*/
function baseRandom(lower, upper) {
return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
}
export default baseRandom;

28
.internal/baseRange.js Normal file
View File

@@ -0,0 +1,28 @@
/* Built-in method references for those with the same name as other `lodash` methods. */
const nativeCeil = Math.ceil;
const nativeMax = Math.max;
/**
* The base implementation of `range` and `rangeRight` which doesn't
* coerce arguments.
*
* @private
* @param {number} start The start of the range.
* @param {number} end The end of the range.
* @param {number} step The value to increment or decrement by.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the range of numbers.
*/
function baseRange(start, end, step, fromRight) {
let index = -1;
let length = nativeMax(nativeCeil((end - start) / (step || 1)), 0);
const result = Array(length);
while (length--) {
result[fromRight ? length : ++index] = start;
start += step;
}
return result;
}
export default baseRange;

23
.internal/baseReduce.js Normal file
View File

@@ -0,0 +1,23 @@
/**
* The base implementation of `reduce` and `reduceRight` 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, (value, index, collection) => {
accumulator = initAccum
? (initAccum = false, value)
: iteratee(accumulator, value, index, collection);
});
return accumulator;
}
export default baseReduce;

35
.internal/baseRepeat.js Normal file
View File

@@ -0,0 +1,35 @@
/** Used as references for various `Number` constants. */
const MAX_SAFE_INTEGER = 9007199254740991;
/* Built-in method references for those with the same name as other `lodash` methods. */
const nativeFloor = Math.floor;
/**
* The base implementation of `repeat` which doesn't coerce arguments.
*
* @private
* @param {string} string The string to repeat.
* @param {number} n The number of times to repeat the string.
* @returns {string} Returns the repeated string.
*/
function baseRepeat(string, n) {
let result = '';
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
return result;
}
// Leverage the exponentiation by squaring algorithm for a faster repeat.
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
do {
if (n % 2) {
result += string;
}
n = nativeFloor(n / 2);
if (n) {
string += string;
}
} while (n);
return result;
}
export default baseRepeat;

Some files were not shown because too many files have changed in this diff Show More