mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8349627be6 | ||
|
|
a2438ffc51 | ||
|
|
d46bcaa98d | ||
|
|
6c2960211f | ||
|
|
8166b65853 | ||
|
|
65e5d998b3 | ||
|
|
ae51b52aa1 | ||
|
|
ce259221bd | ||
|
|
3514f50902 |
29
LICENSE
29
LICENSE
@@ -1,7 +1,17 @@
|
|||||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
|
||||||
|
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||||
|
|
||||||
|
This software consists of voluntary contributions made by many
|
||||||
|
individuals. For exact contribution history, see the revision history
|
||||||
|
available at https://github.com/lodash/lodash
|
||||||
|
|
||||||
|
The following license applies to all parts of this software except as
|
||||||
|
documented below:
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
"Software"), to deal in the Software without restriction, including
|
"Software"), to deal in the Software without restriction, including
|
||||||
@@ -20,3 +30,18 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Copyright and related rights for sample code are waived via CC0. Sample
|
||||||
|
code is defined as all source code displayed within the prose of the
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Files located in the node_modules and vendor directories are externally
|
||||||
|
maintained libraries used by this software which have their own
|
||||||
|
licenses; we recommend you read them, as their terms may differ from the
|
||||||
|
terms above.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# lodash-amd v4.2.1
|
# lodash-amd v4.8.2
|
||||||
|
|
||||||
The [lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
||||||
|
|
||||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||||
```bash
|
```bash
|
||||||
@@ -27,4 +27,4 @@ require({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.2.1-amd) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.8.2-amd) for more details.
|
||||||
|
|||||||
7
_DataView.js
Normal file
7
_DataView.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
define(['./_getNative', './_root'], function(getNative, root) {
|
||||||
|
|
||||||
|
/* Built-in method references that are verified to be native. */
|
||||||
|
var DataView = getNative(root, 'DataView');
|
||||||
|
|
||||||
|
return DataView;
|
||||||
|
});
|
||||||
1
_Hash.js
1
_Hash.js
@@ -7,6 +7,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
|
|||||||
* Creates an hash object.
|
* Creates an hash object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @returns {Object} Returns the new hash object.
|
* @returns {Object} Returns the new hash object.
|
||||||
*/
|
*/
|
||||||
function Hash() {}
|
function Hash() {}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ define(['./_baseCreate', './_baseLodash'], function(baseCreate, baseLodash) {
|
|||||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {*} value The value to wrap.
|
* @param {*} value The value to wrap.
|
||||||
*/
|
*/
|
||||||
function LazyWrapper(value) {
|
function LazyWrapper(value) {
|
||||||
@@ -19,6 +20,7 @@ define(['./_baseCreate', './_baseLodash'], function(baseCreate, baseLodash) {
|
|||||||
this.__views__ = [];
|
this.__views__ = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure `LazyWrapper` is an instance of `baseLodash`.
|
||||||
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
||||||
LazyWrapper.prototype.constructor = LazyWrapper;
|
LazyWrapper.prototype.constructor = LazyWrapper;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ define(['./_baseCreate', './_baseLodash'], function(baseCreate, baseLodash) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {*} value The value to wrap.
|
* @param {*} value The value to wrap.
|
||||||
* @param {boolean} [chainAll] Enable chaining for all wrapper methods.
|
* @param {boolean} [chainAll] Enable explicit method chain sequences.
|
||||||
*/
|
*/
|
||||||
function LodashWrapper(value, chainAll) {
|
function LodashWrapper(value, chainAll) {
|
||||||
this.__wrapped__ = value;
|
this.__wrapped__ = value;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ define(['./_mapClear', './_mapDelete', './_mapGet', './_mapHas', './_mapSet'], f
|
|||||||
* Creates a map cache object to store key-value pairs.
|
* Creates a map cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function MapCache(values) {
|
function MapCache(values) {
|
||||||
@@ -17,7 +18,7 @@ define(['./_mapClear', './_mapDelete', './_mapGet', './_mapHas', './_mapSet'], f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add functions to the `MapCache`.
|
// Add methods to `MapCache`.
|
||||||
MapCache.prototype.clear = mapClear;
|
MapCache.prototype.clear = mapClear;
|
||||||
MapCache.prototype['delete'] = mapDelete;
|
MapCache.prototype['delete'] = mapDelete;
|
||||||
MapCache.prototype.get = mapGet;
|
MapCache.prototype.get = mapGet;
|
||||||
|
|||||||
7
_Promise.js
Normal file
7
_Promise.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
define(['./_getNative', './_root'], function(getNative, root) {
|
||||||
|
|
||||||
|
/* Built-in method references that are verified to be native. */
|
||||||
|
var Promise = getNative(root, 'Promise');
|
||||||
|
|
||||||
|
return Promise;
|
||||||
|
});
|
||||||
@@ -5,6 +5,7 @@ define(['./_MapCache', './_cachePush'], function(MapCache, cachePush) {
|
|||||||
* Creates a set cache object to store unique values.
|
* Creates a set cache object to store unique values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function SetCache(values) {
|
function SetCache(values) {
|
||||||
@@ -17,7 +18,7 @@ define(['./_MapCache', './_cachePush'], function(MapCache, cachePush) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add functions to the `SetCache`.
|
// Add methods to `SetCache`.
|
||||||
SetCache.prototype.push = cachePush;
|
SetCache.prototype.push = cachePush;
|
||||||
|
|
||||||
return SetCache;
|
return SetCache;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ define(['./_stackClear', './_stackDelete', './_stackGet', './_stackHas', './_sta
|
|||||||
* Creates a stack cache object to store key-value pairs.
|
* Creates a stack cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function Stack(values) {
|
function Stack(values) {
|
||||||
@@ -17,7 +18,7 @@ define(['./_stackClear', './_stackDelete', './_stackGet', './_stackHas', './_sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add functions to the `Stack` cache.
|
// Add methods to `Stack`.
|
||||||
Stack.prototype.clear = stackClear;
|
Stack.prototype.clear = stackClear;
|
||||||
Stack.prototype['delete'] = stackDelete;
|
Stack.prototype['delete'] = stackDelete;
|
||||||
Stack.prototype.get = stackGet;
|
Stack.prototype.get = stackGet;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ define([], function() {
|
|||||||
* @returns {Object} Returns `map`.
|
* @returns {Object} Returns `map`.
|
||||||
*/
|
*/
|
||||||
function addMapEntry(map, pair) {
|
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]);
|
map.set(pair[0], pair[1]);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ define([], function() {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to invoke.
|
* @param {Function} func The function to invoke.
|
||||||
* @param {*} thisArg The `this` binding of `func`.
|
* @param {*} thisArg The `this` binding of `func`.
|
||||||
* @param {...*} args The arguments to invoke `func` with.
|
* @param {Array} args The arguments to invoke `func` with.
|
||||||
* @returns {*} Returns the result of `func`.
|
* @returns {*} Returns the result of `func`.
|
||||||
*/
|
*/
|
||||||
function apply(func, thisArg, args) {
|
function apply(func, thisArg, args) {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define([], function() {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} predicate The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`.
|
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||||
|
* else `false`.
|
||||||
*/
|
*/
|
||||||
function arrayEvery(array, predicate) {
|
function arrayEvery(array, predicate) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ define([], function() {
|
|||||||
function arrayFilter(array, predicate) {
|
function arrayFilter(array, predicate) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
resIndex = -1,
|
resIndex = 0,
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (predicate(value, index, array)) {
|
if (predicate(value, index, array)) {
|
||||||
result[++resIndex] = value;
|
result[resIndex++] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.includesWith` for arrays without support for
|
* This function is like `arrayIncludes` except that it accepts a comparator.
|
||||||
* specifying an index to search from.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to search.
|
* @param {Array} array The array to search.
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ define([], function() {
|
|||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
|
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
||||||
|
* the initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ define([], function() {
|
|||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @param {boolean} [initAccum] Specify using the last element of `array` as the initial value.
|
* @param {boolean} [initAccum] Specify using the last element of `array` as
|
||||||
|
* the initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
|
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define([], function() {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} predicate The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||||
|
* else `false`.
|
||||||
*/
|
*/
|
||||||
function arraySome(array, predicate) {
|
function arraySome(array, predicate) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ define(['./eq'], function(eq) {
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @private
|
||||||
* @param {Object} object The object to modify.
|
* @param {Object} object The object to modify.
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ define(['./eq'], function(eq) {
|
|||||||
*/
|
*/
|
||||||
function assignValue(object, key, value) {
|
function assignValue(object, key, value) {
|
||||||
var objValue = object[key];
|
var objValue = object[key];
|
||||||
if ((!eq(objValue, value) ||
|
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
|
|
||||||
(value === undefined && !(key in object))) {
|
(value === undefined && !(key in object))) {
|
||||||
object[key] = value;
|
object[key] = value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ define(['./_assocIndexOf'], function(assocIndexOf) {
|
|||||||
* Removes `key` and its value from the associative array.
|
* Removes `key` and its value from the associative array.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to modify.
|
||||||
* @param {string} key The key of the value to remove.
|
* @param {string} key The key of the value to remove.
|
||||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
define(['./eq'], function(eq) {
|
define(['./eq'], function(eq) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index at which the first occurrence of `key` is found in `array`
|
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||||||
* of key-value pairs.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to search.
|
* @param {Array} array The array to search.
|
||||||
|
|||||||
15
_baseCastArrayLikeObject.js
Normal file
15
_baseCastArrayLikeObject.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
define(['./isArrayLikeObject'], function(isArrayLikeObject) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to an empty array if it's not an array like object.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array|Object} Returns the cast array-like object.
|
||||||
|
*/
|
||||||
|
function baseCastArrayLikeObject(value) {
|
||||||
|
return isArrayLikeObject(value) ? value : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseCastArrayLikeObject;
|
||||||
|
});
|
||||||
15
_baseCastFunction.js
Normal file
15
_baseCastFunction.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
define(['./identity'], function(identity) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to `identity` if it's not a function.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Function} Returns cast function.
|
||||||
|
*/
|
||||||
|
function baseCastFunction(value) {
|
||||||
|
return typeof value == 'function' ? value : identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseCastFunction;
|
||||||
|
});
|
||||||
15
_baseCastKey.js
Normal file
15
_baseCastKey.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
define(['./isSymbol'], function(isSymbol) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to a string if it's not a string or symbol.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {string|symbol} Returns the cast key.
|
||||||
|
*/
|
||||||
|
function baseCastKey(key) {
|
||||||
|
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseCastKey;
|
||||||
|
});
|
||||||
15
_baseCastPath.js
Normal file
15
_baseCastPath.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
define(['./isArray', './_stringToPath'], function(isArray, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseCastPath;
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseForOwn', './_copyArray', './_copySymbols', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './_isHostObject', './isObject'], function(Stack, arrayEach, assignValue, baseAssign, baseForOwn, copyArray, copySymbols, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isHostObject, isObject) {
|
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_cloneBuffer', './_copyArray', './_copySymbols', './_getAllKeys', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './isBuffer', './_isHostObject', './isObject', './keys'], function(Stack, arrayEach, assignValue, baseAssign, cloneBuffer, copyArray, copySymbols, getAllKeys, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isBuffer, isHostObject, isObject, keys) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -21,6 +21,7 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
|||||||
weakMapTag = '[object WeakMap]';
|
weakMapTag = '[object WeakMap]';
|
||||||
|
|
||||||
var arrayBufferTag = '[object ArrayBuffer]',
|
var arrayBufferTag = '[object ArrayBuffer]',
|
||||||
|
dataViewTag = '[object DataView]',
|
||||||
float32Tag = '[object Float32Array]',
|
float32Tag = '[object Float32Array]',
|
||||||
float64Tag = '[object Float64Array]',
|
float64Tag = '[object Float64Array]',
|
||||||
int8Tag = '[object Int8Array]',
|
int8Tag = '[object Int8Array]',
|
||||||
@@ -34,16 +35,16 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
|||||||
/** Used to identify `toStringTag` values supported by `_.clone`. */
|
/** Used to identify `toStringTag` values supported by `_.clone`. */
|
||||||
var cloneableTags = {};
|
var cloneableTags = {};
|
||||||
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
||||||
cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
|
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
|
||||||
cloneableTags[dateTag] = cloneableTags[float32Tag] =
|
cloneableTags[boolTag] = cloneableTags[dateTag] =
|
||||||
cloneableTags[float64Tag] = cloneableTags[int8Tag] =
|
cloneableTags[float32Tag] = cloneableTags[float64Tag] =
|
||||||
cloneableTags[int16Tag] = cloneableTags[int32Tag] =
|
cloneableTags[int8Tag] = cloneableTags[int16Tag] =
|
||||||
cloneableTags[mapTag] = cloneableTags[numberTag] =
|
cloneableTags[int32Tag] = cloneableTags[mapTag] =
|
||||||
cloneableTags[objectTag] = cloneableTags[regexpTag] =
|
cloneableTags[numberTag] = cloneableTags[objectTag] =
|
||||||
cloneableTags[setTag] = cloneableTags[stringTag] =
|
cloneableTags[regexpTag] = cloneableTags[setTag] =
|
||||||
cloneableTags[symbolTag] = cloneableTags[uint8Tag] =
|
cloneableTags[stringTag] = cloneableTags[symbolTag] =
|
||||||
cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] =
|
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
|
||||||
cloneableTags[uint32Tag] = true;
|
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
||||||
cloneableTags[errorTag] = cloneableTags[funcTag] =
|
cloneableTags[errorTag] = cloneableTags[funcTag] =
|
||||||
cloneableTags[weakMapTag] = false;
|
cloneableTags[weakMapTag] = false;
|
||||||
|
|
||||||
@@ -54,13 +55,14 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
|||||||
* @private
|
* @private
|
||||||
* @param {*} value The value to clone.
|
* @param {*} value The value to clone.
|
||||||
* @param {boolean} [isDeep] Specify a deep 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 {Function} [customizer] The function to customize cloning.
|
||||||
* @param {string} [key] The key of `value`.
|
* @param {string} [key] The key of `value`.
|
||||||
* @param {Object} [object] The parent object of `value`.
|
* @param {Object} [object] The parent object of `value`.
|
||||||
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
|
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
|
||||||
* @returns {*} Returns the cloned value.
|
* @returns {*} Returns the cloned value.
|
||||||
*/
|
*/
|
||||||
function baseClone(value, isDeep, customizer, key, object, stack) {
|
function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||||||
var result;
|
var result;
|
||||||
if (customizer) {
|
if (customizer) {
|
||||||
result = object ? customizer(value, key, object, stack) : customizer(value);
|
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||||||
@@ -81,6 +83,9 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
|||||||
var tag = getTag(value),
|
var tag = getTag(value),
|
||||||
isFunc = tag == funcTag || tag == genTag;
|
isFunc = tag == funcTag || tag == genTag;
|
||||||
|
|
||||||
|
if (isBuffer(value)) {
|
||||||
|
return cloneBuffer(value, isDeep);
|
||||||
|
}
|
||||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||||
if (isHostObject(value)) {
|
if (isHostObject(value)) {
|
||||||
return object ? value : {};
|
return object ? value : {};
|
||||||
@@ -90,9 +95,10 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
|||||||
return copySymbols(value, baseAssign(result, value));
|
return copySymbols(value, baseAssign(result, value));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return cloneableTags[tag]
|
if (!cloneableTags[tag]) {
|
||||||
? initCloneByTag(value, tag, isDeep)
|
return object ? value : {};
|
||||||
: (object ? value : {});
|
}
|
||||||
|
result = initCloneByTag(value, tag, baseClone, isDeep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for circular references and return its corresponding clone.
|
// Check for circular references and return its corresponding clone.
|
||||||
@@ -103,11 +109,18 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
|||||||
}
|
}
|
||||||
stack.set(value, result);
|
stack.set(value, result);
|
||||||
|
|
||||||
|
if (!isArr) {
|
||||||
|
var props = isFull ? getAllKeys(value) : keys(value);
|
||||||
|
}
|
||||||
// Recursively populate clone (susceptible to call stack limits).
|
// Recursively populate clone (susceptible to call stack limits).
|
||||||
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
arrayEach(props || value, function(subValue, key) {
|
||||||
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack));
|
if (props) {
|
||||||
|
key = subValue;
|
||||||
|
subValue = value[key];
|
||||||
|
}
|
||||||
|
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
|
||||||
});
|
});
|
||||||
return isArr ? result : copySymbols(value, result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseClone;
|
return baseClone;
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ define(['./keys'], function(keys) {
|
|||||||
predicate = source[key],
|
predicate = source[key],
|
||||||
value = object[key];
|
value = object[key];
|
||||||
|
|
||||||
if ((value === undefined && !(key in Object(object))) || !predicate(value)) {
|
if ((value === undefined &&
|
||||||
|
!(key in Object(object))) || !predicate(value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define(['./isObject'], function(isObject) {
|
define(['./isObject'], function(isObject) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Built-in value references. */
|
||||||
var undefined;
|
var objectCreate = Object.create;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.create` without support for assigning
|
* The base implementation of `_.create` without support for assigning
|
||||||
@@ -11,17 +11,9 @@ define(['./isObject'], function(isObject) {
|
|||||||
* @param {Object} prototype The object to inherit from.
|
* @param {Object} prototype The object to inherit from.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
var baseCreate = (function() {
|
function baseCreate(proto) {
|
||||||
function object() {}
|
return isObject(proto) ? objectCreate(proto) : {};
|
||||||
return function(prototype) {
|
}
|
||||||
if (isObject(prototype)) {
|
|
||||||
object.prototype = prototype;
|
|
||||||
var result = new object;
|
|
||||||
object.prototype = undefined;
|
|
||||||
}
|
|
||||||
return result || {};
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
return baseCreate;
|
return baseCreate;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ define([], function() {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to delay.
|
* @param {Function} func The function to delay.
|
||||||
* @param {number} wait The number of milliseconds to delay invocation.
|
* @param {number} wait The number of milliseconds to delay invocation.
|
||||||
* @param {Object} args The arguments provide to `func`.
|
* @param {Object} args The arguments to provide to `func`.
|
||||||
* @returns {number} Returns the timer id.
|
* @returns {number} Returns the timer id.
|
||||||
*/
|
*/
|
||||||
function baseDelay(func, wait, args) {
|
function baseDelay(func, wait, args) {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
|||||||
var LARGE_ARRAY_SIZE = 200;
|
var LARGE_ARRAY_SIZE = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.difference` without support for
|
* The base implementation of methods like `_.difference` without support
|
||||||
* excluding multiple arrays or iteratee shorthands.
|
* for excluding multiple arrays or iteratee shorthands.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ define(['./_baseEach'], function(baseEach) {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} predicate The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`
|
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||||
|
* else `false`
|
||||||
*/
|
*/
|
||||||
function baseEvery(collection, predicate) {
|
function baseEvery(collection, predicate) {
|
||||||
var result = true;
|
var result = true;
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ define([], function() {
|
|||||||
* @param {Array|Object} collection The collection to search.
|
* @param {Array|Object} collection The collection to search.
|
||||||
* @param {Function} predicate The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @param {Function} eachFunc The function to iterate over `collection`.
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||||
* @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself.
|
* @param {boolean} [retKey] Specify returning the key of the found element
|
||||||
|
* instead of the element itself.
|
||||||
* @returns {*} Returns the found element or its key, else `undefined`.
|
* @returns {*} Returns the found element or its key, else `undefined`.
|
||||||
*/
|
*/
|
||||||
function baseFind(collection, predicate, eachFunc, retKey) {
|
function baseFind(collection, predicate, eachFunc, retKey) {
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
* @param {number} depth The maximum recursion depth.
|
||||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||||
* @param {Array} [result=[]] The initial result value.
|
* @param {Array} [result=[]] The initial result value.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, result) {
|
function baseFlatten(array, depth, isStrict, result) {
|
||||||
result || (result = []);
|
result || (result = []);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -18,11 +18,11 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (isArrayLikeObject(value) &&
|
if (depth > 0 && isArrayLikeObject(value) &&
|
||||||
(isStrict || isArray(value) || isArguments(value))) {
|
(isStrict || isArray(value) || isArguments(value))) {
|
||||||
if (isDeep) {
|
if (depth > 1) {
|
||||||
// Recursively flatten arrays (susceptible to call stack limits).
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
baseFlatten(value, isDeep, isStrict, result);
|
baseFlatten(value, depth - 1, isStrict, result);
|
||||||
} else {
|
} else {
|
||||||
arrayPush(result, value);
|
arrayPush(result, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
define(['./_createBaseFor'], function(createBaseFor) {
|
define(['./_createBaseFor'], function(createBaseFor) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
* The base implementation of `baseForOwn` which iterates over `object`
|
||||||
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
* properties returned by `keysFunc` invoking `iteratee` for each property.
|
||||||
* each property. Iteratee functions may exit iteration early by explicitly
|
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||||
* returning `false`.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
define(['./_baseFor', './keysIn'], function(baseFor, keysIn) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.forIn` without support for iteratee shorthands.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Object} object The object to iterate over.
|
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
|
||||||
* @returns {Object} Returns `object`.
|
|
||||||
*/
|
|
||||||
function baseForIn(object, iteratee) {
|
|
||||||
return object == null ? object : baseFor(object, iteratee, keysIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseForIn;
|
|
||||||
});
|
|
||||||
@@ -2,7 +2,7 @@ define(['./_arrayFilter', './isFunction'], function(arrayFilter, isFunction) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.functions` which creates an array of
|
* The base implementation of `_.functions` which creates an array of
|
||||||
* `object` function property names filtered from those provided.
|
* `object` function property names filtered from `props`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
|
define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -12,7 +12,7 @@ define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
|
|||||||
* @returns {*} Returns the resolved value.
|
* @returns {*} Returns the resolved value.
|
||||||
*/
|
*/
|
||||||
function baseGet(object, path) {
|
function baseGet(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|||||||
22
_baseGetAllKeys.js
Normal file
22
_baseGetAllKeys.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
define(['./_arrayPush', './isArray'], function(arrayPush, isArray) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
|
||||||
|
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
|
||||||
|
* symbols of `object`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The object to query.
|
||||||
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
||||||
|
* @param {Function} symbolsFunc The function to get the symbols of `object`.
|
||||||
|
* @returns {Array} Returns the array of property names and symbols.
|
||||||
|
*/
|
||||||
|
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
||||||
|
var result = keysFunc(object);
|
||||||
|
return isArray(object)
|
||||||
|
? result
|
||||||
|
: arrayPush(result, symbolsFunc(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseGetAllKeys;
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define([], function() {
|
define(['./_getPrototype'], function(getPrototype) {
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -6,9 +6,6 @@ define([], function() {
|
|||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
var getPrototypeOf = Object.getPrototypeOf;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.has` without support for deep paths.
|
* The base implementation of `_.has` without support for deep paths.
|
||||||
*
|
*
|
||||||
@@ -22,7 +19,7 @@ define([], function() {
|
|||||||
// that are composed entirely of index properties, return `false` for
|
// that are composed entirely of index properties, return `false` for
|
||||||
// `hasOwnProperty` checks of them.
|
// `hasOwnProperty` checks of them.
|
||||||
return hasOwnProperty.call(object, key) ||
|
return hasOwnProperty.call(object, key) ||
|
||||||
(typeof object == 'object' && key in object && getPrototypeOf(object) === null);
|
(typeof object == 'object' && key in object && getPrototype(object) === null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseHas;
|
return baseHas;
|
||||||
|
|||||||
26
_baseIndexOfWith.js
Normal file
26
_baseIndexOfWith.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseIndexOfWith;
|
||||||
|
});
|
||||||
@@ -3,6 +3,9 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
|
/* 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
|
* The base implementation of methods like `_.intersection`, without support
|
||||||
* for iteratee shorthands, that accepts an array of arrays to inspect.
|
* for iteratee shorthands, that accepts an array of arrays to inspect.
|
||||||
@@ -15,9 +18,11 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
|||||||
*/
|
*/
|
||||||
function baseIntersection(arrays, iteratee, comparator) {
|
function baseIntersection(arrays, iteratee, comparator) {
|
||||||
var includes = comparator ? arrayIncludesWith : arrayIncludes,
|
var includes = comparator ? arrayIncludesWith : arrayIncludes,
|
||||||
|
length = arrays[0].length,
|
||||||
othLength = arrays.length,
|
othLength = arrays.length,
|
||||||
othIndex = othLength,
|
othIndex = othLength,
|
||||||
caches = Array(othLength),
|
caches = Array(othLength),
|
||||||
|
maxLength = Infinity,
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
while (othIndex--) {
|
while (othIndex--) {
|
||||||
@@ -25,26 +30,32 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
|||||||
if (othIndex && iteratee) {
|
if (othIndex && iteratee) {
|
||||||
array = arrayMap(array, baseUnary(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)
|
? new SetCache(othIndex && array)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
array = arrays[0];
|
array = arrays[0];
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length,
|
|
||||||
seen = caches[0];
|
seen = caches[0];
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
while (++index < length) {
|
while (++index < length && result.length < maxLength) {
|
||||||
var value = array[index],
|
var value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
computed = iteratee ? iteratee(value) : value;
|
||||||
|
|
||||||
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
|
if (!(seen
|
||||||
var othIndex = othLength;
|
? cacheHas(seen, computed)
|
||||||
|
: includes(result, computed, comparator)
|
||||||
|
)) {
|
||||||
|
othIndex = othLength;
|
||||||
while (--othIndex) {
|
while (--othIndex) {
|
||||||
var cache = caches[othIndex];
|
var cache = caches[othIndex];
|
||||||
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
|
if (!(cache
|
||||||
|
? cacheHas(cache, computed)
|
||||||
|
: includes(arrays[othIndex], computed, comparator))
|
||||||
|
) {
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], function(apply, baseToPath, isKey, last, parent) {
|
define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], function(apply, baseCastPath, isKey, last, parent) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -15,7 +15,7 @@ define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], functio
|
|||||||
*/
|
*/
|
||||||
function baseInvoke(object, path, args) {
|
function baseInvoke(object, path, args) {
|
||||||
if (!isKey(path, object)) {
|
if (!isKey(path, object)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
path = last(path);
|
path = last(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
|
|||||||
* @param {Object} other The other object to compare.
|
* @param {Object} other The other object to compare.
|
||||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||||
* @param {Function} [customizer] The function to customize comparisons.
|
* @param {Function} [customizer] The function to customize comparisons.
|
||||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
|
||||||
|
* for more details.
|
||||||
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
|
||||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||||
*/
|
*/
|
||||||
@@ -36,41 +37,39 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
|
|||||||
|
|
||||||
if (!objIsArr) {
|
if (!objIsArr) {
|
||||||
objTag = getTag(object);
|
objTag = getTag(object);
|
||||||
if (objTag == argsTag) {
|
objTag = objTag == argsTag ? objectTag : objTag;
|
||||||
objTag = objectTag;
|
|
||||||
} else if (objTag != objectTag) {
|
|
||||||
objIsArr = isTypedArray(object);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!othIsArr) {
|
if (!othIsArr) {
|
||||||
othTag = getTag(other);
|
othTag = getTag(other);
|
||||||
if (othTag == argsTag) {
|
othTag = othTag == argsTag ? objectTag : othTag;
|
||||||
othTag = objectTag;
|
|
||||||
} else if (othTag != objectTag) {
|
|
||||||
othIsArr = isTypedArray(other);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
if (isSameTag && !(objIsArr || objIsObj)) {
|
if (isSameTag && !objIsObj) {
|
||||||
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
|
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 (!(bitmask & PARTIAL_COMPARE_FLAG)) {
|
||||||
if (!isPartial) {
|
|
||||||
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
||||||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||||
|
|
||||||
if (objIsWrapped || othIsWrapped) {
|
if (objIsWrapped || othIsWrapped) {
|
||||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
var objUnwrapped = objIsWrapped ? object.value() : object,
|
||||||
|
othUnwrapped = othIsWrapped ? other.value() : other;
|
||||||
|
|
||||||
|
stack || (stack = new Stack);
|
||||||
|
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isSameTag) {
|
if (!isSameTag) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
stack || (stack = new Stack);
|
stack || (stack = new Stack);
|
||||||
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
|
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseIsEqualDeep;
|
return baseIsEqualDeep;
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ define(['./_Stack', './_baseIsEqual'], function(Stack, baseIsEqual) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var stack = new Stack,
|
var stack = new Stack;
|
||||||
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined;
|
if (customizer) {
|
||||||
|
var result = customizer(objValue, srcValue, key, object, source, stack);
|
||||||
|
}
|
||||||
if (!(result === undefined
|
if (!(result === undefined
|
||||||
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
|
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
|
||||||
: result
|
: result
|
||||||
|
|||||||
@@ -8,14 +8,15 @@ define(['./_baseMatches', './_baseMatchesProperty', './identity', './isArray', '
|
|||||||
* @returns {Function} Returns the iteratee.
|
* @returns {Function} Returns the iteratee.
|
||||||
*/
|
*/
|
||||||
function baseIteratee(value) {
|
function baseIteratee(value) {
|
||||||
var type = typeof value;
|
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
|
||||||
if (type == 'function') {
|
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
|
||||||
|
if (typeof value == 'function') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
if (type == 'object') {
|
if (typeof value == 'object') {
|
||||||
return isArray(value)
|
return isArray(value)
|
||||||
? baseMatchesProperty(value[0], value[1])
|
? baseMatchesProperty(value[0], value[1])
|
||||||
: baseMatches(value);
|
: baseMatches(value);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ define([], function() {
|
|||||||
* property of prototypes or treat sparse arrays as dense.
|
* property of prototypes or treat sparse arrays as dense.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @type Function
|
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The function whose prototype all chaining wrappers inherit from.
|
* The function whose prototype chain sequence wrappers inherit from.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData) {
|
define(['./_baseIsMatch', './_getMatchData', './_matchesStrictComparable'], function(baseIsMatch, getMatchData, matchesStrictComparable) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
||||||
var undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.matches` which doesn't clone `source`.
|
* The base implementation of `_.matches` which doesn't clone `source`.
|
||||||
@@ -13,16 +10,7 @@ define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData
|
|||||||
function baseMatches(source) {
|
function baseMatches(source) {
|
||||||
var matchData = getMatchData(source);
|
var matchData = getMatchData(source);
|
||||||
if (matchData.length == 1 && matchData[0][2]) {
|
if (matchData.length == 1 && matchData[0][2]) {
|
||||||
var key = matchData[0][0],
|
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
||||||
value = matchData[0][1];
|
|
||||||
|
|
||||||
return function(object) {
|
|
||||||
if (object == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return object[key] === value &&
|
|
||||||
(value !== undefined || (key in Object(object)));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return function(object) {
|
return function(object) {
|
||||||
return object === source || baseIsMatch(object, source, matchData);
|
return object === source || baseIsMatch(object, source, matchData);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_baseIsEqual', './get', './hasIn'], function(baseIsEqual, get, hasIn) {
|
define(['./_baseIsEqual', './get', './hasIn', './_isKey', './_isStrictComparable', './_matchesStrictComparable'], function(baseIsEqual, get, hasIn, isKey, isStrictComparable, matchesStrictComparable) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -16,6 +16,9 @@ define(['./_baseIsEqual', './get', './hasIn'], function(baseIsEqual, get, hasIn)
|
|||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
*/
|
*/
|
||||||
function baseMatchesProperty(path, srcValue) {
|
function baseMatchesProperty(path, srcValue) {
|
||||||
|
if (isKey(path) && isStrictComparable(srcValue)) {
|
||||||
|
return matchesStrictComparable(path, srcValue);
|
||||||
|
}
|
||||||
return function(object) {
|
return function(object) {
|
||||||
var objValue = get(object, path);
|
var objValue = get(object, path);
|
||||||
return (objValue === undefined && objValue === srcValue)
|
return (objValue === undefined && objValue === srcValue)
|
||||||
|
|||||||
21
_baseMean.js
Normal file
21
_baseMean.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
define(['./_baseSum'], function(baseSum) {
|
||||||
|
|
||||||
|
/** Used as references for various `Number` constants. */
|
||||||
|
var NAN = 0 / 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.mean` and `_.meanBy` without support for
|
||||||
|
* iteratee shorthands.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to iterate over.
|
||||||
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
|
* @returns {number} Returns the mean.
|
||||||
|
*/
|
||||||
|
function baseMean(array, iteratee) {
|
||||||
|
var length = array ? array.length : 0;
|
||||||
|
return length ? (baseSum(array, iteratee) / length) : NAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseMean;
|
||||||
|
});
|
||||||
@@ -11,13 +11,16 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
|
|||||||
* @param {Object} source The source object.
|
* @param {Object} source The source object.
|
||||||
* @param {number} srcIndex The index of `source`.
|
* @param {number} srcIndex The index of `source`.
|
||||||
* @param {Function} [customizer] The function to customize merged values.
|
* @param {Function} [customizer] The function to customize merged values.
|
||||||
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
|
* @param {Object} [stack] Tracks traversed source values and their merged
|
||||||
|
* counterparts.
|
||||||
*/
|
*/
|
||||||
function baseMerge(object, source, srcIndex, customizer, stack) {
|
function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||||
if (object === source) {
|
if (object === source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
|
if (!(isArray(source) || isTypedArray(source))) {
|
||||||
|
var props = keysIn(source);
|
||||||
|
}
|
||||||
arrayEach(props || source, function(srcValue, key) {
|
arrayEach(props || source, function(srcValue, key) {
|
||||||
if (props) {
|
if (props) {
|
||||||
key = srcValue;
|
key = srcValue;
|
||||||
@@ -28,7 +31,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
|
|||||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
|
var newValue = customizer
|
||||||
|
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
|||||||
* @param {number} srcIndex The index of `source`.
|
* @param {number} srcIndex The index of `source`.
|
||||||
* @param {Function} mergeFunc The function to merge values.
|
* @param {Function} mergeFunc The function to merge values.
|
||||||
* @param {Function} [customizer] The function to customize assigned values.
|
* @param {Function} [customizer] The function to customize assigned values.
|
||||||
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
|
* @param {Object} [stack] Tracks traversed source values and their merged
|
||||||
|
* counterparts.
|
||||||
*/
|
*/
|
||||||
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
||||||
var objValue = object[key],
|
var objValue = object[key],
|
||||||
@@ -26,21 +27,24 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
|||||||
assignMergeValue(object, key, stacked);
|
assignMergeValue(object, key, stacked);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
var newValue = customizer
|
||||||
isCommon = newValue === undefined;
|
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var isCommon = newValue === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||||
if (isArray(objValue)) {
|
if (isArray(objValue)) {
|
||||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
else if (isArrayLikeObject(objValue)) {
|
else if (isArrayLikeObject(objValue)) {
|
||||||
newValue = copyArray(objValue);
|
newValue = copyArray(objValue);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
@@ -49,10 +53,10 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
|||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -65,6 +69,7 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
|||||||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||||
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
||||||
}
|
}
|
||||||
|
stack['delete'](srcValue);
|
||||||
assignMergeValue(object, key, newValue);
|
assignMergeValue(object, key, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_compareMultiple'], function(arrayMap, baseIteratee, baseMap, baseSortBy, compareMultiple) {
|
define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_compareMultiple', './identity'], function(arrayMap, baseIteratee, baseMap, baseSortBy, compareMultiple, identity) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.orderBy` without param guards.
|
* The base implementation of `_.orderBy` without param guards.
|
||||||
@@ -10,12 +10,8 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_com
|
|||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
*/
|
*/
|
||||||
function baseOrderBy(collection, iteratees, orders) {
|
function baseOrderBy(collection, iteratees, orders) {
|
||||||
var index = -1,
|
var index = -1;
|
||||||
toIteratee = baseIteratee;
|
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
|
||||||
|
|
||||||
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
|
|
||||||
return toIteratee(iteratee);
|
|
||||||
});
|
|
||||||
|
|
||||||
var result = baseMap(collection, function(value, key, collection) {
|
var result = baseMap(collection, function(value, key, collection) {
|
||||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ define(['./_arrayReduce'], function(arrayReduce) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pick` without support for individual
|
* The base implementation of `_.pick` without support for individual
|
||||||
* property names.
|
* property identifiers.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
* @param {string[]} props The property names to pick.
|
* @param {string[]} props The property identifiers to pick.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
function basePick(object, props) {
|
function basePick(object, props) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_baseForIn'], function(baseForIn) {
|
define(['./_getAllKeysIn'], function(getAllKeysIn) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||||
@@ -9,12 +9,19 @@ define(['./_baseForIn'], function(baseForIn) {
|
|||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
function basePickBy(object, predicate) {
|
function basePickBy(object, predicate) {
|
||||||
var result = {};
|
var index = -1,
|
||||||
baseForIn(object, function(value, key) {
|
props = getAllKeysIn(object),
|
||||||
|
length = props.length,
|
||||||
|
result = {};
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
var key = props[index],
|
||||||
|
value = object[key];
|
||||||
|
|
||||||
if (predicate(value, key)) {
|
if (predicate(value, key)) {
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,44 @@
|
|||||||
define(['./_basePullAllBy'], function(basePullAllBy) {
|
define(['./_arrayMap', './_baseIndexOf', './_baseIndexOfWith', './_baseUnary'], function(arrayMap, baseIndexOf, baseIndexOfWith, 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
|
* @private
|
||||||
* @param {Array} array The array to modify.
|
* @param {Array} array The array to modify.
|
||||||
* @param {Array} values The values to remove.
|
* @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`.
|
* @returns {Array} Returns `array`.
|
||||||
*/
|
*/
|
||||||
function basePullAll(array, values) {
|
function basePullAll(array, values, iteratee, comparator) {
|
||||||
return basePullAllBy(array, values);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return basePullAll;
|
return basePullAll;
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
define(['./_arrayMap', './_baseIndexOf'], function(arrayMap, 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return basePullAllBy;
|
|
||||||
});
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], function(baseToPath, isIndex, isKey, last, parent) {
|
define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], function(baseCastPath, isIndex, isKey, last, parent) {
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
@@ -27,7 +27,7 @@ define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], funct
|
|||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
}
|
}
|
||||||
else if (!isKey(index, array)) {
|
else if (!isKey(index, array)) {
|
||||||
var path = baseToPath(index),
|
var path = baseCastPath(index),
|
||||||
object = parent(array, path);
|
object = parent(array, path);
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ define([], function() {
|
|||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} accumulator The initial value.
|
* @param {*} accumulator The initial value.
|
||||||
* @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
|
* @param {boolean} initAccum Specify using the first or last element of
|
||||||
|
* `collection` as the initial value.
|
||||||
* @param {Function} eachFunc The function to iterate over `collection`.
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
|
|||||||
38
_baseRepeat.js
Normal file
38
_baseRepeat.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as references for various `Number` constants. */
|
||||||
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
||||||
|
|
||||||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeFloor = Math.floor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.repeat` which doesn't coerce arguments.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {string} string The string to repeat.
|
||||||
|
* @param {number} n The number of times to repeat the string.
|
||||||
|
* @returns {string} Returns the repeated string.
|
||||||
|
*/
|
||||||
|
function baseRepeat(string, n) {
|
||||||
|
var result = '';
|
||||||
|
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// Leverage the exponentiation by squaring algorithm for a faster repeat.
|
||||||
|
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
|
||||||
|
do {
|
||||||
|
if (n % 2) {
|
||||||
|
result += string;
|
||||||
|
}
|
||||||
|
n = nativeFloor(n / 2);
|
||||||
|
if (n) {
|
||||||
|
string += string;
|
||||||
|
}
|
||||||
|
} while (n);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseRepeat;
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseToPath, isIndex, isKey, isObject) {
|
define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseCastPath, isIndex, isKey, isObject) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseSet(object, path, value, customizer) {
|
function baseSet(object, path, value, customizer) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
@@ -29,7 +29,9 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
|
|||||||
var objValue = nested[key];
|
var objValue = nested[key];
|
||||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
newValue = objValue == null
|
||||||
|
? (isIndex(path[index + 1]) ? [] : {})
|
||||||
|
: objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assignValue(nested, key, newValue);
|
assignValue(nested, key, newValue);
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ define(['./_baseEach'], function(baseEach) {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} predicate The function invoked per iteration.
|
* @param {Function} predicate The function invoked per iteration.
|
||||||
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||||
|
* else `false`.
|
||||||
*/
|
*/
|
||||||
function baseSome(collection, predicate) {
|
function baseSome(collection, predicate) {
|
||||||
var result;
|
var result;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.sortBy` which uses `comparer` to define
|
* The base implementation of `_.sortBy` which uses `comparer` to define the
|
||||||
* the sort order of `array` and replaces criteria objects with their
|
* sort order of `array` and replaces criteria objects with their corresponding
|
||||||
* corresponding values.
|
* values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to sort.
|
* @param {Array} array The array to sort.
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ define([], function() {
|
|||||||
* @param {*} value The value to evaluate.
|
* @param {*} value The value to evaluate.
|
||||||
* @param {Function} iteratee The iteratee invoked per element.
|
* @param {Function} iteratee The iteratee invoked per element.
|
||||||
* @param {boolean} [retHighest] Specify returning the highest qualified index.
|
* @param {boolean} [retHighest] Specify returning the highest qualified index.
|
||||||
* @returns {number} Returns the index at which `value` should be inserted into `array`.
|
* @returns {number} Returns the index at which `value` should be inserted
|
||||||
|
* into `array`.
|
||||||
*/
|
*/
|
||||||
function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
||||||
value = iteratee(value);
|
value = iteratee(value);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ define(['./eq'], function(eq) {
|
|||||||
value = array[0],
|
value = array[0],
|
||||||
computed = iteratee ? iteratee(value) : value,
|
computed = iteratee ? iteratee(value) : value,
|
||||||
seen = computed,
|
seen = computed,
|
||||||
resIndex = 0,
|
resIndex = 1,
|
||||||
result = [value];
|
result = [value];
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
@@ -24,7 +24,7 @@ define(['./eq'], function(eq) {
|
|||||||
|
|
||||||
if (!eq(computed, seen)) {
|
if (!eq(computed, seen)) {
|
||||||
seen = computed;
|
seen = computed;
|
||||||
result[++resIndex] = value;
|
result[resIndex++] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ define([], function() {
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.sum` without support for iteratee shorthands.
|
* The base implementation of `_.sum` and `_.sumBy` without support for
|
||||||
|
* iteratee shorthands.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
define(['./isArray', './_stringToPath'], function(isArray, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseToPath;
|
|
||||||
});
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_baseToPath', './has', './_isKey', './last', './_parent'], function(baseToPath, has, isKey, last, parent) {
|
define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function(baseCastPath, has, isKey, last, parent) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.unset`.
|
* The base implementation of `_.unset`.
|
||||||
@@ -9,7 +9,7 @@ define(['./_baseToPath', './has', './_isKey', './last', './_parent'], function(b
|
|||||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseUnset(object, path) {
|
function baseUnset(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
var key = last(path);
|
var key = last(path);
|
||||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||||
|
|||||||
18
_baseUpdate.js
Normal file
18
_baseUpdate.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
define(['./_baseGet', './_baseSet'], function(baseGet, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseUpdate;
|
||||||
|
});
|
||||||
@@ -7,7 +7,7 @@ define([], function() {
|
|||||||
* This base implementation of `_.zipObject` which assigns values using `assignFunc`.
|
* This base implementation of `_.zipObject` which assigns values using `assignFunc`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} props The property names.
|
* @param {Array} props The property identifiers.
|
||||||
* @param {Array} values The property values.
|
* @param {Array} values The property values.
|
||||||
* @param {Function} assignFunc The function to assign values.
|
* @param {Function} assignFunc The function to assign values.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
@@ -19,7 +19,8 @@ define([], function() {
|
|||||||
result = {};
|
result = {};
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
assignFunc(result, props[index], index < valsLength ? values[index] : undefined);
|
var value = index < valsLength ? values[index] : undefined;
|
||||||
|
assignFunc(result, props[index], value);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
17
_cloneArrayBuffer.js
Normal file
17
_cloneArrayBuffer.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
define(['./_Uint8Array'], function(Uint8Array) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a clone of `arrayBuffer`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
||||||
|
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||||||
|
*/
|
||||||
|
function cloneArrayBuffer(arrayBuffer) {
|
||||||
|
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||||||
|
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cloneArrayBuffer;
|
||||||
|
});
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
define(['./_Uint8Array'], function(Uint8Array) {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `buffer`.
|
* Creates a clone of `buffer`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {ArrayBuffer} buffer The array buffer to clone.
|
* @param {Buffer} buffer The buffer to clone.
|
||||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
|
* @returns {Buffer} Returns the cloned buffer.
|
||||||
*/
|
*/
|
||||||
function cloneBuffer(buffer) {
|
function cloneBuffer(buffer, isDeep) {
|
||||||
var Ctor = buffer.constructor,
|
if (isDeep) {
|
||||||
result = new Ctor(buffer.byteLength),
|
return buffer.slice();
|
||||||
view = new Uint8Array(result);
|
}
|
||||||
|
var result = new buffer.constructor(buffer.length);
|
||||||
view.set(new Uint8Array(buffer));
|
buffer.copy(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
_cloneDataView.js
Normal file
17
_cloneDataView.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a clone of `dataView`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} dataView The data view to clone.
|
||||||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
|
* @returns {Object} Returns the cloned data view.
|
||||||
|
*/
|
||||||
|
function cloneDataView(dataView, isDeep) {
|
||||||
|
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
||||||
|
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cloneDataView;
|
||||||
|
});
|
||||||
@@ -5,11 +5,13 @@ define(['./_addMapEntry', './_arrayReduce', './_mapToArray'], function(addMapEnt
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} map The map to clone.
|
* @param {Object} map The map to clone.
|
||||||
|
* @param {Function} cloneFunc The function to clone values.
|
||||||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
* @returns {Object} Returns the cloned map.
|
* @returns {Object} Returns the cloned map.
|
||||||
*/
|
*/
|
||||||
function cloneMap(map) {
|
function cloneMap(map, isDeep, cloneFunc) {
|
||||||
var Ctor = map.constructor;
|
var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
|
||||||
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
|
return arrayReduce(array, addMapEntry, new map.constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cloneMap;
|
return cloneMap;
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ define([], function() {
|
|||||||
* @returns {Object} Returns the cloned regexp.
|
* @returns {Object} Returns the cloned regexp.
|
||||||
*/
|
*/
|
||||||
function cloneRegExp(regexp) {
|
function cloneRegExp(regexp) {
|
||||||
var Ctor = regexp.constructor,
|
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||||||
result = new Ctor(regexp.source, reFlags.exec(regexp));
|
|
||||||
|
|
||||||
result.lastIndex = regexp.lastIndex;
|
result.lastIndex = regexp.lastIndex;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ define(['./_addSetEntry', './_arrayReduce', './_setToArray'], function(addSetEnt
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} set The set to clone.
|
* @param {Object} set The set to clone.
|
||||||
|
* @param {Function} cloneFunc The function to clone values.
|
||||||
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
* @returns {Object} Returns the cloned set.
|
* @returns {Object} Returns the cloned set.
|
||||||
*/
|
*/
|
||||||
function cloneSet(set) {
|
function cloneSet(set, isDeep, cloneFunc) {
|
||||||
var Ctor = set.constructor;
|
var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
|
||||||
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
|
return arrayReduce(array, addSetEntry, new set.constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cloneSet;
|
return cloneSet;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ define(['./_Symbol'], function(Symbol) {
|
|||||||
|
|
||||||
/** Used to convert symbols to primitives and strings. */
|
/** Used to convert symbols to primitives and strings. */
|
||||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
|
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of the `symbol` object.
|
* Creates a clone of the `symbol` object.
|
||||||
@@ -15,7 +15,7 @@ define(['./_Symbol'], function(Symbol) {
|
|||||||
* @returns {Object} Returns the cloned symbol object.
|
* @returns {Object} Returns the cloned symbol object.
|
||||||
*/
|
*/
|
||||||
function cloneSymbol(symbol) {
|
function cloneSymbol(symbol) {
|
||||||
return Symbol ? Object(symbolValueOf.call(symbol)) : {};
|
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return cloneSymbol;
|
return cloneSymbol;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_cloneBuffer'], function(cloneBuffer) {
|
define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `typedArray`.
|
* Creates a clone of `typedArray`.
|
||||||
@@ -9,10 +9,8 @@ define(['./_cloneBuffer'], function(cloneBuffer) {
|
|||||||
* @returns {Object} Returns the cloned typed array.
|
* @returns {Object} Returns the cloned typed array.
|
||||||
*/
|
*/
|
||||||
function cloneTypedArray(typedArray, isDeep) {
|
function cloneTypedArray(typedArray, isDeep) {
|
||||||
var buffer = typedArray.buffer,
|
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||||||
Ctor = typedArray.constructor;
|
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||||||
|
|
||||||
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cloneTypedArray;
|
return cloneTypedArray;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ define(['./_compareAscending'], function(compareAscending) {
|
|||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// This also ensures a stable sort in V8 and other engines.
|
// This also ensures a stable sort in V8 and other engines.
|
||||||
// See https://code.google.com/p/v8/issues/detail?id=90 for more details.
|
// See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
|
||||||
return object.index - other.index;
|
return object.index - other.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,23 +11,28 @@ define([], function() {
|
|||||||
* @param {Array|Object} args The provided arguments.
|
* @param {Array|Object} args The provided arguments.
|
||||||
* @param {Array} partials The arguments to prepend to those provided.
|
* @param {Array} partials The arguments to prepend to those provided.
|
||||||
* @param {Array} holders The `partials` placeholder indexes.
|
* @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.
|
* @returns {Array} Returns the new array of composed arguments.
|
||||||
*/
|
*/
|
||||||
function composeArgs(args, partials, holders) {
|
function composeArgs(args, partials, holders, isCurried) {
|
||||||
var holdersLength = holders.length,
|
var argsIndex = -1,
|
||||||
argsIndex = -1,
|
argsLength = args.length,
|
||||||
argsLength = nativeMax(args.length - holdersLength, 0),
|
holdersLength = holders.length,
|
||||||
leftIndex = -1,
|
leftIndex = -1,
|
||||||
leftLength = partials.length,
|
leftLength = partials.length,
|
||||||
result = Array(leftLength + argsLength);
|
rangeLength = nativeMax(argsLength - holdersLength, 0),
|
||||||
|
result = Array(leftLength + rangeLength),
|
||||||
|
isUncurried = !isCurried;
|
||||||
|
|
||||||
while (++leftIndex < leftLength) {
|
while (++leftIndex < leftLength) {
|
||||||
result[leftIndex] = partials[leftIndex];
|
result[leftIndex] = partials[leftIndex];
|
||||||
}
|
}
|
||||||
while (++argsIndex < holdersLength) {
|
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++];
|
result[leftIndex++] = args[argsIndex++];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -11,18 +11,21 @@ define([], function() {
|
|||||||
* @param {Array|Object} args The provided arguments.
|
* @param {Array|Object} args The provided arguments.
|
||||||
* @param {Array} partials The arguments to append to those provided.
|
* @param {Array} partials The arguments to append to those provided.
|
||||||
* @param {Array} holders The `partials` placeholder indexes.
|
* @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.
|
* @returns {Array} Returns the new array of composed arguments.
|
||||||
*/
|
*/
|
||||||
function composeArgsRight(args, partials, holders) {
|
function composeArgsRight(args, partials, holders, isCurried) {
|
||||||
var holdersIndex = -1,
|
var argsIndex = -1,
|
||||||
|
argsLength = args.length,
|
||||||
|
holdersIndex = -1,
|
||||||
holdersLength = holders.length,
|
holdersLength = holders.length,
|
||||||
argsIndex = -1,
|
|
||||||
argsLength = nativeMax(args.length - holdersLength, 0),
|
|
||||||
rightIndex = -1,
|
rightIndex = -1,
|
||||||
rightLength = partials.length,
|
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];
|
result[argsIndex] = args[argsIndex];
|
||||||
}
|
}
|
||||||
var offset = argsIndex;
|
var offset = argsIndex;
|
||||||
@@ -30,7 +33,9 @@ define([], function() {
|
|||||||
result[offset + rightIndex] = partials[rightIndex];
|
result[offset + rightIndex] = partials[rightIndex];
|
||||||
}
|
}
|
||||||
while (++holdersIndex < holdersLength) {
|
while (++holdersIndex < holdersLength) {
|
||||||
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
if (isUncurried || argsIndex < argsLength) {
|
||||||
|
result[offset + holders[holdersIndex]] = args[argsIndex++];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ define(['./_copyObjectWith'], function(copyObjectWith) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} source The object to copy properties from.
|
* @param {Object} source The object to copy properties from.
|
||||||
* @param {Array} props The property names to copy.
|
* @param {Array} props The property identifiers to copy.
|
||||||
* @param {Object} [object={}] The object to copy properties to.
|
* @param {Object} [object={}] The object to copy properties to.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ define(['./_assignValue'], function(assignValue) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} source The object to copy properties from.
|
* @param {Object} source The object to copy properties from.
|
||||||
* @param {Array} props The property names to copy.
|
* @param {Array} props The property identifiers to copy.
|
||||||
* @param {Object} [object={}] The object to copy properties to.
|
* @param {Object} [object={}] The object to copy properties to.
|
||||||
* @param {Function} [customizer] The function to customize copied values.
|
* @param {Function} [customizer] The function to customize copied values.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
@@ -18,8 +18,11 @@ define(['./_assignValue'], function(assignValue) {
|
|||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index],
|
var key = props[index];
|
||||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
|
||||||
|
var newValue = customizer
|
||||||
|
? customizer(object[key], source[key], key, object, source)
|
||||||
|
: source[key];
|
||||||
|
|
||||||
assignValue(object, key, newValue);
|
assignValue(object, key, newValue);
|
||||||
}
|
}
|
||||||
|
|||||||
24
_countHolders.js
Normal file
24
_countHolders.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return countHolders;
|
||||||
|
});
|
||||||
@@ -17,7 +17,10 @@ define(['./_isIterateeCall', './rest'], function(isIterateeCall, rest) {
|
|||||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||||
guard = length > 2 ? sources[2] : undefined;
|
guard = length > 2 ? sources[2] : undefined;
|
||||||
|
|
||||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
customizer = typeof customizer == 'function'
|
||||||
|
? (length--, customizer)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||||
customizer = length < 3 ? undefined : customizer;
|
customizer = length < 3 ? undefined : customizer;
|
||||||
length = 1;
|
length = 1;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a base function for methods like `_.forIn`.
|
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ define(['./_createCtorWrapper', './_root'], function(createCtorWrapper, root) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to wrap.
|
* @param {Function} func The function to wrap.
|
||||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
|
||||||
|
* for more details.
|
||||||
* @param {*} [thisArg] The `this` binding of `func`.
|
* @param {*} [thisArg] The `this` binding of `func`.
|
||||||
* @returns {Function} Returns the new wrapped function.
|
* @returns {Function} Returns the new wrapped function.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
|
|||||||
return function(string) {
|
return function(string) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
|
|
||||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
var strSymbols = reHasComplexSymbol.test(string)
|
||||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
? stringToArray(string)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||||
|
|
||||||
return chr[methodName]() + trailing;
|
return chr[methodName]() + trailing;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ define(['./_baseCreate', './isObject'], function(baseCreate, isObject) {
|
|||||||
*/
|
*/
|
||||||
function createCtorWrapper(Ctor) {
|
function createCtorWrapper(Ctor) {
|
||||||
return function() {
|
return function() {
|
||||||
// Use a `switch` statement to work with class constructors.
|
// Use a `switch` statement to work with class constructors. See
|
||||||
// See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
|
// http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
|
||||||
// for more details.
|
// for more details.
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_createRecurryWrapper', './_replaceHolders', './_root'], function(apply, createCtorWrapper, createHybridWrapper, createRecurryWrapper, replaceHolders, root) {
|
define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_createRecurryWrapper', './_getPlaceholder', './_replaceHolders', './_root'], function(apply, createCtorWrapper, createHybridWrapper, createRecurryWrapper, getPlaceholder, replaceHolders, root) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -8,7 +8,8 @@ define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_create
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to wrap.
|
* @param {Function} func The function to wrap.
|
||||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
|
||||||
|
* for more details.
|
||||||
* @param {number} arity The arity of `func`.
|
* @param {number} arity The arity of `func`.
|
||||||
* @returns {Function} Returns the new wrapped function.
|
* @returns {Function} Returns the new wrapped function.
|
||||||
*/
|
*/
|
||||||
@@ -17,10 +18,9 @@ define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_create
|
|||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
var length = arguments.length,
|
var length = arguments.length,
|
||||||
index = length,
|
|
||||||
args = Array(length),
|
args = Array(length),
|
||||||
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func,
|
index = length,
|
||||||
placeholder = wrapper.placeholder;
|
placeholder = getPlaceholder(wrapper);
|
||||||
|
|
||||||
while (index--) {
|
while (index--) {
|
||||||
args[index] = arguments[index];
|
args[index] = arguments[index];
|
||||||
@@ -30,9 +30,13 @@ define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_create
|
|||||||
: replaceHolders(args, placeholder);
|
: replaceHolders(args, placeholder);
|
||||||
|
|
||||||
length -= holders.length;
|
length -= holders.length;
|
||||||
return length < arity
|
if (length < arity) {
|
||||||
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length)
|
return createRecurryWrapper(
|
||||||
: apply(fn, this, args);
|
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;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** 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. */
|
/** Used as the size to enable large array optimizations. */
|
||||||
var LARGE_ARRAY_SIZE = 200;
|
var LARGE_ARRAY_SIZE = 200;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Used as the `TypeError` message for "Functions" methods. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
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.
|
* Creates a `_.flow` or `_.flowRight` function.
|
||||||
*
|
*
|
||||||
@@ -24,7 +24,7 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
|
|||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return rest(function(funcs) {
|
return rest(function(funcs) {
|
||||||
funcs = baseFlatten(funcs);
|
funcs = baseFlatten(funcs, 1);
|
||||||
|
|
||||||
var length = funcs.length,
|
var length = funcs.length,
|
||||||
index = length,
|
index = length,
|
||||||
@@ -49,17 +49,23 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
|
|||||||
var funcName = getFuncName(func),
|
var funcName = getFuncName(func),
|
||||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
data = funcName == 'wrapper' ? getData(func) : undefined;
|
||||||
|
|
||||||
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
if (data && isLaziable(data[0]) &&
|
||||||
|
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
|
||||||
|
!data[4].length && data[9] == 1
|
||||||
|
) {
|
||||||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||||
} else {
|
} else {
|
||||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
wrapper = (func.length == 1 && isLaziable(func))
|
||||||
|
? wrapper[funcName]()
|
||||||
|
: wrapper.thru(func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
value = args[0];
|
value = args[0];
|
||||||
|
|
||||||
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
if (wrapper && args.length == 1 &&
|
||||||
|
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||||
return wrapper.plant(value).value();
|
return wrapper.plant(value).value();
|
||||||
}
|
}
|
||||||
var index = 0,
|
var index = 0,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_createRecurryWrapper', './_reorder', './_replaceHolders', './_root'], function(composeArgs, composeArgsRight, createCtorWrapper, createRecurryWrapper, reorder, replaceHolders, root) {
|
define(['./_composeArgs', './_composeArgsRight', './_countHolders', './_createCtorWrapper', './_createRecurryWrapper', './_getPlaceholder', './_reorder', './_replaceHolders', './_root'], function(composeArgs, composeArgsRight, countHolders, createCtorWrapper, createRecurryWrapper, getPlaceholder, reorder, replaceHolders, root) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -17,11 +17,14 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function|string} func The function or method name to wrap.
|
* @param {Function|string} func The function or method name to wrap.
|
||||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
|
||||||
|
* for more details.
|
||||||
* @param {*} [thisArg] The `this` binding of `func`.
|
* @param {*} [thisArg] The `this` binding of `func`.
|
||||||
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
|
* @param {Array} [partials] The arguments to prepend to those provided to
|
||||||
|
* the new function.
|
||||||
* @param {Array} [holders] The `partials` placeholder indexes.
|
* @param {Array} [holders] The `partials` placeholder indexes.
|
||||||
* @param {Array} [partialsRight] The arguments to append to those provided to the new function.
|
* @param {Array} [partialsRight] The arguments to append to those provided
|
||||||
|
* to the new function.
|
||||||
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
|
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
|
||||||
* @param {Array} [argPos] The argument positions of the new function.
|
* @param {Array} [argPos] The argument positions of the new function.
|
||||||
* @param {number} [ary] The arity cap of `func`.
|
* @param {number} [ary] The arity cap of `func`.
|
||||||
@@ -32,8 +35,7 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
|
|||||||
var isAry = bitmask & ARY_FLAG,
|
var isAry = bitmask & ARY_FLAG,
|
||||||
isBind = bitmask & BIND_FLAG,
|
isBind = bitmask & BIND_FLAG,
|
||||||
isBindKey = bitmask & BIND_KEY_FLAG,
|
isBindKey = bitmask & BIND_KEY_FLAG,
|
||||||
isCurry = bitmask & CURRY_FLAG,
|
isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
|
||||||
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
|
|
||||||
isFlip = bitmask & FLIP_FLAG,
|
isFlip = bitmask & FLIP_FLAG,
|
||||||
Ctor = isBindKey ? undefined : createCtorWrapper(func);
|
Ctor = isBindKey ? undefined : createCtorWrapper(func);
|
||||||
|
|
||||||
@@ -45,30 +47,34 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
|
|||||||
while (index--) {
|
while (index--) {
|
||||||
args[index] = arguments[index];
|
args[index] = arguments[index];
|
||||||
}
|
}
|
||||||
|
if (isCurried) {
|
||||||
|
var placeholder = getPlaceholder(wrapper),
|
||||||
|
holdersCount = countHolders(args, placeholder);
|
||||||
|
}
|
||||||
if (partials) {
|
if (partials) {
|
||||||
args = composeArgs(args, partials, holders);
|
args = composeArgs(args, partials, holders, isCurried);
|
||||||
}
|
}
|
||||||
if (partialsRight) {
|
if (partialsRight) {
|
||||||
args = composeArgsRight(args, partialsRight, holdersRight);
|
args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
|
||||||
}
|
}
|
||||||
if (isCurry || isCurryRight) {
|
length -= holdersCount;
|
||||||
var placeholder = wrapper.placeholder,
|
if (isCurried && length < arity) {
|
||||||
argsHolders = replaceHolders(args, placeholder);
|
var newHolders = replaceHolders(args, placeholder);
|
||||||
|
return createRecurryWrapper(
|
||||||
length -= argsHolders.length;
|
func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
|
||||||
if (length < arity) {
|
args, newHolders, argPos, ary, arity - length
|
||||||
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var thisBinding = isBind ? thisArg : this,
|
var thisBinding = isBind ? thisArg : this,
|
||||||
fn = isBindKey ? thisBinding[func] : func;
|
fn = isBindKey ? thisBinding[func] : func;
|
||||||
|
|
||||||
|
length = args.length;
|
||||||
if (argPos) {
|
if (argPos) {
|
||||||
args = reorder(args, argPos);
|
args = reorder(args, argPos);
|
||||||
} else if (isFlip && args.length > 1) {
|
} else if (isFlip && length > 1) {
|
||||||
args.reverse();
|
args.reverse();
|
||||||
}
|
}
|
||||||
if (isAry && ary < args.length) {
|
if (isAry && ary < length) {
|
||||||
args.length = ary;
|
args.length = ary;
|
||||||
}
|
}
|
||||||
if (this && this !== root && this instanceof wrapper) {
|
if (this && this !== root && this instanceof wrapper) {
|
||||||
|
|||||||
30
_createMathOperation.js
Normal file
30
_createMathOperation.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
define([], function() {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a function that performs a mathematical operation on two values.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} operator The function to perform the operation.
|
||||||
|
* @returns {Function} Returns the new mathematical operation function.
|
||||||
|
*/
|
||||||
|
function createMathOperation(operator) {
|
||||||
|
return function(value, other) {
|
||||||
|
var result;
|
||||||
|
if (value === undefined && other === undefined) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (value !== undefined) {
|
||||||
|
result = value;
|
||||||
|
}
|
||||||
|
if (other !== undefined) {
|
||||||
|
result = result === undefined ? other : operator(result, other);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return createMathOperation;
|
||||||
|
});
|
||||||
@@ -9,7 +9,7 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './rest'
|
|||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return rest(function(iteratees) {
|
return rest(function(iteratees) {
|
||||||
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
|
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var thisArg = this;
|
var thisArg = this;
|
||||||
return arrayFunc(iteratees, function(iteratee) {
|
return arrayFunc(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./repeat', './_stringSize', './_stringToArray', './toInteger'], function(repeat, stringSize, stringToArray, toInteger) {
|
define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepeat, stringSize, stringToArray) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -23,25 +23,21 @@ define(['./repeat', './_stringSize', './_stringToArray', './toInteger'], functio
|
|||||||
* is truncated if the number of characters exceeds `length`.
|
* is truncated if the number of characters exceeds `length`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {string} string The string to create padding for.
|
* @param {number} length The padding length.
|
||||||
* @param {number} [length=0] The padding length.
|
|
||||||
* @param {string} [chars=' '] The string used as padding.
|
* @param {string} [chars=' '] The string used as padding.
|
||||||
* @returns {string} Returns the padding for `string`.
|
* @returns {string} Returns the padding for `string`.
|
||||||
*/
|
*/
|
||||||
function createPadding(string, length, chars) {
|
function createPadding(length, chars) {
|
||||||
length = toInteger(length);
|
|
||||||
|
|
||||||
var strLength = stringSize(string);
|
|
||||||
if (!length || strLength >= length) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var padLength = length - strLength;
|
|
||||||
chars = chars === undefined ? ' ' : (chars + '');
|
chars = chars === undefined ? ' ' : (chars + '');
|
||||||
|
|
||||||
var result = repeat(chars, nativeCeil(padLength / stringSize(chars)));
|
var charsLength = chars.length;
|
||||||
|
if (charsLength < 2) {
|
||||||
|
return charsLength ? baseRepeat(chars, length) : chars;
|
||||||
|
}
|
||||||
|
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
|
||||||
return reHasComplexSymbol.test(chars)
|
return reHasComplexSymbol.test(chars)
|
||||||
? stringToArray(result).slice(0, padLength).join('')
|
? stringToArray(result).slice(0, length).join('')
|
||||||
: result.slice(0, padLength);
|
: result.slice(0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return createPadding;
|
return createPadding;
|
||||||
|
|||||||
@@ -4,15 +4,16 @@ define(['./_apply', './_createCtorWrapper', './_root'], function(apply, createCt
|
|||||||
var BIND_FLAG = 1;
|
var BIND_FLAG = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that wraps `func` to invoke it with the optional `this`
|
* Creates a function that wraps `func` to invoke it with the `this` binding
|
||||||
* binding of `thisArg` and the `partials` prepended to those provided to
|
* of `thisArg` and `partials` prepended to the arguments it receives.
|
||||||
* the wrapper.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to wrap.
|
* @param {Function} func The function to wrap.
|
||||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
|
||||||
|
* for more details.
|
||||||
* @param {*} thisArg The `this` binding of `func`.
|
* @param {*} thisArg The `this` binding of `func`.
|
||||||
* @param {Array} partials The arguments to prepend to those provided to the new function.
|
* @param {Array} partials The arguments to prepend to those provided to
|
||||||
|
* the new function.
|
||||||
* @returns {Function} Returns the new wrapped function.
|
* @returns {Function} Returns the new wrapped function.
|
||||||
*/
|
*/
|
||||||
function createPartialWrapper(func, bitmask, thisArg, partials) {
|
function createPartialWrapper(func, bitmask, thisArg, partials) {
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to wrap.
|
* @param {Function} func The function to wrap.
|
||||||
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
|
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
|
||||||
|
* for more details.
|
||||||
* @param {Function} wrapFunc The function to create the `func` wrapper.
|
* @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 {*} [thisArg] The `this` binding of `func`.
|
||||||
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
|
* @param {Array} [partials] The arguments to prepend to those provided to
|
||||||
|
* the new function.
|
||||||
* @param {Array} [holders] The `partials` placeholder indexes.
|
* @param {Array} [holders] The `partials` placeholder indexes.
|
||||||
* @param {Array} [argPos] The argument positions of the new function.
|
* @param {Array} [argPos] The argument positions of the new function.
|
||||||
* @param {number} [ary] The arity cap of `func`.
|
* @param {number} [ary] The arity cap of `func`.
|
||||||
@@ -30,7 +32,7 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
|
|||||||
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
||||||
var isCurry = bitmask & CURRY_FLAG,
|
var isCurry = bitmask & CURRY_FLAG,
|
||||||
newArgPos = argPos ? copyArray(argPos) : undefined,
|
newArgPos = argPos ? copyArray(argPos) : undefined,
|
||||||
newsHolders = isCurry ? holders : undefined,
|
newHolders = isCurry ? holders : undefined,
|
||||||
newHoldersRight = isCurry ? undefined : holders,
|
newHoldersRight = isCurry ? undefined : holders,
|
||||||
newPartials = isCurry ? partials : undefined,
|
newPartials = isCurry ? partials : undefined,
|
||||||
newPartialsRight = isCurry ? undefined : partials;
|
newPartialsRight = isCurry ? undefined : partials;
|
||||||
@@ -41,9 +43,12 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
|
|||||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||||
}
|
}
|
||||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
var newData = [
|
||||||
result = wrapFunc.apply(undefined, newData);
|
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||||
|
newHoldersRight, newArgPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
|
var result = wrapFunc.apply(undefined, newData);
|
||||||
if (isLaziable(func)) {
|
if (isLaziable(func)) {
|
||||||
setData(result, newData);
|
setData(result, newData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
|
/** Used as the `TypeError` message for "Functions" methods. */
|
||||||
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
BIND_KEY_FLAG = 2,
|
BIND_KEY_FLAG = 2,
|
||||||
@@ -11,9 +14,6 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
|
|||||||
PARTIAL_FLAG = 32,
|
PARTIAL_FLAG = 32,
|
||||||
PARTIAL_RIGHT_FLAG = 64;
|
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. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeMax = Math.max;
|
var nativeMax = Math.max;
|
||||||
|
|
||||||
@@ -62,8 +62,12 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
|
|||||||
|
|
||||||
partials = holders = undefined;
|
partials = holders = undefined;
|
||||||
}
|
}
|
||||||
var data = isBindKey ? undefined : getData(func),
|
var data = isBindKey ? undefined : getData(func);
|
||||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
|
||||||
|
var newData = [
|
||||||
|
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||||
|
argPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mergeData(newData, data);
|
mergeData(newData, data);
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ define(['./_arraySome'], function(arraySome) {
|
|||||||
* @param {Array} array The array to compare.
|
* @param {Array} array The array to compare.
|
||||||
* @param {Array} other The other array to compare.
|
* @param {Array} other The other array to compare.
|
||||||
* @param {Function} equalFunc The function to determine equivalents of values.
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
||||||
* @param {Function} [customizer] The function to customize comparisons.
|
* @param {Function} customizer The function to customize comparisons.
|
||||||
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
|
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
|
||||||
* @param {Object} [stack] Tracks traversed `array` and `other` objects.
|
* for more details.
|
||||||
|
* @param {Object} stack Tracks traversed `array` and `other` objects.
|
||||||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||||||
*/
|
*/
|
||||||
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
||||||
@@ -58,12 +59,16 @@ define(['./_arraySome'], function(arraySome) {
|
|||||||
// Recursively compare arrays (susceptible to call stack limits).
|
// Recursively compare arrays (susceptible to call stack limits).
|
||||||
if (isUnordered) {
|
if (isUnordered) {
|
||||||
if (!arraySome(other, function(othValue) {
|
if (!arraySome(other, function(othValue) {
|
||||||
return arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack);
|
return arrValue === othValue ||
|
||||||
|
equalFunc(arrValue, othValue, customizer, bitmask, stack);
|
||||||
})) {
|
})) {
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
} else if (!(
|
||||||
|
arrValue === othValue ||
|
||||||
|
equalFunc(arrValue, othValue, customizer, bitmask, stack)
|
||||||
|
)) {
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user