mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f10bb8b80b | ||
|
|
b7e3b3febd | ||
|
|
e8cff1ef54 | ||
|
|
723c02dbfa | ||
|
|
ce0b51888c | ||
|
|
a83b4ebd53 | ||
|
|
7da4c55415 | ||
|
|
9055c4e483 | ||
|
|
2b1eb3f480 | ||
|
|
94ba2e24e8 | ||
|
|
8bff780a94 | ||
|
|
f18e5950b9 | ||
|
|
365d103439 | ||
|
|
466c67a8b6 |
29
LICENSE
29
LICENSE
@@ -1,7 +1,17 @@
|
||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
||||
Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
|
||||
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/lodash/lodash
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
====
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
@@ -20,3 +30,18 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
Copyright and related rights for sample code are waived via CC0. Sample
|
||||
code is defined as all source code displayed within the prose of the
|
||||
documentation.
|
||||
|
||||
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
====
|
||||
|
||||
Files located in the node_modules and vendor directories are externally
|
||||
maintained libraries used by this software which have their own
|
||||
licenses; we recommend you read them, as their terms may differ from the
|
||||
terms above.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# lodash-es v4.0.1
|
||||
# lodash-es v4.10.0
|
||||
|
||||
The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
|
||||
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
|
||||
|
||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||
```bash
|
||||
$ lodash modularize exports=es -o ./
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.0.1-es) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.10.0-es) for more details.
|
||||
|
||||
7
_DataView.js
Normal file
7
_DataView.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import getNative from './_getNative';
|
||||
import root from './_root';
|
||||
|
||||
/* Built-in method references that are verified to be native. */
|
||||
var DataView = getNative(root, 'DataView');
|
||||
|
||||
export default DataView;
|
||||
@@ -1,12 +1,13 @@
|
||||
import nativeCreate from './nativeCreate';
|
||||
import nativeCreate from './_nativeCreate';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Creates an hash object.
|
||||
* Creates a hash object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @returns {Object} Returns the new hash object.
|
||||
*/
|
||||
function Hash() {}
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseCreate from './baseCreate';
|
||||
import baseLodash from './baseLodash';
|
||||
import baseCreate from './_baseCreate';
|
||||
import baseLodash from './_baseLodash';
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295;
|
||||
@@ -8,6 +8,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
|
||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {*} value The value to wrap.
|
||||
*/
|
||||
function LazyWrapper(value) {
|
||||
@@ -20,6 +21,7 @@ function LazyWrapper(value) {
|
||||
this.__views__ = [];
|
||||
}
|
||||
|
||||
// Ensure `LazyWrapper` is an instance of `baseLodash`.
|
||||
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
||||
LazyWrapper.prototype.constructor = LazyWrapper;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import baseCreate from './baseCreate';
|
||||
import baseLodash from './baseLodash';
|
||||
import baseCreate from './_baseCreate';
|
||||
import baseLodash from './_baseLodash';
|
||||
|
||||
/**
|
||||
* The base constructor for creating `lodash` wrapper objects.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to wrap.
|
||||
* @param {boolean} [chainAll] Enable chaining for all wrapper methods.
|
||||
* @param {boolean} [chainAll] Enable explicit method chain sequences.
|
||||
*/
|
||||
function LodashWrapper(value, chainAll) {
|
||||
this.__wrapped__ = value;
|
||||
@@ -1,5 +1,5 @@
|
||||
import getNative from './getNative';
|
||||
import root from './root';
|
||||
import getNative from './_getNative';
|
||||
import root from './_root';
|
||||
|
||||
/* Built-in method references that are verified to be native. */
|
||||
var Map = getNative(root, 'Map');
|
||||
@@ -1,13 +1,14 @@
|
||||
import mapClear from './mapClear';
|
||||
import mapDelete from './mapDelete';
|
||||
import mapGet from './mapGet';
|
||||
import mapHas from './mapHas';
|
||||
import mapSet from './mapSet';
|
||||
import mapClear from './_mapClear';
|
||||
import mapDelete from './_mapDelete';
|
||||
import mapGet from './_mapGet';
|
||||
import mapHas from './_mapHas';
|
||||
import mapSet from './_mapSet';
|
||||
|
||||
/**
|
||||
* Creates a map cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function MapCache(values) {
|
||||
@@ -21,7 +22,7 @@ function MapCache(values) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add functions to the `MapCache`.
|
||||
// Add methods to `MapCache`.
|
||||
MapCache.prototype.clear = mapClear;
|
||||
MapCache.prototype['delete'] = mapDelete;
|
||||
MapCache.prototype.get = mapGet;
|
||||
7
_Promise.js
Normal file
7
_Promise.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import getNative from './_getNative';
|
||||
import root from './_root';
|
||||
|
||||
/* Built-in method references that are verified to be native. */
|
||||
var Promise = getNative(root, 'Promise');
|
||||
|
||||
export default Promise;
|
||||
@@ -1,4 +1,4 @@
|
||||
import root from './root';
|
||||
import root from './_root';
|
||||
|
||||
/** Built-in value references. */
|
||||
var Reflect = root.Reflect;
|
||||
@@ -1,5 +1,5 @@
|
||||
import getNative from './getNative';
|
||||
import root from './root';
|
||||
import getNative from './_getNative';
|
||||
import root from './_root';
|
||||
|
||||
/* Built-in method references that are verified to be native. */
|
||||
var Set = getNative(root, 'Set');
|
||||
@@ -1,11 +1,12 @@
|
||||
import MapCache from './MapCache';
|
||||
import cachePush from './cachePush';
|
||||
import MapCache from './_MapCache';
|
||||
import cachePush from './_cachePush';
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a set cache object to store unique values.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function SetCache(values) {
|
||||
@@ -18,7 +19,7 @@ function SetCache(values) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add functions to the `SetCache`.
|
||||
// Add methods to `SetCache`.
|
||||
SetCache.prototype.push = cachePush;
|
||||
|
||||
export default SetCache;
|
||||
@@ -1,13 +1,14 @@
|
||||
import stackClear from './stackClear';
|
||||
import stackDelete from './stackDelete';
|
||||
import stackGet from './stackGet';
|
||||
import stackHas from './stackHas';
|
||||
import stackSet from './stackSet';
|
||||
import stackClear from './_stackClear';
|
||||
import stackDelete from './_stackDelete';
|
||||
import stackGet from './_stackGet';
|
||||
import stackHas from './_stackHas';
|
||||
import stackSet from './_stackSet';
|
||||
|
||||
/**
|
||||
* Creates a stack cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function Stack(values) {
|
||||
@@ -21,7 +22,7 @@ function Stack(values) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add functions to the `Stack` cache.
|
||||
// Add methods to `Stack`.
|
||||
Stack.prototype.clear = stackClear;
|
||||
Stack.prototype['delete'] = stackDelete;
|
||||
Stack.prototype.get = stackGet;
|
||||
@@ -1,4 +1,4 @@
|
||||
import root from './root';
|
||||
import root from './_root';
|
||||
|
||||
/** Built-in value references. */
|
||||
var Symbol = root.Symbol;
|
||||
@@ -1,4 +1,4 @@
|
||||
import root from './root';
|
||||
import root from './_root';
|
||||
|
||||
/** Built-in value references. */
|
||||
var Uint8Array = root.Uint8Array;
|
||||
@@ -1,5 +1,5 @@
|
||||
import getNative from './getNative';
|
||||
import root from './root';
|
||||
import getNative from './_getNative';
|
||||
import root from './_root';
|
||||
|
||||
/* Built-in method references that are verified to be native. */
|
||||
var WeakMap = getNative(root, 'WeakMap');
|
||||
@@ -7,6 +7,7 @@
|
||||
* @returns {Object} Returns `map`.
|
||||
*/
|
||||
function addMapEntry(map, pair) {
|
||||
// Don't return `Map#set` because it doesn't return the map instance in IE 11.
|
||||
map.set(pair[0], pair[1]);
|
||||
return map;
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
* @private
|
||||
* @param {Function} func The function to invoke.
|
||||
* @param {*} thisArg The `this` binding of `func`.
|
||||
* @param {...*} [args] The arguments to invoke `func` with.
|
||||
* @param {Array} args The arguments to invoke `func` with.
|
||||
* @returns {*} Returns the result of `func`.
|
||||
*/
|
||||
function apply(func, thisArg, args) {
|
||||
var length = args ? args.length : 0;
|
||||
var length = args.length;
|
||||
switch (length) {
|
||||
case 0: return func.call(thisArg);
|
||||
case 1: return func.call(thisArg, args[0]);
|
||||
22
_arrayAggregator.js
Normal file
22
_arrayAggregator.js
Normal 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) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
setter(accumulator, value, iteratee(value), array);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export default arrayAggregator;
|
||||
@@ -5,7 +5,8 @@
|
||||
* @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`.
|
||||
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`.
|
||||
*/
|
||||
function arrayEvery(array, predicate) {
|
||||
var index = -1,
|
||||
@@ -10,13 +10,13 @@
|
||||
function arrayFilter(array, predicate) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (predicate(value, index, array)) {
|
||||
result[++resIndex] = value;
|
||||
result[resIndex++] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseIndexOf from './baseIndexOf';
|
||||
import baseIndexOf from './_baseIndexOf';
|
||||
|
||||
/**
|
||||
* A specialized version of `_.includes` for arrays without support for
|
||||
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* A specialized version of `_.includesWith` for arrays without support for
|
||||
* specifying an index to search from.
|
||||
* This function is like `arrayIncludes` except that it accepts a comparator.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
@@ -6,7 +6,8 @@
|
||||
* @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.
|
||||
* @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) {
|
||||
@@ -6,7 +6,8 @@
|
||||
* @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.
|
||||
* @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) {
|
||||
@@ -5,7 +5,8 @@
|
||||
* @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`.
|
||||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||
* else `false`.
|
||||
*/
|
||||
function arraySome(array, predicate) {
|
||||
var index = -1,
|
||||
@@ -1,4 +1,4 @@
|
||||
import eq from '../eq';
|
||||
import eq from './eq';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -1,7 +1,8 @@
|
||||
import eq from '../eq';
|
||||
import eq from './eq';
|
||||
|
||||
/**
|
||||
* This function is like `assignValue` except that it doesn't assign `undefined` values.
|
||||
* This function is like `assignValue` except that it doesn't assign
|
||||
* `undefined` values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
@@ -1,4 +1,4 @@
|
||||
import eq from '../eq';
|
||||
import eq from './eq';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -18,8 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
*/
|
||||
function assignValue(object, key, value) {
|
||||
var objValue = object[key];
|
||||
if ((!eq(objValue, value) ||
|
||||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import assocIndexOf from './assocIndexOf';
|
||||
import assocIndexOf from './_assocIndexOf';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
@@ -10,7 +10,7 @@ var splice = arrayProto.splice;
|
||||
* Removes `key` and its value from the associative array.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Array} array The array to modify.
|
||||
* @param {string} key The key of the value to remove.
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
import assocIndexOf from './assocIndexOf';
|
||||
import assocIndexOf from './_assocIndexOf';
|
||||
|
||||
/**
|
||||
* Gets the associative array value for `key`.
|
||||
@@ -1,4 +1,4 @@
|
||||
import assocIndexOf from './assocIndexOf';
|
||||
import assocIndexOf from './_assocIndexOf';
|
||||
|
||||
/**
|
||||
* Checks if an associative array value for `key` exists.
|
||||
@@ -1,8 +1,7 @@
|
||||
import eq from '../eq';
|
||||
import eq from './eq';
|
||||
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `key` is found in `array`
|
||||
* of key-value pairs.
|
||||
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
@@ -1,4 +1,4 @@
|
||||
import assocIndexOf from './assocIndexOf';
|
||||
import assocIndexOf from './_assocIndexOf';
|
||||
|
||||
/**
|
||||
* Sets the associative array `key` to `value`.
|
||||
21
_baseAggregator.js
Normal file
21
_baseAggregator.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import baseEach from './_baseEach';
|
||||
|
||||
/**
|
||||
* 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, function(value, key, collection) {
|
||||
setter(accumulator, value, iteratee(value), collection);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export default baseAggregator;
|
||||
@@ -1,5 +1,5 @@
|
||||
import copyObject from './copyObject';
|
||||
import keys from '../keys';
|
||||
import copyObject from './_copyObject';
|
||||
import keys from './keys';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.assign` without support for multiple sources
|
||||
@@ -1,4 +1,4 @@
|
||||
import get from '../get';
|
||||
import get from './get';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.at` without support for individual paths.
|
||||
@@ -1,17 +1,20 @@
|
||||
import Stack from './Stack';
|
||||
import arrayEach from './arrayEach';
|
||||
import assignValue from './assignValue';
|
||||
import baseAssign from './baseAssign';
|
||||
import baseForOwn from './baseForOwn';
|
||||
import copyArray from './copyArray';
|
||||
import copySymbols from './copySymbols';
|
||||
import getTag from './getTag';
|
||||
import initCloneArray from './initCloneArray';
|
||||
import initCloneByTag from './initCloneByTag';
|
||||
import initCloneObject from './initCloneObject';
|
||||
import isArray from '../isArray';
|
||||
import isHostObject from './isHostObject';
|
||||
import isObject from '../isObject';
|
||||
import Stack from './_Stack';
|
||||
import arrayEach from './_arrayEach';
|
||||
import assignValue from './_assignValue';
|
||||
import baseAssign from './_baseAssign';
|
||||
import cloneBuffer from './_cloneBuffer';
|
||||
import copyArray from './_copyArray';
|
||||
import copySymbols from './_copySymbols';
|
||||
import getAllKeys from './_getAllKeys';
|
||||
import getTag from './_getTag';
|
||||
import initCloneArray from './_initCloneArray';
|
||||
import initCloneByTag from './_initCloneByTag';
|
||||
import initCloneObject from './_initCloneObject';
|
||||
import isArray from './isArray';
|
||||
import isBuffer from './isBuffer';
|
||||
import isHostObject from './_isHostObject';
|
||||
import isObject from './isObject';
|
||||
import keys from './keys';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var argsTag = '[object Arguments]',
|
||||
@@ -31,6 +34,7 @@ var argsTag = '[object Arguments]',
|
||||
weakMapTag = '[object WeakMap]';
|
||||
|
||||
var arrayBufferTag = '[object ArrayBuffer]',
|
||||
dataViewTag = '[object DataView]',
|
||||
float32Tag = '[object Float32Array]',
|
||||
float64Tag = '[object Float64Array]',
|
||||
int8Tag = '[object Int8Array]',
|
||||
@@ -44,16 +48,16 @@ var arrayBufferTag = '[object ArrayBuffer]',
|
||||
/** Used to identify `toStringTag` values supported by `_.clone`. */
|
||||
var cloneableTags = {};
|
||||
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
||||
cloneableTags[arrayBufferTag] = 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[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;
|
||||
|
||||
@@ -64,13 +68,14 @@ cloneableTags[weakMapTag] = false;
|
||||
* @private
|
||||
* @param {*} value The value to clone.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @param {boolean} [isFull] Specify a clone including 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, isDeep, customizer, key, object, stack) {
|
||||
function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||||
var result;
|
||||
if (customizer) {
|
||||
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||||
@@ -91,6 +96,9 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
||||
var tag = getTag(value),
|
||||
isFunc = tag == funcTag || tag == genTag;
|
||||
|
||||
if (isBuffer(value)) {
|
||||
return cloneBuffer(value, isDeep);
|
||||
}
|
||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||
if (isHostObject(value)) {
|
||||
return object ? value : {};
|
||||
@@ -100,9 +108,10 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
||||
return copySymbols(value, baseAssign(result, value));
|
||||
}
|
||||
} else {
|
||||
return cloneableTags[tag]
|
||||
? initCloneByTag(value, tag, isDeep)
|
||||
: (object ? value : {});
|
||||
if (!cloneableTags[tag]) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneByTag(value, tag, baseClone, isDeep);
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
@@ -113,11 +122,18 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
||||
}
|
||||
stack.set(value, result);
|
||||
|
||||
if (!isArr) {
|
||||
var props = isFull ? getAllKeys(value) : keys(value);
|
||||
}
|
||||
// Recursively populate clone (susceptible to call stack limits).
|
||||
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
||||
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack));
|
||||
arrayEach(props || value, function(subValue, key) {
|
||||
if (props) {
|
||||
key = subValue;
|
||||
subValue = value[key];
|
||||
}
|
||||
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
|
||||
});
|
||||
return isArr ? result : copySymbols(value, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
export default baseClone;
|
||||
@@ -1,4 +1,4 @@
|
||||
import keys from '../keys';
|
||||
import keys from './keys';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.conforms` which doesn't clone `source`.
|
||||
@@ -21,7 +21,8 @@ function baseConforms(source) {
|
||||
predicate = source[key],
|
||||
value = object[key];
|
||||
|
||||
if ((value === undefined && !(key in Object(object))) || !predicate(value)) {
|
||||
if ((value === undefined &&
|
||||
!(key in Object(object))) || !predicate(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
18
_baseCreate.js
Normal file
18
_baseCreate.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import isObject from './isObject';
|
||||
|
||||
/** 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} prototype The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
|
||||
export default baseCreate;
|
||||
@@ -8,7 +8,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
* @private
|
||||
* @param {Function} func The function to delay.
|
||||
* @param {number} wait The number of milliseconds to delay invocation.
|
||||
* @param {Object} args The arguments provide to `func`.
|
||||
* @param {Object} args The arguments to provide to `func`.
|
||||
* @returns {number} Returns the timer id.
|
||||
*/
|
||||
function baseDelay(func, wait, args) {
|
||||
@@ -1,16 +1,16 @@
|
||||
import SetCache from './SetCache';
|
||||
import arrayIncludes from './arrayIncludes';
|
||||
import arrayIncludesWith from './arrayIncludesWith';
|
||||
import arrayMap from './arrayMap';
|
||||
import baseUnary from './baseUnary';
|
||||
import cacheHas from './cacheHas';
|
||||
import SetCache from './_SetCache';
|
||||
import arrayIncludes from './_arrayIncludes';
|
||||
import arrayIncludesWith from './_arrayIncludesWith';
|
||||
import arrayMap from './_arrayMap';
|
||||
import baseUnary from './_baseUnary';
|
||||
import cacheHas from './_cacheHas';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.difference` without support for
|
||||
* excluding multiple arrays or iteratee shorthands.
|
||||
* The base implementation of methods like `_.difference` without support
|
||||
* for excluding multiple arrays or iteratee shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseForOwn from './baseForOwn';
|
||||
import createBaseEach from './createBaseEach';
|
||||
import baseForOwn from './_baseForOwn';
|
||||
import createBaseEach from './_createBaseEach';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseForOwnRight from './baseForOwnRight';
|
||||
import createBaseEach from './createBaseEach';
|
||||
import baseForOwnRight from './_baseForOwnRight';
|
||||
import createBaseEach from './_createBaseEach';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.forEachRight` without support for iteratee shorthands.
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseEach from './baseEach';
|
||||
import baseEach from './_baseEach';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.every` without support for iteratee shorthands.
|
||||
@@ -6,7 +6,8 @@ import baseEach from './baseEach';
|
||||
* @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`
|
||||
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`
|
||||
*/
|
||||
function baseEvery(collection, predicate) {
|
||||
var result = true;
|
||||
@@ -1,5 +1,5 @@
|
||||
import toInteger from '../toInteger';
|
||||
import toLength from '../toLength';
|
||||
import toInteger from './toInteger';
|
||||
import toLength from './toLength';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.fill` without an iteratee call guard.
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseEach from './baseEach';
|
||||
import baseEach from './_baseEach';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.filter` without support for iteratee shorthands.
|
||||
@@ -7,7 +7,8 @@
|
||||
* @param {Array|Object} collection The collection to search.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||
* @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself.
|
||||
* @param {boolean} [retKey] Specify returning the key of the found element
|
||||
* instead of the element itself.
|
||||
* @returns {*} Returns the found element or its key, else `undefined`.
|
||||
*/
|
||||
function baseFind(collection, predicate, eachFunc, retKey) {
|
||||
@@ -1,31 +1,30 @@
|
||||
import arrayPush from './arrayPush';
|
||||
import isArguments from '../isArguments';
|
||||
import isArray from '../isArray';
|
||||
import isArrayLikeObject from '../isArrayLikeObject';
|
||||
import arrayPush from './_arrayPush';
|
||||
import isFlattenable from './_isFlattenable';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.flatten` with support for restricting flattening.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @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, isDeep, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
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 (isArrayLikeObject(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
if (depth > 0 && predicate(value)) {
|
||||
if (depth > 1) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
baseFlatten(value, isDeep, isStrict, result);
|
||||
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import createBaseFor from './createBaseFor';
|
||||
import createBaseFor from './_createBaseFor';
|
||||
|
||||
/**
|
||||
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
||||
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
||||
* each property. Iteratee functions may exit iteration early by explicitly
|
||||
* returning `false`.
|
||||
* 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.
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseFor from './baseFor';
|
||||
import keys from '../keys';
|
||||
import baseFor from './_baseFor';
|
||||
import keys from './keys';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseForRight from './baseForRight';
|
||||
import keys from '../keys';
|
||||
import baseForRight from './_baseForRight';
|
||||
import keys from './keys';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.forOwnRight` without support for iteratee shorthands.
|
||||
@@ -1,4 +1,4 @@
|
||||
import createBaseFor from './createBaseFor';
|
||||
import createBaseFor from './_createBaseFor';
|
||||
|
||||
/**
|
||||
* This function is like `baseFor` except that it iterates over properties
|
||||
@@ -1,9 +1,9 @@
|
||||
import arrayFilter from './arrayFilter';
|
||||
import isFunction from '../isFunction';
|
||||
import arrayFilter from './_arrayFilter';
|
||||
import isFunction from './isFunction';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.functions` which creates an array of
|
||||
* `object` function property names filtered from those provided.
|
||||
* `object` function property names filtered from `props`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to inspect.
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseToPath from './baseToPath';
|
||||
import isKey from './isKey';
|
||||
import castPath from './_castPath';
|
||||
import isKey from './_isKey';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.get` without support for default values.
|
||||
@@ -10,7 +10,7 @@ import isKey from './isKey';
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function baseGet(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
22
_baseGetAllKeys.js
Normal file
22
_baseGetAllKeys.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import arrayPush from './_arrayPush';
|
||||
import isArray from './isArray';
|
||||
|
||||
/**
|
||||
* 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(object)
|
||||
? result
|
||||
: arrayPush(result, symbolsFunc(object));
|
||||
}
|
||||
|
||||
export default baseGetAllKeys;
|
||||
@@ -1,12 +1,11 @@
|
||||
import getPrototype from './_getPrototype';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Built-in value references. */
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.has` without support for deep paths.
|
||||
*
|
||||
@@ -20,7 +19,7 @@ function baseHas(object, key) {
|
||||
// that are composed entirely of index properties, return `false` for
|
||||
// `hasOwnProperty` checks of them.
|
||||
return hasOwnProperty.call(object, key) ||
|
||||
(typeof object == 'object' && key in object && getPrototypeOf(object) === null);
|
||||
(typeof object == 'object' && key in object && getPrototype(object) === null);
|
||||
}
|
||||
|
||||
export default baseHas;
|
||||
@@ -1,4 +1,4 @@
|
||||
import indexOfNaN from './indexOfNaN';
|
||||
import indexOfNaN from './_indexOfNaN';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||||
23
_baseIndexOfWith.js
Normal file
23
_baseIndexOfWith.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* This function is like `baseIndexOf` except that it accepts a comparator.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @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) {
|
||||
var index = fromIndex - 1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (comparator(array[index], value)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
export default baseIndexOfWith;
|
||||
@@ -1,9 +1,12 @@
|
||||
import SetCache from './SetCache';
|
||||
import arrayIncludes from './arrayIncludes';
|
||||
import arrayIncludesWith from './arrayIncludesWith';
|
||||
import arrayMap from './arrayMap';
|
||||
import baseUnary from './baseUnary';
|
||||
import cacheHas from './cacheHas';
|
||||
import SetCache from './_SetCache';
|
||||
import arrayIncludes from './_arrayIncludes';
|
||||
import arrayIncludesWith from './_arrayIncludesWith';
|
||||
import arrayMap from './_arrayMap';
|
||||
import baseUnary from './_baseUnary';
|
||||
import cacheHas from './_cacheHas';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.intersection`, without support
|
||||
@@ -17,9 +20,11 @@ import cacheHas from './cacheHas';
|
||||
*/
|
||||
function baseIntersection(arrays, iteratee, comparator) {
|
||||
var includes = comparator ? arrayIncludesWith : arrayIncludes,
|
||||
length = arrays[0].length,
|
||||
othLength = arrays.length,
|
||||
othIndex = othLength,
|
||||
caches = Array(othLength),
|
||||
maxLength = Infinity,
|
||||
result = [];
|
||||
|
||||
while (othIndex--) {
|
||||
@@ -27,26 +32,32 @@ function baseIntersection(arrays, iteratee, comparator) {
|
||||
if (othIndex && iteratee) {
|
||||
array = arrayMap(array, baseUnary(iteratee));
|
||||
}
|
||||
caches[othIndex] = !comparator && (iteratee || array.length >= 120)
|
||||
maxLength = nativeMin(array.length, maxLength);
|
||||
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
|
||||
? new SetCache(othIndex && array)
|
||||
: undefined;
|
||||
}
|
||||
array = arrays[0];
|
||||
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
seen = caches[0];
|
||||
|
||||
outer:
|
||||
while (++index < length) {
|
||||
while (++index < length && result.length < maxLength) {
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
|
||||
var othIndex = othLength;
|
||||
if (!(seen
|
||||
? cacheHas(seen, computed)
|
||||
: includes(result, computed, comparator)
|
||||
)) {
|
||||
othIndex = othLength;
|
||||
while (--othIndex) {
|
||||
var cache = caches[othIndex];
|
||||
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
|
||||
if (!(cache
|
||||
? cacheHas(cache, computed)
|
||||
: includes(arrays[othIndex], computed, comparator))
|
||||
) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
21
_baseInverter.js
Normal file
21
_baseInverter.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import baseForOwn from './_baseForOwn';
|
||||
|
||||
/**
|
||||
* 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, function(value, key, object) {
|
||||
setter(accumulator, iteratee(value), key, object);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
export default baseInverter;
|
||||
@@ -1,8 +1,8 @@
|
||||
import apply from './apply';
|
||||
import baseToPath from './baseToPath';
|
||||
import isKey from './isKey';
|
||||
import last from '../last';
|
||||
import parent from './parent';
|
||||
import apply from './_apply';
|
||||
import castPath from './_castPath';
|
||||
import isKey from './_isKey';
|
||||
import last from './last';
|
||||
import parent from './_parent';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.invoke` without support for individual
|
||||
@@ -16,7 +16,7 @@ import parent from './parent';
|
||||
*/
|
||||
function baseInvoke(object, path, args) {
|
||||
if (!isKey(path, object)) {
|
||||
path = baseToPath(path);
|
||||
path = castPath(path);
|
||||
object = parent(object, path);
|
||||
path = last(path);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import baseIsEqualDeep from './baseIsEqualDeep';
|
||||
import isObject from '../isObject';
|
||||
import isObjectLike from '../isObjectLike';
|
||||
import baseIsEqualDeep from './_baseIsEqualDeep';
|
||||
import isObject from './isObject';
|
||||
import isObjectLike from './isObjectLike';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isEqual` which supports partial comparisons
|
||||
@@ -1,11 +1,11 @@
|
||||
import Stack from './Stack';
|
||||
import equalArrays from './equalArrays';
|
||||
import equalByTag from './equalByTag';
|
||||
import equalObjects from './equalObjects';
|
||||
import getTag from './getTag';
|
||||
import isArray from '../isArray';
|
||||
import isHostObject from './isHostObject';
|
||||
import isTypedArray from '../isTypedArray';
|
||||
import Stack from './_Stack';
|
||||
import equalArrays from './_equalArrays';
|
||||
import equalByTag from './_equalByTag';
|
||||
import equalObjects from './_equalObjects';
|
||||
import getTag from './_getTag';
|
||||
import isArray from './isArray';
|
||||
import isHostObject from './_isHostObject';
|
||||
import isTypedArray from './isTypedArray';
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
var PARTIAL_COMPARE_FLAG = 2;
|
||||
@@ -31,7 +31,8 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
|
||||
* for more details.
|
||||
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
@@ -43,41 +44,39 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
if (!objIsArr) {
|
||||
objTag = getTag(object);
|
||||
if (objTag == argsTag) {
|
||||
objTag = objectTag;
|
||||
} else if (objTag != objectTag) {
|
||||
objIsArr = isTypedArray(object);
|
||||
}
|
||||
objTag = objTag == argsTag ? objectTag : objTag;
|
||||
}
|
||||
if (!othIsArr) {
|
||||
othTag = getTag(other);
|
||||
if (othTag == argsTag) {
|
||||
othTag = objectTag;
|
||||
} else if (othTag != objectTag) {
|
||||
othIsArr = isTypedArray(other);
|
||||
}
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
||||
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
|
||||
if (isSameTag && !objIsObj) {
|
||||
stack || (stack = new Stack);
|
||||
return (objIsArr || isTypedArray(object))
|
||||
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
|
||||
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
|
||||
}
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||
if (!isPartial) {
|
||||
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
||||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||
|
||||
if (objIsWrapped || othIsWrapped) {
|
||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||
var objUnwrapped = objIsWrapped ? object.value() : object,
|
||||
othUnwrapped = othIsWrapped ? other.value() : other;
|
||||
|
||||
stack || (stack = new Stack);
|
||||
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
|
||||
}
|
||||
}
|
||||
if (!isSameTag) {
|
||||
return false;
|
||||
}
|
||||
stack || (stack = new Stack);
|
||||
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
|
||||
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
||||
}
|
||||
|
||||
export default baseIsEqualDeep;
|
||||
@@ -1,5 +1,5 @@
|
||||
import Stack from './Stack';
|
||||
import baseIsEqual from './baseIsEqual';
|
||||
import Stack from './_Stack';
|
||||
import baseIsEqual from './_baseIsEqual';
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
var UNORDERED_COMPARE_FLAG = 1,
|
||||
@@ -44,9 +44,10 @@ function baseIsMatch(object, source, matchData, customizer) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
var stack = new Stack,
|
||||
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined;
|
||||
|
||||
var stack = new Stack;
|
||||
if (customizer) {
|
||||
var result = customizer(objValue, srcValue, key, object, source, stack);
|
||||
}
|
||||
if (!(result === undefined
|
||||
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
|
||||
: result
|
||||
@@ -1,8 +1,8 @@
|
||||
import baseMatches from './baseMatches';
|
||||
import baseMatchesProperty from './baseMatchesProperty';
|
||||
import identity from '../identity';
|
||||
import isArray from '../isArray';
|
||||
import property from '../property';
|
||||
import baseMatches from './_baseMatches';
|
||||
import baseMatchesProperty from './_baseMatchesProperty';
|
||||
import identity from './identity';
|
||||
import isArray from './isArray';
|
||||
import property from './property';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.iteratee`.
|
||||
@@ -12,14 +12,15 @@ import property from '../property';
|
||||
* @returns {Function} Returns the iteratee.
|
||||
*/
|
||||
function baseIteratee(value) {
|
||||
var type = typeof value;
|
||||
if (type == 'function') {
|
||||
// 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;
|
||||
}
|
||||
if (type == 'object') {
|
||||
if (typeof value == 'object') {
|
||||
return isArray(value)
|
||||
? baseMatchesProperty(value[0], value[1])
|
||||
: baseMatches(value);
|
||||
@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
|
||||
* property of prototypes or treat sparse arrays as dense.
|
||||
*
|
||||
* @private
|
||||
* @type Function
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
import Reflect from './Reflect';
|
||||
import iteratorToArray from './iteratorToArray';
|
||||
import Reflect from './_Reflect';
|
||||
import iteratorToArray from './_iteratorToArray';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* The function whose prototype all chaining wrappers inherit from.
|
||||
* The function whose prototype chain sequence wrappers inherit from.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
import baseEach from './baseEach';
|
||||
import isArrayLike from '../isArrayLike';
|
||||
import baseEach from './_baseEach';
|
||||
import isArrayLike from './isArrayLike';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.map` without support for iteratee shorthands.
|
||||
@@ -1,5 +1,6 @@
|
||||
import baseIsMatch from './baseIsMatch';
|
||||
import getMatchData from './getMatchData';
|
||||
import baseIsMatch from './_baseIsMatch';
|
||||
import getMatchData from './_getMatchData';
|
||||
import matchesStrictComparable from './_matchesStrictComparable';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.matches` which doesn't clone `source`.
|
||||
@@ -11,16 +12,7 @@ import getMatchData from './getMatchData';
|
||||
function baseMatches(source) {
|
||||
var matchData = getMatchData(source);
|
||||
if (matchData.length == 1 && matchData[0][2]) {
|
||||
var key = matchData[0][0],
|
||||
value = matchData[0][1];
|
||||
|
||||
return function(object) {
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
return object[key] === value &&
|
||||
(value !== undefined || (key in Object(object)));
|
||||
};
|
||||
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
||||
}
|
||||
return function(object) {
|
||||
return object === source || baseIsMatch(object, source, matchData);
|
||||
@@ -1,6 +1,9 @@
|
||||
import baseIsEqual from './baseIsEqual';
|
||||
import get from '../get';
|
||||
import hasIn from '../hasIn';
|
||||
import baseIsEqual from './_baseIsEqual';
|
||||
import get from './get';
|
||||
import hasIn from './hasIn';
|
||||
import isKey from './_isKey';
|
||||
import isStrictComparable from './_isStrictComparable';
|
||||
import matchesStrictComparable from './_matchesStrictComparable';
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
var UNORDERED_COMPARE_FLAG = 1,
|
||||
@@ -15,6 +18,9 @@ var UNORDERED_COMPARE_FLAG = 1,
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseMatchesProperty(path, srcValue) {
|
||||
if (isKey(path) && isStrictComparable(srcValue)) {
|
||||
return matchesStrictComparable(path, srcValue);
|
||||
}
|
||||
return function(object) {
|
||||
var objValue = get(object, path);
|
||||
return (objValue === undefined && objValue === srcValue)
|
||||
20
_baseMean.js
Normal file
20
_baseMean.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import baseSum from './_baseSum';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var NAN = 0 / 0;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.mean` and `_.meanBy` without support for
|
||||
* iteratee shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} iteratee The function invoked per iteration.
|
||||
* @returns {number} Returns the mean.
|
||||
*/
|
||||
function baseMean(array, iteratee) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? (baseSum(array, iteratee) / length) : NAN;
|
||||
}
|
||||
|
||||
export default baseMean;
|
||||
@@ -1,11 +1,11 @@
|
||||
import Stack from './Stack';
|
||||
import arrayEach from './arrayEach';
|
||||
import assignMergeValue from './assignMergeValue';
|
||||
import baseMergeDeep from './baseMergeDeep';
|
||||
import isArray from '../isArray';
|
||||
import isObject from '../isObject';
|
||||
import isTypedArray from '../isTypedArray';
|
||||
import keysIn from '../keysIn';
|
||||
import Stack from './_Stack';
|
||||
import arrayEach from './_arrayEach';
|
||||
import assignMergeValue from './_assignMergeValue';
|
||||
import baseMergeDeep from './_baseMergeDeep';
|
||||
import isArray from './isArray';
|
||||
import isObject from './isObject';
|
||||
import isTypedArray from './isTypedArray';
|
||||
import keysIn from './keysIn';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.merge` without support for multiple sources.
|
||||
@@ -15,13 +15,16 @@ import keysIn from '../keysIn';
|
||||
* @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.
|
||||
* @param {Object} [stack] Tracks traversed source values and their merged
|
||||
* counterparts.
|
||||
*/
|
||||
function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
if (object === source) {
|
||||
return;
|
||||
}
|
||||
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
|
||||
if (!(isArray(source) || isTypedArray(source))) {
|
||||
var props = keysIn(source);
|
||||
}
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
}
|
||||
else {
|
||||
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
|
||||
var newValue = customizer
|
||||
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
if (newValue === undefined) {
|
||||
newValue = srcValue;
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import assignMergeValue from './assignMergeValue';
|
||||
import baseClone from './baseClone';
|
||||
import copyArray from './copyArray';
|
||||
import isArguments from '../isArguments';
|
||||
import isArray from '../isArray';
|
||||
import isArrayLikeObject from '../isArrayLikeObject';
|
||||
import isFunction from '../isFunction';
|
||||
import isObject from '../isObject';
|
||||
import isPlainObject from '../isPlainObject';
|
||||
import isTypedArray from '../isTypedArray';
|
||||
import toPlainObject from '../toPlainObject';
|
||||
import assignMergeValue from './_assignMergeValue';
|
||||
import baseClone from './_baseClone';
|
||||
import copyArray from './_copyArray';
|
||||
import isArguments from './isArguments';
|
||||
import isArray from './isArray';
|
||||
import isArrayLikeObject from './isArrayLikeObject';
|
||||
import isFunction from './isFunction';
|
||||
import isObject from './isObject';
|
||||
import isPlainObject from './isPlainObject';
|
||||
import isTypedArray from './isTypedArray';
|
||||
import toPlainObject from './toPlainObject';
|
||||
|
||||
/**
|
||||
* A specialized version of `baseMerge` for arrays and objects which performs
|
||||
@@ -22,31 +22,36 @@ import toPlainObject from '../toPlainObject';
|
||||
* @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.
|
||||
* @param {Object} [stack] Tracks traversed source values and their merged
|
||||
* counterparts.
|
||||
*/
|
||||
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
||||
var objValue = object[key],
|
||||
srcValue = source[key],
|
||||
stacked = stack.get(srcValue) || stack.get(objValue);
|
||||
stacked = stack.get(srcValue);
|
||||
|
||||
if (stacked) {
|
||||
assignMergeValue(object, key, stacked);
|
||||
return;
|
||||
}
|
||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
||||
isCommon = newValue === undefined;
|
||||
var newValue = customizer
|
||||
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
var isCommon = newValue === undefined;
|
||||
|
||||
if (isCommon) {
|
||||
newValue = srcValue;
|
||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||
if (isArray(objValue)) {
|
||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
else if (isArrayLikeObject(objValue)) {
|
||||
newValue = copyArray(objValue);
|
||||
}
|
||||
else {
|
||||
newValue = baseClone(srcValue);
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
@@ -54,10 +59,11 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
newValue = toPlainObject(objValue);
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
newValue = baseClone(srcValue);
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -70,6 +76,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
||||
}
|
||||
stack['delete'](srcValue);
|
||||
assignMergeValue(object, key, newValue);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import arrayMap from './arrayMap';
|
||||
import baseIteratee from './baseIteratee';
|
||||
import baseMap from './baseMap';
|
||||
import baseSortBy from './baseSortBy';
|
||||
import compareMultiple from './compareMultiple';
|
||||
import arrayMap from './_arrayMap';
|
||||
import baseIteratee from './_baseIteratee';
|
||||
import baseMap from './_baseMap';
|
||||
import baseSortBy from './_baseSortBy';
|
||||
import compareMultiple from './_compareMultiple';
|
||||
import identity from './identity';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.orderBy` without param guards.
|
||||
@@ -14,12 +15,8 @@ import compareMultiple from './compareMultiple';
|
||||
* @returns {Array} Returns the new sorted array.
|
||||
*/
|
||||
function baseOrderBy(collection, iteratees, orders) {
|
||||
var index = -1,
|
||||
toIteratee = baseIteratee;
|
||||
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
|
||||
return toIteratee(iteratee);
|
||||
});
|
||||
var index = -1;
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
|
||||
|
||||
var result = baseMap(collection, function(value, key, collection) {
|
||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||
@@ -1,12 +1,12 @@
|
||||
import arrayReduce from './arrayReduce';
|
||||
import arrayReduce from './_arrayReduce';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pick` without support for individual
|
||||
* property names.
|
||||
* property identifiers.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The source object.
|
||||
* @param {string[]} props The property names to pick.
|
||||
* @param {string[]} props The property identifiers to pick.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function basePick(object, props) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseForIn from './baseForIn';
|
||||
import getAllKeysIn from './_getAllKeysIn';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||
@@ -9,12 +9,19 @@ import baseForIn from './baseForIn';
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function basePickBy(object, predicate) {
|
||||
var result = {};
|
||||
baseForIn(object, function(value, key) {
|
||||
var index = -1,
|
||||
props = getAllKeysIn(object),
|
||||
length = props.length,
|
||||
result = {};
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index],
|
||||
value = object[key];
|
||||
|
||||
if (predicate(value, key)) {
|
||||
result[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseGet from './baseGet';
|
||||
import baseGet from './_baseGet';
|
||||
|
||||
/**
|
||||
* A specialized version of `baseProperty` which supports deep paths.
|
||||
@@ -1,5 +1,7 @@
|
||||
import arrayMap from './arrayMap';
|
||||
import baseIndexOf from './baseIndexOf';
|
||||
import arrayMap from './_arrayMap';
|
||||
import baseIndexOf from './_baseIndexOf';
|
||||
import baseIndexOfWith from './_baseIndexOfWith';
|
||||
import baseUnary from './_baseUnary';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
@@ -15,22 +17,24 @@ var splice = arrayProto.splice;
|
||||
* @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 basePullAllBy(array, values, iteratee) {
|
||||
var index = -1,
|
||||
function basePullAll(array, values, iteratee, comparator) {
|
||||
var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
|
||||
index = -1,
|
||||
length = values.length,
|
||||
seen = array;
|
||||
|
||||
if (iteratee) {
|
||||
seen = arrayMap(array, function(value) { return iteratee(value); });
|
||||
seen = arrayMap(array, baseUnary(iteratee));
|
||||
}
|
||||
while (++index < length) {
|
||||
var fromIndex = 0,
|
||||
value = values[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
|
||||
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
||||
if (seen !== array) {
|
||||
splice.call(seen, fromIndex, 1);
|
||||
}
|
||||
@@ -40,4 +44,4 @@ function basePullAllBy(array, values, iteratee) {
|
||||
return array;
|
||||
}
|
||||
|
||||
export default basePullAllBy;
|
||||
export default basePullAll;
|
||||
@@ -1,8 +1,8 @@
|
||||
import baseToPath from './baseToPath';
|
||||
import isIndex from './isIndex';
|
||||
import isKey from './isKey';
|
||||
import last from '../last';
|
||||
import parent from './parent';
|
||||
import castPath from './_castPath';
|
||||
import isIndex from './_isIndex';
|
||||
import isKey from './_isKey';
|
||||
import last from './last';
|
||||
import parent from './_parent';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else if (!isKey(index, array)) {
|
||||
var path = baseToPath(index),
|
||||
var path = castPath(index),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
@@ -6,7 +6,8 @@
|
||||
* @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 {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.
|
||||
*/
|
||||
35
_baseRepeat.js
Normal file
35
_baseRepeat.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/** Used as references for various `Number` constants. */
|
||||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var 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) {
|
||||
var 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;
|
||||
@@ -1,8 +1,8 @@
|
||||
import assignValue from './assignValue';
|
||||
import baseToPath from './baseToPath';
|
||||
import isIndex from './isIndex';
|
||||
import isKey from './isKey';
|
||||
import isObject from '../isObject';
|
||||
import assignValue from './_assignValue';
|
||||
import castPath from './_castPath';
|
||||
import isIndex from './_isIndex';
|
||||
import isKey from './_isKey';
|
||||
import isObject from './isObject';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.set`.
|
||||
@@ -15,7 +15,7 @@ import isObject from '../isObject';
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseSet(object, path, value, customizer) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
|
||||
var objValue = nested[key];
|
||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||
if (newValue === undefined) {
|
||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
||||
newValue = objValue == null
|
||||
? (isIndex(path[index + 1]) ? [] : {})
|
||||
: objValue;
|
||||
}
|
||||
}
|
||||
assignValue(nested, key, newValue);
|
||||
@@ -1,5 +1,5 @@
|
||||
import identity from '../identity';
|
||||
import metaMap from './metaMap';
|
||||
import identity from './identity';
|
||||
import metaMap from './_metaMap';
|
||||
|
||||
/**
|
||||
* The base implementation of `setData` without support for hot loop detection.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user