mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
501d6b1d41 | ||
|
|
ddf9328c67 | ||
|
|
7eeb5ebd61 | ||
|
|
0dd6798d8b | ||
|
|
91d3468c81 |
14
README.md
14
README.md
@@ -1,4 +1,4 @@
|
||||
# lodash v4.3.0
|
||||
# lodash v4.6.1
|
||||
|
||||
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
|
||||
|
||||
@@ -12,23 +12,23 @@ $ npm i --save lodash
|
||||
|
||||
In Node.js:
|
||||
```js
|
||||
// load the full build
|
||||
// Load the full build.
|
||||
var _ = require('lodash');
|
||||
// load the core build
|
||||
// Load the core build.
|
||||
var _ = require('lodash/core');
|
||||
// load the fp build for immutable auto-curried iteratee-first data-last methods
|
||||
// Load the fp build for immutable auto-curried iteratee-first data-last methods.
|
||||
var _ = require('lodash/fp');
|
||||
|
||||
// or a method category
|
||||
// Load a method category.
|
||||
var array = require('lodash/array');
|
||||
var object = require('lodash/fp/object');
|
||||
|
||||
// or method for smaller builds with browserify/rollup/webpack
|
||||
// Load a single method for smaller builds with browserify/rollup/webpack.
|
||||
var chunk = require('lodash/chunk');
|
||||
var extend = require('lodash/fp/extend');
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.3.0-npm) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.6.1-npm) for more details.
|
||||
|
||||
**Note:**<br>
|
||||
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
||||
|
||||
1
_Hash.js
1
_Hash.js
@@ -7,6 +7,7 @@ var objectProto = Object.prototype;
|
||||
* Creates an hash object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @returns {Object} Returns the new hash object.
|
||||
*/
|
||||
function Hash() {}
|
||||
|
||||
@@ -8,6 +8,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
|
||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {*} value The value to wrap.
|
||||
*/
|
||||
function LazyWrapper(value) {
|
||||
|
||||
@@ -8,6 +8,7 @@ var mapClear = require('./_mapClear'),
|
||||
* Creates a map cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function MapCache(values) {
|
||||
|
||||
@@ -6,6 +6,7 @@ var MapCache = require('./_MapCache'),
|
||||
* Creates a set cache object to store unique values.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function SetCache(values) {
|
||||
|
||||
@@ -8,6 +8,7 @@ var stackClear = require('./_stackClear'),
|
||||
* Creates a stack cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function Stack(values) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* @returns {Object} Returns `map`.
|
||||
*/
|
||||
function addMapEntry(map, pair) {
|
||||
// Don't return `Map#set` because it doesn't return the map instance in IE 11.
|
||||
map.set(pair[0], pair[1]);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
function arrayFilter(array, predicate) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (predicate(value, index, array)) {
|
||||
result[++resIndex] = value;
|
||||
result[resIndex++] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* A specialized version of `_.includesWith` for arrays without support for
|
||||
* specifying an index to search from.
|
||||
* This function is like `arrayIncludes` except that it accepts a comparator.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
var eq = require('./eq');
|
||||
|
||||
/**
|
||||
* This function is like `assignValue` except that it doesn't assign `undefined` values.
|
||||
* This function is like `assignValue` except that it doesn't assign
|
||||
* `undefined` values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
|
||||
@@ -18,8 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
*/
|
||||
function assignValue(object, key, value) {
|
||||
var objValue = object[key];
|
||||
if ((!eq(objValue, value) ||
|
||||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
}
|
||||
|
||||
14
_baseCastArrayLikeObject.js
Normal file
14
_baseCastArrayLikeObject.js
Normal file
@@ -0,0 +1,14 @@
|
||||
var isArrayLikeObject = require('./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 : [];
|
||||
}
|
||||
|
||||
module.exports = baseCastArrayLikeObject;
|
||||
14
_baseCastFunction.js
Normal file
14
_baseCastFunction.js
Normal file
@@ -0,0 +1,14 @@
|
||||
var identity = require('./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;
|
||||
}
|
||||
|
||||
module.exports = baseCastFunction;
|
||||
15
_baseCastPath.js
Normal file
15
_baseCastPath.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var isArray = require('./isArray'),
|
||||
stringToPath = require('./_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);
|
||||
}
|
||||
|
||||
module.exports = baseCastPath;
|
||||
@@ -66,13 +66,14 @@ cloneableTags[weakMapTag] = false;
|
||||
* @private
|
||||
* @param {*} value The value to clone.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @param {boolean} [isFull] Specify a clone including symbols.
|
||||
* @param {Function} [customizer] The function to customize cloning.
|
||||
* @param {string} [key] The key of `value`.
|
||||
* @param {Object} [object] The parent object of `value`.
|
||||
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
|
||||
* @returns {*} Returns the cloned value.
|
||||
*/
|
||||
function baseClone(value, isDeep, customizer, key, object, stack) {
|
||||
function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||||
var result;
|
||||
if (customizer) {
|
||||
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||||
@@ -102,12 +103,14 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
||||
}
|
||||
result = initCloneObject(isFunc ? {} : value);
|
||||
if (!isDeep) {
|
||||
return copySymbols(value, baseAssign(result, value));
|
||||
result = baseAssign(result, value);
|
||||
return isFull ? copySymbols(value, result) : result;
|
||||
}
|
||||
} else {
|
||||
return cloneableTags[tag]
|
||||
? initCloneByTag(value, tag, isDeep)
|
||||
: (object ? value : {});
|
||||
if (!cloneableTags[tag]) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneByTag(value, tag, isDeep);
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
@@ -120,9 +123,9 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
||||
|
||||
// Recursively populate clone (susceptible to call stack limits).
|
||||
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
||||
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack));
|
||||
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
|
||||
});
|
||||
return isArr ? result : copySymbols(value, result);
|
||||
return (isFull && !isArr) ? copySymbols(value, result) : result;
|
||||
}
|
||||
|
||||
module.exports = baseClone;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
var isObject = require('./isObject');
|
||||
|
||||
/** Built-in value references. */
|
||||
var objectCreate = Object.create;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.create` without support for assigning
|
||||
* properties to the created object.
|
||||
@@ -8,16 +11,8 @@ var isObject = require('./isObject');
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(prototype) {
|
||||
if (isObject(prototype)) {
|
||||
object.prototype = prototype;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
}
|
||||
return result || {};
|
||||
};
|
||||
}());
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
|
||||
module.exports = baseCreate;
|
||||
|
||||
@@ -8,12 +8,12 @@ var arrayPush = require('./_arrayPush'),
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||
* @param {number} depth The maximum recursion depth.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @param {Array} [result=[]] The initial result value.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict, result) {
|
||||
function baseFlatten(array, depth, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
var index = -1,
|
||||
@@ -21,11 +21,11 @@ function baseFlatten(array, isDeep, isStrict, result) {
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (isArrayLikeObject(value) &&
|
||||
if (depth > 0 && isArrayLikeObject(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
if (depth > 1) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
baseFlatten(value, isDeep, isStrict, result);
|
||||
baseFlatten(value, depth - 1, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var baseToPath = require('./_baseToPath'),
|
||||
var baseCastPath = require('./_baseCastPath'),
|
||||
isKey = require('./_isKey');
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,7 @@ var baseToPath = require('./_baseToPath'),
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function baseGet(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
|
||||
23
_baseIndexOfWith.js
Normal file
23
_baseIndexOfWith.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* This function is like `baseIndexOf` except that it accepts a comparator.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {*} value The value to search for.
|
||||
* @param {number} fromIndex The index to search from.
|
||||
* @param {Function} comparator The comparator invoked per element.
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function baseIndexOfWith(array, value, fromIndex, comparator) {
|
||||
var index = fromIndex - 1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (comparator(array[index], value)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
module.exports = baseIndexOfWith;
|
||||
@@ -5,6 +5,9 @@ var SetCache = require('./_SetCache'),
|
||||
baseUnary = require('./_baseUnary'),
|
||||
cacheHas = require('./_cacheHas');
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.intersection`, without support
|
||||
* for iteratee shorthands, that accepts an array of arrays to inspect.
|
||||
@@ -17,9 +20,11 @@ var SetCache = require('./_SetCache'),
|
||||
*/
|
||||
function baseIntersection(arrays, iteratee, comparator) {
|
||||
var includes = comparator ? arrayIncludesWith : arrayIncludes,
|
||||
length = arrays[0].length,
|
||||
othLength = arrays.length,
|
||||
othIndex = othLength,
|
||||
caches = Array(othLength),
|
||||
maxLength = Infinity,
|
||||
result = [];
|
||||
|
||||
while (othIndex--) {
|
||||
@@ -27,26 +32,32 @@ function baseIntersection(arrays, iteratee, comparator) {
|
||||
if (othIndex && iteratee) {
|
||||
array = arrayMap(array, baseUnary(iteratee));
|
||||
}
|
||||
caches[othIndex] = !comparator && (iteratee || array.length >= 120)
|
||||
maxLength = nativeMin(array.length, maxLength);
|
||||
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
|
||||
? new SetCache(othIndex && array)
|
||||
: undefined;
|
||||
}
|
||||
array = arrays[0];
|
||||
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
seen = caches[0];
|
||||
|
||||
outer:
|
||||
while (++index < length) {
|
||||
while (++index < length && result.length < maxLength) {
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
|
||||
var othIndex = othLength;
|
||||
if (!(seen
|
||||
? cacheHas(seen, computed)
|
||||
: includes(result, computed, comparator)
|
||||
)) {
|
||||
othIndex = othLength;
|
||||
while (--othIndex) {
|
||||
var cache = caches[othIndex];
|
||||
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
|
||||
if (!(cache
|
||||
? cacheHas(cache, computed)
|
||||
: includes(arrays[othIndex], computed, comparator))
|
||||
) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var apply = require('./_apply'),
|
||||
baseToPath = require('./_baseToPath'),
|
||||
baseCastPath = require('./_baseCastPath'),
|
||||
isKey = require('./_isKey'),
|
||||
last = require('./last'),
|
||||
parent = require('./_parent');
|
||||
@@ -16,7 +16,7 @@ var apply = require('./_apply'),
|
||||
*/
|
||||
function baseInvoke(object, path, args) {
|
||||
if (!isKey(path, object)) {
|
||||
path = baseToPath(path);
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
path = last(path);
|
||||
}
|
||||
|
||||
@@ -43,33 +43,28 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
if (!objIsArr) {
|
||||
objTag = getTag(object);
|
||||
if (objTag == argsTag) {
|
||||
objTag = objectTag;
|
||||
} else if (objTag != objectTag) {
|
||||
objIsArr = isTypedArray(object);
|
||||
}
|
||||
objTag = objTag == argsTag ? objectTag : objTag;
|
||||
}
|
||||
if (!othIsArr) {
|
||||
othTag = getTag(other);
|
||||
if (othTag == argsTag) {
|
||||
othTag = objectTag;
|
||||
} else if (othTag != objectTag) {
|
||||
othIsArr = isTypedArray(other);
|
||||
}
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
||||
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
|
||||
if (isSameTag && !objIsObj) {
|
||||
stack || (stack = new Stack);
|
||||
return (objIsArr || isTypedArray(object))
|
||||
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
|
||||
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
|
||||
}
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||
if (!isPartial) {
|
||||
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
||||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||
|
||||
if (objIsWrapped || othIsWrapped) {
|
||||
stack || (stack = new Stack);
|
||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +72,7 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
return false;
|
||||
}
|
||||
stack || (stack = new Stack);
|
||||
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
|
||||
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
||||
}
|
||||
|
||||
module.exports = baseIsEqualDeep;
|
||||
|
||||
@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
|
||||
* property of prototypes or treat sparse arrays as dense.
|
||||
*
|
||||
* @private
|
||||
* @type Function
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
if (object === source) {
|
||||
return;
|
||||
}
|
||||
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
|
||||
var props = (isArray(source) || isTypedArray(source))
|
||||
? undefined
|
||||
: keysIn(source);
|
||||
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
}
|
||||
else {
|
||||
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
|
||||
var newValue = customizer
|
||||
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
if (newValue === undefined) {
|
||||
newValue = srcValue;
|
||||
}
|
||||
|
||||
@@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
assignMergeValue(object, key, stacked);
|
||||
return;
|
||||
}
|
||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
||||
isCommon = newValue === undefined;
|
||||
var newValue = customizer
|
||||
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
var isCommon = newValue === undefined;
|
||||
|
||||
if (isCommon) {
|
||||
newValue = srcValue;
|
||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||
if (isArray(objValue)) {
|
||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
else if (isArrayLikeObject(objValue)) {
|
||||
newValue = copyArray(objValue);
|
||||
}
|
||||
else {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue);
|
||||
newValue = baseClone(srcValue, !customizer);
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
@@ -56,10 +59,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue);
|
||||
newValue = baseClone(srcValue, !customizer);
|
||||
}
|
||||
else {
|
||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -72,6 +75,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
||||
}
|
||||
stack['delete'](srcValue);
|
||||
assignMergeValue(object, key, newValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,8 @@ var arrayMap = require('./_arrayMap'),
|
||||
* @returns {Array} Returns the new sorted array.
|
||||
*/
|
||||
function baseOrderBy(collection, iteratees, orders) {
|
||||
var index = -1,
|
||||
toIteratee = baseIteratee;
|
||||
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
|
||||
return toIteratee(iteratee);
|
||||
});
|
||||
var index = -1;
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), baseIteratee);
|
||||
|
||||
var result = baseMap(collection, function(value, key, collection) {
|
||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||
|
||||
@@ -1,15 +1,47 @@
|
||||
var basePullAllBy = require('./_basePullAllBy');
|
||||
var arrayMap = require('./_arrayMap'),
|
||||
baseIndexOf = require('./_baseIndexOf'),
|
||||
baseIndexOfWith = require('./_baseIndexOfWith'),
|
||||
baseUnary = require('./_baseUnary');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
|
||||
/** Built-in value references. */
|
||||
var splice = arrayProto.splice;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pullAll`.
|
||||
* The base implementation of `_.pullAllBy` without support for iteratee
|
||||
* shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to modify.
|
||||
* @param {Array} values The values to remove.
|
||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||
* @param {Function} [comparator] The comparator invoked per element.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function basePullAll(array, values) {
|
||||
return basePullAllBy(array, values);
|
||||
function basePullAll(array, values, iteratee, comparator) {
|
||||
var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
|
||||
index = -1,
|
||||
length = values.length,
|
||||
seen = array;
|
||||
|
||||
if (iteratee) {
|
||||
seen = arrayMap(array, baseUnary(iteratee));
|
||||
}
|
||||
while (++index < length) {
|
||||
var fromIndex = 0,
|
||||
value = values[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
|
||||
if (seen !== array) {
|
||||
splice.call(seen, fromIndex, 1);
|
||||
}
|
||||
splice.call(array, fromIndex, 1);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
module.exports = basePullAll;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
var arrayMap = require('./_arrayMap'),
|
||||
baseIndexOf = require('./_baseIndexOf');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
|
||||
/** Built-in value references. */
|
||||
var splice = arrayProto.splice;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pullAllBy` without support for iteratee
|
||||
* shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to modify.
|
||||
* @param {Array} values The values to remove.
|
||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function basePullAllBy(array, values, iteratee) {
|
||||
var index = -1,
|
||||
length = values.length,
|
||||
seen = array;
|
||||
|
||||
if (iteratee) {
|
||||
seen = arrayMap(array, function(value) { return iteratee(value); });
|
||||
}
|
||||
while (++index < length) {
|
||||
var fromIndex = 0,
|
||||
value = values[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
|
||||
if (seen !== array) {
|
||||
splice.call(seen, fromIndex, 1);
|
||||
}
|
||||
splice.call(array, fromIndex, 1);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
module.exports = basePullAllBy;
|
||||
@@ -1,4 +1,4 @@
|
||||
var baseToPath = require('./_baseToPath'),
|
||||
var baseCastPath = require('./_baseCastPath'),
|
||||
isIndex = require('./_isIndex'),
|
||||
isKey = require('./_isKey'),
|
||||
last = require('./last'),
|
||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else if (!isKey(index, array)) {
|
||||
var path = baseToPath(index),
|
||||
var path = baseCastPath(index),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var assignValue = require('./_assignValue'),
|
||||
baseToPath = require('./_baseToPath'),
|
||||
baseCastPath = require('./_baseCastPath'),
|
||||
isIndex = require('./_isIndex'),
|
||||
isKey = require('./_isKey'),
|
||||
isObject = require('./isObject');
|
||||
@@ -15,7 +15,7 @@ var assignValue = require('./_assignValue'),
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseSet(object, path, value, customizer) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
|
||||
var objValue = nested[key];
|
||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||
if (newValue === undefined) {
|
||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
||||
newValue = objValue == null
|
||||
? (isIndex(path[index + 1]) ? [] : {})
|
||||
: objValue;
|
||||
}
|
||||
}
|
||||
assignValue(nested, key, newValue);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* The base implementation of `_.sortBy` which uses `comparer` to define
|
||||
* the sort order of `array` and replaces criteria objects with their
|
||||
* corresponding values.
|
||||
* The base implementation of `_.sortBy` which uses `comparer` to define the
|
||||
* sort order of `array` and replaces criteria objects with their corresponding
|
||||
* values.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to sort.
|
||||
|
||||
@@ -15,7 +15,7 @@ function baseSortedUniqBy(array, iteratee) {
|
||||
value = array[0],
|
||||
computed = iteratee ? iteratee(value) : value,
|
||||
seen = computed,
|
||||
resIndex = 0,
|
||||
resIndex = 1,
|
||||
result = [value];
|
||||
|
||||
while (++index < length) {
|
||||
@@ -24,7 +24,7 @@ function baseSortedUniqBy(array, iteratee) {
|
||||
|
||||
if (!eq(computed, seen)) {
|
||||
seen = computed;
|
||||
result[++resIndex] = value;
|
||||
result[resIndex++] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
var isArray = require('./isArray'),
|
||||
stringToPath = require('./_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);
|
||||
}
|
||||
|
||||
module.exports = baseToPath;
|
||||
@@ -1,4 +1,4 @@
|
||||
var baseToPath = require('./_baseToPath'),
|
||||
var baseCastPath = require('./_baseCastPath'),
|
||||
has = require('./has'),
|
||||
isKey = require('./_isKey'),
|
||||
last = require('./last'),
|
||||
@@ -13,7 +13,7 @@ var baseToPath = require('./_baseToPath'),
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
*/
|
||||
function baseUnset(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
var key = last(path);
|
||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||
|
||||
18
_baseUpdate.js
Normal file
18
_baseUpdate.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var baseGet = require('./_baseGet'),
|
||||
baseSet = require('./_baseSet');
|
||||
|
||||
/**
|
||||
* The base implementation of `_.update`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Array|string} path The path of the property to update.
|
||||
* @param {Function} updater The function to produce the updated value.
|
||||
* @param {Function} [customizer] The function to customize path creation.
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseUpdate(object, path, updater, customizer) {
|
||||
return baseSet(object, path, updater(baseGet(object, path)), customizer);
|
||||
}
|
||||
|
||||
module.exports = baseUpdate;
|
||||
@@ -8,11 +8,8 @@ var Uint8Array = require('./_Uint8Array');
|
||||
* @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));
|
||||
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||||
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ function cloneBuffer(buffer, isDeep) {
|
||||
if (isDeep) {
|
||||
return buffer.slice();
|
||||
}
|
||||
var Ctor = buffer.constructor,
|
||||
result = new Ctor(buffer.length);
|
||||
|
||||
var result = new buffer.constructor(buffer.length);
|
||||
buffer.copy(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ var addMapEntry = require('./_addMapEntry'),
|
||||
* @returns {Object} Returns the cloned map.
|
||||
*/
|
||||
function cloneMap(map) {
|
||||
var Ctor = map.constructor;
|
||||
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
|
||||
return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
|
||||
}
|
||||
|
||||
module.exports = cloneMap;
|
||||
|
||||
@@ -9,9 +9,7 @@ var reFlags = /\w*$/;
|
||||
* @returns {Object} Returns the cloned regexp.
|
||||
*/
|
||||
function cloneRegExp(regexp) {
|
||||
var Ctor = regexp.constructor,
|
||||
result = new Ctor(regexp.source, reFlags.exec(regexp));
|
||||
|
||||
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||||
result.lastIndex = regexp.lastIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ var addSetEntry = require('./_addSetEntry'),
|
||||
* @returns {Object} Returns the cloned set.
|
||||
*/
|
||||
function cloneSet(set) {
|
||||
var Ctor = set.constructor;
|
||||
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
|
||||
return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
|
||||
}
|
||||
|
||||
module.exports = cloneSet;
|
||||
|
||||
@@ -2,7 +2,7 @@ var Symbol = require('./_Symbol');
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
|
||||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||||
|
||||
/**
|
||||
* Creates a clone of the `symbol` object.
|
||||
@@ -12,7 +12,7 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
* @returns {Object} Returns the cloned symbol object.
|
||||
*/
|
||||
function cloneSymbol(symbol) {
|
||||
return Symbol ? Object(symbolValueOf.call(symbol)) : {};
|
||||
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
||||
}
|
||||
|
||||
module.exports = cloneSymbol;
|
||||
|
||||
@@ -9,10 +9,8 @@ var cloneArrayBuffer = require('./_cloneArrayBuffer');
|
||||
* @returns {Object} Returns the cloned typed array.
|
||||
*/
|
||||
function cloneTypedArray(typedArray, isDeep) {
|
||||
var buffer = typedArray.buffer,
|
||||
Ctor = typedArray.constructor;
|
||||
|
||||
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
||||
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||||
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||||
}
|
||||
|
||||
module.exports = cloneTypedArray;
|
||||
|
||||
@@ -9,23 +9,28 @@ var nativeMax = Math.max;
|
||||
* @param {Array|Object} args The provided arguments.
|
||||
* @param {Array} partials The arguments to prepend to those provided.
|
||||
* @param {Array} holders The `partials` placeholder indexes.
|
||||
* @params {boolean} [isCurried] Specify composing for a curried function.
|
||||
* @returns {Array} Returns the new array of composed arguments.
|
||||
*/
|
||||
function composeArgs(args, partials, holders) {
|
||||
var holdersLength = holders.length,
|
||||
argsIndex = -1,
|
||||
argsLength = nativeMax(args.length - holdersLength, 0),
|
||||
function composeArgs(args, partials, holders, isCurried) {
|
||||
var argsIndex = -1,
|
||||
argsLength = args.length,
|
||||
holdersLength = holders.length,
|
||||
leftIndex = -1,
|
||||
leftLength = partials.length,
|
||||
result = Array(leftLength + argsLength);
|
||||
rangeLength = nativeMax(argsLength - holdersLength, 0),
|
||||
result = Array(leftLength + rangeLength),
|
||||
isUncurried = !isCurried;
|
||||
|
||||
while (++leftIndex < leftLength) {
|
||||
result[leftIndex] = partials[leftIndex];
|
||||
}
|
||||
while (++argsIndex < holdersLength) {
|
||||
result[holders[argsIndex]] = args[argsIndex];
|
||||
if (isUncurried || argsIndex < argsLength) {
|
||||
result[holders[argsIndex]] = args[argsIndex];
|
||||
}
|
||||
}
|
||||
while (argsLength--) {
|
||||
while (rangeLength--) {
|
||||
result[leftIndex++] = args[argsIndex++];
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -9,18 +9,21 @@ var nativeMax = Math.max;
|
||||
* @param {Array|Object} args The provided arguments.
|
||||
* @param {Array} partials The arguments to append to those provided.
|
||||
* @param {Array} holders The `partials` placeholder indexes.
|
||||
* @params {boolean} [isCurried] Specify composing for a curried function.
|
||||
* @returns {Array} Returns the new array of composed arguments.
|
||||
*/
|
||||
function composeArgsRight(args, partials, holders) {
|
||||
var holdersIndex = -1,
|
||||
function composeArgsRight(args, partials, holders, isCurried) {
|
||||
var argsIndex = -1,
|
||||
argsLength = args.length,
|
||||
holdersIndex = -1,
|
||||
holdersLength = holders.length,
|
||||
argsIndex = -1,
|
||||
argsLength = nativeMax(args.length - holdersLength, 0),
|
||||
rightIndex = -1,
|
||||
rightLength = partials.length,
|
||||
result = Array(argsLength + rightLength);
|
||||
rangeLength = nativeMax(argsLength - holdersLength, 0),
|
||||
result = Array(rangeLength + rightLength),
|
||||
isUncurried = !isCurried;
|
||||
|
||||
while (++argsIndex < argsLength) {
|
||||
while (++argsIndex < rangeLength) {
|
||||
result[argsIndex] = args[argsIndex];
|
||||
}
|
||||
var offset = argsIndex;
|
||||
@@ -28,7 +31,9 @@ function composeArgsRight(args, partials, holders) {
|
||||
result[offset + rightIndex] = partials[rightIndex];
|
||||
}
|
||||
while (++holdersIndex < holdersLength) {
|
||||
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||
if (isUncurried || argsIndex < argsLength) {
|
||||
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) {
|
||||
length = props.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index],
|
||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
||||
var key = props[index];
|
||||
|
||||
var newValue = customizer
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: source[key];
|
||||
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
|
||||
21
_countHolders.js
Normal file
21
_countHolders.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Gets the number of `placeholder` occurrences in `array`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} placeholder The placeholder to search for.
|
||||
* @returns {number} Returns the placeholder count.
|
||||
*/
|
||||
function countHolders(array, placeholder) {
|
||||
var length = array.length,
|
||||
result = 0;
|
||||
|
||||
while (length--) {
|
||||
if (array[length] === placeholder) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = countHolders;
|
||||
@@ -15,7 +15,10 @@ function createAssigner(assigner) {
|
||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||
guard = length > 2 ? sources[2] : undefined;
|
||||
|
||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
||||
customizer = typeof customizer == 'function'
|
||||
? (length--, customizer)
|
||||
: undefined;
|
||||
|
||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||
customizer = length < 3 ? undefined : customizer;
|
||||
length = 1;
|
||||
|
||||
@@ -24,8 +24,11 @@ function createCaseFirst(methodName) {
|
||||
return function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
var strSymbols = reHasComplexSymbol.test(string)
|
||||
? stringToArray(string)
|
||||
: undefined;
|
||||
|
||||
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||
|
||||
return chr[methodName]() + trailing;
|
||||
|
||||
@@ -2,6 +2,7 @@ var apply = require('./_apply'),
|
||||
createCtorWrapper = require('./_createCtorWrapper'),
|
||||
createHybridWrapper = require('./_createHybridWrapper'),
|
||||
createRecurryWrapper = require('./_createRecurryWrapper'),
|
||||
getPlaceholder = require('./_getPlaceholder'),
|
||||
replaceHolders = require('./_replaceHolders'),
|
||||
root = require('./_root');
|
||||
|
||||
@@ -19,10 +20,9 @@ function createCurryWrapper(func, bitmask, arity) {
|
||||
|
||||
function wrapper() {
|
||||
var length = arguments.length,
|
||||
index = length,
|
||||
args = Array(length),
|
||||
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func,
|
||||
placeholder = wrapper.placeholder;
|
||||
index = length,
|
||||
placeholder = getPlaceholder(wrapper);
|
||||
|
||||
while (index--) {
|
||||
args[index] = arguments[index];
|
||||
@@ -32,9 +32,13 @@ function createCurryWrapper(func, bitmask, arity) {
|
||||
: replaceHolders(args, placeholder);
|
||||
|
||||
length -= holders.length;
|
||||
return length < arity
|
||||
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length)
|
||||
: apply(fn, this, args);
|
||||
if (length < arity) {
|
||||
return createRecurryWrapper(
|
||||
func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
|
||||
args, holders, undefined, undefined, arity - length);
|
||||
}
|
||||
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
||||
return apply(fn, this, args);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -6,18 +6,18 @@ var LodashWrapper = require('./_LodashWrapper'),
|
||||
isLaziable = require('./_isLaziable'),
|
||||
rest = require('./rest');
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var CURRY_FLAG = 8,
|
||||
PARTIAL_FLAG = 32,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var CURRY_FLAG = 8,
|
||||
PARTIAL_FLAG = 32,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/**
|
||||
* Creates a `_.flow` or `_.flowRight` function.
|
||||
*
|
||||
@@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
*/
|
||||
function createFlow(fromRight) {
|
||||
return rest(function(funcs) {
|
||||
funcs = baseFlatten(funcs);
|
||||
funcs = baseFlatten(funcs, 1);
|
||||
|
||||
var length = funcs.length,
|
||||
index = length,
|
||||
@@ -52,7 +52,10 @@ function createFlow(fromRight) {
|
||||
var funcName = getFuncName(func),
|
||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
||||
|
||||
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
||||
if (data && isLaziable(data[0]) &&
|
||||
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
|
||||
!data[4].length && data[9] == 1
|
||||
) {
|
||||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||
} else {
|
||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||
@@ -62,7 +65,8 @@ function createFlow(fromRight) {
|
||||
var args = arguments,
|
||||
value = args[0];
|
||||
|
||||
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
if (wrapper && args.length == 1 &&
|
||||
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
return wrapper.plant(value).value();
|
||||
}
|
||||
var index = 0,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
var composeArgs = require('./_composeArgs'),
|
||||
composeArgsRight = require('./_composeArgsRight'),
|
||||
countHolders = require('./_countHolders'),
|
||||
createCtorWrapper = require('./_createCtorWrapper'),
|
||||
createRecurryWrapper = require('./_createRecurryWrapper'),
|
||||
getPlaceholder = require('./_getPlaceholder'),
|
||||
reorder = require('./_reorder'),
|
||||
replaceHolders = require('./_replaceHolders'),
|
||||
root = require('./_root');
|
||||
@@ -35,8 +37,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
||||
var isAry = bitmask & ARY_FLAG,
|
||||
isBind = bitmask & BIND_FLAG,
|
||||
isBindKey = bitmask & BIND_KEY_FLAG,
|
||||
isCurry = bitmask & CURRY_FLAG,
|
||||
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
|
||||
isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
|
||||
isFlip = bitmask & FLIP_FLAG,
|
||||
Ctor = isBindKey ? undefined : createCtorWrapper(func);
|
||||
|
||||
@@ -48,30 +49,34 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
||||
while (index--) {
|
||||
args[index] = arguments[index];
|
||||
}
|
||||
if (isCurried) {
|
||||
var placeholder = getPlaceholder(wrapper),
|
||||
holdersCount = countHolders(args, placeholder);
|
||||
}
|
||||
if (partials) {
|
||||
args = composeArgs(args, partials, holders);
|
||||
args = composeArgs(args, partials, holders, isCurried);
|
||||
}
|
||||
if (partialsRight) {
|
||||
args = composeArgsRight(args, partialsRight, holdersRight);
|
||||
args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
|
||||
}
|
||||
if (isCurry || isCurryRight) {
|
||||
var placeholder = wrapper.placeholder,
|
||||
argsHolders = replaceHolders(args, placeholder);
|
||||
|
||||
length -= argsHolders.length;
|
||||
if (length < arity) {
|
||||
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
|
||||
}
|
||||
length -= holdersCount;
|
||||
if (isCurried && length < arity) {
|
||||
var newHolders = replaceHolders(args, placeholder);
|
||||
return createRecurryWrapper(
|
||||
func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
|
||||
args, newHolders, argPos, ary, arity - length
|
||||
);
|
||||
}
|
||||
var thisBinding = isBind ? thisArg : this,
|
||||
fn = isBindKey ? thisBinding[func] : func;
|
||||
|
||||
length = args.length;
|
||||
if (argPos) {
|
||||
args = reorder(args, argPos);
|
||||
} else if (isFlip && args.length > 1) {
|
||||
} else if (isFlip && length > 1) {
|
||||
args.reverse();
|
||||
}
|
||||
if (isAry && ary < args.length) {
|
||||
if (isAry && ary < length) {
|
||||
args.length = ary;
|
||||
}
|
||||
if (this && this !== root && this instanceof wrapper) {
|
||||
|
||||
@@ -13,7 +13,7 @@ var apply = require('./_apply'),
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return rest(function(iteratees) {
|
||||
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
|
||||
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
|
||||
return rest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
|
||||
@@ -17,7 +17,7 @@ var BIND_FLAG = 1,
|
||||
* @param {Function} func The function to wrap.
|
||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
||||
* @param {Function} wrapFunc The function to create the `func` wrapper.
|
||||
* @param {*} placeholder The placeholder to replace.
|
||||
* @param {*} placeholder The placeholder value.
|
||||
* @param {*} [thisArg] The `this` binding of `func`.
|
||||
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
|
||||
* @param {Array} [holders] The `partials` placeholder indexes.
|
||||
@@ -29,7 +29,7 @@ var BIND_FLAG = 1,
|
||||
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
||||
var isCurry = bitmask & CURRY_FLAG,
|
||||
newArgPos = argPos ? copyArray(argPos) : undefined,
|
||||
newsHolders = isCurry ? holders : undefined,
|
||||
newHolders = isCurry ? holders : undefined,
|
||||
newHoldersRight = isCurry ? undefined : holders,
|
||||
newPartials = isCurry ? partials : undefined,
|
||||
newPartialsRight = isCurry ? undefined : partials;
|
||||
@@ -40,9 +40,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||
}
|
||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
||||
result = wrapFunc.apply(undefined, newData);
|
||||
var newData = [
|
||||
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||
newHoldersRight, newArgPos, ary, arity
|
||||
];
|
||||
|
||||
var result = wrapFunc.apply(undefined, newData);
|
||||
if (isLaziable(func)) {
|
||||
setData(result, newData);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ var baseSetData = require('./_baseSetData'),
|
||||
setData = require('./_setData'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
BIND_KEY_FLAG = 2,
|
||||
@@ -16,9 +19,6 @@ var BIND_FLAG = 1,
|
||||
PARTIAL_FLAG = 32,
|
||||
PARTIAL_RIGHT_FLAG = 64;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
|
||||
@@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
||||
|
||||
partials = holders = undefined;
|
||||
}
|
||||
var data = isBindKey ? undefined : getData(func),
|
||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
||||
var data = isBindKey ? undefined : getData(func);
|
||||
|
||||
var newData = [
|
||||
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||
argPos, ary, arity
|
||||
];
|
||||
|
||||
if (data) {
|
||||
mergeData(newData, data);
|
||||
|
||||
@@ -12,9 +12,9 @@ var UNORDERED_COMPARE_FLAG = 1,
|
||||
* @param {Array} array The array to compare.
|
||||
* @param {Array} other The other array to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} [stack] Tracks traversed `array` and `other` objects.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||||
*/
|
||||
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var Symbol = require('./_Symbol'),
|
||||
Uint8Array = require('./_Uint8Array'),
|
||||
equalArrays = require('./_equalArrays'),
|
||||
mapToArray = require('./_mapToArray'),
|
||||
setToArray = require('./_setToArray');
|
||||
|
||||
@@ -22,7 +23,7 @@ var arrayBufferTag = '[object ArrayBuffer]';
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
|
||||
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||||
@@ -36,11 +37,12 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {string} tag The `toStringTag` of the objects to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
if ((object.byteLength != other.byteLength) ||
|
||||
@@ -75,12 +77,21 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||
convert || (convert = setToArray);
|
||||
|
||||
if (object.size != other.size && !isPartial) {
|
||||
return false;
|
||||
}
|
||||
// Assume cyclic values are equal.
|
||||
var stacked = stack.get(object);
|
||||
if (stacked) {
|
||||
return stacked == other;
|
||||
}
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
return (isPartial || object.size == other.size) &&
|
||||
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
|
||||
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other));
|
||||
|
||||
case symbolTag:
|
||||
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
|
||||
if (symbolValueOf) {
|
||||
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ var PARTIAL_COMPARE_FLAG = 2;
|
||||
* @param {Object} object The object to compare.
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
@@ -9,7 +9,7 @@ var isNative = require('./isNative');
|
||||
* @returns {*} Returns the function if it's native, else `undefined`.
|
||||
*/
|
||||
function getNative(object, key) {
|
||||
var value = object == null ? undefined : object[key];
|
||||
var value = object[key];
|
||||
return isNative(value) ? value : undefined;
|
||||
}
|
||||
|
||||
|
||||
13
_getPlaceholder.js
Normal file
13
_getPlaceholder.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Gets the argument placeholder value for `func`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to inspect.
|
||||
* @returns {*} Returns the placeholder value.
|
||||
*/
|
||||
function getPlaceholder(func) {
|
||||
var object = func;
|
||||
return object.placeholder;
|
||||
}
|
||||
|
||||
module.exports = getPlaceholder;
|
||||
@@ -1,4 +1,4 @@
|
||||
var baseToPath = require('./_baseToPath'),
|
||||
var baseCastPath = require('./_baseCastPath'),
|
||||
isArguments = require('./isArguments'),
|
||||
isArray = require('./isArray'),
|
||||
isIndex = require('./_isIndex'),
|
||||
@@ -23,7 +23,7 @@ function hasPath(object, path, hasFunc) {
|
||||
}
|
||||
var result = hasFunc(object, path);
|
||||
if (!result && !isKey(path)) {
|
||||
path = baseToPath(path);
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
if (object != null) {
|
||||
path = last(path);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
var baseCreate = require('./_baseCreate'),
|
||||
isFunction = require('./isFunction'),
|
||||
isPrototype = require('./_isPrototype');
|
||||
|
||||
/** Built-in value references. */
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
|
||||
/**
|
||||
* Initializes an object clone.
|
||||
*
|
||||
@@ -10,11 +12,9 @@ var baseCreate = require('./_baseCreate'),
|
||||
* @returns {Object} Returns the initialized clone.
|
||||
*/
|
||||
function initCloneObject(object) {
|
||||
if (isPrototype(object)) {
|
||||
return {};
|
||||
}
|
||||
var Ctor = object.constructor;
|
||||
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
|
||||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||||
? baseCreate(getPrototypeOf(object))
|
||||
: {};
|
||||
}
|
||||
|
||||
module.exports = initCloneObject;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
function isKeyable(value) {
|
||||
var type = typeof value;
|
||||
return type == 'number' || type == 'boolean' ||
|
||||
(type == 'string' && value !== '__proto__') || value == null;
|
||||
(type == 'string' && value != '__proto__') || value == null;
|
||||
}
|
||||
|
||||
module.exports = isKeyable;
|
||||
|
||||
@@ -36,7 +36,8 @@ function lazyValue() {
|
||||
resIndex = 0,
|
||||
takeCount = nativeMin(length, this.__takeCount__);
|
||||
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
|
||||
(arrLength == length && takeCount == length)) {
|
||||
return baseWrapperValue(array, this.__actions__);
|
||||
}
|
||||
var result = [];
|
||||
|
||||
@@ -9,7 +9,11 @@ var Hash = require('./_Hash'),
|
||||
* @memberOf MapCache
|
||||
*/
|
||||
function mapClear() {
|
||||
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
|
||||
this.__data__ = {
|
||||
'hash': new Hash,
|
||||
'map': Map ? new Map : [],
|
||||
'string': new Hash
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = mapClear;
|
||||
|
||||
@@ -3,6 +3,9 @@ var composeArgs = require('./_composeArgs'),
|
||||
copyArray = require('./_copyArray'),
|
||||
replaceHolders = require('./_replaceHolders');
|
||||
|
||||
/** Used as the internal argument placeholder. */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
BIND_KEY_FLAG = 2,
|
||||
@@ -11,9 +14,6 @@ var BIND_FLAG = 1,
|
||||
ARY_FLAG = 128,
|
||||
REARG_FLAG = 256;
|
||||
|
||||
/** Used as the internal argument placeholder. */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
|
||||
@@ -39,9 +39,9 @@ function mergeData(data, source) {
|
||||
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
|
||||
|
||||
var isCombo =
|
||||
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) ||
|
||||
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
||||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
||||
((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
|
||||
((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
||||
((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
||||
|
||||
// Exit early if metadata can't be merged.
|
||||
if (!(isCommon || isCombo)) {
|
||||
@@ -51,7 +51,7 @@ function mergeData(data, source) {
|
||||
if (srcBitmask & BIND_FLAG) {
|
||||
data[2] = source[2];
|
||||
// Set when currying a bound function.
|
||||
newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
|
||||
newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
|
||||
}
|
||||
// Compose partial arguments.
|
||||
var value = source[3];
|
||||
|
||||
@@ -15,8 +15,7 @@ var baseMerge = require('./_baseMerge'),
|
||||
*/
|
||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||
if (isObject(objValue) && isObject(srcValue)) {
|
||||
stack.set(srcValue, objValue);
|
||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
|
||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ var PLACEHOLDER = '__lodash_placeholder__';
|
||||
function replaceHolders(array, placeholder) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === placeholder) {
|
||||
var value = array[index];
|
||||
if (value === placeholder || value === PLACEHOLDER) {
|
||||
array[index] = PLACEHOLDER;
|
||||
result[++resIndex] = index;
|
||||
result[resIndex++] = index;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
12
_root.js
12
_root.js
@@ -7,10 +7,14 @@ var objectTypes = {
|
||||
};
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||
? exports
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||
? module
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||
@@ -30,6 +34,8 @@ var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
|
||||
var root = freeGlobal ||
|
||||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
|
||||
freeSelf || thisGlobal || Function('return this')();
|
||||
|
||||
module.exports = root;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
var isArrayLikeObject = require('./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 : [];
|
||||
}
|
||||
|
||||
module.exports = toArrayLikeObject;
|
||||
@@ -1,14 +0,0 @@
|
||||
var identity = require('./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;
|
||||
}
|
||||
|
||||
module.exports = toFunction;
|
||||
2
array.js
2
array.js
@@ -14,6 +14,7 @@ module.exports = {
|
||||
'findLastIndex': require('./findLastIndex'),
|
||||
'flatten': require('./flatten'),
|
||||
'flattenDeep': require('./flattenDeep'),
|
||||
'flattenDepth': require('./flattenDepth'),
|
||||
'fromPairs': require('./fromPairs'),
|
||||
'head': require('./head'),
|
||||
'indexOf': require('./indexOf'),
|
||||
@@ -27,6 +28,7 @@ module.exports = {
|
||||
'pull': require('./pull'),
|
||||
'pullAll': require('./pullAll'),
|
||||
'pullAllBy': require('./pullAllBy'),
|
||||
'pullAllWith': require('./pullAllWith'),
|
||||
'pullAt': require('./pullAt'),
|
||||
'remove': require('./remove'),
|
||||
'reverse': require('./reverse'),
|
||||
|
||||
27
assign.js
27
assign.js
@@ -1,7 +1,22 @@
|
||||
var copyObject = require('./_copyObject'),
|
||||
var assignValue = require('./_assignValue'),
|
||||
copyObject = require('./_copyObject'),
|
||||
createAssigner = require('./_createAssigner'),
|
||||
isArrayLike = require('./isArrayLike'),
|
||||
isPrototype = require('./_isPrototype'),
|
||||
keys = require('./keys');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Built-in value references. */
|
||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
|
||||
/**
|
||||
* Assigns own enumerable properties of source objects to the destination
|
||||
* object. Source objects are applied from left to right. Subsequent sources
|
||||
@@ -33,7 +48,15 @@ var copyObject = require('./_copyObject'),
|
||||
* // => { 'a': 1, 'c': 3, 'e': 5 }
|
||||
*/
|
||||
var assign = createAssigner(function(object, source) {
|
||||
copyObject(source, keys(source), object);
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keys(source), object);
|
||||
return;
|
||||
}
|
||||
for (var key in source) {
|
||||
if (hasOwnProperty.call(source, key)) {
|
||||
assignValue(object, key, source[key]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = assign;
|
||||
|
||||
22
assignIn.js
22
assignIn.js
@@ -1,7 +1,19 @@
|
||||
var copyObject = require('./_copyObject'),
|
||||
var assignValue = require('./_assignValue'),
|
||||
copyObject = require('./_copyObject'),
|
||||
createAssigner = require('./_createAssigner'),
|
||||
isArrayLike = require('./isArrayLike'),
|
||||
isPrototype = require('./_isPrototype'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Built-in value references. */
|
||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it iterates over own and
|
||||
* inherited source properties.
|
||||
@@ -32,7 +44,13 @@ var copyObject = require('./_copyObject'),
|
||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
|
||||
*/
|
||||
var assignIn = createAssigner(function(object, source) {
|
||||
copyObject(source, keysIn(source), object);
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keysIn(source), object);
|
||||
return;
|
||||
}
|
||||
for (var key in source) {
|
||||
assignValue(object, key, source[key]);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = assignIn;
|
||||
|
||||
2
at.js
2
at.js
@@ -23,7 +23,7 @@ var baseAt = require('./_baseAt'),
|
||||
* // => ['a', 'c']
|
||||
*/
|
||||
var at = rest(function(object, paths) {
|
||||
return baseAt(object, baseFlatten(paths));
|
||||
return baseAt(object, baseFlatten(paths, 1));
|
||||
});
|
||||
|
||||
module.exports = at;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var apply = require('./_apply'),
|
||||
isObject = require('./isObject'),
|
||||
isError = require('./isError'),
|
||||
rest = require('./rest');
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ var attempt = rest(function(func, args) {
|
||||
try {
|
||||
return apply(func, undefined, args);
|
||||
} catch (e) {
|
||||
return isObject(e) ? e : new Error(e);
|
||||
return isError(e) ? e : new Error(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
5
bind.js
5
bind.js
@@ -1,4 +1,5 @@
|
||||
var createWrapper = require('./_createWrapper'),
|
||||
getPlaceholder = require('./_getPlaceholder'),
|
||||
replaceHolders = require('./_replaceHolders'),
|
||||
rest = require('./rest');
|
||||
|
||||
@@ -44,9 +45,7 @@ var BIND_FLAG = 1,
|
||||
var bind = rest(function(func, thisArg, partials) {
|
||||
var bitmask = BIND_FLAG;
|
||||
if (partials.length) {
|
||||
var placeholder = bind.placeholder,
|
||||
holders = replaceHolders(partials, placeholder);
|
||||
|
||||
var holders = replaceHolders(partials, getPlaceholder(bind));
|
||||
bitmask |= PARTIAL_FLAG;
|
||||
}
|
||||
return createWrapper(func, bitmask, thisArg, partials, holders);
|
||||
|
||||
@@ -30,7 +30,7 @@ var arrayEach = require('./_arrayEach'),
|
||||
* // => logs 'clicked docs' when clicked
|
||||
*/
|
||||
var bindAll = rest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames), function(key) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
object[key] = bind(object[key], object);
|
||||
});
|
||||
return object;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var createWrapper = require('./_createWrapper'),
|
||||
getPlaceholder = require('./_getPlaceholder'),
|
||||
replaceHolders = require('./_replaceHolders'),
|
||||
rest = require('./rest');
|
||||
|
||||
@@ -54,9 +55,7 @@ var BIND_FLAG = 1,
|
||||
var bindKey = rest(function(object, key, partials) {
|
||||
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
||||
if (partials.length) {
|
||||
var placeholder = bindKey.placeholder,
|
||||
holders = replaceHolders(partials, placeholder);
|
||||
|
||||
var holders = replaceHolders(partials, getPlaceholder(bindKey));
|
||||
bitmask |= PARTIAL_FLAG;
|
||||
}
|
||||
return createWrapper(key, bitmask, object, partials, holders);
|
||||
|
||||
43
castArray.js
Normal file
43
castArray.js
Normal file
@@ -0,0 +1,43 @@
|
||||
var isArray = require('./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];
|
||||
}
|
||||
|
||||
module.exports = castArray;
|
||||
4
chunk.js
4
chunk.js
@@ -32,11 +32,11 @@ function chunk(array, size) {
|
||||
return [];
|
||||
}
|
||||
var index = 0,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = Array(nativeCeil(length / size));
|
||||
|
||||
while (index < length) {
|
||||
result[++resIndex] = baseSlice(array, index, (index += size));
|
||||
result[resIndex++] = baseSlice(array, index, (index += size));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
2
clone.js
2
clone.js
@@ -25,7 +25,7 @@ var baseClone = require('./_baseClone');
|
||||
* // => true
|
||||
*/
|
||||
function clone(value) {
|
||||
return baseClone(value);
|
||||
return baseClone(value, false, true);
|
||||
}
|
||||
|
||||
module.exports = clone;
|
||||
|
||||
@@ -17,7 +17,7 @@ var baseClone = require('./_baseClone');
|
||||
* // => false
|
||||
*/
|
||||
function cloneDeep(value) {
|
||||
return baseClone(value, true);
|
||||
return baseClone(value, true, true);
|
||||
}
|
||||
|
||||
module.exports = cloneDeep;
|
||||
|
||||
@@ -27,7 +27,7 @@ var baseClone = require('./_baseClone');
|
||||
* // => 20
|
||||
*/
|
||||
function cloneDeepWith(value, customizer) {
|
||||
return baseClone(value, true, customizer);
|
||||
return baseClone(value, true, true, customizer);
|
||||
}
|
||||
|
||||
module.exports = cloneDeepWith;
|
||||
|
||||
@@ -30,7 +30,7 @@ var baseClone = require('./_baseClone');
|
||||
* // => 0
|
||||
*/
|
||||
function cloneWith(value, customizer) {
|
||||
return baseClone(value, false, customizer);
|
||||
return baseClone(value, false, true, customizer);
|
||||
}
|
||||
|
||||
module.exports = cloneWith;
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
function compact(array) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0,
|
||||
resIndex = -1,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (value) {
|
||||
result[++resIndex] = value;
|
||||
result[resIndex++] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -28,7 +28,7 @@ var concat = rest(function(array, values) {
|
||||
if (!isArray(array)) {
|
||||
array = array == null ? [] : [Object(array)];
|
||||
}
|
||||
values = baseFlatten(values);
|
||||
values = baseFlatten(values, 1);
|
||||
return arrayConcat(array, values);
|
||||
});
|
||||
|
||||
|
||||
294
core.js
294
core.js
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 4.3.0 (Custom Build) <https://lodash.com/>
|
||||
* lodash 4.6.1 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash core -o ./dist/lodash.core.js`
|
||||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
@@ -13,7 +13,10 @@
|
||||
var undefined;
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.3.0';
|
||||
var VERSION = '4.6.1';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
@@ -23,11 +26,9 @@
|
||||
var UNORDERED_COMPARE_FLAG = 1,
|
||||
PARTIAL_COMPARE_FLAG = 2;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||||
var INFINITY = 1 / 0,
|
||||
MAX_SAFE_INTEGER = 9007199254740991;
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var argsTag = '[object Arguments]',
|
||||
@@ -66,10 +67,19 @@
|
||||
};
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||
? exports
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||
? module
|
||||
: undefined;
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
var moduleExports = (freeModule && freeModule.exports === freeExports)
|
||||
? freeExports
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||
@@ -80,9 +90,6 @@
|
||||
/** Detect free variable `window`. */
|
||||
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
|
||||
|
||||
/** Detect `this` as the global object. */
|
||||
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
||||
|
||||
@@ -92,7 +99,9 @@
|
||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
|
||||
var root = freeGlobal ||
|
||||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
|
||||
freeSelf || thisGlobal || Function('return this')();
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -365,6 +374,7 @@
|
||||
Symbol = root.Symbol,
|
||||
Uint8Array = root.Uint8Array,
|
||||
enumerate = Reflect ? Reflect.enumerate : undefined,
|
||||
objectCreate = Object.create,
|
||||
propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
@@ -413,51 +423,54 @@
|
||||
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
|
||||
*
|
||||
* The chainable wrapper methods are:
|
||||
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
|
||||
* `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
|
||||
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
|
||||
* `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
|
||||
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
|
||||
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
|
||||
* `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
|
||||
* `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`,
|
||||
* `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
|
||||
* `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
|
||||
* `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`,
|
||||
* `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`,
|
||||
* `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
|
||||
* `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
|
||||
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
|
||||
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
|
||||
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
|
||||
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
|
||||
* `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
|
||||
* `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
|
||||
* `flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`,
|
||||
* `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`,
|
||||
* `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`,
|
||||
* `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`,
|
||||
* `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`,
|
||||
* `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`,
|
||||
* `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`,
|
||||
* `partition`, `pick`, `pickBy`, `plant`, `property`, `propertyOf`, `pull`,
|
||||
* `pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `push`, `range`,
|
||||
* `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
|
||||
* `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
|
||||
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
|
||||
* `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
|
||||
* `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
|
||||
* `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
|
||||
* `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
|
||||
* `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `update`, `values`,
|
||||
* `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
|
||||
* `zipObjectDeep`, and `zipWith`
|
||||
*
|
||||
* The wrapper methods that are **not** chainable by default are:
|
||||
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
|
||||
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`,
|
||||
* `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
|
||||
* `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`,
|
||||
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
|
||||
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
|
||||
* `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
|
||||
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
|
||||
* `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`,
|
||||
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `each`, `eachRight`,
|
||||
* `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`,
|
||||
* `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`, `floor`,
|
||||
* `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
|
||||
* `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`,
|
||||
* `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`,
|
||||
* `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`,
|
||||
* `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`,
|
||||
* `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`,
|
||||
* `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`,
|
||||
* `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`,
|
||||
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`,
|
||||
* `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`,
|
||||
* `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
|
||||
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
|
||||
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
||||
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
|
||||
* `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`,
|
||||
* `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`,
|
||||
* `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`,
|
||||
* `upperCase`, `upperFirst`, `value`, and `words`
|
||||
* `isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`,
|
||||
* `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`,
|
||||
* `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`,
|
||||
* `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`,
|
||||
* `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
|
||||
* `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
|
||||
* `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
|
||||
* `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`,
|
||||
* `template`, `times`, `toInteger`, `toJSON`, `toLength`, `toLower`,
|
||||
* `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`,
|
||||
* `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`,
|
||||
* `value`, and `words`
|
||||
*
|
||||
* @name _
|
||||
* @constructor
|
||||
@@ -542,13 +555,23 @@
|
||||
*/
|
||||
function assignValue(object, key, value) {
|
||||
var objValue = object[key];
|
||||
if ((!eq(objValue, value) ||
|
||||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.create` without support for assigning
|
||||
* properties to the created object.
|
||||
@@ -557,17 +580,9 @@
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(prototype) {
|
||||
if (isObject(prototype)) {
|
||||
object.prototype = prototype;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
}
|
||||
return result || {};
|
||||
};
|
||||
}());
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.delay` and `_.defer` which accepts an array
|
||||
@@ -636,12 +651,12 @@
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||
* @param {number} depth The maximum recursion depth.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @param {Array} [result=[]] The initial result value.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict, result) {
|
||||
function baseFlatten(array, depth, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
var index = -1,
|
||||
@@ -649,11 +664,11 @@
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (isArrayLikeObject(value) &&
|
||||
if (depth > 0 && isArrayLikeObject(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
if (depth > 1) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
baseFlatten(value, isDeep, isStrict, result);
|
||||
baseFlatten(value, depth - 1, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
@@ -752,35 +767,16 @@
|
||||
|
||||
if (!objIsArr) {
|
||||
objTag = objectToString.call(object);
|
||||
if (objTag == argsTag) {
|
||||
objTag = objectTag;
|
||||
}
|
||||
objTag = objTag == argsTag ? objectTag : objTag;
|
||||
}
|
||||
if (!othIsArr) {
|
||||
othTag = objectToString.call(other);
|
||||
if (othTag == argsTag) {
|
||||
othTag = objectTag;
|
||||
}
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
||||
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
|
||||
}
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||
if (!isPartial) {
|
||||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||
|
||||
if (objIsWrapped || othIsWrapped) {
|
||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||
}
|
||||
}
|
||||
if (!isSameTag) {
|
||||
return false;
|
||||
}
|
||||
stack || (stack = []);
|
||||
var stacked = find(stack, function(entry) {
|
||||
return entry[0] === object;
|
||||
@@ -789,7 +785,27 @@
|
||||
return stacked[1] == other;
|
||||
}
|
||||
stack.push([object, other]);
|
||||
var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
|
||||
if (isSameTag && !objIsObj) {
|
||||
var result = (objIsArr || isTypedArray(object))
|
||||
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
|
||||
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
|
||||
stack.pop();
|
||||
return result;
|
||||
}
|
||||
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
||||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||
|
||||
if (objIsWrapped || othIsWrapped) {
|
||||
var result = equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||
stack.pop();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (!isSameTag) {
|
||||
return false;
|
||||
}
|
||||
var result = equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
||||
stack.pop();
|
||||
return result;
|
||||
}
|
||||
@@ -816,7 +832,6 @@
|
||||
* property of prototypes or treat sparse arrays as dense.
|
||||
*
|
||||
* @private
|
||||
* @type Function
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
@@ -1032,8 +1047,11 @@
|
||||
length = props.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index],
|
||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
||||
var key = props[index];
|
||||
|
||||
var newValue = customizer
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: source[key];
|
||||
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
@@ -1053,7 +1071,10 @@
|
||||
length = sources.length,
|
||||
customizer = length > 1 ? sources[length - 1] : undefined;
|
||||
|
||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
||||
customizer = typeof customizer == 'function'
|
||||
? (length--, customizer)
|
||||
: undefined;
|
||||
|
||||
object = Object(object);
|
||||
while (++index < length) {
|
||||
var source = sources[index];
|
||||
@@ -1187,9 +1208,9 @@
|
||||
* @param {Array} array The array to compare.
|
||||
* @param {Array} other The other array to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} [stack] Tracks traversed `array` and `other` objects.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||||
*/
|
||||
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
||||
@@ -1245,11 +1266,12 @@
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {string} tag The `toStringTag` of the objects to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||
switch (tag) {
|
||||
|
||||
case boolTag:
|
||||
@@ -1283,9 +1305,9 @@
|
||||
* @param {Object} object The object to compare.
|
||||
* @param {Object} other The other object to compare.
|
||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||
* @param {Function} [customizer] The function to customize comparisons.
|
||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
||||
* @param {Function} customizer The function to customize comparisons.
|
||||
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
|
||||
* @param {Object} stack Tracks traversed `object` and `other` objects.
|
||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||
*/
|
||||
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
@@ -1382,17 +1404,6 @@
|
||||
return value === proto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of `wrapper`.
|
||||
*
|
||||
@@ -1451,12 +1462,12 @@
|
||||
if (!isArray(array)) {
|
||||
array = array == null ? [] : [Object(array)];
|
||||
}
|
||||
values = baseFlatten(values);
|
||||
values = baseFlatten(values, 1);
|
||||
return arrayConcat(array, values);
|
||||
});
|
||||
|
||||
/**
|
||||
* Flattens `array` a single level.
|
||||
* Flattens `array` a single level deep.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -1465,30 +1476,30 @@
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flatten([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, [4]]
|
||||
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, [3, [4]], 5]
|
||||
*/
|
||||
function flatten(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array) : [];
|
||||
return length ? baseFlatten(array, 1) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is like `_.flatten` except that it recursively flattens `array`.
|
||||
* Recursively flattens `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} array The array to recursively flatten.
|
||||
* @param {Array} array The array to flatten.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, 4]
|
||||
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, 3, 4, 5]
|
||||
*/
|
||||
function flattenDeep(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array, true) : [];
|
||||
return length ? baseFlatten(array, INFINITY) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1872,7 +1883,7 @@
|
||||
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
||||
*/
|
||||
function forEach(collection, iteratee) {
|
||||
return baseEach(collection, toFunction(iteratee));
|
||||
return baseEach(collection, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2400,7 +2411,7 @@
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @type {Function}
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
@@ -2427,7 +2438,6 @@
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||
@@ -2446,8 +2456,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function isArrayLike(value) {
|
||||
return value != null &&
|
||||
!(typeof value == 'function' && isFunction(value)) && isLength(getLength(value));
|
||||
return value != null && isLength(getLength(value)) && !isFunction(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2456,7 +2465,6 @@
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
||||
@@ -2520,14 +2528,14 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is empty. A value is considered empty unless it's an
|
||||
* `arguments` object, array, string, or jQuery-like collection with a length
|
||||
* greater than `0` or an object with own enumerable properties.
|
||||
* Checks if `value` is an empty collection or object. A value is considered
|
||||
* empty if it's an `arguments` object, array, string, or jQuery-like collection
|
||||
* with a length of `0` or has no own enumerable properties.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {Array|Object|string} value The value to inspect.
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
||||
* @example
|
||||
*
|
||||
@@ -2548,7 +2556,8 @@
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) {
|
||||
(isArray(value) || isString(value) ||
|
||||
isFunction(value.splice) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
for (var key in value) {
|
||||
@@ -2636,8 +2645,8 @@
|
||||
*/
|
||||
function isFunction(value) {
|
||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||
// in Safari 8 which returns 'object' for typed array constructors, and
|
||||
// PhantomJS 1.9 which returns 'function' for `NodeList` instances.
|
||||
// in Safari 8 which returns 'object' for typed array and weak map constructors,
|
||||
// and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
|
||||
var tag = isObject(value) ? objectToString.call(value) : '';
|
||||
return tag == funcTag || tag == genTag;
|
||||
}
|
||||
@@ -2667,7 +2676,8 @@
|
||||
* // => false
|
||||
*/
|
||||
function isLength(value) {
|
||||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||||
return typeof value == 'number' &&
|
||||
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3295,7 +3305,7 @@
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
*/
|
||||
var pick = rest(function(object, props) {
|
||||
return object == null ? {} : basePick(object, baseFlatten(props));
|
||||
return object == null ? {} : basePick(object, baseFlatten(props, 1));
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -3429,7 +3439,8 @@
|
||||
* Creates a function that invokes `func` with the arguments of the created
|
||||
* function. If `func` is a property name the created callback returns the
|
||||
* property value for a given element. If `func` is an object the created
|
||||
* callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
|
||||
* callback returns `true` for elements that contain the equivalent object
|
||||
* properties, otherwise it returns `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -3457,9 +3468,10 @@
|
||||
var iteratee = baseIteratee;
|
||||
|
||||
/**
|
||||
* Creates a function that performs a deep partial comparison between a given
|
||||
* Creates a function that performs a partial deep comparison between a given
|
||||
* object and `source`, returning `true` if the given object has equivalent
|
||||
* property values, else `false`.
|
||||
* property values, else `false`. The created function is equivalent to
|
||||
* `_.isMatch` with a `source` partially applied.
|
||||
*
|
||||
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||
*
|
||||
@@ -3597,7 +3609,7 @@
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {string} [prefix] The value to prefix the ID with.
|
||||
* @param {string} [prefix=''] The value to prefix the ID with.
|
||||
* @returns {string} Returns the unique ID.
|
||||
* @example
|
||||
*
|
||||
@@ -3759,7 +3771,7 @@
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type string
|
||||
* @type {string}
|
||||
*/
|
||||
lodash.VERSION = VERSION;
|
||||
|
||||
|
||||
29
core.min.js
vendored
Normal file
29
core.min.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 4.6.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
|
||||
* Build: `lodash core -o ./dist/lodash.core.js`
|
||||
*/
|
||||
;(function(){function n(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function t(n,t,r){for(var e=-1,u=n.length;++e<u;){var o=n[e],i=t(o);if(null!=i&&(c===an?i===i:r(i,c)))var c=i,f=o}return f}function r(n,t,r){var e;return r(n,function(n,r,u){return t(n,r,u)?(e=n,false):void 0}),e}function e(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function u(n,t){return O(t,function(t){return n[t]})}function o(n){return n&&n.Object===Object?n:null}function i(n){return vn[n];
|
||||
}function c(n){var t=false;if(null!=n&&typeof n.toString!="function")try{t=!!(n+"")}catch(r){}return t}function f(n,t){return n=typeof n=="number"||hn.test(n)?+n:-1,n>-1&&0==n%1&&(null==t?9007199254740991:t)>n}function a(n){if(Y(n)&&!Pn(n)){if(n instanceof l)return n;if(An.call(n,"__wrapped__")){var t=new l(n.__wrapped__,n.__chain__);return t.__actions__=N(n.__actions__),t}}return new l(n)}function l(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function p(n,t,r,e){var u;return(u=n===an)||(u=xn[r],
|
||||
u=(n===u||n!==n&&u!==u)&&!An.call(e,r)),u?t:n}function s(n){return X(n)?Fn(n):{}}function h(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){n.apply(an,r)},t)}function v(n,t){var r=true;return $n(n,function(n,e,u){return r=!!t(n,e,u)}),r}function y(n,t){var r=[];return $n(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function _(t,r,e,u){u||(u=[]);for(var o=-1,i=t.length;++o<i;){var c=t[o];r>0&&Y(c)&&L(c)&&(e||Pn(c)||K(c))?r>1?_(c,r-1,e,u):n(u,c):e||(u[u.length]=c);
|
||||
}return u}function b(n,t){return n&&qn(n,t,en)}function g(n,t){return y(t,function(t){return Q(n[t])})}function j(n,t,r,e,u){return n===t?true:null==n||null==t||!X(n)&&!Y(t)?n!==n&&t!==t:d(n,t,j,r,e,u)}function d(n,t,r,e,u,o){var i=Pn(n),f=Pn(t),a="[object Array]",l="[object Array]";i||(a=kn.call(n),a="[object Arguments]"==a?"[object Object]":a),f||(l=kn.call(t),l="[object Arguments]"==l?"[object Object]":l);var p="[object Object]"==a&&!c(n),f="[object Object]"==l&&!c(t),l=a==l;o||(o=[]);var s=J(o,function(t){
|
||||
return t[0]===n});return s&&s[1]?s[1]==t:(o.push([n,t]),l&&!p?(t=i||isTypedArray(n)?I(n,t,r,e,u,o):$(n,t,a),o.pop(),t):2&u||(i=p&&An.call(n,"__wrapped__"),a=f&&An.call(t,"__wrapped__"),!i&&!a)?l?(t=q(n,t,r,e,u,o),o.pop(),t):false:(t=r(i?n.value():n,a?t.value():t,e,u,o),o.pop(),t))}function m(n){var t=typeof n;return"function"==t?n:null==n?cn:("object"==t?x:E)(n)}function w(n){n=null==n?n:Object(n);var t,r=[];for(t in n)r.push(t);return r}function O(n,t){var r=-1,e=L(n)?Array(n.length):[];return $n(n,function(n,u,o){
|
||||
e[++r]=t(n,u,o)}),e}function x(n){var t=en(n);return function(r){var e=t.length;if(null==r)return!e;for(r=Object(r);e--;){var u=t[e];if(!(u in r&&j(n[u],r[u],an,3)))return false}return true}}function A(n,t){return n=Object(n),P(t,function(t,r){return r in n&&(t[r]=n[r]),t},{})}function E(n){return function(t){return null==t?an:t[n]}}function k(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e<u;)r[e]=n[e+t];return r}function N(n){return k(n,0,n.length);
|
||||
}function S(n,t){var r;return $n(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function T(t,r){return P(r,function(t,r){return r.func.apply(r.thisArg,n([t],r.args))},t)}function F(n,t,r,e){r||(r={});for(var u=-1,o=t.length;++u<o;){var i=t[u],c=e?e(r[i],n[i],i,r,n):n[i],f=r,a=f[i];An.call(f,i)&&(a===c||a!==a&&c!==c)&&(c!==an||i in f)||(f[i]=c)}return r}function R(n){return V(function(t,r){var e=-1,u=r.length,o=u>1?r[u-1]:an,o=typeof o=="function"?(u--,o):an;for(t=Object(t);++e<u;){var i=r[e];i&&n(t,i,e,o);
|
||||
}return t})}function B(n){return function(){var t=arguments,r=s(n.prototype),t=n.apply(r,t);return X(t)?t:r}}function D(n,t,r){function e(){for(var o=-1,i=arguments.length,c=-1,f=r.length,a=Array(f+i),l=this&&this!==wn&&this instanceof e?u:n;++c<f;)a[c]=r[c];for(;i--;)a[c++]=arguments[++o];return l.apply(t,a)}if(typeof n!="function")throw new TypeError("Expected a function");var u=B(n);return e}function I(n,t,r,e,u,o){var i=-1,c=1&u,f=n.length,a=t.length;if(f!=a&&!(2&u&&a>f))return false;for(a=true;++i<f;){
|
||||
var l=n[i],p=t[i];if(void 0!==an){a=false;break}if(c){if(!S(t,function(n){return l===n||r(l,n,e,u,o)})){a=false;break}}else if(l!==p&&!r(l,p,e,u,o)){a=false;break}}return a}function $(n,t,r){switch(r){case"[object Boolean]":case"[object Date]":return+n==+t;case"[object Error]":return n.name==t.name&&n.message==t.message;case"[object Number]":return n!=+n?t!=+t:n==+t;case"[object RegExp]":case"[object String]":return n==t+""}return false}function q(n,t,r,e,u,o){var i=2&u,c=en(n),f=c.length,a=en(t).length;if(f!=a&&!i)return false;
|
||||
for(var l=f;l--;){var p=c[l];if(!(i?p in t:An.call(t,p)))return false}for(a=true;++l<f;){var p=c[l],s=n[p],h=t[p];if(void 0!==an||s!==h&&!r(s,h,e,u,o)){a=false;break}i||(i="constructor"==p)}return a&&!i&&(r=n.constructor,e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!(typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)&&(a=false)),a}function z(n){var t=n?n.length:an;if(W(t)&&(Pn(n)||nn(n)||K(n))){n=String;for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);t=e}else t=null;return t}
|
||||
function C(n){var t=n&&n.constructor;return n===(typeof t=="function"&&t.prototype||xn)}function G(n){return n?n[0]:an}function J(n,t){return r(n,m(t),$n)}function M(n,t){return $n(n,typeof t=="function"?t:cn)}function P(n,t,r){return e(n,m(t),r,3>arguments.length,$n)}function U(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Un(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=an),r}}function V(n){var t;if(typeof n!="function")throw new TypeError("Expected a function");
|
||||
return t=In(t===an?n.length-1:Un(t),0),function(){for(var r=arguments,e=-1,u=In(r.length-t,0),o=Array(u);++e<u;)o[e]=r[t+e];for(u=Array(t+1),e=-1;++e<t;)u[e]=r[e];return u[t]=o,n.apply(this,u)}}function H(n,t){return n>t}function K(n){return Y(n)&&L(n)&&An.call(n,"callee")&&(!Rn.call(n,"callee")||"[object Arguments]"==kn.call(n))}function L(n){return null!=n&&W(zn(n))&&!Q(n)}function Q(n){return n=X(n)?kn.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function W(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n;
|
||||
}function X(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function Y(n){return!!n&&typeof n=="object"}function Z(n){return typeof n=="number"||Y(n)&&"[object Number]"==kn.call(n)}function nn(n){return typeof n=="string"||!Pn(n)&&Y(n)&&"[object String]"==kn.call(n)}function tn(n,t){return t>n}function rn(n){return typeof n=="string"?n:null==n?"":n+""}function en(n){var t=C(n);if(!t&&!L(n))return Dn(Object(n));var r,e=z(n),u=!!e,e=e||[],o=e.length;for(r in n)!An.call(n,r)||u&&("length"==r||f(r,o))||t&&"constructor"==r||e.push(r);
|
||||
return e}function un(n){for(var t=-1,r=C(n),e=w(n),u=e.length,o=z(n),i=!!o,o=o||[],c=o.length;++t<u;){var a=e[t];i&&("length"==a||f(a,c))||"constructor"==a&&(r||!An.call(n,a))||o.push(a)}return o}function on(n){return n?u(n,en(n)):[]}function cn(n){return n}function fn(t,r,e){var u=en(r),o=g(r,u);null!=e||X(r)&&(o.length||!u.length)||(e=r,r=t,t=this,o=g(r,en(r)));var i=X(e)&&"chain"in e?e.chain:true,c=Q(t);return $n(o,function(e){var u=r[e];t[e]=u,c&&(t.prototype[e]=function(){var r=this.__chain__;if(i||r){
|
||||
var e=t(this.__wrapped__);return(e.__actions__=N(this.__actions__)).push({func:u,args:arguments,thisArg:t}),e.__chain__=r,e}return u.apply(t,n([this.value()],arguments))})}),t}var an,ln=1/0,pn=/[&<>"'`]/g,sn=RegExp(pn.source),hn=/^(?:0|[1-9]\d*)$/,vn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},yn={"function":true,object:true},_n=yn[typeof exports]&&exports&&!exports.nodeType?exports:an,bn=yn[typeof module]&&module&&!module.nodeType?module:an,gn=bn&&bn.exports===_n?_n:an,jn=o(yn[typeof self]&&self),dn=o(yn[typeof window]&&window),mn=o(yn[typeof this]&&this),wn=o(_n&&bn&&typeof global=="object"&&global)||dn!==(mn&&mn.window)&&dn||jn||mn||Function("return this")(),On=Array.prototype,xn=Object.prototype,An=xn.hasOwnProperty,En=0,kn=xn.toString,Nn=wn._,Sn=wn.Reflect,Tn=Sn?Sn.f:an,Fn=Object.create,Rn=xn.propertyIsEnumerable,Bn=wn.isFinite,Dn=Object.keys,In=Math.max,$n=function(n,t){
|
||||
return function(r,e){if(null==r)return r;if(!L(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}(b),qn=function(n){return function(t,r,e){var u=-1,o=Object(t);e=e(t);for(var i=e.length;i--;){var c=e[n?i:++u];if(false===r(o[c],c,o))break}return t}}();Tn&&!Rn.call({valueOf:1},"valueOf")&&(w=function(n){n=Tn(n);for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r});var zn=E("length"),Cn=V(function(t,r){return Pn(t)||(t=null==t?[]:[Object(t)]),_(r,1),
|
||||
n(N(t),on)}),Gn=V(function(n,t,r){return D(n,t,r)}),Jn=V(function(n,t){return h(n,1,t)}),Mn=V(function(n,t,r){return h(n,Vn(t)||0,r)}),Pn=Array.isArray,Un=Number,Vn=Number,Hn=R(function(n,t){F(t,en(t),n)}),Kn=R(function(n,t){F(t,un(t),n)}),Ln=R(function(n,t,r,e){F(t,un(t),n,e)}),Qn=V(function(n){return n.push(an,p),Ln.apply(an,n)}),Wn=V(function(n,t){return null==n?{}:A(n,_(t,1))}),Xn=m;l.prototype=s(a.prototype),l.prototype.constructor=l,a.assignIn=Kn,a.before=U,a.bind=Gn,a.chain=function(n){return n=a(n),
|
||||
n.__chain__=true,n},a.compact=function(n){return y(n,Boolean)},a.concat=Cn,a.create=function(n,t){var r=s(n);return t?Hn(r,t):r},a.defaults=Qn,a.defer=Jn,a.delay=Mn,a.filter=function(n,t){return y(n,m(t))},a.flatten=function(n){return n&&n.length?_(n,1):[]},a.flattenDeep=function(n){return n&&n.length?_(n,ln):[]},a.iteratee=Xn,a.keys=en,a.map=function(n,t){return O(n,m(t))},a.matches=function(n){return x(Hn({},n))},a.mixin=fn,a.negate=function(n){if(typeof n!="function")throw new TypeError("Expected a function");
|
||||
return function(){return!n.apply(this,arguments)}},a.once=function(n){return U(2,n)},a.pick=Wn,a.slice=function(n,t,r){var e=n?n.length:0;return r=r===an?e:+r,e?k(n,null==t?0:+t,r):[]},a.sortBy=function(n,t){var r=0;return t=m(t),O(O(n,function(n,e,u){return{c:n,b:r++,a:t(n,e,u)}}).sort(function(n,t){var r;n:{r=n.a;var e=t.a;if(r!==e){var u=null===r,o=r===an,i=r===r,c=null===e,f=e===an,a=e===e;if(r>e&&!c||!i||u&&!f&&a||o&&a){r=1;break n}if(e>r&&!u||!a||c&&!o&&i||f&&i){r=-1;break n}}r=0}return r||n.b-t.b;
|
||||
}),E("c"))},a.tap=function(n,t){return t(n),n},a.thru=function(n,t){return t(n)},a.toArray=function(n){return L(n)?n.length?N(n):[]:on(n)},a.values=on,a.extend=Kn,fn(a,a),a.clone=function(n){return X(n)?Pn(n)?N(n):F(n,en(n)):n},a.escape=function(n){return(n=rn(n))&&sn.test(n)?n.replace(pn,i):n},a.every=function(n,t,r){return t=r?an:t,v(n,m(t))},a.find=J,a.forEach=M,a.has=function(n,t){return null!=n&&An.call(n,t)},a.head=G,a.identity=cn,a.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?In(e+r,0):r:0,
|
||||
r=(r||0)-1;for(var u=t===t;++r<e;){var o=n[r];if(u?o===t:o!==o)return r}return-1},a.isArguments=K,a.isArray=Pn,a.isBoolean=function(n){return true===n||false===n||Y(n)&&"[object Boolean]"==kn.call(n)},a.isDate=function(n){return Y(n)&&"[object Date]"==kn.call(n)},a.isEmpty=function(n){if(L(n)&&(Pn(n)||nn(n)||Q(n.splice)||K(n)))return!n.length;for(var t in n)if(An.call(n,t))return false;return true},a.isEqual=function(n,t){return j(n,t)},a.isFinite=function(n){return typeof n=="number"&&Bn(n)},a.isFunction=Q,a.isNaN=function(n){
|
||||
return Z(n)&&n!=+n},a.isNull=function(n){return null===n},a.isNumber=Z,a.isObject=X,a.isRegExp=function(n){return X(n)&&"[object RegExp]"==kn.call(n)},a.isString=nn,a.isUndefined=function(n){return n===an},a.last=function(n){var t=n?n.length:0;return t?n[t-1]:an},a.max=function(n){return n&&n.length?t(n,cn,H):an},a.min=function(n){return n&&n.length?t(n,cn,tn):an},a.noConflict=function(){return wn._===this&&(wn._=Nn),this},a.noop=function(){},a.reduce=P,a.result=function(n,t,r){return t=null==n?an:n[t],
|
||||
t===an&&(t=r),Q(t)?t.call(n):t},a.size=function(n){return null==n?0:(n=L(n)?n:en(n),n.length)},a.some=function(n,t,r){return t=r?an:t,S(n,m(t))},a.uniqueId=function(n){var t=++En;return rn(n)+t},a.each=M,a.first=G,fn(a,function(){var n={};return b(a,function(t,r){An.call(a.prototype,r)||(n[r]=t)}),n}(),{chain:false}),a.VERSION="4.6.1",$n("pop join replace reverse split push shift sort splice unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?String.prototype:On)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|join|replace|shift)$/.test(n);
|
||||
a.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=function(){return T(this.__wrapped__,this.__actions__)},(dn||jn||{})._=a,typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return a}):_n&&bn?(gn&&((bn.exports=a)._=a),_n._=a):wn._=a}).call(this);
|
||||
@@ -138,8 +138,10 @@ function debounce(func, wait, options) {
|
||||
if (!lastCalled && !maxTimeoutId && !leading) {
|
||||
lastCalled = stamp;
|
||||
}
|
||||
var remaining = maxWait - (stamp - lastCalled),
|
||||
isCalled = remaining <= 0 || remaining > maxWait;
|
||||
var remaining = maxWait - (stamp - lastCalled);
|
||||
|
||||
var isCalled = (remaining <= 0 || remaining > maxWait) &&
|
||||
(leading || maxTimeoutId);
|
||||
|
||||
if (isCalled) {
|
||||
if (maxTimeoutId) {
|
||||
|
||||
@@ -6,7 +6,8 @@ var baseDifference = require('./_baseDifference'),
|
||||
/**
|
||||
* Creates an array of unique `array` values not included in the other
|
||||
* given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
* for equality comparisons. The order of result values is determined by the
|
||||
* order they occur in the first array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -21,7 +22,7 @@ var baseDifference = require('./_baseDifference'),
|
||||
*/
|
||||
var difference = rest(function(array, values) {
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true))
|
||||
? baseDifference(array, baseFlatten(values, 1, true))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ var baseDifference = require('./_baseDifference'),
|
||||
/**
|
||||
* This method is like `_.difference` except that it accepts `iteratee` which
|
||||
* is invoked for each element of `array` and `values` to generate the criterion
|
||||
* by which uniqueness is computed. The iteratee is invoked with one argument: (value).
|
||||
* by which they're compared. Result values are chosen from the first array.
|
||||
* The iteratee is invoked with one argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -32,7 +33,7 @@ var differenceBy = rest(function(array, values) {
|
||||
iteratee = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee))
|
||||
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ var baseDifference = require('./_baseDifference'),
|
||||
|
||||
/**
|
||||
* This method is like `_.difference` except that it accepts `comparator`
|
||||
* which is invoked to compare elements of `array` to `values`. The comparator
|
||||
* is invoked with two arguments: (arrVal, othVal).
|
||||
* which is invoked to compare elements of `array` to `values`. Result values
|
||||
* are chosen from the first array. The comparator is invoked with two arguments:
|
||||
* (arrVal, othVal).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -29,7 +30,7 @@ var differenceWith = rest(function(array, values) {
|
||||
comparator = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
|
||||
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ var baseFlatten = require('./_baseFlatten'),
|
||||
* // => [1, 1, 2, 2]
|
||||
*/
|
||||
function flatMap(collection, iteratee) {
|
||||
return baseFlatten(map(collection, iteratee));
|
||||
return baseFlatten(map(collection, iteratee), 1);
|
||||
}
|
||||
|
||||
module.exports = flatMap;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var baseFlatten = require('./_baseFlatten');
|
||||
|
||||
/**
|
||||
* Flattens `array` a single level.
|
||||
* Flattens `array` a single level deep.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -10,12 +10,12 @@ var baseFlatten = require('./_baseFlatten');
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flatten([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, [4]]
|
||||
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, [3, [4]], 5]
|
||||
*/
|
||||
function flatten(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array) : [];
|
||||
return length ? baseFlatten(array, 1) : [];
|
||||
}
|
||||
|
||||
module.exports = flatten;
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
var baseFlatten = require('./_baseFlatten');
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
|
||||
/**
|
||||
* This method is like `_.flatten` except that it recursively flattens `array`.
|
||||
* Recursively flattens `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} array The array to recursively flatten.
|
||||
* @param {Array} array The array to flatten.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, 4]
|
||||
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, 3, 4, 5]
|
||||
*/
|
||||
function flattenDeep(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array, true) : [];
|
||||
return length ? baseFlatten(array, INFINITY) : [];
|
||||
}
|
||||
|
||||
module.exports = flattenDeep;
|
||||
|
||||
32
flattenDepth.js
Normal file
32
flattenDepth.js
Normal file
@@ -0,0 +1,32 @@
|
||||
var baseFlatten = require('./_baseFlatten'),
|
||||
toInteger = require('./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);
|
||||
}
|
||||
|
||||
module.exports = flattenDepth;
|
||||
@@ -1,7 +1,7 @@
|
||||
var arrayEach = require('./_arrayEach'),
|
||||
baseCastFunction = require('./_baseCastFunction'),
|
||||
baseEach = require('./_baseEach'),
|
||||
isArray = require('./isArray'),
|
||||
toFunction = require('./_toFunction');
|
||||
isArray = require('./isArray');
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
||||
@@ -34,7 +34,7 @@ var arrayEach = require('./_arrayEach'),
|
||||
function forEach(collection, iteratee) {
|
||||
return (typeof iteratee == 'function' && isArray(collection))
|
||||
? arrayEach(collection, iteratee)
|
||||
: baseEach(collection, toFunction(iteratee));
|
||||
: baseEach(collection, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
module.exports = forEach;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var arrayEachRight = require('./_arrayEachRight'),
|
||||
baseCastFunction = require('./_baseCastFunction'),
|
||||
baseEachRight = require('./_baseEachRight'),
|
||||
isArray = require('./isArray'),
|
||||
toFunction = require('./_toFunction');
|
||||
isArray = require('./isArray');
|
||||
|
||||
/**
|
||||
* This method is like `_.forEach` except that it iterates over elements of
|
||||
@@ -24,7 +24,7 @@ var arrayEachRight = require('./_arrayEachRight'),
|
||||
function forEachRight(collection, iteratee) {
|
||||
return (typeof iteratee == 'function' && isArray(collection))
|
||||
? arrayEachRight(collection, iteratee)
|
||||
: baseEachRight(collection, toFunction(iteratee));
|
||||
: baseEachRight(collection, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
module.exports = forEachRight;
|
||||
|
||||
10
forIn.js
10
forIn.js
@@ -1,6 +1,6 @@
|
||||
var baseFor = require('./_baseFor'),
|
||||
keysIn = require('./keysIn'),
|
||||
toFunction = require('./_toFunction');
|
||||
var baseCastFunction = require('./_baseCastFunction'),
|
||||
baseFor = require('./_baseFor'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* Iterates over own and inherited enumerable properties of an object invoking
|
||||
@@ -29,7 +29,9 @@ var baseFor = require('./_baseFor'),
|
||||
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
|
||||
*/
|
||||
function forIn(object, iteratee) {
|
||||
return object == null ? object : baseFor(object, toFunction(iteratee), keysIn);
|
||||
return object == null
|
||||
? object
|
||||
: baseFor(object, baseCastFunction(iteratee), keysIn);
|
||||
}
|
||||
|
||||
module.exports = forIn;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var baseForRight = require('./_baseForRight'),
|
||||
keysIn = require('./keysIn'),
|
||||
toFunction = require('./_toFunction');
|
||||
var baseCastFunction = require('./_baseCastFunction'),
|
||||
baseForRight = require('./_baseForRight'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* This method is like `_.forIn` except that it iterates over properties of
|
||||
@@ -27,7 +27,9 @@ var baseForRight = require('./_baseForRight'),
|
||||
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
|
||||
*/
|
||||
function forInRight(object, iteratee) {
|
||||
return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn);
|
||||
return object == null
|
||||
? object
|
||||
: baseForRight(object, baseCastFunction(iteratee), keysIn);
|
||||
}
|
||||
|
||||
module.exports = forInRight;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user