mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94ba2e24e8 | ||
|
|
8bff780a94 | ||
|
|
f18e5950b9 | ||
|
|
365d103439 |
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.1.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.1.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.4.0-es) for more details.
|
||||||
|
|||||||
1
_Hash.js
1
_Hash.js
@@ -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() {}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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) {
|
||||||
|
|||||||
@@ -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]);
|
||||||
|
|||||||
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 assignValue from './_assignValue';
|
||||||
import baseAssign from './_baseAssign';
|
import baseAssign from './_baseAssign';
|
||||||
import baseForOwn from './_baseForOwn';
|
import baseForOwn from './_baseForOwn';
|
||||||
|
import cloneBuffer from './_cloneBuffer';
|
||||||
import copyArray from './_copyArray';
|
import copyArray from './_copyArray';
|
||||||
import copySymbols from './_copySymbols';
|
import copySymbols from './_copySymbols';
|
||||||
import getTag from './_getTag';
|
import getTag from './_getTag';
|
||||||
@@ -10,6 +11,7 @@ import initCloneArray from './_initCloneArray';
|
|||||||
import initCloneByTag from './_initCloneByTag';
|
import initCloneByTag from './_initCloneByTag';
|
||||||
import initCloneObject from './_initCloneObject';
|
import initCloneObject from './_initCloneObject';
|
||||||
import isArray from './isArray';
|
import isArray from './isArray';
|
||||||
|
import isBuffer from './isBuffer';
|
||||||
import isHostObject from './_isHostObject';
|
import isHostObject from './_isHostObject';
|
||||||
import isObject from './isObject';
|
import isObject from './isObject';
|
||||||
|
|
||||||
@@ -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,5 +1,8 @@
|
|||||||
import isObject from './isObject';
|
import isObject from './isObject';
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var objectCreate = Object.create;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.create` without support for assigning
|
* The base implementation of `_.create` without support for assigning
|
||||||
* properties to the created object.
|
* properties to the created object.
|
||||||
@@ -8,16 +11,8 @@ import isObject from './isObject';
|
|||||||
* @param {Object} prototype The object to inherit from.
|
* @param {Object} prototype The object to inherit from.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
var baseCreate = (function() {
|
function baseCreate(proto) {
|
||||||
function object() {}
|
return isObject(proto) ? objectCreate(proto) : {};
|
||||||
return function(prototype) {
|
}
|
||||||
if (isObject(prototype)) {
|
|
||||||
object.prototype = prototype;
|
|
||||||
var result = new object;
|
|
||||||
object.prototype = undefined;
|
|
||||||
}
|
|
||||||
return result || {};
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
export default baseCreate;
|
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) {
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import isArrayLikeObject from './isArrayLikeObject';
|
|||||||
*
|
*
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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,4 +1,4 @@
|
|||||||
import baseToPath from './_baseToPath';
|
import baseCastPath from './_baseCastPath';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
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';
|
||||||
@@ -16,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ 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;
|
||||||
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
|||||||
baseMergeDeep(object, source, key, srcIndex, 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
assignMergeValue(object, key, stacked);
|
assignMergeValue(object, key, stacked);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
var newValue = customizer
|
||||||
isCommon = newValue === undefined;
|
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var isCommon = newValue === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||||
if (isArray(objValue)) {
|
if (isArray(objValue)) {
|
||||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
else if (isArrayLikeObject(objValue)) {
|
else if (isArrayLikeObject(objValue)) {
|
||||||
newValue = copyArray(objValue);
|
newValue = copyArray(objValue);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
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))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
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';
|
||||||
@@ -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,5 +1,5 @@
|
|||||||
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';
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function baseSum(array, iteratee) {
|
|||||||
result = result === undefined ? current : (result + current);
|
result = result === undefined ? current : (result + current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return length ? result : 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseSum;
|
export default baseSum;
|
||||||
|
|||||||
@@ -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 has from './has';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
@@ -13,7 +13,7 @@ import parent from './_parent';
|
|||||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseUnset(object, path) {
|
function baseUnset(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
var key = last(path);
|
var key = last(path);
|
||||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||||
|
|||||||
19
_cloneArrayBuffer.js
Normal file
19
_cloneArrayBuffer.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
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 Ctor = arrayBuffer.constructor,
|
||||||
|
result = new Ctor(arrayBuffer.byteLength),
|
||||||
|
view = new Uint8Array(result);
|
||||||
|
|
||||||
|
view.set(new Uint8Array(arrayBuffer));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default cloneArrayBuffer;
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
import Uint8Array from './_Uint8Array';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `buffer`.
|
* Creates a clone of `buffer`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {ArrayBuffer} buffer The array buffer to clone.
|
* @param {Buffer} buffer The buffer to clone.
|
||||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
|
* @returns {Buffer} Returns the cloned buffer.
|
||||||
*/
|
*/
|
||||||
function cloneBuffer(buffer) {
|
function cloneBuffer(buffer, isDeep) {
|
||||||
|
if (isDeep) {
|
||||||
|
return buffer.slice();
|
||||||
|
}
|
||||||
var Ctor = buffer.constructor,
|
var Ctor = buffer.constructor,
|
||||||
result = new Ctor(buffer.byteLength),
|
result = new Ctor(buffer.length);
|
||||||
view = new Uint8Array(result);
|
|
||||||
|
|
||||||
view.set(new Uint8Array(buffer));
|
buffer.copy(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import cloneBuffer from './_cloneBuffer';
|
import cloneArrayBuffer from './_cloneArrayBuffer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `typedArray`.
|
* Creates a clone of `typedArray`.
|
||||||
@@ -9,10 +9,11 @@ import cloneBuffer from './_cloneBuffer';
|
|||||||
* @returns {Object} Returns the cloned typed array.
|
* @returns {Object} Returns the cloned typed array.
|
||||||
*/
|
*/
|
||||||
function cloneTypedArray(typedArray, isDeep) {
|
function cloneTypedArray(typedArray, isDeep) {
|
||||||
var buffer = typedArray.buffer,
|
var arrayBuffer = typedArray.buffer,
|
||||||
|
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
|
||||||
Ctor = typedArray.constructor;
|
Ctor = typedArray.constructor;
|
||||||
|
|
||||||
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default cloneTypedArray;
|
export default cloneTypedArray;
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) {
|
|||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index],
|
var key = props[index];
|
||||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
|
||||||
|
var newValue = customizer
|
||||||
|
? customizer(object[key], source[key], key, object, source)
|
||||||
|
: source[key];
|
||||||
|
|
||||||
assignValue(object, key, newValue);
|
assignValue(object, key, newValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ function createAssigner(assigner) {
|
|||||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||||
guard = length > 2 ? sources[2] : 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)) {
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||||
customizer = length < 3 ? undefined : customizer;
|
customizer = length < 3 ? undefined : customizer;
|
||||||
length = 1;
|
length = 1;
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ function createCaseFirst(methodName) {
|
|||||||
return function(string) {
|
return function(string) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
|
|
||||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
var strSymbols = reHasComplexSymbol.test(string)
|
||||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
? stringToArray(string)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||||
|
|
||||||
return chr[methodName]() + trailing;
|
return chr[methodName]() + trailing;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
|||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return rest(function(funcs) {
|
return rest(function(funcs) {
|
||||||
funcs = baseFlatten(funcs);
|
funcs = baseFlatten(funcs, 1);
|
||||||
|
|
||||||
var length = funcs.length,
|
var length = funcs.length,
|
||||||
index = length,
|
index = length,
|
||||||
@@ -52,7 +52,10 @@ function createFlow(fromRight) {
|
|||||||
var funcName = getFuncName(func),
|
var funcName = getFuncName(func),
|
||||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
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]);
|
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||||
} else {
|
} else {
|
||||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||||
@@ -62,7 +65,8 @@ function createFlow(fromRight) {
|
|||||||
var args = arguments,
|
var args = arguments,
|
||||||
value = args[0];
|
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();
|
return wrapper.plant(value).value();
|
||||||
}
|
}
|
||||||
var index = 0,
|
var index = 0,
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
|||||||
|
|
||||||
length -= argsHolders.length;
|
length -= argsHolders.length;
|
||||||
if (length < arity) {
|
if (length < arity) {
|
||||||
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
|
return createRecurryWrapper(
|
||||||
|
func, bitmask, createHybridWrapper, placeholder, thisArg, args,
|
||||||
|
argsHolders, argPos, ary, arity - length
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var thisBinding = isBind ? thisArg : this,
|
var thisBinding = isBind ? thisArg : this,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return rest(function(iteratees) {
|
return rest(function(iteratees) {
|
||||||
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
|
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var thisArg = this;
|
var thisArg = this;
|
||||||
return arrayFunc(iteratees, function(iteratee) {
|
return arrayFunc(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -40,9 +40,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
|||||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||||
}
|
}
|
||||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
var newData = [
|
||||||
result = wrapFunc.apply(undefined, newData);
|
func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight,
|
||||||
|
newHoldersRight, newArgPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
|
var result = wrapFunc.apply(undefined, newData);
|
||||||
if (isLaziable(func)) {
|
if (isLaziable(func)) {
|
||||||
setData(result, newData);
|
setData(result, newData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
|||||||
|
|
||||||
partials = holders = undefined;
|
partials = holders = undefined;
|
||||||
}
|
}
|
||||||
var data = isBindKey ? undefined : getData(func),
|
var data = isBindKey ? undefined : getData(func);
|
||||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
|
||||||
|
var newData = [
|
||||||
|
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||||
|
argPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mergeData(newData, data);
|
mergeData(newData, data);
|
||||||
|
|||||||
24
_getTag.js
24
_getTag.js
@@ -1,10 +1,12 @@
|
|||||||
import Map from './_Map';
|
import Map from './_Map';
|
||||||
import Set from './_Set';
|
import Set from './_Set';
|
||||||
|
import WeakMap from './_WeakMap';
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var mapTag = '[object Map]',
|
var mapTag = '[object Map]',
|
||||||
objectTag = '[object Object]',
|
objectTag = '[object Object]',
|
||||||
setTag = '[object Set]';
|
setTag = '[object Set]',
|
||||||
|
weakMapTag = '[object WeakMap]';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -18,9 +20,10 @@ var funcToString = Function.prototype.toString;
|
|||||||
*/
|
*/
|
||||||
var objectToString = objectProto.toString;
|
var objectToString = objectProto.toString;
|
||||||
|
|
||||||
/** Used to detect maps and sets. */
|
/** Used to detect maps, sets, and weakmaps. */
|
||||||
var mapCtorString = Map ? funcToString.call(Map) : '',
|
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`.
|
* Gets the `toStringTag` of `value`.
|
||||||
@@ -33,19 +36,20 @@ function getTag(value) {
|
|||||||
return objectToString.call(value);
|
return objectToString.call(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for IE 11 providing `toStringTag` values for maps and sets.
|
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
|
||||||
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) {
|
if ((Map && getTag(new Map) != mapTag) ||
|
||||||
|
(Set && getTag(new Set) != setTag) ||
|
||||||
|
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||||||
getTag = function(value) {
|
getTag = function(value) {
|
||||||
var result = objectToString.call(value),
|
var result = objectToString.call(value),
|
||||||
Ctor = result == objectTag ? value.constructor : null,
|
Ctor = result == objectTag ? value.constructor : null,
|
||||||
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
|
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
|
||||||
|
|
||||||
if (ctorString) {
|
if (ctorString) {
|
||||||
if (ctorString == mapCtorString) {
|
switch (ctorString) {
|
||||||
return mapTag;
|
case mapCtorString: return mapTag;
|
||||||
}
|
case setCtorString: return setTag;
|
||||||
if (ctorString == setCtorString) {
|
case weakMapCtorString: return weakMapTag;
|
||||||
return setTag;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import baseToPath from './_baseToPath';
|
import baseCastPath from './_baseCastPath';
|
||||||
import isArguments from './isArguments';
|
import isArguments from './isArguments';
|
||||||
import isArray from './isArray';
|
import isArray from './isArray';
|
||||||
import isIndex from './_isIndex';
|
import isIndex from './_isIndex';
|
||||||
@@ -23,7 +23,7 @@ function hasPath(object, path, hasFunc) {
|
|||||||
}
|
}
|
||||||
var result = hasFunc(object, path);
|
var result = hasFunc(object, path);
|
||||||
if (!result && !isKey(path)) {
|
if (!result && !isKey(path)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
path = last(path);
|
path = last(path);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import cloneBuffer from './_cloneBuffer';
|
import cloneArrayBuffer from './_cloneArrayBuffer';
|
||||||
import cloneMap from './_cloneMap';
|
import cloneMap from './_cloneMap';
|
||||||
import cloneRegExp from './_cloneRegExp';
|
import cloneRegExp from './_cloneRegExp';
|
||||||
import cloneSet from './_cloneSet';
|
import cloneSet from './_cloneSet';
|
||||||
@@ -42,7 +42,7 @@ function initCloneByTag(object, tag, isDeep) {
|
|||||||
var Ctor = object.constructor;
|
var Ctor = object.constructor;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case arrayBufferTag:
|
case arrayBufferTag:
|
||||||
return cloneBuffer(object);
|
return cloneArrayBuffer(object);
|
||||||
|
|
||||||
case boolTag:
|
case boolTag:
|
||||||
case dateTag:
|
case dateTag:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import isIndex from './_isIndex';
|
|||||||
import isObject from './isObject';
|
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
|
* @private
|
||||||
* @param {*} value The potential iteratee value argument.
|
* @param {*} value The potential iteratee value argument.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
function isKeyable(value) {
|
function isKeyable(value) {
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
return type == 'number' || type == 'boolean' ||
|
return type == 'number' || type == 'boolean' ||
|
||||||
(type == 'string' && value !== '__proto__') || value == null;
|
(type == 'string' && value != '__proto__') || value == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isKeyable;
|
export default isKeyable;
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ function lazyValue() {
|
|||||||
resIndex = 0,
|
resIndex = 0,
|
||||||
takeCount = nativeMin(length, this.__takeCount__);
|
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__);
|
return baseWrapperValue(array, this.__actions__);
|
||||||
}
|
}
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ import Map from './_Map';
|
|||||||
* @memberOf MapCache
|
* @memberOf MapCache
|
||||||
*/
|
*/
|
||||||
function mapClear() {
|
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;
|
export default mapClear;
|
||||||
|
|||||||
12
_root.js
12
_root.js
@@ -7,10 +7,14 @@ var objectTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Detect free variable `exports`. */
|
/** 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`. */
|
/** 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. */
|
/** Detect free variable `global` from Node.js. */
|
||||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
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
|
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||||
* restricted `window` object, otherwise the `window` object is used.
|
* 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;
|
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) {
|
function add(augend, addend) {
|
||||||
var result;
|
var result;
|
||||||
|
if (augend === undefined && addend === undefined) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (augend !== undefined) {
|
if (augend !== undefined) {
|
||||||
result = augend;
|
result = augend;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import dropWhile from './dropWhile';
|
|||||||
import fill from './fill';
|
import fill from './fill';
|
||||||
import findIndex from './findIndex';
|
import findIndex from './findIndex';
|
||||||
import findLastIndex from './findLastIndex';
|
import findLastIndex from './findLastIndex';
|
||||||
import flatMap from './flatMap';
|
|
||||||
import flatten from './flatten';
|
import flatten from './flatten';
|
||||||
import flattenDeep from './flattenDeep';
|
import flattenDeep from './flattenDeep';
|
||||||
|
import flattenDepth from './flattenDepth';
|
||||||
import fromPairs from './fromPairs';
|
import fromPairs from './fromPairs';
|
||||||
import head from './head';
|
import head from './head';
|
||||||
import indexOf from './indexOf';
|
import indexOf from './indexOf';
|
||||||
@@ -64,8 +64,8 @@ import zipWith from './zipWith';
|
|||||||
export default {
|
export default {
|
||||||
chunk, compact, concat, difference, differenceBy,
|
chunk, compact, concat, difference, differenceBy,
|
||||||
differenceWith, drop, dropRight, dropRightWhile, dropWhile,
|
differenceWith, drop, dropRight, dropRightWhile, dropWhile,
|
||||||
fill, findIndex, findLastIndex, flatMap, flatten,
|
fill, findIndex, findLastIndex, flatten, flattenDeep,
|
||||||
flattenDeep, fromPairs, head, indexOf, initial,
|
flattenDepth, fromPairs, head, indexOf, initial,
|
||||||
intersection, intersectionBy, intersectionWith, join, last,
|
intersection, intersectionBy, intersectionWith, join, last,
|
||||||
lastIndexOf, pull, pullAll, pullAllBy, pullAt,
|
lastIndexOf, pull, pullAll, pullAllBy, pullAt,
|
||||||
remove, reverse, slice, sortedIndex, sortedIndexBy,
|
remove, reverse, slice, sortedIndex, sortedIndexBy,
|
||||||
|
|||||||
2
array.js
2
array.js
@@ -11,9 +11,9 @@ export { default as dropWhile } from './dropWhile';
|
|||||||
export { default as fill } from './fill';
|
export { default as fill } from './fill';
|
||||||
export { default as findIndex } from './findIndex';
|
export { default as findIndex } from './findIndex';
|
||||||
export { default as findLastIndex } from './findLastIndex';
|
export { default as findLastIndex } from './findLastIndex';
|
||||||
export { default as flatMap } from './flatMap';
|
|
||||||
export { default as flatten } from './flatten';
|
export { default as flatten } from './flatten';
|
||||||
export { default as flattenDeep } from './flattenDeep';
|
export { default as flattenDeep } from './flattenDeep';
|
||||||
|
export { default as flattenDepth } from './flattenDepth';
|
||||||
export { default as fromPairs } from './fromPairs';
|
export { default as fromPairs } from './fromPairs';
|
||||||
export { default as head } from './head';
|
export { default as head } from './head';
|
||||||
export { default as indexOf } from './indexOf';
|
export { default as indexOf } from './indexOf';
|
||||||
|
|||||||
2
at.js
2
at.js
@@ -23,7 +23,7 @@ import rest from './rest';
|
|||||||
* // => ['a', 'c']
|
* // => ['a', 'c']
|
||||||
*/
|
*/
|
||||||
var at = rest(function(object, paths) {
|
var at = rest(function(object, paths) {
|
||||||
return baseAt(object, baseFlatten(paths));
|
return baseAt(object, baseFlatten(paths, 1));
|
||||||
});
|
});
|
||||||
|
|
||||||
export default at;
|
export default at;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import rest from './rest';
|
|||||||
* @returns {*} Returns the `func` result or error object.
|
* @returns {*} Returns the `func` result or error object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* // avoid throwing errors for invalid selectors
|
* // Avoid throwing errors for invalid selectors.
|
||||||
* var elements = _.attempt(function(selector) {
|
* var elements = _.attempt(function(selector) {
|
||||||
* return document.querySelectorAll(selector);
|
* return document.querySelectorAll(selector);
|
||||||
* }, '>_>');
|
* }, '>_>');
|
||||||
|
|||||||
9
bind.js
9
bind.js
@@ -36,7 +36,7 @@ var BIND_FLAG = 1,
|
|||||||
* bound('!');
|
* bound('!');
|
||||||
* // => 'hi fred!'
|
* // => 'hi fred!'
|
||||||
*
|
*
|
||||||
* // using placeholders
|
* // Bound with placeholders.
|
||||||
* var bound = _.bind(greet, object, _, '!');
|
* var bound = _.bind(greet, object, _, '!');
|
||||||
* bound('hi');
|
* bound('hi');
|
||||||
* // => 'hi fred!'
|
* // => 'hi fred!'
|
||||||
@@ -44,10 +44,15 @@ var BIND_FLAG = 1,
|
|||||||
var bind = rest(function(func, thisArg, partials) {
|
var bind = rest(function(func, thisArg, partials) {
|
||||||
var bitmask = BIND_FLAG;
|
var bitmask = BIND_FLAG;
|
||||||
if (partials.length) {
|
if (partials.length) {
|
||||||
var holders = replaceHolders(partials, bind.placeholder);
|
var placeholder = bind.placeholder,
|
||||||
|
holders = replaceHolders(partials, placeholder);
|
||||||
|
|
||||||
bitmask |= PARTIAL_FLAG;
|
bitmask |= PARTIAL_FLAG;
|
||||||
}
|
}
|
||||||
return createWrapper(func, bitmask, thisArg, partials, holders);
|
return createWrapper(func, bitmask, thisArg, partials, holders);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Assign default placeholders.
|
||||||
|
bind.placeholder = {};
|
||||||
|
|
||||||
export default bind;
|
export default bind;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import rest from './rest';
|
|||||||
* // => logs 'clicked docs' when clicked
|
* // => logs 'clicked docs' when clicked
|
||||||
*/
|
*/
|
||||||
var bindAll = rest(function(object, methodNames) {
|
var bindAll = rest(function(object, methodNames) {
|
||||||
arrayEach(baseFlatten(methodNames), function(key) {
|
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||||
object[key] = bind(object[key], object);
|
object[key] = bind(object[key], object);
|
||||||
});
|
});
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ var BIND_FLAG = 1,
|
|||||||
* bound('!');
|
* bound('!');
|
||||||
* // => 'hiya fred!'
|
* // => 'hiya fred!'
|
||||||
*
|
*
|
||||||
* // using placeholders
|
* // Bound with placeholders.
|
||||||
* var bound = _.bindKey(object, 'greet', _, '!');
|
* var bound = _.bindKey(object, 'greet', _, '!');
|
||||||
* bound('hi');
|
* bound('hi');
|
||||||
* // => 'hiya fred!'
|
* // => 'hiya fred!'
|
||||||
@@ -54,10 +54,15 @@ var BIND_FLAG = 1,
|
|||||||
var bindKey = rest(function(object, key, partials) {
|
var bindKey = rest(function(object, key, partials) {
|
||||||
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
||||||
if (partials.length) {
|
if (partials.length) {
|
||||||
var holders = replaceHolders(partials, bindKey.placeholder);
|
var placeholder = bindKey.placeholder,
|
||||||
|
holders = replaceHolders(partials, placeholder);
|
||||||
|
|
||||||
bitmask |= PARTIAL_FLAG;
|
bitmask |= PARTIAL_FLAG;
|
||||||
}
|
}
|
||||||
return createWrapper(key, bitmask, object, partials, holders);
|
return createWrapper(key, bitmask, object, partials, holders);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Assign default placeholders.
|
||||||
|
bindKey.placeholder = {};
|
||||||
|
|
||||||
export default bindKey;
|
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;
|
||||||
@@ -6,6 +6,7 @@ import every from './every';
|
|||||||
import filter from './filter';
|
import filter from './filter';
|
||||||
import find from './find';
|
import find from './find';
|
||||||
import findLast from './findLast';
|
import findLast from './findLast';
|
||||||
|
import flatMap from './flatMap';
|
||||||
import forEach from './forEach';
|
import forEach from './forEach';
|
||||||
import forEachRight from './forEachRight';
|
import forEachRight from './forEachRight';
|
||||||
import groupBy from './groupBy';
|
import groupBy from './groupBy';
|
||||||
@@ -27,9 +28,9 @@ import sortBy from './sortBy';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
at, countBy, each, eachRight, every,
|
at, countBy, each, eachRight, every,
|
||||||
filter, find, findLast, forEach, forEachRight,
|
filter, find, findLast, flatMap, forEach,
|
||||||
groupBy, includes, invokeMap, keyBy, map,
|
forEachRight, groupBy, includes, invokeMap, keyBy,
|
||||||
orderBy, partition, reduce, reduceRight, reject,
|
map, orderBy, partition, reduce, reduceRight,
|
||||||
sample, sampleSize, shuffle, size, some,
|
reject, sample, sampleSize, shuffle, size,
|
||||||
sortBy
|
some, sortBy
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export { default as every } from './every';
|
|||||||
export { default as filter } from './filter';
|
export { default as filter } from './filter';
|
||||||
export { default as find } from './find';
|
export { default as find } from './find';
|
||||||
export { default as findLast } from './findLast';
|
export { default as findLast } from './findLast';
|
||||||
|
export { default as flatMap } from './flatMap';
|
||||||
export { default as forEach } from './forEach';
|
export { default as forEach } from './forEach';
|
||||||
export { default as forEachRight } from './forEachRight';
|
export { default as forEachRight } from './forEachRight';
|
||||||
export { default as groupBy } from './groupBy';
|
export { default as groupBy } from './groupBy';
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ var concat = rest(function(array, values) {
|
|||||||
if (!isArray(array)) {
|
if (!isArray(array)) {
|
||||||
array = array == null ? [] : [Object(array)];
|
array = array == null ? [] : [Object(array)];
|
||||||
}
|
}
|
||||||
values = baseFlatten(values);
|
values = baseFlatten(values, 1);
|
||||||
return arrayConcat(array, values);
|
return arrayConcat(array, values);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import baseCreate from './_baseCreate';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an object that inherits from the `prototype` object. If a `properties`
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
5
curry.js
5
curry.js
@@ -39,7 +39,7 @@ var CURRY_FLAG = 8;
|
|||||||
* curried(1, 2, 3);
|
* curried(1, 2, 3);
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*
|
*
|
||||||
* // using placeholders
|
* // Curried with placeholders.
|
||||||
* curried(1)(_, 3)(2);
|
* curried(1)(_, 3)(2);
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
@@ -50,4 +50,7 @@ function curry(func, arity, guard) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assign default placeholders.
|
||||||
|
curry.placeholder = {};
|
||||||
|
|
||||||
export default curry;
|
export default curry;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var CURRY_RIGHT_FLAG = 16;
|
|||||||
* curried(1, 2, 3);
|
* curried(1, 2, 3);
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*
|
*
|
||||||
* // using placeholders
|
* // Curried with placeholders.
|
||||||
* curried(3)(1, _)(2);
|
* curried(3)(1, _)(2);
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
@@ -47,4 +47,7 @@ function curryRight(func, arity, guard) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assign default placeholders.
|
||||||
|
curryRight.placeholder = {};
|
||||||
|
|
||||||
export default curryRight;
|
export default curryRight;
|
||||||
|
|||||||
18
debounce.js
18
debounce.js
@@ -19,7 +19,7 @@ var nativeMax = Math.max;
|
|||||||
* to the debounced function return the result of the last `func` invocation.
|
* to the debounced function return the result of the last `func` invocation.
|
||||||
*
|
*
|
||||||
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
* **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.
|
* invoked more than once during the `wait` timeout.
|
||||||
*
|
*
|
||||||
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
||||||
@@ -40,21 +40,21 @@ var nativeMax = Math.max;
|
|||||||
* @returns {Function} Returns the new debounced function.
|
* @returns {Function} Returns the new debounced function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* // avoid costly calculations while the window size is in flux
|
* // Avoid costly calculations while the window size is in flux.
|
||||||
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
||||||
*
|
*
|
||||||
* // invoke `sendMail` when clicked, debouncing subsequent calls
|
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
||||||
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
||||||
* 'leading': true,
|
* 'leading': true,
|
||||||
* 'trailing': false
|
* 'trailing': false
|
||||||
* }));
|
* }));
|
||||||
*
|
*
|
||||||
* // ensure `batchLog` is invoked once after 1 second of debounced calls
|
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
||||||
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
||||||
* var source = new EventSource('/stream');
|
* var source = new EventSource('/stream');
|
||||||
* jQuery(source).on('message', debounced);
|
* jQuery(source).on('message', debounced);
|
||||||
*
|
*
|
||||||
* // cancel a trailing debounced invocation
|
* // Cancel the trailing debounced invocation.
|
||||||
* jQuery(window).on('popstate', debounced.cancel);
|
* jQuery(window).on('popstate', debounced.cancel);
|
||||||
*/
|
*/
|
||||||
function debounce(func, wait, options) {
|
function debounce(func, wait, options) {
|
||||||
@@ -135,11 +135,13 @@ function debounce(func, wait, options) {
|
|||||||
if (maxWait === false) {
|
if (maxWait === false) {
|
||||||
var leadingCall = leading && !timeoutId;
|
var leadingCall = leading && !timeoutId;
|
||||||
} else {
|
} else {
|
||||||
if (!maxTimeoutId && !leading) {
|
if (!lastCalled && !maxTimeoutId && !leading) {
|
||||||
lastCalled = stamp;
|
lastCalled = stamp;
|
||||||
}
|
}
|
||||||
var remaining = maxWait - (stamp - lastCalled),
|
var remaining = maxWait - (stamp - lastCalled);
|
||||||
isCalled = remaining <= 0 || remaining > maxWait;
|
|
||||||
|
var isCalled = (remaining <= 0 || remaining > maxWait) &&
|
||||||
|
(leading || maxTimeoutId);
|
||||||
|
|
||||||
if (isCalled) {
|
if (isCalled) {
|
||||||
if (maxTimeoutId) {
|
if (maxTimeoutId) {
|
||||||
|
|||||||
2
defer.js
2
defer.js
@@ -16,7 +16,7 @@ import rest from './rest';
|
|||||||
* _.defer(function(text) {
|
* _.defer(function(text) {
|
||||||
* console.log(text);
|
* console.log(text);
|
||||||
* }, 'deferred');
|
* }, 'deferred');
|
||||||
* // logs 'deferred' after one or more milliseconds
|
* // => logs 'deferred' after one or more milliseconds
|
||||||
*/
|
*/
|
||||||
var defer = rest(function(func, args) {
|
var defer = rest(function(func, args) {
|
||||||
return baseDelay(func, 1, args);
|
return baseDelay(func, 1, args);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import rest from './rest';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of unique `array` values not included in the other
|
* 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)
|
* given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||||
* for equality comparisons.
|
* for equality comparisons.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
@@ -21,7 +21,7 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
var difference = rest(function(array, values) {
|
var difference = rest(function(array, values) {
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true))
|
? baseDifference(array, baseFlatten(values, 1, true))
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import rest from './rest';
|
|||||||
* _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor);
|
* _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor);
|
||||||
* // => [3.1, 1.3]
|
* // => [3.1, 1.3]
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
|
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
|
||||||
* // => [{ 'x': 2 }]
|
* // => [{ 'x': 2 }]
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ var differenceBy = rest(function(array, values) {
|
|||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee))
|
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var differenceWith = rest(function(array, values) {
|
|||||||
comparator = undefined;
|
comparator = undefined;
|
||||||
}
|
}
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
|
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ import baseWhile from './_baseWhile';
|
|||||||
* _.dropRightWhile(users, function(o) { return !o.active; });
|
* _.dropRightWhile(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['barney']
|
* // => objects for ['barney']
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
|
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
|
||||||
* // => objects for ['barney', 'fred']
|
* // => objects for ['barney', 'fred']
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.dropRightWhile(users, ['active', false]);
|
* _.dropRightWhile(users, ['active', false]);
|
||||||
* // => objects for ['barney']
|
* // => objects for ['barney']
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.dropRightWhile(users, 'active');
|
* _.dropRightWhile(users, 'active');
|
||||||
* // => objects for ['barney', 'fred', 'pebbles']
|
* // => objects for ['barney', 'fred', 'pebbles']
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ import baseWhile from './_baseWhile';
|
|||||||
* _.dropWhile(users, function(o) { return !o.active; });
|
* _.dropWhile(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['pebbles']
|
* // => objects for ['pebbles']
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.dropWhile(users, { 'user': 'barney', 'active': false });
|
* _.dropWhile(users, { 'user': 'barney', 'active': false });
|
||||||
* // => objects for ['fred', 'pebbles']
|
* // => objects for ['fred', 'pebbles']
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.dropWhile(users, ['active', false]);
|
* _.dropWhile(users, ['active', false]);
|
||||||
* // => objects for ['pebbles']
|
* // => objects for ['pebbles']
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.dropWhile(users, 'active');
|
* _.dropWhile(users, 'active');
|
||||||
* // => objects for ['barney', 'fred', 'pebbles']
|
* // => objects for ['barney', 'fred', 'pebbles']
|
||||||
*/
|
*/
|
||||||
|
|||||||
6
every.js
6
every.js
@@ -26,15 +26,15 @@ import isIterateeCall from './_isIterateeCall';
|
|||||||
* { 'user': 'fred', 'active': false }
|
* { 'user': 'fred', 'active': false }
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.every(users, { 'user': 'barney', 'active': false });
|
* _.every(users, { 'user': 'barney', 'active': false });
|
||||||
* // => false
|
* // => false
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.every(users, ['active', false]);
|
* _.every(users, ['active', false]);
|
||||||
* // => true
|
* // => true
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.every(users, 'active');
|
* _.every(users, 'active');
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ import isArray from './isArray';
|
|||||||
* _.filter(users, function(o) { return !o.active; });
|
* _.filter(users, function(o) { return !o.active; });
|
||||||
* // => objects for ['fred']
|
* // => objects for ['fred']
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.filter(users, { 'age': 36, 'active': true });
|
* _.filter(users, { 'age': 36, 'active': true });
|
||||||
* // => objects for ['barney']
|
* // => objects for ['barney']
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.filter(users, ['active', false]);
|
* _.filter(users, ['active', false]);
|
||||||
* // => objects for ['fred']
|
* // => objects for ['fred']
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.filter(users, 'active');
|
* _.filter(users, 'active');
|
||||||
* // => objects for ['barney']
|
* // => objects for ['barney']
|
||||||
*/
|
*/
|
||||||
|
|||||||
6
find.js
6
find.js
@@ -26,15 +26,15 @@ import isArray from './isArray';
|
|||||||
* _.find(users, function(o) { return o.age < 40; });
|
* _.find(users, function(o) { return o.age < 40; });
|
||||||
* // => object for 'barney'
|
* // => object for 'barney'
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.find(users, { 'age': 1, 'active': true });
|
* _.find(users, { 'age': 1, 'active': true });
|
||||||
* // => object for 'pebbles'
|
* // => object for 'pebbles'
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.find(users, ['active', false]);
|
* _.find(users, ['active', false]);
|
||||||
* // => object for 'fred'
|
* // => object for 'fred'
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.find(users, 'active');
|
* _.find(users, 'active');
|
||||||
* // => object for 'barney'
|
* // => object for 'barney'
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* _.findIndex(users, function(o) { return o.user == 'barney'; });
|
* _.findIndex(users, function(o) { return o.user == 'barney'; });
|
||||||
* // => 0
|
* // => 0
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.findIndex(users, { 'user': 'fred', 'active': false });
|
* _.findIndex(users, { 'user': 'fred', 'active': false });
|
||||||
* // => 1
|
* // => 1
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.findIndex(users, ['active', false]);
|
* _.findIndex(users, ['active', false]);
|
||||||
* // => 0
|
* // => 0
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.findIndex(users, 'active');
|
* _.findIndex(users, 'active');
|
||||||
* // => 2
|
* // => 2
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* _.findKey(users, function(o) { return o.age < 40; });
|
* _.findKey(users, function(o) { return o.age < 40; });
|
||||||
* // => 'barney' (iteration order is not guaranteed)
|
* // => 'barney' (iteration order is not guaranteed)
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.findKey(users, { 'age': 1, 'active': true });
|
* _.findKey(users, { 'age': 1, 'active': true });
|
||||||
* // => 'pebbles'
|
* // => 'pebbles'
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.findKey(users, ['active', false]);
|
* _.findKey(users, ['active', false]);
|
||||||
* // => 'fred'
|
* // => 'fred'
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.findKey(users, 'active');
|
* _.findKey(users, 'active');
|
||||||
* // => 'barney'
|
* // => 'barney'
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
|
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
|
||||||
* // => 2
|
* // => 2
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
|
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
|
||||||
* // => 0
|
* // => 0
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.findLastIndex(users, ['active', false]);
|
* _.findLastIndex(users, ['active', false]);
|
||||||
* // => 2
|
* // => 2
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.findLastIndex(users, 'active');
|
* _.findLastIndex(users, 'active');
|
||||||
* // => 0
|
* // => 0
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* _.findLastKey(users, function(o) { return o.age < 40; });
|
* _.findLastKey(users, function(o) { return o.age < 40; });
|
||||||
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
|
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
|
||||||
*
|
*
|
||||||
* // using the `_.matches` iteratee shorthand
|
* // The `_.matches` iteratee shorthand.
|
||||||
* _.findLastKey(users, { 'age': 36, 'active': true });
|
* _.findLastKey(users, { 'age': 36, 'active': true });
|
||||||
* // => 'barney'
|
* // => 'barney'
|
||||||
*
|
*
|
||||||
* // using the `_.matchesProperty` iteratee shorthand
|
* // The `_.matchesProperty` iteratee shorthand.
|
||||||
* _.findLastKey(users, ['active', false]);
|
* _.findLastKey(users, ['active', false]);
|
||||||
* // => 'fred'
|
* // => 'fred'
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.findLastKey(users, 'active');
|
* _.findLastKey(users, 'active');
|
||||||
* // => 'pebbles'
|
* // => 'pebbles'
|
||||||
*/
|
*/
|
||||||
|
|||||||
18
flatMap.js
18
flatMap.js
@@ -1,18 +1,17 @@
|
|||||||
import arrayMap from './_arrayMap';
|
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseIteratee from './_baseIteratee';
|
import map from './map';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of flattened values by running each element in `array`
|
* Creates an array of flattened values by running each element in `collection`
|
||||||
* through `iteratee` and concating its result to the other mapped values.
|
* through `iteratee` and concating its result to the other mapped values.
|
||||||
* The iteratee is invoked with three arguments: (value, index|key, array).
|
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Array
|
* @category Collection
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function duplicate(n) {
|
* function duplicate(n) {
|
||||||
@@ -22,9 +21,8 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* _.flatMap([1, 2], duplicate);
|
* _.flatMap([1, 2], duplicate);
|
||||||
* // => [1, 1, 2, 2]
|
* // => [1, 1, 2, 2]
|
||||||
*/
|
*/
|
||||||
function flatMap(array, iteratee) {
|
function flatMap(collection, iteratee) {
|
||||||
var length = array ? array.length : 0;
|
return baseFlatten(map(collection, iteratee), 1);
|
||||||
return length ? baseFlatten(arrayMap(array, baseIteratee(iteratee, 3))) : [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default flatMap;
|
export default flatMap;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flattens `array` a single level.
|
* Flattens `array` a single level deep.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -10,12 +10,12 @@ import baseFlatten from './_baseFlatten';
|
|||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flatten([1, [2, 3, [4]]]);
|
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||||
* // => [1, 2, 3, [4]]
|
* // => [1, 2, [3, [4]], 5]
|
||||||
*/
|
*/
|
||||||
function flatten(array) {
|
function flatten(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array) : [];
|
return length ? baseFlatten(array, 1) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default flatten;
|
export default flatten;
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
import baseFlatten from './_baseFlatten';
|
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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to recursively flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||||
* // => [1, 2, 3, 4]
|
* // => [1, 2, 3, 4, 5]
|
||||||
*/
|
*/
|
||||||
function flattenDeep(array) {
|
function flattenDeep(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array, true) : [];
|
return length ? baseFlatten(array, INFINITY) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default flattenDeep;
|
export default flattenDeep;
|
||||||
|
|||||||
32
flattenDepth.js
Normal file
32
flattenDepth.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import baseFlatten from './_baseFlatten';
|
||||||
|
import toInteger from './toInteger';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively flatten `array` up to `depth` times.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category Array
|
||||||
|
* @param {Array} array The array to flatten.
|
||||||
|
* @param {number} [depth=1] The maximum recursion depth.
|
||||||
|
* @returns {Array} Returns the new flattened array.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var array = [1, [2, [3, [4]], 5]];
|
||||||
|
*
|
||||||
|
* _.flattenDepth(array, 1);
|
||||||
|
* // => [1, 2, [3, [4]], 5]
|
||||||
|
*
|
||||||
|
* _.flattenDepth(array, 2);
|
||||||
|
* // => [1, 2, 3, [4], 5]
|
||||||
|
*/
|
||||||
|
function flattenDepth(array, depth) {
|
||||||
|
var length = array ? array.length : 0;
|
||||||
|
if (!length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
depth = depth === undefined ? 1 : toInteger(depth);
|
||||||
|
return baseFlatten(array, depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default flattenDepth;
|
||||||
6
flow.js
6
flow.js
@@ -1,9 +1,9 @@
|
|||||||
import createFlow from './_createFlow';
|
import createFlow from './_createFlow';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that returns the result of invoking the provided
|
* Creates a function that returns the result of invoking the given functions
|
||||||
* functions with the `this` binding of the created function, where each
|
* with the `this` binding of the created function, where each successive
|
||||||
* successive invocation is supplied the return value of the previous.
|
* invocation is supplied the return value of the previous.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import createFlow from './_createFlow';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.flow` except that it creates a function that
|
* This method is like `_.flow` except that it creates a function that
|
||||||
* invokes the provided functions from right to left.
|
* invokes the given functions from right to left.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import arrayEach from './_arrayEach';
|
import arrayEach from './_arrayEach';
|
||||||
|
import baseCastFunction from './_baseCastFunction';
|
||||||
import baseEach from './_baseEach';
|
import baseEach from './_baseEach';
|
||||||
import isArray from './isArray';
|
import isArray from './isArray';
|
||||||
import toFunction from './_toFunction';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
||||||
@@ -34,7 +34,7 @@ import toFunction from './_toFunction';
|
|||||||
function forEach(collection, iteratee) {
|
function forEach(collection, iteratee) {
|
||||||
return (typeof iteratee == 'function' && isArray(collection))
|
return (typeof iteratee == 'function' && isArray(collection))
|
||||||
? arrayEach(collection, iteratee)
|
? arrayEach(collection, iteratee)
|
||||||
: baseEach(collection, toFunction(iteratee));
|
: baseEach(collection, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forEach;
|
export default forEach;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import arrayEachRight from './_arrayEachRight';
|
import arrayEachRight from './_arrayEachRight';
|
||||||
|
import baseCastFunction from './_baseCastFunction';
|
||||||
import baseEachRight from './_baseEachRight';
|
import baseEachRight from './_baseEachRight';
|
||||||
import isArray from './isArray';
|
import isArray from './isArray';
|
||||||
import toFunction from './_toFunction';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forEach` except that it iterates over elements of
|
* This method is like `_.forEach` except that it iterates over elements of
|
||||||
@@ -24,7 +24,7 @@ import toFunction from './_toFunction';
|
|||||||
function forEachRight(collection, iteratee) {
|
function forEachRight(collection, iteratee) {
|
||||||
return (typeof iteratee == 'function' && isArray(collection))
|
return (typeof iteratee == 'function' && isArray(collection))
|
||||||
? arrayEachRight(collection, iteratee)
|
? arrayEachRight(collection, iteratee)
|
||||||
: baseEachRight(collection, toFunction(iteratee));
|
: baseEachRight(collection, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forEachRight;
|
export default forEachRight;
|
||||||
|
|||||||
6
forIn.js
6
forIn.js
@@ -1,6 +1,6 @@
|
|||||||
|
import baseCastFunction from './_baseCastFunction';
|
||||||
import baseFor from './_baseFor';
|
import baseFor from './_baseFor';
|
||||||
import keysIn from './keysIn';
|
import keysIn from './keysIn';
|
||||||
import toFunction from './_toFunction';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own and inherited enumerable properties of an object invoking
|
* Iterates over own and inherited enumerable properties of an object invoking
|
||||||
@@ -29,7 +29,9 @@ import toFunction from './_toFunction';
|
|||||||
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
|
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function forIn(object, iteratee) {
|
function forIn(object, iteratee) {
|
||||||
return object == null ? object : baseFor(object, toFunction(iteratee), keysIn);
|
return object == null
|
||||||
|
? object
|
||||||
|
: baseFor(object, baseCastFunction(iteratee), keysIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forIn;
|
export default forIn;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import baseCastFunction from './_baseCastFunction';
|
||||||
import baseForRight from './_baseForRight';
|
import baseForRight from './_baseForRight';
|
||||||
import keysIn from './keysIn';
|
import keysIn from './keysIn';
|
||||||
import toFunction from './_toFunction';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forIn` except that it iterates over properties of
|
* This method is like `_.forIn` except that it iterates over properties of
|
||||||
@@ -27,7 +27,9 @@ import toFunction from './_toFunction';
|
|||||||
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
|
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
|
||||||
*/
|
*/
|
||||||
function forInRight(object, iteratee) {
|
function forInRight(object, iteratee) {
|
||||||
return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn);
|
return object == null
|
||||||
|
? object
|
||||||
|
: baseForRight(object, baseCastFunction(iteratee), keysIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forInRight;
|
export default forInRight;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import baseCastFunction from './_baseCastFunction';
|
||||||
import baseForOwn from './_baseForOwn';
|
import baseForOwn from './_baseForOwn';
|
||||||
import toFunction from './_toFunction';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own enumerable properties of an object invoking `iteratee`
|
* Iterates over own enumerable properties of an object invoking `iteratee`
|
||||||
@@ -28,7 +28,7 @@ import toFunction from './_toFunction';
|
|||||||
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function forOwn(object, iteratee) {
|
function forOwn(object, iteratee) {
|
||||||
return object && baseForOwn(object, toFunction(iteratee));
|
return object && baseForOwn(object, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forOwn;
|
export default forOwn;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import baseCastFunction from './_baseCastFunction';
|
||||||
import baseForOwnRight from './_baseForOwnRight';
|
import baseForOwnRight from './_baseForOwnRight';
|
||||||
import toFunction from './_toFunction';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forOwn` except that it iterates over properties of
|
* This method is like `_.forOwn` except that it iterates over properties of
|
||||||
@@ -26,7 +26,7 @@ import toFunction from './_toFunction';
|
|||||||
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
|
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
|
||||||
*/
|
*/
|
||||||
function forOwnRight(object, iteratee) {
|
function forOwnRight(object, iteratee) {
|
||||||
return object && baseForOwnRight(object, toFunction(iteratee));
|
return object && baseForOwnRight(object, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forOwnRight;
|
export default forOwnRight;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
|
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
|
||||||
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
* // => { '4': [4.2], '6': [6.1, 6.3] }
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.groupBy(['one', 'two', 'three'], 'length');
|
* _.groupBy(['one', 'two', 'three'], 'length');
|
||||||
* // => { '3': ['one', 'two'], '5': ['three'] }
|
* // => { '3': ['one', 'two'], '5': ['three'] }
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* This method returns the first argument provided to it.
|
* This method returns the first argument given to it.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ var nativeMax = Math.max;
|
|||||||
* Gets the index at which the first occurrence of `value` is found in `array`
|
* Gets the index at which the first occurrence of `value` is found in `array`
|
||||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||||
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
|
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
|
||||||
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
|
* from the end of `array`.
|
||||||
* performs a faster binary search.
|
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -23,7 +22,7 @@ var nativeMax = Math.max;
|
|||||||
* _.indexOf([1, 2, 1, 2], 2);
|
* _.indexOf([1, 2, 1, 2], 2);
|
||||||
* // => 1
|
* // => 1
|
||||||
*
|
*
|
||||||
* // using `fromIndex`
|
* // Search from the `fromIndex`.
|
||||||
* _.indexOf([1, 2, 1, 2], 2, 2);
|
* _.indexOf([1, 2, 1, 2], 2, 2);
|
||||||
* // => 3
|
* // => 3
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
|
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
|
||||||
import baseIntersection from './_baseIntersection';
|
import baseIntersection from './_baseIntersection';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
import toArrayLikeObject from './_toArrayLikeObject';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of unique values that are included in all of the provided
|
* Creates an array of unique values that are included in all given arrays
|
||||||
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||||
* for equality comparisons.
|
* for equality comparisons.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
@@ -19,7 +19,7 @@ import toArrayLikeObject from './_toArrayLikeObject';
|
|||||||
* // => [2]
|
* // => [2]
|
||||||
*/
|
*/
|
||||||
var intersection = rest(function(arrays) {
|
var intersection = rest(function(arrays) {
|
||||||
var mapped = arrayMap(arrays, toArrayLikeObject);
|
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||||
return (mapped.length && mapped[0] === arrays[0])
|
return (mapped.length && mapped[0] === arrays[0])
|
||||||
? baseIntersection(mapped)
|
? baseIntersection(mapped)
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
|
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
|
||||||
import baseIntersection from './_baseIntersection';
|
import baseIntersection from './_baseIntersection';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
import toArrayLikeObject from './_toArrayLikeObject';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.intersection` except that it accepts `iteratee`
|
* This method is like `_.intersection` except that it accepts `iteratee`
|
||||||
@@ -21,13 +21,13 @@ import toArrayLikeObject from './_toArrayLikeObject';
|
|||||||
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
|
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
|
||||||
* // => [2.1]
|
* // => [2.1]
|
||||||
*
|
*
|
||||||
* // using the `_.property` iteratee shorthand
|
* // The `_.property` iteratee shorthand.
|
||||||
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
||||||
* // => [{ 'x': 1 }]
|
* // => [{ 'x': 1 }]
|
||||||
*/
|
*/
|
||||||
var intersectionBy = rest(function(arrays) {
|
var intersectionBy = rest(function(arrays) {
|
||||||
var iteratee = last(arrays),
|
var iteratee = last(arrays),
|
||||||
mapped = arrayMap(arrays, toArrayLikeObject);
|
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||||
|
|
||||||
if (iteratee === last(mapped)) {
|
if (iteratee === last(mapped)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
|
import baseCastArrayLikeObject from './_baseCastArrayLikeObject';
|
||||||
import baseIntersection from './_baseIntersection';
|
import baseIntersection from './_baseIntersection';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
import toArrayLikeObject from './_toArrayLikeObject';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.intersection` except that it accepts `comparator`
|
* This method is like `_.intersection` except that it accepts `comparator`
|
||||||
@@ -25,7 +25,7 @@ import toArrayLikeObject from './_toArrayLikeObject';
|
|||||||
*/
|
*/
|
||||||
var intersectionWith = rest(function(arrays) {
|
var intersectionWith = rest(function(arrays) {
|
||||||
var comparator = last(arrays),
|
var comparator = last(arrays),
|
||||||
mapped = arrayMap(arrays, toArrayLikeObject);
|
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||||
|
|
||||||
if (comparator === last(mapped)) {
|
if (comparator === last(mapped)) {
|
||||||
comparator = undefined;
|
comparator = undefined;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
* @type {Function}
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||||
|
|||||||
34
isArrayBuffer.js
Normal file
34
isArrayBuffer.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import isObjectLike from './isObjectLike';
|
||||||
|
|
||||||
|
var arrayBufferTag = '[object ArrayBuffer]';
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||||||
|
* of values.
|
||||||
|
*/
|
||||||
|
var objectToString = objectProto.toString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is classified as an `ArrayBuffer` object.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category Lang
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.isArrayBuffer(new ArrayBuffer(2));
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* _.isArrayBuffer(new Array(2));
|
||||||
|
* // => false
|
||||||
|
*/
|
||||||
|
function isArrayBuffer(value) {
|
||||||
|
return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default isArrayBuffer;
|
||||||
@@ -9,7 +9,6 @@ import isLength from './isLength';
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import isObjectLike from './isObjectLike';
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
||||||
|
|||||||
48
isBuffer.js
Normal file
48
isBuffer.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import constant from './constant';
|
||||||
|
import root from './_root';
|
||||||
|
|
||||||
|
/** Used to determine if values are of the language type `Object`. */
|
||||||
|
var objectTypes = {
|
||||||
|
'function': true,
|
||||||
|
'object': true
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Detect free variable `exports`. */
|
||||||
|
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||||
|
? exports
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
/** Detect free variable `module`. */
|
||||||
|
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||||
|
? module
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
/** Detect the popular CommonJS extension `module.exports`. */
|
||||||
|
var moduleExports = (freeModule && freeModule.exports === freeExports)
|
||||||
|
? freeExports
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var Buffer = moduleExports ? root.Buffer : undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `value` is a buffer.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category Lang
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.isBuffer(new Buffer(2));
|
||||||
|
* // => true
|
||||||
|
*
|
||||||
|
* _.isBuffer(new Uint8Array(2));
|
||||||
|
* // => false
|
||||||
|
*/
|
||||||
|
var isBuffer = !Buffer ? constant(false) : function(value) {
|
||||||
|
return value instanceof Buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default isBuffer;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user