mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94ba2e24e8 | ||
|
|
8bff780a94 | ||
|
|
f18e5950b9 | ||
|
|
365d103439 | ||
|
|
466c67a8b6 | ||
|
|
7af5d55f22 |
33
LICENSE
33
LICENSE
@@ -1,22 +1,23 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
||||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
a copy of this software and associated documentation files (the
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
"Software"), to deal in the Software without restriction, including
|
in the Software without restriction, including without limitation the rights
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
furnished to do so, subject to the following conditions:
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be included in all
|
||||||
included in all copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
SOFTWARE.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# lodash-es v4.0.0
|
# lodash-es v4.4.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.
|
||||||
|
|
||||||
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
|||||||
$ lodash modularize exports=es -o ./
|
$ lodash modularize exports=es -o ./
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.0.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.4.0-es) for more details.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import nativeCreate from './nativeCreate';
|
import nativeCreate from './_nativeCreate';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -7,6 +7,7 @@ var objectProto = Object.prototype;
|
|||||||
* Creates an hash object.
|
* Creates an hash object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @returns {Object} Returns the new hash object.
|
* @returns {Object} Returns the new hash object.
|
||||||
*/
|
*/
|
||||||
function Hash() {}
|
function Hash() {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseCreate from './baseCreate';
|
import baseCreate from './_baseCreate';
|
||||||
import baseLodash from './baseLodash';
|
import baseLodash from './_baseLodash';
|
||||||
|
|
||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = 4294967295;
|
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.
|
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {*} value The value to wrap.
|
* @param {*} value The value to wrap.
|
||||||
*/
|
*/
|
||||||
function LazyWrapper(value) {
|
function LazyWrapper(value) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseCreate from './baseCreate';
|
import baseCreate from './_baseCreate';
|
||||||
import baseLodash from './baseLodash';
|
import baseLodash from './_baseLodash';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base constructor for creating `lodash` wrapper objects.
|
* The base constructor for creating `lodash` wrapper objects.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import getNative from './getNative';
|
import getNative from './_getNative';
|
||||||
import root from './root';
|
import root from './_root';
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var Map = getNative(root, 'Map');
|
var Map = getNative(root, 'Map');
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
import mapClear from './mapClear';
|
import mapClear from './_mapClear';
|
||||||
import mapDelete from './mapDelete';
|
import mapDelete from './_mapDelete';
|
||||||
import mapGet from './mapGet';
|
import mapGet from './_mapGet';
|
||||||
import mapHas from './mapHas';
|
import mapHas from './_mapHas';
|
||||||
import mapSet from './mapSet';
|
import mapSet from './_mapSet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a map cache object to store key-value pairs.
|
* Creates a map cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function MapCache(values) {
|
function MapCache(values) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import root from './root';
|
import root from './_root';
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Reflect = root.Reflect;
|
var Reflect = root.Reflect;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import getNative from './getNative';
|
import getNative from './_getNative';
|
||||||
import root from './root';
|
import root from './_root';
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var Set = getNative(root, 'Set');
|
var Set = getNative(root, 'Set');
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import MapCache from './MapCache';
|
import MapCache from './_MapCache';
|
||||||
import cachePush from './cachePush';
|
import cachePush from './_cachePush';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Creates a set cache object to store unique values.
|
* Creates a set cache object to store unique values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function SetCache(values) {
|
function SetCache(values) {
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
import stackClear from './stackClear';
|
import stackClear from './_stackClear';
|
||||||
import stackDelete from './stackDelete';
|
import stackDelete from './_stackDelete';
|
||||||
import stackGet from './stackGet';
|
import stackGet from './_stackGet';
|
||||||
import stackHas from './stackHas';
|
import stackHas from './_stackHas';
|
||||||
import stackSet from './stackSet';
|
import stackSet from './_stackSet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stack cache object to store key-value pairs.
|
* Creates a stack cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function Stack(values) {
|
function Stack(values) {
|
||||||
6
_Symbol.js
Normal file
6
_Symbol.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import root from './_root';
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var Symbol = root.Symbol;
|
||||||
|
|
||||||
|
export default Symbol;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import root from './root';
|
import root from './_root';
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Uint8Array = root.Uint8Array;
|
var Uint8Array = root.Uint8Array;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import getNative from './getNative';
|
import getNative from './_getNative';
|
||||||
import root from './root';
|
import root from './_root';
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var WeakMap = getNative(root, 'WeakMap');
|
var WeakMap = getNative(root, 'WeakMap');
|
||||||
@@ -5,11 +5,11 @@
|
|||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to invoke.
|
* @param {Function} func The function to invoke.
|
||||||
* @param {*} thisArg The `this` binding of `func`.
|
* @param {*} thisArg The `this` binding of `func`.
|
||||||
* @param {...*} [args] The arguments to invoke `func` with.
|
* @param {...*} args The arguments to invoke `func` with.
|
||||||
* @returns {*} Returns the result of `func`.
|
* @returns {*} Returns the result of `func`.
|
||||||
*/
|
*/
|
||||||
function apply(func, thisArg, args) {
|
function apply(func, thisArg, args) {
|
||||||
var length = args ? args.length : 0;
|
var length = args.length;
|
||||||
switch (length) {
|
switch (length) {
|
||||||
case 0: return func.call(thisArg);
|
case 0: return func.call(thisArg);
|
||||||
case 1: return func.call(thisArg, args[0]);
|
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;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseIndexOf from './baseIndexOf';
|
import baseIndexOf from './_baseIndexOf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.includes` for arrays without support for
|
* A specialized version of `_.includes` for arrays without support for
|
||||||
@@ -6,14 +6,14 @@
|
|||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @param {boolean} [initFromArray] 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.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function arrayReduce(array, iteratee, accumulator, initFromArray) {
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length;
|
length = array.length;
|
||||||
|
|
||||||
if (initFromArray && length) {
|
if (initAccum && length) {
|
||||||
accumulator = array[++index];
|
accumulator = array[++index];
|
||||||
}
|
}
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
@@ -6,12 +6,12 @@
|
|||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @param {boolean} [initFromArray] 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.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
|
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
|
||||||
var length = array.length;
|
var length = array.length;
|
||||||
if (initFromArray && length) {
|
if (initAccum && length) {
|
||||||
accumulator = array[--length];
|
accumulator = array[--length];
|
||||||
}
|
}
|
||||||
while (length--) {
|
while (length--) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import eq from '../eq';
|
import eq from './eq';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
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.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import eq from '../eq';
|
import eq from './eq';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import assocIndexOf from './assocIndexOf';
|
import assocIndexOf from './_assocIndexOf';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import assocIndexOf from './assocIndexOf';
|
import assocIndexOf from './_assocIndexOf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the associative array value for `key`.
|
* 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.
|
* Checks if an associative array value for `key` exists.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import eq from '../eq';
|
import eq from './eq';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index at which the first occurrence of `key` is found in `array`
|
* Gets the index at which the first occurrence of `key` is found in `array`
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import assocIndexOf from './assocIndexOf';
|
import assocIndexOf from './_assocIndexOf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the associative array `key` to `value`.
|
* 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 copyObject from './_copyObject';
|
||||||
import keys from '../keys';
|
import keys from './keys';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.assign` without support for multiple sources
|
* 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.
|
* The base implementation of `_.at` without support for individual paths.
|
||||||
14
_baseCastArrayLikeObject.js
Normal file
14
_baseCastArrayLikeObject.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import isArrayLikeObject from './isArrayLikeObject';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to an empty array if it's not an array like object.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the array-like object.
|
||||||
|
*/
|
||||||
|
function baseCastArrayLikeObject(value) {
|
||||||
|
return isArrayLikeObject(value) ? value : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseCastArrayLikeObject;
|
||||||
14
_baseCastFunction.js
Normal file
14
_baseCastFunction.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import identity from './identity';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to `identity` if it's not a function.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the array-like object.
|
||||||
|
*/
|
||||||
|
function baseCastFunction(value) {
|
||||||
|
return typeof value == 'function' ? value : identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseCastFunction;
|
||||||
15
_baseCastPath.js
Normal file
15
_baseCastPath.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import isArray from './isArray';
|
||||||
|
import stringToPath from './_stringToPath';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to a path array if it's not one.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the cast property path array.
|
||||||
|
*/
|
||||||
|
function baseCastPath(value) {
|
||||||
|
return isArray(value) ? value : stringToPath(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseCastPath;
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
import Stack from './Stack';
|
import Stack from './_Stack';
|
||||||
import arrayEach from './arrayEach';
|
import arrayEach from './_arrayEach';
|
||||||
import assignValue from './assignValue';
|
import assignValue from './_assignValue';
|
||||||
import baseAssign from './baseAssign';
|
import baseAssign from './_baseAssign';
|
||||||
import baseForOwn from './baseForOwn';
|
import baseForOwn from './_baseForOwn';
|
||||||
import copyArray from './copyArray';
|
import cloneBuffer from './_cloneBuffer';
|
||||||
import copySymbols from './copySymbols';
|
import copyArray from './_copyArray';
|
||||||
import getTag from './getTag';
|
import copySymbols from './_copySymbols';
|
||||||
import initCloneArray from './initCloneArray';
|
import getTag from './_getTag';
|
||||||
import initCloneByTag from './initCloneByTag';
|
import initCloneArray from './_initCloneArray';
|
||||||
import initCloneObject from './initCloneObject';
|
import initCloneByTag from './_initCloneByTag';
|
||||||
import isArray from '../isArray';
|
import initCloneObject from './_initCloneObject';
|
||||||
import isHostObject from './isHostObject';
|
import isArray from './isArray';
|
||||||
import isObject from '../isObject';
|
import isBuffer from './isBuffer';
|
||||||
|
import isHostObject from './_isHostObject';
|
||||||
|
import isObject from './isObject';
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var argsTag = '[object Arguments]',
|
var argsTag = '[object Arguments]',
|
||||||
@@ -91,6 +93,9 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
|||||||
var tag = getTag(value),
|
var tag = getTag(value),
|
||||||
isFunc = tag == funcTag || tag == genTag;
|
isFunc = tag == funcTag || tag == genTag;
|
||||||
|
|
||||||
|
if (isBuffer(value)) {
|
||||||
|
return cloneBuffer(value, isDeep);
|
||||||
|
}
|
||||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||||
if (isHostObject(value)) {
|
if (isHostObject(value)) {
|
||||||
return object ? value : {};
|
return object ? value : {};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import keys from '../keys';
|
import keys from './keys';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.conforms` which doesn't clone `source`.
|
* The base implementation of `_.conforms` which doesn't clone `source`.
|
||||||
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
|
* @private
|
||||||
* @param {Function} func The function to delay.
|
* @param {Function} func The function to delay.
|
||||||
* @param {number} wait The number of milliseconds to delay invocation.
|
* @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.
|
* @returns {number} Returns the timer id.
|
||||||
*/
|
*/
|
||||||
function baseDelay(func, wait, args) {
|
function baseDelay(func, wait, args) {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import SetCache from './SetCache';
|
import SetCache from './_SetCache';
|
||||||
import arrayIncludes from './arrayIncludes';
|
import arrayIncludes from './_arrayIncludes';
|
||||||
import arrayIncludesWith from './arrayIncludesWith';
|
import arrayIncludesWith from './_arrayIncludesWith';
|
||||||
import arrayMap from './arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseUnary from './baseUnary';
|
import baseUnary from './_baseUnary';
|
||||||
import cacheHas from './cacheHas';
|
import cacheHas from './_cacheHas';
|
||||||
|
|
||||||
/** Used as the size to enable large array optimizations. */
|
/** Used as the size to enable large array optimizations. */
|
||||||
var LARGE_ARRAY_SIZE = 200;
|
var LARGE_ARRAY_SIZE = 200;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseForOwn from './baseForOwn';
|
import baseForOwn from './_baseForOwn';
|
||||||
import createBaseEach from './createBaseEach';
|
import createBaseEach from './_createBaseEach';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseForOwnRight from './baseForOwnRight';
|
import baseForOwnRight from './_baseForOwnRight';
|
||||||
import createBaseEach from './createBaseEach';
|
import createBaseEach from './_createBaseEach';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forEachRight` without support for iteratee shorthands.
|
* 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.
|
* The base implementation of `_.every` without support for iteratee shorthands.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import toInteger from '../toInteger';
|
import toInteger from './toInteger';
|
||||||
import toLength from '../toLength';
|
import toLength from './toLength';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.fill` without an iteratee call guard.
|
* 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.
|
* The base implementation of `_.filter` without support for iteratee shorthands.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.find` and `_.findKey`, without
|
* The base implementation of methods like `_.find` and `_.findKey`, without
|
||||||
* support for iteratee shorthands, which iterates over `collection` using
|
* support for iteratee shorthands, which iterates over `collection` using
|
||||||
* the provided `eachFunc`.
|
* `eachFunc`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to search.
|
* @param {Array|Object} collection The collection to search.
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
import arrayPush from './arrayPush';
|
import arrayPush from './_arrayPush';
|
||||||
import isArguments from '../isArguments';
|
import isArguments from './isArguments';
|
||||||
import isArray from '../isArray';
|
import isArray from './isArray';
|
||||||
import isArrayLikeObject from '../isArrayLikeObject';
|
import isArrayLikeObject from './isArrayLikeObject';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.flatten` with support for restricting flattening.
|
* The base implementation of `_.flatten` with support for restricting flattening.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
* @param {number} depth The maximum recursion depth.
|
||||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||||
* @param {Array} [result=[]] The initial result value.
|
* @param {Array} [result=[]] The initial result value.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, result) {
|
function baseFlatten(array, depth, isStrict, result) {
|
||||||
result || (result = []);
|
result || (result = []);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -21,11 +21,11 @@ function baseFlatten(array, isDeep, isStrict, result) {
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (isArrayLikeObject(value) &&
|
if (depth > 0 && isArrayLikeObject(value) &&
|
||||||
(isStrict || isArray(value) || isArguments(value))) {
|
(isStrict || isArray(value) || isArguments(value))) {
|
||||||
if (isDeep) {
|
if (depth > 1) {
|
||||||
// Recursively flatten arrays (susceptible to call stack limits).
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
baseFlatten(value, isDeep, isStrict, result);
|
baseFlatten(value, depth - 1, isStrict, result);
|
||||||
} else {
|
} else {
|
||||||
arrayPush(result, value);
|
arrayPush(result, value);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import createBaseFor from './createBaseFor';
|
import createBaseFor from './_createBaseFor';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseFor from './baseFor';
|
import baseFor from './_baseFor';
|
||||||
import keysIn from '../keysIn';
|
import keysIn from './keysIn';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forIn` without support for iteratee shorthands.
|
* The base implementation of `_.forIn` without support for iteratee shorthands.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseFor from './baseFor';
|
import baseFor from './_baseFor';
|
||||||
import keys from '../keys';
|
import keys from './keys';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseForRight from './baseForRight';
|
import baseForRight from './_baseForRight';
|
||||||
import keys from '../keys';
|
import keys from './keys';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.forOwnRight` without support for iteratee shorthands.
|
* 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
|
* This function is like `baseFor` except that it iterates over properties
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import arrayFilter from './arrayFilter';
|
import arrayFilter from './_arrayFilter';
|
||||||
import isFunction from '../isFunction';
|
import isFunction from './isFunction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.functions` which creates an array of
|
* 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
|
* @private
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseToPath from './baseToPath';
|
import baseCastPath from './_baseCastPath';
|
||||||
import isKey from './isKey';
|
import isKey from './_isKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.get` without support for default values.
|
* The base implementation of `_.get` without support for default values.
|
||||||
@@ -10,7 +10,7 @@ import isKey from './isKey';
|
|||||||
* @returns {*} Returns the resolved value.
|
* @returns {*} Returns the resolved value.
|
||||||
*/
|
*/
|
||||||
function baseGet(object, path) {
|
function baseGet(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import indexOfNaN from './indexOfNaN';
|
import indexOfNaN from './_indexOfNaN';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import SetCache from './SetCache';
|
import SetCache from './_SetCache';
|
||||||
import arrayIncludes from './arrayIncludes';
|
import arrayIncludes from './_arrayIncludes';
|
||||||
import arrayIncludesWith from './arrayIncludesWith';
|
import arrayIncludesWith from './_arrayIncludesWith';
|
||||||
import arrayMap from './arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseUnary from './baseUnary';
|
import baseUnary from './_baseUnary';
|
||||||
import cacheHas from './cacheHas';
|
import cacheHas from './_cacheHas';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.intersection`, without support
|
* The base implementation of methods like `_.intersection`, without support
|
||||||
@@ -42,11 +42,17 @@ function baseIntersection(arrays, iteratee, comparator) {
|
|||||||
var value = array[index],
|
var value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
computed = iteratee ? iteratee(value) : value;
|
||||||
|
|
||||||
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
|
if (!(seen
|
||||||
|
? cacheHas(seen, computed)
|
||||||
|
: includes(result, computed, comparator)
|
||||||
|
)) {
|
||||||
var othIndex = othLength;
|
var othIndex = othLength;
|
||||||
while (--othIndex) {
|
while (--othIndex) {
|
||||||
var cache = caches[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;
|
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,14 +1,13 @@
|
|||||||
import apply from './apply';
|
import apply from './_apply';
|
||||||
import baseToPath from './baseToPath';
|
import baseCastPath from './_baseCastPath';
|
||||||
import isKey from './isKey';
|
import isKey from './_isKey';
|
||||||
import last from '../last';
|
import last from './last';
|
||||||
import parent from './parent';
|
import parent from './_parent';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.invoke` without support for individual
|
* The base implementation of `_.invoke` without support for individual
|
||||||
* method arguments.
|
* method arguments.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
* @param {Array|string} path The path of the method to invoke.
|
* @param {Array|string} path The path of the method to invoke.
|
||||||
@@ -17,7 +16,7 @@ import parent from './parent';
|
|||||||
*/
|
*/
|
||||||
function baseInvoke(object, path, args) {
|
function baseInvoke(object, path, args) {
|
||||||
if (!isKey(path, object)) {
|
if (!isKey(path, object)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
path = last(path);
|
path = last(path);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import baseIsEqualDeep from './baseIsEqualDeep';
|
import baseIsEqualDeep from './_baseIsEqualDeep';
|
||||||
import isObject from '../isObject';
|
import isObject from './isObject';
|
||||||
import isObjectLike from '../isObjectLike';
|
import isObjectLike from './isObjectLike';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.isEqual` which supports partial comparisons
|
* The base implementation of `_.isEqual` which supports partial comparisons
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import Stack from './Stack';
|
import Stack from './_Stack';
|
||||||
import equalArrays from './equalArrays';
|
import equalArrays from './_equalArrays';
|
||||||
import equalByTag from './equalByTag';
|
import equalByTag from './_equalByTag';
|
||||||
import equalObjects from './equalObjects';
|
import equalObjects from './_equalObjects';
|
||||||
import getTag from './getTag';
|
import getTag from './_getTag';
|
||||||
import isArray from '../isArray';
|
import isArray from './isArray';
|
||||||
import isHostObject from './isHostObject';
|
import isHostObject from './_isHostObject';
|
||||||
import isTypedArray from '../isTypedArray';
|
import isTypedArray from './isTypedArray';
|
||||||
|
|
||||||
/** Used to compose bitmasks for comparison styles. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
var PARTIAL_COMPARE_FLAG = 2;
|
var PARTIAL_COMPARE_FLAG = 2;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import Stack from './Stack';
|
import Stack from './_Stack';
|
||||||
import baseIsEqual from './baseIsEqual';
|
import baseIsEqual from './_baseIsEqual';
|
||||||
|
|
||||||
/** Used to compose bitmasks for comparison styles. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
var UNORDERED_COMPARE_FLAG = 1,
|
var UNORDERED_COMPARE_FLAG = 1,
|
||||||
@@ -47,7 +47,10 @@ function baseIsMatch(object, source, matchData, customizer) {
|
|||||||
var stack = new Stack,
|
var stack = new Stack,
|
||||||
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined;
|
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined;
|
||||||
|
|
||||||
if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
|
if (!(result === undefined
|
||||||
|
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
|
||||||
|
: result
|
||||||
|
)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import baseMatches from './baseMatches';
|
import baseMatches from './_baseMatches';
|
||||||
import baseMatchesProperty from './baseMatchesProperty';
|
import baseMatchesProperty from './_baseMatchesProperty';
|
||||||
import identity from '../identity';
|
import identity from './identity';
|
||||||
import isArray from '../isArray';
|
import isArray from './isArray';
|
||||||
import property from '../property';
|
import property from './property';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.iteratee`.
|
* The base implementation of `_.iteratee`.
|
||||||
@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
|
|||||||
* property of prototypes or treat sparse arrays as dense.
|
* property of prototypes or treat sparse arrays as dense.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @type Function
|
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import Reflect from './Reflect';
|
import Reflect from './_Reflect';
|
||||||
import iteratorToArray from './iteratorToArray';
|
import iteratorToArray from './_iteratorToArray';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseEach from './baseEach';
|
import baseEach from './_baseEach';
|
||||||
import isArrayLike from '../isArrayLike';
|
import isArrayLike from './isArrayLike';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.map` without support for iteratee shorthands.
|
* The base implementation of `_.map` without support for iteratee shorthands.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseIsMatch from './baseIsMatch';
|
import baseIsMatch from './_baseIsMatch';
|
||||||
import getMatchData from './getMatchData';
|
import getMatchData from './_getMatchData';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.matches` which doesn't clone `source`.
|
* The base implementation of `_.matches` which doesn't clone `source`.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import baseIsEqual from './baseIsEqual';
|
import baseIsEqual from './_baseIsEqual';
|
||||||
import get from '../get';
|
import get from './get';
|
||||||
import hasIn from '../hasIn';
|
import hasIn from './hasIn';
|
||||||
|
|
||||||
/** Used to compose bitmasks for comparison styles. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
var UNORDERED_COMPARE_FLAG = 1,
|
var UNORDERED_COMPARE_FLAG = 1,
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import Stack from './Stack';
|
import Stack from './_Stack';
|
||||||
import arrayEach from './arrayEach';
|
import arrayEach from './_arrayEach';
|
||||||
import assignMergeValue from './assignMergeValue';
|
import assignMergeValue from './_assignMergeValue';
|
||||||
import baseMergeDeep from './baseMergeDeep';
|
import baseMergeDeep from './_baseMergeDeep';
|
||||||
import isArray from '../isArray';
|
import isArray from './isArray';
|
||||||
import isObject from '../isObject';
|
import isObject from './isObject';
|
||||||
import isTypedArray from '../isTypedArray';
|
import isTypedArray from './isTypedArray';
|
||||||
import keysIn from '../keysIn';
|
import keysIn from './keysIn';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.merge` without support for multiple sources.
|
* The base implementation of `_.merge` without support for multiple sources.
|
||||||
@@ -13,14 +13,18 @@ import keysIn from '../keysIn';
|
|||||||
* @private
|
* @private
|
||||||
* @param {Object} object The destination object.
|
* @param {Object} object The destination object.
|
||||||
* @param {Object} source The source object.
|
* @param {Object} source The source object.
|
||||||
|
* @param {number} srcIndex The index of `source`.
|
||||||
* @param {Function} [customizer] The function to customize merged values.
|
* @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, customizer, stack) {
|
function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||||
if (object === source) {
|
if (object === source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
|
var props = (isArray(source) || isTypedArray(source))
|
||||||
|
? undefined
|
||||||
|
: keysIn(source);
|
||||||
|
|
||||||
arrayEach(props || source, function(srcValue, key) {
|
arrayEach(props || source, function(srcValue, key) {
|
||||||
if (props) {
|
if (props) {
|
||||||
key = srcValue;
|
key = srcValue;
|
||||||
@@ -28,10 +32,13 @@ function baseMerge(object, source, customizer, stack) {
|
|||||||
}
|
}
|
||||||
if (isObject(srcValue)) {
|
if (isObject(srcValue)) {
|
||||||
stack || (stack = new Stack);
|
stack || (stack = new Stack);
|
||||||
baseMergeDeep(object, source, key, baseMerge, customizer, stack);
|
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if (newValue === undefined) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
}
|
}
|
||||||
81
_baseMergeDeep.js
Normal file
81
_baseMergeDeep.js
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
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
|
||||||
|
* 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) {
|
||||||
|
var objValue = object[key],
|
||||||
|
srcValue = source[key],
|
||||||
|
stacked = stack.get(srcValue);
|
||||||
|
|
||||||
|
if (stacked) {
|
||||||
|
assignMergeValue(object, key, stacked);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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 = objValue;
|
||||||
|
}
|
||||||
|
else if (isArrayLikeObject(objValue)) {
|
||||||
|
newValue = copyArray(objValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isCommon = false;
|
||||||
|
newValue = baseClone(srcValue, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
|
if (isArguments(objValue)) {
|
||||||
|
newValue = toPlainObject(objValue);
|
||||||
|
}
|
||||||
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
|
isCommon = false;
|
||||||
|
newValue = baseClone(srcValue, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newValue = objValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isCommon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.set(srcValue, newValue);
|
||||||
|
|
||||||
|
if (isCommon) {
|
||||||
|
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||||
|
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
||||||
|
}
|
||||||
|
assignMergeValue(object, key, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseMergeDeep;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import arrayMap from './arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseIteratee from './baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import baseMap from './baseMap';
|
import baseMap from './_baseMap';
|
||||||
import baseSortBy from './baseSortBy';
|
import baseSortBy from './_baseSortBy';
|
||||||
import compareMultiple from './compareMultiple';
|
import compareMultiple from './_compareMultiple';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.orderBy` without param guards.
|
* The base implementation of `_.orderBy` without param guards.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import arrayReduce from './arrayReduce';
|
import arrayReduce from './_arrayReduce';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pick` without support for individual
|
* The base implementation of `_.pick` without support for individual
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseForIn from './baseForIn';
|
import baseForIn from './_baseForIn';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||||
@@ -11,7 +11,7 @@ import baseForIn from './baseForIn';
|
|||||||
function basePickBy(object, predicate) {
|
function basePickBy(object, predicate) {
|
||||||
var result = {};
|
var result = {};
|
||||||
baseForIn(object, function(value, key) {
|
baseForIn(object, function(value, key) {
|
||||||
if (predicate(value)) {
|
if (predicate(value, key)) {
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseGet from './baseGet';
|
import baseGet from './_baseGet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `baseProperty` which supports deep paths.
|
* A specialized version of `baseProperty` which supports deep paths.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import basePullAllBy from './basePullAllBy';
|
import basePullAllBy from './_basePullAllBy';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pullAll`.
|
* The base implementation of `_.pullAll`.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import arrayMap from './arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseIndexOf from './baseIndexOf';
|
import baseIndexOf from './_baseIndexOf';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import baseToPath from './baseToPath';
|
import baseCastPath from './_baseCastPath';
|
||||||
import isIndex from './isIndex';
|
import isIndex from './_isIndex';
|
||||||
import isKey from './isKey';
|
import isKey from './_isKey';
|
||||||
import last from '../last';
|
import last from './last';
|
||||||
import parent from './parent';
|
import parent from './_parent';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
|||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
}
|
}
|
||||||
else if (!isKey(index, array)) {
|
else if (!isKey(index, array)) {
|
||||||
var path = baseToPath(index),
|
var path = baseCastPath(index),
|
||||||
object = parent(array, path);
|
object = parent(array, path);
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
||||||
* for iteratee shorthands, which iterates over `collection` using the provided
|
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
|
||||||
* `eachFunc`.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} accumulator The initial value.
|
* @param {*} accumulator The initial value.
|
||||||
* @param {boolean} initFromCollection 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`.
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
|
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
||||||
eachFunc(collection, function(value, index, collection) {
|
eachFunc(collection, function(value, index, collection) {
|
||||||
accumulator = initFromCollection
|
accumulator = initAccum
|
||||||
? (initFromCollection = false, value)
|
? (initAccum = false, value)
|
||||||
: iteratee(accumulator, value, index, collection);
|
: iteratee(accumulator, value, index, collection);
|
||||||
});
|
});
|
||||||
return accumulator;
|
return accumulator;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import assignValue from './assignValue';
|
import assignValue from './_assignValue';
|
||||||
import baseToPath from './baseToPath';
|
import baseCastPath from './_baseCastPath';
|
||||||
import isIndex from './isIndex';
|
import isIndex from './_isIndex';
|
||||||
import isKey from './isKey';
|
import isKey from './_isKey';
|
||||||
import isObject from '../isObject';
|
import isObject from './isObject';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.set`.
|
* The base implementation of `_.set`.
|
||||||
@@ -15,7 +15,7 @@ import isObject from '../isObject';
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseSet(object, path, value, customizer) {
|
function baseSet(object, path, value, customizer) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
|
|||||||
var objValue = nested[key];
|
var objValue = nested[key];
|
||||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
newValue = objValue == null
|
||||||
|
? (isIndex(path[index + 1]) ? [] : {})
|
||||||
|
: objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assignValue(nested, key, newValue);
|
assignValue(nested, key, newValue);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import identity from '../identity';
|
import identity from './identity';
|
||||||
import metaMap from './metaMap';
|
import metaMap from './_metaMap';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `setData` without support for hot loop detection.
|
* The base implementation of `setData` without support for hot loop detection.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseEach from './baseEach';
|
import baseEach from './_baseEach';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.some` without support for iteratee shorthands.
|
* The base implementation of `_.some` without support for iteratee shorthands.
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user