mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7da4c55415 | ||
|
|
9055c4e483 | ||
|
|
2b1eb3f480 | ||
|
|
94ba2e24e8 | ||
|
|
8bff780a94 | ||
|
|
f18e5950b9 |
33
LICENSE
33
LICENSE
@@ -1,22 +1,23 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
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
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
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 without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
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.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND 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.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# lodash-es v4.2.0
|
||||
# lodash-es v4.6.0
|
||||
|
||||
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 ./
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.2.0-es) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.6.0-es) for more details.
|
||||
|
||||
1
_Hash.js
1
_Hash.js
@@ -7,6 +7,7 @@ var objectProto = Object.prototype;
|
||||
* Creates an hash object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @returns {Object} Returns the new hash object.
|
||||
*/
|
||||
function Hash() {}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -8,6 +8,7 @@ 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) {
|
||||
|
||||
@@ -6,6 +6,7 @@ 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) {
|
||||
|
||||
@@ -8,6 +8,7 @@ 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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,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.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -3,6 +3,7 @@ import arrayEach from './_arrayEach';
|
||||
import assignValue from './_assignValue';
|
||||
import baseAssign from './_baseAssign';
|
||||
import baseForOwn from './_baseForOwn';
|
||||
import cloneBuffer from './_cloneBuffer';
|
||||
import copyArray from './_copyArray';
|
||||
import copySymbols from './_copySymbols';
|
||||
import getTag from './_getTag';
|
||||
@@ -10,6 +11,7 @@ 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';
|
||||
|
||||
@@ -91,6 +93,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 +105,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, isDeep);
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
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.
|
||||
@@ -8,16 +11,8 @@ import isObject from './isObject';
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(prototype) {
|
||||
if (isObject(prototype)) {
|
||||
object.prototype = prototype;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
}
|
||||
return result || {};
|
||||
};
|
||||
}());
|
||||
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) {
|
||||
|
||||
@@ -8,12 +8,12 @@ import isArrayLikeObject from './isArrayLikeObject';
|
||||
*
|
||||
* @private
|
||||
* @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 {Array} [result=[]] The initial result value.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict, result) {
|
||||
function baseFlatten(array, depth, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
var index = -1,
|
||||
@@ -21,11 +21,11 @@ function baseFlatten(array, isDeep, isStrict, result) {
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (isArrayLikeObject(value) &&
|
||||
if (depth > 0 && isArrayLikeObject(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
if (depth > 1) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
baseFlatten(value, isDeep, isStrict, result);
|
||||
baseFlatten(value, depth - 1, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ 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,4 +1,4 @@
|
||||
import baseToPath from './_baseToPath';
|
||||
import baseCastPath from './_baseCastPath';
|
||||
import isKey from './_isKey';
|
||||
|
||||
/**
|
||||
@@ -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 + ''] : baseCastPath(path);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
|
||||
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;
|
||||
@@ -5,6 +5,9 @@ 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
|
||||
* for iteratee shorthands, that accepts an array of arrays to inspect.
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import apply from './_apply';
|
||||
import baseToPath from './_baseToPath';
|
||||
import baseCastPath from './_baseCastPath';
|
||||
import isKey from './_isKey';
|
||||
import last from './last';
|
||||
import parent from './_parent';
|
||||
@@ -16,7 +16,7 @@ import parent from './_parent';
|
||||
*/
|
||||
function baseInvoke(object, path, args) {
|
||||
if (!isKey(path, object)) {
|
||||
path = baseToPath(path);
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
path = last(path);
|
||||
}
|
||||
|
||||
@@ -43,33 +43,28 @@ 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) {
|
||||
stack || (stack = new Stack);
|
||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +72,7 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
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;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
if (object === source) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
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 {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue);
|
||||
newValue = baseClone(srcValue, !customizer);
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
@@ -56,10 +59,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue);
|
||||
newValue = baseClone(srcValue, !customizer);
|
||||
}
|
||||
else {
|
||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -72,6 +75,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,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 : Array(1), baseIteratee);
|
||||
|
||||
var result = baseMap(collection, function(value, key, collection) {
|
||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||
|
||||
@@ -1,15 +1,47 @@
|
||||
import basePullAllBy from './_basePullAllBy';
|
||||
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;
|
||||
|
||||
/** Built-in value references. */
|
||||
var splice = arrayProto.splice;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pullAll`.
|
||||
* The base implementation of `_.pullAllBy` without support for iteratee
|
||||
* shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to modify.
|
||||
* @param {Array} values The values to remove.
|
||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||
* @param {Function} [comparator] The comparator invoked per element.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function basePullAll(array, values) {
|
||||
return basePullAllBy(array, values);
|
||||
function basePullAll(array, values, iteratee, comparator) {
|
||||
var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
|
||||
index = -1,
|
||||
length = values.length,
|
||||
seen = array;
|
||||
|
||||
if (iteratee) {
|
||||
seen = arrayMap(array, baseUnary(iteratee));
|
||||
}
|
||||
while (++index < length) {
|
||||
var fromIndex = 0,
|
||||
value = values[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
||||
if (seen !== array) {
|
||||
splice.call(seen, fromIndex, 1);
|
||||
}
|
||||
splice.call(array, fromIndex, 1);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export default basePullAll;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import arrayMap from './_arrayMap';
|
||||
import baseIndexOf from './_baseIndexOf';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
|
||||
/** Built-in value references. */
|
||||
var splice = arrayProto.splice;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pullAllBy` without support for iteratee
|
||||
* shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to modify.
|
||||
* @param {Array} values The values to remove.
|
||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function basePullAllBy(array, values, iteratee) {
|
||||
var index = -1,
|
||||
length = values.length,
|
||||
seen = array;
|
||||
|
||||
if (iteratee) {
|
||||
seen = arrayMap(array, function(value) { return iteratee(value); });
|
||||
}
|
||||
while (++index < length) {
|
||||
var fromIndex = 0,
|
||||
value = values[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
|
||||
if (seen !== array) {
|
||||
splice.call(seen, fromIndex, 1);
|
||||
}
|
||||
splice.call(array, fromIndex, 1);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export default basePullAllBy;
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseToPath from './_baseToPath';
|
||||
import baseCastPath from './_baseCastPath';
|
||||
import isIndex from './_isIndex';
|
||||
import isKey from './_isKey';
|
||||
import last from './last';
|
||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else if (!isKey(index, array)) {
|
||||
var path = baseToPath(index),
|
||||
var path = baseCastPath(index),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import assignValue from './_assignValue';
|
||||
import baseToPath from './_baseToPath';
|
||||
import baseCastPath from './_baseCastPath';
|
||||
import isIndex from './_isIndex';
|
||||
import isKey from './_isKey';
|
||||
import isObject from './isObject';
|
||||
@@ -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 + ''] : baseCastPath(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,7 +1,7 @@
|
||||
/**
|
||||
* The base implementation of `_.sortBy` which uses `comparer` to define
|
||||
* the sort order of `array` and replaces criteria objects with their
|
||||
* corresponding values.
|
||||
* The base implementation of `_.sortBy` which uses `comparer` to define the
|
||||
* sort order of `array` and replaces criteria objects with their corresponding
|
||||
* values.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to sort.
|
||||
|
||||
@@ -15,7 +15,7 @@ function baseSortedUniqBy(array, iteratee) {
|
||||
value = array[0],
|
||||
computed = iteratee ? iteratee(value) : value,
|
||||
seen = computed,
|
||||
resIndex = 0,
|
||||
resIndex = 1,
|
||||
result = [value];
|
||||
|
||||
while (++index < length) {
|
||||
@@ -24,7 +24,7 @@ function baseSortedUniqBy(array, iteratee) {
|
||||
|
||||
if (!eq(computed, seen)) {
|
||||
seen = computed;
|
||||
result[++resIndex] = value;
|
||||
result[resIndex++] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import isArray from './isArray';
|
||||
import stringToPath from './_stringToPath';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.toPath` which only converts `value` to a
|
||||
* path if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
function baseToPath(value) {
|
||||
return isArray(value) ? value : stringToPath(value);
|
||||
}
|
||||
|
||||
export default baseToPath;
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseToPath from './_baseToPath';
|
||||
import baseCastPath from './_baseCastPath';
|
||||
import has from './has';
|
||||
import isKey from './_isKey';
|
||||
import last from './last';
|
||||
@@ -13,7 +13,7 @@ import parent from './_parent';
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
*/
|
||||
function baseUnset(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
var key = last(path);
|
||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||
|
||||
18
_baseUpdate.js
Normal file
18
_baseUpdate.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import baseGet from './_baseGet';
|
||||
import baseSet from './_baseSet';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.update`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Array|string} path The path of the property to update.
|
||||
* @param {Function} updater The function to produce the updated value.
|
||||
* @param {Function} [customizer] The function to customize path creation.
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseUpdate(object, path, updater, customizer) {
|
||||
return baseSet(object, path, updater(baseGet(object, path)), customizer);
|
||||
}
|
||||
|
||||
export default baseUpdate;
|
||||
16
_cloneArrayBuffer.js
Normal file
16
_cloneArrayBuffer.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import Uint8Array from './_Uint8Array';
|
||||
|
||||
/**
|
||||
* Creates a clone of `arrayBuffer`.
|
||||
*
|
||||
* @private
|
||||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||||
*/
|
||||
function cloneArrayBuffer(arrayBuffer) {
|
||||
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||||
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
||||
return result;
|
||||
}
|
||||
|
||||
export default cloneArrayBuffer;
|
||||
@@ -1,18 +1,17 @@
|
||||
import Uint8Array from './_Uint8Array';
|
||||
|
||||
/**
|
||||
* Creates a clone of `buffer`.
|
||||
* Creates a clone of `buffer`.
|
||||
*
|
||||
* @private
|
||||
* @param {ArrayBuffer} buffer The array buffer to clone.
|
||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||||
* @param {Buffer} buffer The buffer to clone.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @returns {Buffer} Returns the cloned buffer.
|
||||
*/
|
||||
function cloneBuffer(buffer) {
|
||||
var Ctor = buffer.constructor,
|
||||
result = new Ctor(buffer.byteLength),
|
||||
view = new Uint8Array(result);
|
||||
|
||||
view.set(new Uint8Array(buffer));
|
||||
function cloneBuffer(buffer, isDeep) {
|
||||
if (isDeep) {
|
||||
return buffer.slice();
|
||||
}
|
||||
var result = new buffer.constructor(buffer.length);
|
||||
buffer.copy(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ import mapToArray from './_mapToArray';
|
||||
* @returns {Object} Returns the cloned map.
|
||||
*/
|
||||
function cloneMap(map) {
|
||||
var Ctor = map.constructor;
|
||||
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
|
||||
return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
|
||||
}
|
||||
|
||||
export default cloneMap;
|
||||
|
||||
@@ -9,9 +9,7 @@ var reFlags = /\w*$/;
|
||||
* @returns {Object} Returns the cloned regexp.
|
||||
*/
|
||||
function cloneRegExp(regexp) {
|
||||
var Ctor = regexp.constructor,
|
||||
result = new Ctor(regexp.source, reFlags.exec(regexp));
|
||||
|
||||
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||||
result.lastIndex = regexp.lastIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ import setToArray from './_setToArray';
|
||||
* @returns {Object} Returns the cloned set.
|
||||
*/
|
||||
function cloneSet(set) {
|
||||
var Ctor = set.constructor;
|
||||
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
|
||||
return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
|
||||
}
|
||||
|
||||
export default cloneSet;
|
||||
|
||||
@@ -2,7 +2,7 @@ import Symbol from './_Symbol';
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
|
||||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||||
|
||||
/**
|
||||
* Creates a clone of the `symbol` object.
|
||||
@@ -12,7 +12,7 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
* @returns {Object} Returns the cloned symbol object.
|
||||
*/
|
||||
function cloneSymbol(symbol) {
|
||||
return Symbol ? Object(symbolValueOf.call(symbol)) : {};
|
||||
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
||||
}
|
||||
|
||||
export default cloneSymbol;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import cloneBuffer from './_cloneBuffer';
|
||||
import cloneArrayBuffer from './_cloneArrayBuffer';
|
||||
|
||||
/**
|
||||
* Creates a clone of `typedArray`.
|
||||
@@ -9,10 +9,8 @@ import cloneBuffer from './_cloneBuffer';
|
||||
* @returns {Object} Returns the cloned typed array.
|
||||
*/
|
||||
function cloneTypedArray(typedArray, isDeep) {
|
||||
var buffer = typedArray.buffer,
|
||||
Ctor = typedArray.constructor;
|
||||
|
||||
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
||||
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||||
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||||
}
|
||||
|
||||
export default cloneTypedArray;
|
||||
|
||||
@@ -9,23 +9,28 @@ var nativeMax = Math.max;
|
||||
* @param {Array|Object} args The provided arguments.
|
||||
* @param {Array} partials The arguments to prepend to those provided.
|
||||
* @param {Array} holders The `partials` placeholder indexes.
|
||||
* @params {boolean} [isCurried] Specify composing for a curried function.
|
||||
* @returns {Array} Returns the new array of composed arguments.
|
||||
*/
|
||||
function composeArgs(args, partials, holders) {
|
||||
var holdersLength = holders.length,
|
||||
argsIndex = -1,
|
||||
argsLength = nativeMax(args.length - holdersLength, 0),
|
||||
function composeArgs(args, partials, holders, isCurried) {
|
||||
var argsIndex = -1,
|
||||
argsLength = args.length,
|
||||
holdersLength = holders.length,
|
||||
leftIndex = -1,
|
||||
leftLength = partials.length,
|
||||
result = Array(leftLength + argsLength);
|
||||
rangeLength = nativeMax(argsLength - holdersLength, 0),
|
||||
result = Array(leftLength + rangeLength),
|
||||
isUncurried = !isCurried;
|
||||
|
||||
while (++leftIndex < leftLength) {
|
||||
result[leftIndex] = partials[leftIndex];
|
||||
}
|
||||
while (++argsIndex < holdersLength) {
|
||||
result[holders[argsIndex]] = args[argsIndex];
|
||||
if (isUncurried || argsIndex < argsLength) {
|
||||
result[holders[argsIndex]] = args[argsIndex];
|
||||
}
|
||||
}
|
||||
while (argsLength--) {
|
||||
while (rangeLength--) {
|
||||
result[leftIndex++] = args[argsIndex++];
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -9,18 +9,21 @@ var nativeMax = Math.max;
|
||||
* @param {Array|Object} args The provided arguments.
|
||||
* @param {Array} partials The arguments to append to those provided.
|
||||
* @param {Array} holders The `partials` placeholder indexes.
|
||||
* @params {boolean} [isCurried] Specify composing for a curried function.
|
||||
* @returns {Array} Returns the new array of composed arguments.
|
||||
*/
|
||||
function composeArgsRight(args, partials, holders) {
|
||||
var holdersIndex = -1,
|
||||
function composeArgsRight(args, partials, holders, isCurried) {
|
||||
var argsIndex = -1,
|
||||
argsLength = args.length,
|
||||
holdersIndex = -1,
|
||||
holdersLength = holders.length,
|
||||
argsIndex = -1,
|
||||
argsLength = nativeMax(args.length - holdersLength, 0),
|
||||
rightIndex = -1,
|
||||
rightLength = partials.length,
|
||||
result = Array(argsLength + rightLength);
|
||||
rangeLength = nativeMax(argsLength - holdersLength, 0),
|
||||
result = Array(rangeLength + rightLength),
|
||||
isUncurried = !isCurried;
|
||||
|
||||
while (++argsIndex < argsLength) {
|
||||
while (++argsIndex < rangeLength) {
|
||||
result[argsIndex] = args[argsIndex];
|
||||
}
|
||||
var offset = argsIndex;
|
||||
@@ -28,7 +31,9 @@ function composeArgsRight(args, partials, holders) {
|
||||
result[offset + rightIndex] = partials[rightIndex];
|
||||
}
|
||||
while (++holdersIndex < holdersLength) {
|
||||
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||
if (isUncurried || argsIndex < argsLength) {
|
||||
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) {
|
||||
length = props.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index],
|
||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
||||
var key = props[index];
|
||||
|
||||
var newValue = customizer
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: source[key];
|
||||
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
|
||||
21
_countHolders.js
Normal file
21
_countHolders.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Gets the number of `placeholder` occurrences in `array`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} placeholder The placeholder to search for.
|
||||
* @returns {number} Returns the placeholder count.
|
||||
*/
|
||||
function countHolders(array, placeholder) {
|
||||
var length = array.length,
|
||||
result = 0;
|
||||
|
||||
while (length--) {
|
||||
if (array[length] === placeholder) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default countHolders;
|
||||
@@ -15,7 +15,10 @@ function createAssigner(assigner) {
|
||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||
guard = length > 2 ? sources[2] : undefined;
|
||||
|
||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
||||
customizer = typeof customizer == 'function'
|
||||
? (length--, customizer)
|
||||
: undefined;
|
||||
|
||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||
customizer = length < 3 ? undefined : customizer;
|
||||
length = 1;
|
||||
|
||||
@@ -24,8 +24,11 @@ function createCaseFirst(methodName) {
|
||||
return function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
var strSymbols = reHasComplexSymbol.test(string)
|
||||
? stringToArray(string)
|
||||
: undefined;
|
||||
|
||||
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||
|
||||
return chr[methodName]() + trailing;
|
||||
|
||||
@@ -2,6 +2,7 @@ import apply from './_apply';
|
||||
import createCtorWrapper from './_createCtorWrapper';
|
||||
import createHybridWrapper from './_createHybridWrapper';
|
||||
import createRecurryWrapper from './_createRecurryWrapper';
|
||||
import getPlaceholder from './_getPlaceholder';
|
||||
import replaceHolders from './_replaceHolders';
|
||||
import root from './_root';
|
||||
|
||||
@@ -19,10 +20,9 @@ function createCurryWrapper(func, bitmask, arity) {
|
||||
|
||||
function wrapper() {
|
||||
var length = arguments.length,
|
||||
index = length,
|
||||
args = Array(length),
|
||||
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func,
|
||||
placeholder = wrapper.placeholder;
|
||||
index = length,
|
||||
placeholder = getPlaceholder(wrapper);
|
||||
|
||||
while (index--) {
|
||||
args[index] = arguments[index];
|
||||
@@ -32,9 +32,13 @@ function createCurryWrapper(func, bitmask, arity) {
|
||||
: replaceHolders(args, placeholder);
|
||||
|
||||
length -= holders.length;
|
||||
return length < arity
|
||||
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length)
|
||||
: apply(fn, this, args);
|
||||
if (length < arity) {
|
||||
return createRecurryWrapper(
|
||||
func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
|
||||
args, holders, undefined, undefined, arity - length);
|
||||
}
|
||||
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
||||
return apply(fn, this, args);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -6,18 +6,18 @@ import isArray from './isArray';
|
||||
import isLaziable from './_isLaziable';
|
||||
import rest from './rest';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var CURRY_FLAG = 8,
|
||||
PARTIAL_FLAG = 32,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var CURRY_FLAG = 8,
|
||||
PARTIAL_FLAG = 32,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/**
|
||||
* Creates a `_.flow` or `_.flowRight` function.
|
||||
*
|
||||
@@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
*/
|
||||
function createFlow(fromRight) {
|
||||
return rest(function(funcs) {
|
||||
funcs = baseFlatten(funcs);
|
||||
funcs = baseFlatten(funcs, 1);
|
||||
|
||||
var length = funcs.length,
|
||||
index = length,
|
||||
@@ -52,7 +52,10 @@ function createFlow(fromRight) {
|
||||
var funcName = getFuncName(func),
|
||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
||||
|
||||
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
||||
if (data && isLaziable(data[0]) &&
|
||||
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
|
||||
!data[4].length && data[9] == 1
|
||||
) {
|
||||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||
} else {
|
||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||
@@ -62,7 +65,8 @@ function createFlow(fromRight) {
|
||||
var args = arguments,
|
||||
value = args[0];
|
||||
|
||||
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
if (wrapper && args.length == 1 &&
|
||||
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
return wrapper.plant(value).value();
|
||||
}
|
||||
var index = 0,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import composeArgs from './_composeArgs';
|
||||
import composeArgsRight from './_composeArgsRight';
|
||||
import countHolders from './_countHolders';
|
||||
import createCtorWrapper from './_createCtorWrapper';
|
||||
import createRecurryWrapper from './_createRecurryWrapper';
|
||||
import getPlaceholder from './_getPlaceholder';
|
||||
import reorder from './_reorder';
|
||||
import replaceHolders from './_replaceHolders';
|
||||
import root from './_root';
|
||||
@@ -35,8 +37,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
||||
var isAry = bitmask & ARY_FLAG,
|
||||
isBind = bitmask & BIND_FLAG,
|
||||
isBindKey = bitmask & BIND_KEY_FLAG,
|
||||
isCurry = bitmask & CURRY_FLAG,
|
||||
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
|
||||
isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
|
||||
isFlip = bitmask & FLIP_FLAG,
|
||||
Ctor = isBindKey ? undefined : createCtorWrapper(func);
|
||||
|
||||
@@ -48,30 +49,34 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
||||
while (index--) {
|
||||
args[index] = arguments[index];
|
||||
}
|
||||
if (isCurried) {
|
||||
var placeholder = getPlaceholder(wrapper),
|
||||
holdersCount = countHolders(args, placeholder);
|
||||
}
|
||||
if (partials) {
|
||||
args = composeArgs(args, partials, holders);
|
||||
args = composeArgs(args, partials, holders, isCurried);
|
||||
}
|
||||
if (partialsRight) {
|
||||
args = composeArgsRight(args, partialsRight, holdersRight);
|
||||
args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
|
||||
}
|
||||
if (isCurry || isCurryRight) {
|
||||
var placeholder = wrapper.placeholder,
|
||||
argsHolders = replaceHolders(args, placeholder);
|
||||
|
||||
length -= argsHolders.length;
|
||||
if (length < arity) {
|
||||
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
|
||||
}
|
||||
length -= holdersCount;
|
||||
if (isCurried && length < arity) {
|
||||
var newHolders = replaceHolders(args, placeholder);
|
||||
return createRecurryWrapper(
|
||||
func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
|
||||
args, newHolders, argPos, ary, arity - length
|
||||
);
|
||||
}
|
||||
var thisBinding = isBind ? thisArg : this,
|
||||
fn = isBindKey ? thisBinding[func] : func;
|
||||
|
||||
length = args.length;
|
||||
if (argPos) {
|
||||
args = reorder(args, argPos);
|
||||
} else if (isFlip && args.length > 1) {
|
||||
} else if (isFlip && length > 1) {
|
||||
args.reverse();
|
||||
}
|
||||
if (isAry && ary < args.length) {
|
||||
if (isAry && ary < length) {
|
||||
args.length = ary;
|
||||
}
|
||||
if (this && this !== root && this instanceof wrapper) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import rest from './rest';
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return rest(function(iteratees) {
|
||||
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
|
||||
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
|
||||
return rest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
|
||||
@@ -17,7 +17,7 @@ var BIND_FLAG = 1,
|
||||
* @param {Function} func The function to wrap.
|
||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
||||
* @param {Function} wrapFunc The function to create the `func` wrapper.
|
||||
* @param {*} placeholder The placeholder to replace.
|
||||
* @param {*} placeholder The placeholder value.
|
||||
* @param {*} [thisArg] The `this` binding of `func`.
|
||||
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
|
||||
* @param {Array} [holders] The `partials` placeholder indexes.
|
||||
@@ -29,7 +29,7 @@ var BIND_FLAG = 1,
|
||||
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
||||
var isCurry = bitmask & CURRY_FLAG,
|
||||
newArgPos = argPos ? copyArray(argPos) : undefined,
|
||||
newsHolders = isCurry ? holders : undefined,
|
||||
newHolders = isCurry ? holders : undefined,
|
||||
newHoldersRight = isCurry ? undefined : holders,
|
||||
newPartials = isCurry ? partials : undefined,
|
||||
newPartialsRight = isCurry ? undefined : partials;
|
||||
@@ -40,9 +40,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||
}
|
||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
||||
result = wrapFunc.apply(undefined, newData);
|
||||
var newData = [
|
||||
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||
newHoldersRight, newArgPos, ary, arity
|
||||
];
|
||||
|
||||
var result = wrapFunc.apply(undefined, newData);
|
||||
if (isLaziable(func)) {
|
||||
setData(result, newData);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import mergeData from './_mergeData';
|
||||
import setData from './_setData';
|
||||
import toInteger from './toInteger';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
BIND_KEY_FLAG = 2,
|
||||
@@ -16,9 +19,6 @@ var BIND_FLAG = 1,
|
||||
PARTIAL_FLAG = 32,
|
||||
PARTIAL_RIGHT_FLAG = 64;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
|
||||
@@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
||||
|
||||
partials = holders = undefined;
|
||||
}
|
||||
var data = isBindKey ? undefined : getData(func),
|
||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
||||
var data = isBindKey ? undefined : getData(func);
|
||||
|
||||
var newData = [
|
||||
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||
argPos, ary, arity
|
||||
];
|
||||
|
||||
if (data) {
|
||||
mergeData(newData, data);
|
||||
|
||||
@@ -12,9 +12,9 @@ var UNORDERED_COMPARE_FLAG = 1,
|
||||
* @param {Array} array The array to compare.
|
||||
* @param {Array} other The other array 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 {Object} [stack] Tracks traversed `array` and `other` objects.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||||
*/
|
||||
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Symbol from './_Symbol';
|
||||
import Uint8Array from './_Uint8Array';
|
||||
import equalArrays from './_equalArrays';
|
||||
import mapToArray from './_mapToArray';
|
||||
import setToArray from './_setToArray';
|
||||
|
||||
@@ -22,7 +23,7 @@ var arrayBufferTag = '[object ArrayBuffer]';
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
|
||||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||||
@@ -36,11 +37,12 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {string} tag The `toStringTag` of the objects 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 {Function} customizer The function to customize comparisons.
|
||||
* @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`.
|
||||
*/
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
if ((object.byteLength != other.byteLength) ||
|
||||
@@ -75,12 +77,21 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||
convert || (convert = setToArray);
|
||||
|
||||
if (object.size != other.size && !isPartial) {
|
||||
return false;
|
||||
}
|
||||
// Assume cyclic values are equal.
|
||||
var stacked = stack.get(object);
|
||||
if (stacked) {
|
||||
return stacked == other;
|
||||
}
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
return (isPartial || object.size == other.size) &&
|
||||
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
|
||||
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other));
|
||||
|
||||
case symbolTag:
|
||||
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
|
||||
if (symbolValueOf) {
|
||||
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ var PARTIAL_COMPARE_FLAG = 2;
|
||||
* @param {Object} object The object to compare.
|
||||
* @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 {Object} [stack] Tracks traversed `object` and `other` objects.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @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`.
|
||||
*/
|
||||
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import isNative from './isNative';
|
||||
* @returns {*} Returns the function if it's native, else `undefined`.
|
||||
*/
|
||||
function getNative(object, key) {
|
||||
var value = object == null ? undefined : object[key];
|
||||
var value = object[key];
|
||||
return isNative(value) ? value : undefined;
|
||||
}
|
||||
|
||||
|
||||
13
_getPlaceholder.js
Normal file
13
_getPlaceholder.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Gets the argument placeholder value for `func`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to inspect.
|
||||
* @returns {*} Returns the placeholder value.
|
||||
*/
|
||||
function getPlaceholder(func) {
|
||||
var object = func;
|
||||
return object.placeholder;
|
||||
}
|
||||
|
||||
export default getPlaceholder;
|
||||
24
_getTag.js
24
_getTag.js
@@ -1,10 +1,12 @@
|
||||
import Map from './_Map';
|
||||
import Set from './_Set';
|
||||
import WeakMap from './_WeakMap';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
objectTag = '[object Object]',
|
||||
setTag = '[object Set]';
|
||||
setTag = '[object Set]',
|
||||
weakMapTag = '[object WeakMap]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -18,9 +20,10 @@ var funcToString = Function.prototype.toString;
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/** Used to detect maps and sets. */
|
||||
/** Used to detect maps, sets, and weakmaps. */
|
||||
var mapCtorString = Map ? funcToString.call(Map) : '',
|
||||
setCtorString = Set ? funcToString.call(Set) : '';
|
||||
setCtorString = Set ? funcToString.call(Set) : '',
|
||||
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
|
||||
|
||||
/**
|
||||
* Gets the `toStringTag` of `value`.
|
||||
@@ -33,19 +36,20 @@ function getTag(value) {
|
||||
return objectToString.call(value);
|
||||
}
|
||||
|
||||
// Fallback for IE 11 providing `toStringTag` values for maps and sets.
|
||||
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) {
|
||||
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
|
||||
if ((Map && getTag(new Map) != mapTag) ||
|
||||
(Set && getTag(new Set) != setTag) ||
|
||||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||||
getTag = function(value) {
|
||||
var result = objectToString.call(value),
|
||||
Ctor = result == objectTag ? value.constructor : null,
|
||||
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
|
||||
|
||||
if (ctorString) {
|
||||
if (ctorString == mapCtorString) {
|
||||
return mapTag;
|
||||
}
|
||||
if (ctorString == setCtorString) {
|
||||
return setTag;
|
||||
switch (ctorString) {
|
||||
case mapCtorString: return mapTag;
|
||||
case setCtorString: return setTag;
|
||||
case weakMapCtorString: return weakMapTag;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import baseToPath from './_baseToPath';
|
||||
import baseCastPath from './_baseCastPath';
|
||||
import isArguments from './isArguments';
|
||||
import isArray from './isArray';
|
||||
import isIndex from './_isIndex';
|
||||
@@ -23,7 +23,7 @@ function hasPath(object, path, hasFunc) {
|
||||
}
|
||||
var result = hasFunc(object, path);
|
||||
if (!result && !isKey(path)) {
|
||||
path = baseToPath(path);
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
if (object != null) {
|
||||
path = last(path);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import cloneBuffer from './_cloneBuffer';
|
||||
import cloneArrayBuffer from './_cloneArrayBuffer';
|
||||
import cloneMap from './_cloneMap';
|
||||
import cloneRegExp from './_cloneRegExp';
|
||||
import cloneSet from './_cloneSet';
|
||||
@@ -42,7 +42,7 @@ function initCloneByTag(object, tag, isDeep) {
|
||||
var Ctor = object.constructor;
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
return cloneBuffer(object);
|
||||
return cloneArrayBuffer(object);
|
||||
|
||||
case boolTag:
|
||||
case dateTag:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import baseCreate from './_baseCreate';
|
||||
import isFunction from './isFunction';
|
||||
import isPrototype from './_isPrototype';
|
||||
|
||||
/** Built-in value references. */
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
|
||||
/**
|
||||
* Initializes an object clone.
|
||||
*
|
||||
@@ -10,11 +12,9 @@ import isPrototype from './_isPrototype';
|
||||
* @returns {Object} Returns the initialized clone.
|
||||
*/
|
||||
function initCloneObject(object) {
|
||||
if (isPrototype(object)) {
|
||||
return {};
|
||||
}
|
||||
var Ctor = object.constructor;
|
||||
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
|
||||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||||
? baseCreate(getPrototypeOf(object))
|
||||
: {};
|
||||
}
|
||||
|
||||
export default initCloneObject;
|
||||
|
||||
@@ -4,7 +4,7 @@ import isIndex from './_isIndex';
|
||||
import isObject from './isObject';
|
||||
|
||||
/**
|
||||
* Checks if the provided arguments are from an iteratee call.
|
||||
* Checks if the given arguments are from an iteratee call.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The potential iteratee value argument.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
function isKeyable(value) {
|
||||
var type = typeof value;
|
||||
return type == 'number' || type == 'boolean' ||
|
||||
(type == 'string' && value !== '__proto__') || value == null;
|
||||
(type == 'string' && value != '__proto__') || value == null;
|
||||
}
|
||||
|
||||
export default isKeyable;
|
||||
|
||||
@@ -36,7 +36,8 @@ function lazyValue() {
|
||||
resIndex = 0,
|
||||
takeCount = nativeMin(length, this.__takeCount__);
|
||||
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
|
||||
(arrLength == length && takeCount == length)) {
|
||||
return baseWrapperValue(array, this.__actions__);
|
||||
}
|
||||
var result = [];
|
||||
|
||||
@@ -9,7 +9,11 @@ import Map from './_Map';
|
||||
* @memberOf MapCache
|
||||
*/
|
||||
function mapClear() {
|
||||
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
|
||||
this.__data__ = {
|
||||
'hash': new Hash,
|
||||
'map': Map ? new Map : [],
|
||||
'string': new Hash
|
||||
};
|
||||
}
|
||||
|
||||
export default mapClear;
|
||||
|
||||
@@ -3,6 +3,9 @@ import composeArgsRight from './_composeArgsRight';
|
||||
import copyArray from './_copyArray';
|
||||
import replaceHolders from './_replaceHolders';
|
||||
|
||||
/** Used as the internal argument placeholder. */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
BIND_KEY_FLAG = 2,
|
||||
@@ -11,9 +14,6 @@ var BIND_FLAG = 1,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/** Used as the internal argument placeholder. */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
|
||||
@@ -39,9 +39,9 @@ function mergeData(data, source) {
|
||||
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
|
||||
|
||||
var isCombo =
|
||||
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) ||
|
||||
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
||||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
||||
((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
|
||||
((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
||||
((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
||||
|
||||
// Exit early if metadata can't be merged.
|
||||
if (!(isCommon || isCombo)) {
|
||||
@@ -51,7 +51,7 @@ function mergeData(data, source) {
|
||||
if (srcBitmask & BIND_FLAG) {
|
||||
data[2] = source[2];
|
||||
// Set when currying a bound function.
|
||||
newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
|
||||
newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
|
||||
}
|
||||
// Compose partial arguments.
|
||||
var value = source[3];
|
||||
|
||||
@@ -15,8 +15,7 @@ import isObject from './isObject';
|
||||
*/
|
||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||
if (isObject(objValue) && isObject(srcValue)) {
|
||||
stack.set(srcValue, objValue);
|
||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
|
||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ var PLACEHOLDER = '__lodash_placeholder__';
|
||||
function replaceHolders(array, placeholder) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === placeholder) {
|
||||
var value = array[index];
|
||||
if (value === placeholder || value === PLACEHOLDER) {
|
||||
array[index] = PLACEHOLDER;
|
||||
result[++resIndex] = index;
|
||||
result[resIndex++] = index;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
12
_root.js
12
_root.js
@@ -7,10 +7,14 @@ var objectTypes = {
|
||||
};
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||
? exports
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||
? module
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||
@@ -30,6 +34,8 @@ var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
|
||||
var root = freeGlobal ||
|
||||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
|
||||
freeSelf || thisGlobal || Function('return this')();
|
||||
|
||||
export default root;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import isArrayLikeObject from './isArrayLikeObject';
|
||||
|
||||
/**
|
||||
* Converts `value` to an array-like object if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Array} Returns the array-like object.
|
||||
*/
|
||||
function toArrayLikeObject(value) {
|
||||
return isArrayLikeObject(value) ? value : [];
|
||||
}
|
||||
|
||||
export default toArrayLikeObject;
|
||||
@@ -1,14 +0,0 @@
|
||||
import identity from './identity';
|
||||
|
||||
/**
|
||||
* Converts `value` to a function if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Function} Returns the function.
|
||||
*/
|
||||
function toFunction(value) {
|
||||
return typeof value == 'function' ? value : identity;
|
||||
}
|
||||
|
||||
export default toFunction;
|
||||
3
add.js
3
add.js
@@ -14,6 +14,9 @@
|
||||
*/
|
||||
function add(augend, addend) {
|
||||
var result;
|
||||
if (augend === undefined && addend === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (augend !== undefined) {
|
||||
result = augend;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import findIndex from './findIndex';
|
||||
import findLastIndex from './findLastIndex';
|
||||
import flatten from './flatten';
|
||||
import flattenDeep from './flattenDeep';
|
||||
import flattenDepth from './flattenDepth';
|
||||
import fromPairs from './fromPairs';
|
||||
import head from './head';
|
||||
import indexOf from './indexOf';
|
||||
@@ -26,6 +27,7 @@ import lastIndexOf from './lastIndexOf';
|
||||
import pull from './pull';
|
||||
import pullAll from './pullAll';
|
||||
import pullAllBy from './pullAllBy';
|
||||
import pullAllWith from './pullAllWith';
|
||||
import pullAt from './pullAt';
|
||||
import remove from './remove';
|
||||
import reverse from './reverse';
|
||||
@@ -64,14 +66,14 @@ export default {
|
||||
chunk, compact, concat, difference, differenceBy,
|
||||
differenceWith, drop, dropRight, dropRightWhile, dropWhile,
|
||||
fill, findIndex, findLastIndex, flatten, flattenDeep,
|
||||
fromPairs, head, indexOf, initial, intersection,
|
||||
intersectionBy, intersectionWith, join, last, lastIndexOf,
|
||||
pull, pullAll, pullAllBy, pullAt, remove,
|
||||
reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf,
|
||||
sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy,
|
||||
tail, take, takeRight, takeRightWhile, takeWhile,
|
||||
union, unionBy, unionWith, uniq, uniqBy,
|
||||
uniqWith, unzip, unzipWith, without, xor,
|
||||
xorBy, xorWith, zip, zipObject, zipObjectDeep,
|
||||
zipWith
|
||||
flattenDepth, fromPairs, head, indexOf, initial,
|
||||
intersection, intersectionBy, intersectionWith, join, last,
|
||||
lastIndexOf, pull, pullAll, pullAllBy, pullAllWith,
|
||||
pullAt, remove, reverse, slice, sortedIndex,
|
||||
sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf,
|
||||
sortedUniq, sortedUniqBy, tail, take, takeRight,
|
||||
takeRightWhile, takeWhile, union, unionBy, unionWith,
|
||||
uniq, uniqBy, uniqWith, unzip, unzipWith,
|
||||
without, xor, xorBy, xorWith, zip,
|
||||
zipObject, zipObjectDeep, zipWith
|
||||
};
|
||||
|
||||
2
array.js
2
array.js
@@ -13,6 +13,7 @@ export { default as findIndex } from './findIndex';
|
||||
export { default as findLastIndex } from './findLastIndex';
|
||||
export { default as flatten } from './flatten';
|
||||
export { default as flattenDeep } from './flattenDeep';
|
||||
export { default as flattenDepth } from './flattenDepth';
|
||||
export { default as fromPairs } from './fromPairs';
|
||||
export { default as head } from './head';
|
||||
export { default as indexOf } from './indexOf';
|
||||
@@ -26,6 +27,7 @@ export { default as lastIndexOf } from './lastIndexOf';
|
||||
export { default as pull } from './pull';
|
||||
export { default as pullAll } from './pullAll';
|
||||
export { default as pullAllBy } from './pullAllBy';
|
||||
export { default as pullAllWith } from './pullAllWith';
|
||||
export { default as pullAt } from './pullAt';
|
||||
export { default as remove } from './remove';
|
||||
export { default as reverse } from './reverse';
|
||||
|
||||
22
assign.js
22
assign.js
@@ -1,7 +1,19 @@
|
||||
import assignValue from './_assignValue';
|
||||
import copyObject from './_copyObject';
|
||||
import createAssigner from './_createAssigner';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isPrototype from './_isPrototype';
|
||||
import keys from './keys';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
|
||||
|
||||
/**
|
||||
* Assigns own enumerable properties of source objects to the destination
|
||||
* object. Source objects are applied from left to right. Subsequent sources
|
||||
@@ -33,7 +45,15 @@ import keys from './keys';
|
||||
* // => { 'a': 1, 'c': 3, 'e': 5 }
|
||||
*/
|
||||
var assign = createAssigner(function(object, source) {
|
||||
copyObject(source, keys(source), object);
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keys(source), object);
|
||||
return;
|
||||
}
|
||||
for (var key in source) {
|
||||
if (hasOwnProperty.call(source, key)) {
|
||||
assignValue(object, key, source[key]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default assign;
|
||||
|
||||
14
assignIn.js
14
assignIn.js
@@ -1,7 +1,13 @@
|
||||
import assignValue from './_assignValue';
|
||||
import copyObject from './_copyObject';
|
||||
import createAssigner from './_createAssigner';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isPrototype from './_isPrototype';
|
||||
import keysIn from './keysIn';
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it iterates over own and
|
||||
* inherited source properties.
|
||||
@@ -32,7 +38,13 @@ import keysIn from './keysIn';
|
||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
|
||||
*/
|
||||
var assignIn = createAssigner(function(object, source) {
|
||||
copyObject(source, keysIn(source), object);
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keysIn(source), object);
|
||||
return;
|
||||
}
|
||||
for (var key in source) {
|
||||
assignValue(object, key, source[key]);
|
||||
}
|
||||
});
|
||||
|
||||
export default assignIn;
|
||||
|
||||
2
at.js
2
at.js
@@ -23,7 +23,7 @@ import rest from './rest';
|
||||
* // => ['a', 'c']
|
||||
*/
|
||||
var at = rest(function(object, paths) {
|
||||
return baseAt(object, baseFlatten(paths));
|
||||
return baseAt(object, baseFlatten(paths, 1));
|
||||
});
|
||||
|
||||
export default at;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import apply from './_apply';
|
||||
import isObject from './isObject';
|
||||
import isError from './isError';
|
||||
import rest from './rest';
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ var attempt = rest(function(func, args) {
|
||||
try {
|
||||
return apply(func, undefined, args);
|
||||
} catch (e) {
|
||||
return isObject(e) ? e : new Error(e);
|
||||
return isError(e) ? e : new Error(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
6
bind.js
6
bind.js
@@ -1,4 +1,5 @@
|
||||
import createWrapper from './_createWrapper';
|
||||
import getPlaceholder from './_getPlaceholder';
|
||||
import replaceHolders from './_replaceHolders';
|
||||
import rest from './rest';
|
||||
|
||||
@@ -44,10 +45,13 @@ var BIND_FLAG = 1,
|
||||
var bind = rest(function(func, thisArg, partials) {
|
||||
var bitmask = BIND_FLAG;
|
||||
if (partials.length) {
|
||||
var holders = replaceHolders(partials, bind.placeholder);
|
||||
var holders = replaceHolders(partials, getPlaceholder(bind));
|
||||
bitmask |= PARTIAL_FLAG;
|
||||
}
|
||||
return createWrapper(func, bitmask, thisArg, partials, holders);
|
||||
});
|
||||
|
||||
// Assign default placeholders.
|
||||
bind.placeholder = {};
|
||||
|
||||
export default bind;
|
||||
|
||||
@@ -30,7 +30,7 @@ import rest from './rest';
|
||||
* // => logs 'clicked docs' when clicked
|
||||
*/
|
||||
var bindAll = rest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames), function(key) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
object[key] = bind(object[key], object);
|
||||
});
|
||||
return object;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import createWrapper from './_createWrapper';
|
||||
import getPlaceholder from './_getPlaceholder';
|
||||
import replaceHolders from './_replaceHolders';
|
||||
import rest from './rest';
|
||||
|
||||
@@ -54,10 +55,13 @@ var BIND_FLAG = 1,
|
||||
var bindKey = rest(function(object, key, partials) {
|
||||
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
||||
if (partials.length) {
|
||||
var holders = replaceHolders(partials, bindKey.placeholder);
|
||||
var holders = replaceHolders(partials, getPlaceholder(bindKey));
|
||||
bitmask |= PARTIAL_FLAG;
|
||||
}
|
||||
return createWrapper(key, bitmask, object, partials, holders);
|
||||
});
|
||||
|
||||
// Assign default placeholders.
|
||||
bindKey.placeholder = {};
|
||||
|
||||
export default bindKey;
|
||||
|
||||
43
castArray.js
Normal file
43
castArray.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import isArray from './isArray';
|
||||
|
||||
/**
|
||||
* Casts `value` as an array if it's not one.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast array.
|
||||
* @example
|
||||
*
|
||||
* _.castArray(1);
|
||||
* // => [1]
|
||||
*
|
||||
* _.castArray({ 'a': 1 });
|
||||
* // => [{ 'a': 1 }]
|
||||
*
|
||||
* _.castArray('abc');
|
||||
* // => ['abc']
|
||||
*
|
||||
* _.castArray(null);
|
||||
* // => [null]
|
||||
*
|
||||
* _.castArray(undefined);
|
||||
* // => [undefined]
|
||||
*
|
||||
* _.castArray();
|
||||
* // => []
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
* console.log(_.castArray(array) === array);
|
||||
* // => true
|
||||
*/
|
||||
function castArray() {
|
||||
if (!arguments.length) {
|
||||
return [];
|
||||
}
|
||||
var value = arguments[0];
|
||||
return isArray(value) ? value : [value];
|
||||
}
|
||||
|
||||
export default castArray;
|
||||
4
chunk.js
4
chunk.js
@@ -32,11 +32,11 @@ function chunk(array, size) {
|
||||
return [];
|
||||
}
|
||||
var index = 0,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = Array(nativeCeil(length / size));
|
||||
|
||||
while (index < length) {
|
||||
result[++resIndex] = baseSlice(array, index, (index += size));
|
||||
result[resIndex++] = baseSlice(array, index, (index += size));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
function compact(array) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (value) {
|
||||
result[++resIndex] = value;
|
||||
result[resIndex++] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -28,7 +28,7 @@ var concat = rest(function(array, values) {
|
||||
if (!isArray(array)) {
|
||||
array = array == null ? [] : [Object(array)];
|
||||
}
|
||||
values = baseFlatten(values);
|
||||
values = baseFlatten(values, 1);
|
||||
return arrayConcat(array, values);
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import baseCreate from './_baseCreate';
|
||||
|
||||
/**
|
||||
* Creates an object that inherits from the `prototype` object. If a `properties`
|
||||
* object is provided its own enumerable properties are assigned to the created object.
|
||||
* object is given its own enumerable properties are assigned to the created object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
3
curry.js
3
curry.js
@@ -50,4 +50,7 @@ function curry(func, arity, guard) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Assign default placeholders.
|
||||
curry.placeholder = {};
|
||||
|
||||
export default curry;
|
||||
|
||||
@@ -47,4 +47,7 @@ function curryRight(func, arity, guard) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Assign default placeholders.
|
||||
curryRight.placeholder = {};
|
||||
|
||||
export default curryRight;
|
||||
|
||||
10
debounce.js
10
debounce.js
@@ -19,7 +19,7 @@ var nativeMax = Math.max;
|
||||
* to the debounced function return the result of the last `func` invocation.
|
||||
*
|
||||
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
||||
* on the trailing edge of the timeout only if the the debounced function is
|
||||
* on the trailing edge of the timeout only if the debounced function is
|
||||
* invoked more than once during the `wait` timeout.
|
||||
*
|
||||
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
||||
@@ -135,11 +135,13 @@ function debounce(func, wait, options) {
|
||||
if (maxWait === false) {
|
||||
var leadingCall = leading && !timeoutId;
|
||||
} else {
|
||||
if (!maxTimeoutId && !leading) {
|
||||
if (!lastCalled && !maxTimeoutId && !leading) {
|
||||
lastCalled = stamp;
|
||||
}
|
||||
var remaining = maxWait - (stamp - lastCalled),
|
||||
isCalled = remaining <= 0 || remaining > maxWait;
|
||||
var remaining = maxWait - (stamp - lastCalled);
|
||||
|
||||
var isCalled = (remaining <= 0 || remaining > maxWait) &&
|
||||
(leading || maxTimeoutId);
|
||||
|
||||
if (isCalled) {
|
||||
if (maxTimeoutId) {
|
||||
|
||||
@@ -5,8 +5,9 @@ import rest from './rest';
|
||||
|
||||
/**
|
||||
* Creates an array of unique `array` values not included in the other
|
||||
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
* given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* for equality comparisons. The order of result values is determined by the
|
||||
* order they occur in the first array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -21,7 +22,7 @@ import rest from './rest';
|
||||
*/
|
||||
var difference = rest(function(array, values) {
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true))
|
||||
? baseDifference(array, baseFlatten(values, 1, true))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ import rest from './rest';
|
||||
/**
|
||||
* This method is like `_.difference` except that it accepts `iteratee` which
|
||||
* is invoked for each element of `array` and `values` to generate the criterion
|
||||
* by which uniqueness is computed. The iteratee is invoked with one argument: (value).
|
||||
* by which they're compared. Result values are chosen from the first array.
|
||||
* The iteratee is invoked with one argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -32,7 +33,7 @@ var differenceBy = rest(function(array, values) {
|
||||
iteratee = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee))
|
||||
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ import rest from './rest';
|
||||
|
||||
/**
|
||||
* This method is like `_.difference` except that it accepts `comparator`
|
||||
* which is invoked to compare elements of `array` to `values`. The comparator
|
||||
* is invoked with two arguments: (arrVal, othVal).
|
||||
* which is invoked to compare elements of `array` to `values`. Result values
|
||||
* are chosen from the first array. The comparator is invoked with two arguments:
|
||||
* (arrVal, othVal).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -29,7 +30,7 @@ var differenceWith = rest(function(array, values) {
|
||||
comparator = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
|
||||
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import map from './map';
|
||||
* // => [1, 1, 2, 2]
|
||||
*/
|
||||
function flatMap(collection, iteratee) {
|
||||
return baseFlatten(map(collection, iteratee));
|
||||
return baseFlatten(map(collection, iteratee), 1);
|
||||
}
|
||||
|
||||
export default flatMap;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import baseFlatten from './_baseFlatten';
|
||||
|
||||
/**
|
||||
* Flattens `array` a single level.
|
||||
* Flattens `array` a single level deep.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -10,12 +10,12 @@ import baseFlatten from './_baseFlatten';
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flatten([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, [4]]
|
||||
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, [3, [4]], 5]
|
||||
*/
|
||||
function flatten(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array) : [];
|
||||
return length ? baseFlatten(array, 1) : [];
|
||||
}
|
||||
|
||||
export default flatten;
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
import baseFlatten from './_baseFlatten';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
|
||||
/**
|
||||
* This method is like `_.flatten` except that it recursively flattens `array`.
|
||||
* Recursively flattens `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} array The array to recursively flatten.
|
||||
* @param {Array} array The array to flatten.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, 4]
|
||||
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, 3, 4, 5]
|
||||
*/
|
||||
function flattenDeep(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array, true) : [];
|
||||
return length ? baseFlatten(array, INFINITY) : [];
|
||||
}
|
||||
|
||||
export default flattenDeep;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user