mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
501d6b1d41 | ||
|
|
ddf9328c67 | ||
|
|
7eeb5ebd61 | ||
|
|
0dd6798d8b | ||
|
|
91d3468c81 | ||
|
|
e2aef0def9 | ||
|
|
bd7f722175 | ||
|
|
d8bc95999f | ||
|
|
24a4285b70 |
33
LICENSE
33
LICENSE
@@ -1,22 +1,23 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
||||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
a copy of this software and associated documentation files (the
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
"Software"), to deal in the Software without restriction, including
|
in the Software without restriction, including without limitation the rights
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
furnished to do so, subject to the following conditions:
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be included in all
|
||||||
included in all copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
SOFTWARE.
|
||||||
|
|||||||
34
README.md
34
README.md
@@ -1,4 +1,4 @@
|
|||||||
# lodash v4.1.0
|
# lodash v4.6.1
|
||||||
|
|
||||||
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
|
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
|
||||||
|
|
||||||
@@ -12,45 +12,29 @@ $ npm i --save lodash
|
|||||||
|
|
||||||
In Node.js:
|
In Node.js:
|
||||||
```js
|
```js
|
||||||
// load the full build
|
// Load the full build.
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
// load the core build
|
// Load the core build.
|
||||||
var _ = require('lodash/core');
|
var _ = require('lodash/core');
|
||||||
// load the fp build for immutable auto-curried iteratee-first data-last methods
|
// Load the fp build for immutable auto-curried iteratee-first data-last methods.
|
||||||
var _ = require('lodash/fp');
|
var _ = require('lodash/fp');
|
||||||
|
|
||||||
// or a method category
|
// Load a method category.
|
||||||
var array = require('lodash/array');
|
var array = require('lodash/array');
|
||||||
var object = require('lodash/fp/object');
|
var object = require('lodash/fp/object');
|
||||||
|
|
||||||
// or method for smaller builds with browserify/rollup/webpack
|
// Load a single method for smaller builds with browserify/rollup/webpack.
|
||||||
var chunk = require('lodash/chunk');
|
var chunk = require('lodash/chunk');
|
||||||
var extend = require('lodash/fp/extend');
|
var extend = require('lodash/fp/extend');
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.1.0-npm) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.6.1-npm) for more details.
|
||||||
|
|
||||||
**Note:**<br>
|
**Note:**<br>
|
||||||
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
||||||
Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default.
|
Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default.
|
||||||
|
|
||||||
## Module formats
|
|
||||||
|
|
||||||
Lodash is also available in a variety of other builds & module formats.
|
|
||||||
|
|
||||||
* [lodash](https://www.npmjs.com/package/lodash) & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) packages
|
|
||||||
* [lodash-amd](https://www.npmjs.com/package/lodash-amd)
|
|
||||||
* [lodash-es](https://www.npmjs.com/package/lodash-es) & [babel-plugin-lodash](https://www.npmjs.com/package/babel-plugin-lodash)
|
|
||||||
|
|
||||||
## Further Reading
|
|
||||||
|
|
||||||
* [API Documentation](https://lodash.com/docs)
|
|
||||||
* [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences)
|
|
||||||
* [Changelog](https://github.com/lodash/lodash/wiki/Changelog)
|
|
||||||
* [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap)
|
|
||||||
* [More Resources](https://github.com/lodash/lodash/wiki/Resources)
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
Tested in Chrome 46-47, Firefox 42-43, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10, 0.12, 4, & 5, & PhantomJS 1.9.8.
|
Tested in Chrome 47-48, Firefox 43-44, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10, 0.12, 4, & 5, & PhantomJS 1.9.8.<br>
|
||||||
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.
|
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available.
|
||||||
|
|||||||
3
_Hash.js
3
_Hash.js
@@ -1,12 +1,13 @@
|
|||||||
var nativeCreate = require('./_nativeCreate');
|
var nativeCreate = require('./_nativeCreate');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an hash object.
|
* Creates an hash object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @returns {Object} Returns the new hash object.
|
* @returns {Object} Returns the new hash object.
|
||||||
*/
|
*/
|
||||||
function Hash() {}
|
function Hash() {}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
|
|||||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {*} value The value to wrap.
|
* @param {*} value The value to wrap.
|
||||||
*/
|
*/
|
||||||
function LazyWrapper(value) {
|
function LazyWrapper(value) {
|
||||||
|
|||||||
5
_Map.js
5
_Map.js
@@ -1,6 +1,7 @@
|
|||||||
var getNative = require('./_getNative');
|
var getNative = require('./_getNative'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var Map = getNative(global, 'Map');
|
var Map = getNative(root, 'Map');
|
||||||
|
|
||||||
module.exports = Map;
|
module.exports = Map;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var mapClear = require('./_mapClear'),
|
|||||||
* Creates a map cache object to store key-value pairs.
|
* Creates a map cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function MapCache(values) {
|
function MapCache(values) {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
var root = require('./_root');
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Reflect = global.Reflect;
|
var Reflect = root.Reflect;
|
||||||
|
|
||||||
module.exports = Reflect;
|
module.exports = Reflect;
|
||||||
|
|||||||
5
_Set.js
5
_Set.js
@@ -1,6 +1,7 @@
|
|||||||
var getNative = require('./_getNative');
|
var getNative = require('./_getNative'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var Set = getNative(global, 'Set');
|
var Set = getNative(root, 'Set');
|
||||||
|
|
||||||
module.exports = Set;
|
module.exports = Set;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var MapCache = require('./_MapCache'),
|
|||||||
* Creates a set cache object to store unique values.
|
* Creates a set cache object to store unique values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function SetCache(values) {
|
function SetCache(values) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var stackClear = require('./_stackClear'),
|
|||||||
* 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) {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
var root = require('./_root');
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Symbol = global.Symbol;
|
var Symbol = root.Symbol;
|
||||||
|
|
||||||
module.exports = Symbol;
|
module.exports = Symbol;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
var root = require('./_root');
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Uint8Array = global.Uint8Array;
|
var Uint8Array = root.Uint8Array;
|
||||||
|
|
||||||
module.exports = Uint8Array;
|
module.exports = Uint8Array;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
var getNative = require('./_getNative');
|
var getNative = require('./_getNative'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var WeakMap = getNative(global, 'WeakMap');
|
var WeakMap = getNative(root, 'WeakMap');
|
||||||
|
|
||||||
module.exports = WeakMap;
|
module.exports = WeakMap;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* @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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to invoke.
|
* @param {Function} func The function to invoke.
|
||||||
* @param {*} thisArg The `this` binding of `func`.
|
* @param {*} thisArg The `this` binding of `func`.
|
||||||
* @param {...*} [args] The arguments to invoke `func` with.
|
* @param {...*} args The arguments to invoke `func` with.
|
||||||
* @returns {*} Returns the result of `func`.
|
* @returns {*} Returns the result of `func`.
|
||||||
*/
|
*/
|
||||||
function apply(func, thisArg, args) {
|
function apply(func, thisArg, args) {
|
||||||
var length = args ? args.length : 0;
|
var length = args.length;
|
||||||
switch (length) {
|
switch (length) {
|
||||||
case 0: return func.call(thisArg);
|
case 0: return func.call(thisArg);
|
||||||
case 1: return func.call(thisArg, args[0]);
|
case 1: return func.call(thisArg, args[0]);
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
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,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var eq = require('./eq');
|
var eq = require('./eq');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
var eq = require('./eq');
|
var eq = require('./eq');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is like `assignValue` except that it doesn't assign `undefined` values.
|
* This function is like `assignValue` except that it doesn't assign
|
||||||
|
* `undefined` values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to modify.
|
* @param {Object} object The object to modify.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var eq = require('./eq');
|
var eq = require('./eq');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
@@ -18,8 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var assocIndexOf = require('./_assocIndexOf');
|
var assocIndexOf = require('./_assocIndexOf');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = global.Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var splice = arrayProto.splice;
|
var splice = arrayProto.splice;
|
||||||
|
|||||||
14
_baseCastArrayLikeObject.js
Normal file
14
_baseCastArrayLikeObject.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
var isArrayLikeObject = require('./isArrayLikeObject');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to an empty array if it's not an array like object.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the array-like object.
|
||||||
|
*/
|
||||||
|
function baseCastArrayLikeObject(value) {
|
||||||
|
return isArrayLikeObject(value) ? value : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseCastArrayLikeObject;
|
||||||
14
_baseCastFunction.js
Normal file
14
_baseCastFunction.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
var identity = require('./identity');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to `identity` if it's not a function.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the array-like object.
|
||||||
|
*/
|
||||||
|
function baseCastFunction(value) {
|
||||||
|
return typeof value == 'function' ? value : identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseCastFunction;
|
||||||
15
_baseCastPath.js
Normal file
15
_baseCastPath.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
var isArray = require('./isArray'),
|
||||||
|
stringToPath = require('./_stringToPath');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to a path array if it's not one.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the cast property path array.
|
||||||
|
*/
|
||||||
|
function baseCastPath(value) {
|
||||||
|
return isArray(value) ? value : stringToPath(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseCastPath;
|
||||||
@@ -3,6 +3,7 @@ var Stack = require('./_Stack'),
|
|||||||
assignValue = require('./_assignValue'),
|
assignValue = require('./_assignValue'),
|
||||||
baseAssign = require('./_baseAssign'),
|
baseAssign = require('./_baseAssign'),
|
||||||
baseForOwn = require('./_baseForOwn'),
|
baseForOwn = require('./_baseForOwn'),
|
||||||
|
cloneBuffer = require('./_cloneBuffer'),
|
||||||
copyArray = require('./_copyArray'),
|
copyArray = require('./_copyArray'),
|
||||||
copySymbols = require('./_copySymbols'),
|
copySymbols = require('./_copySymbols'),
|
||||||
getTag = require('./_getTag'),
|
getTag = require('./_getTag'),
|
||||||
@@ -10,6 +11,7 @@ var Stack = require('./_Stack'),
|
|||||||
initCloneByTag = require('./_initCloneByTag'),
|
initCloneByTag = require('./_initCloneByTag'),
|
||||||
initCloneObject = require('./_initCloneObject'),
|
initCloneObject = require('./_initCloneObject'),
|
||||||
isArray = require('./isArray'),
|
isArray = require('./isArray'),
|
||||||
|
isBuffer = require('./isBuffer'),
|
||||||
isHostObject = require('./_isHostObject'),
|
isHostObject = require('./_isHostObject'),
|
||||||
isObject = require('./isObject');
|
isObject = require('./isObject');
|
||||||
|
|
||||||
@@ -64,13 +66,14 @@ cloneableTags[weakMapTag] = false;
|
|||||||
* @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);
|
||||||
@@ -91,18 +94,23 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
|||||||
var tag = getTag(value),
|
var tag = getTag(value),
|
||||||
isFunc = tag == funcTag || tag == genTag;
|
isFunc = tag == funcTag || tag == genTag;
|
||||||
|
|
||||||
|
if (isBuffer(value)) {
|
||||||
|
return cloneBuffer(value, isDeep);
|
||||||
|
}
|
||||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||||
if (isHostObject(value)) {
|
if (isHostObject(value)) {
|
||||||
return object ? value : {};
|
return object ? value : {};
|
||||||
}
|
}
|
||||||
result = initCloneObject(isFunc ? {} : value);
|
result = initCloneObject(isFunc ? {} : value);
|
||||||
if (!isDeep) {
|
if (!isDeep) {
|
||||||
return copySymbols(value, baseAssign(result, value));
|
result = baseAssign(result, value);
|
||||||
|
return isFull ? copySymbols(value, result) : result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return cloneableTags[tag]
|
if (!cloneableTags[tag]) {
|
||||||
? initCloneByTag(value, tag, isDeep)
|
return object ? value : {};
|
||||||
: (object ? value : {});
|
}
|
||||||
|
result = initCloneByTag(value, tag, isDeep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for circular references and return its corresponding clone.
|
// Check for circular references and return its corresponding clone.
|
||||||
@@ -115,9 +123,9 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
|
|||||||
|
|
||||||
// Recursively populate clone (susceptible to call stack limits).
|
// Recursively populate clone (susceptible to call stack limits).
|
||||||
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
||||||
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack));
|
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
|
||||||
});
|
});
|
||||||
return isArr ? result : copySymbols(value, result);
|
return (isFull && !isArr) ? copySymbols(value, result) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = baseClone;
|
module.exports = baseClone;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
var isObject = require('./isObject');
|
var isObject = require('./isObject');
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var objectCreate = Object.create;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.create` without support for assigning
|
* The base implementation of `_.create` without support for assigning
|
||||||
* properties to the created object.
|
* properties to the created object.
|
||||||
@@ -8,16 +11,8 @@ var isObject = require('./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 || {};
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
module.exports = baseCreate;
|
module.exports = baseCreate;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
|||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to delay.
|
* @param {Function} func The function to delay.
|
||||||
* @param {number} wait The number of milliseconds to delay invocation.
|
* @param {number} wait The number of milliseconds to delay invocation.
|
||||||
* @param {Object} args The arguments provide to `func`.
|
* @param {Object} args The arguments to provide to `func`.
|
||||||
* @returns {number} Returns the timer id.
|
* @returns {number} Returns the timer id.
|
||||||
*/
|
*/
|
||||||
function baseDelay(func, wait, args) {
|
function baseDelay(func, wait, args) {
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ var arrayPush = require('./_arrayPush'),
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
* @param {number} depth The maximum recursion depth.
|
||||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||||
* @param {Array} [result=[]] The initial result value.
|
* @param {Array} [result=[]] The initial result value.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, result) {
|
function baseFlatten(array, depth, isStrict, result) {
|
||||||
result || (result = []);
|
result || (result = []);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -21,11 +21,11 @@ function baseFlatten(array, isDeep, isStrict, result) {
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (isArrayLikeObject(value) &&
|
if (depth > 0 && isArrayLikeObject(value) &&
|
||||||
(isStrict || isArray(value) || isArguments(value))) {
|
(isStrict || isArray(value) || isArguments(value))) {
|
||||||
if (isDeep) {
|
if (depth > 1) {
|
||||||
// Recursively flatten arrays (susceptible to call stack limits).
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
baseFlatten(value, isDeep, isStrict, result);
|
baseFlatten(value, depth - 1, isStrict, result);
|
||||||
} else {
|
} else {
|
||||||
arrayPush(result, value);
|
arrayPush(result, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ var arrayFilter = require('./_arrayFilter'),
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
isKey = require('./_isKey');
|
isKey = require('./_isKey');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +10,7 @@ var baseToPath = require('./_baseToPath'),
|
|||||||
* @returns {*} Returns the resolved value.
|
* @returns {*} Returns the resolved value.
|
||||||
*/
|
*/
|
||||||
function baseGet(object, path) {
|
function baseGet(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|||||||
23
_baseIndexOfWith.js
Normal file
23
_baseIndexOfWith.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* This function is like `baseIndexOf` except that it accepts a comparator.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to search.
|
||||||
|
* @param {*} value The value to search for.
|
||||||
|
* @param {number} fromIndex The index to search from.
|
||||||
|
* @param {Function} comparator The comparator invoked per element.
|
||||||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||||
|
*/
|
||||||
|
function baseIndexOfWith(array, value, fromIndex, comparator) {
|
||||||
|
var index = fromIndex - 1,
|
||||||
|
length = array.length;
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
if (comparator(array[index], value)) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseIndexOfWith;
|
||||||
@@ -5,6 +5,9 @@ var SetCache = require('./_SetCache'),
|
|||||||
baseUnary = require('./_baseUnary'),
|
baseUnary = require('./_baseUnary'),
|
||||||
cacheHas = require('./_cacheHas');
|
cacheHas = require('./_cacheHas');
|
||||||
|
|
||||||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeMin = Math.min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.intersection`, without support
|
* 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.
|
||||||
@@ -17,9 +20,11 @@ var SetCache = require('./_SetCache'),
|
|||||||
*/
|
*/
|
||||||
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--) {
|
||||||
@@ -27,26 +32,32 @@ function baseIntersection(arrays, iteratee, comparator) {
|
|||||||
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,5 +1,5 @@
|
|||||||
var apply = require('./_apply'),
|
var apply = require('./_apply'),
|
||||||
baseToPath = require('./_baseToPath'),
|
baseCastPath = require('./_baseCastPath'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
parent = require('./_parent');
|
parent = require('./_parent');
|
||||||
@@ -16,7 +16,7 @@ var apply = require('./_apply'),
|
|||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var argsTag = '[object Arguments]',
|
|||||||
objectTag = '[object Object]';
|
objectTag = '[object Object]';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
@@ -43,33 +43,28 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
|||||||
|
|
||||||
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) {
|
||||||
|
stack || (stack = new Stack);
|
||||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +72,7 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
|||||||
return false;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = baseIsEqualDeep;
|
module.exports = baseIsEqualDeep;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
|
|||||||
* property of prototypes or treat sparse arrays as dense.
|
* property of prototypes or treat sparse arrays as dense.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @type Function
|
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var Reflect = require('./_Reflect'),
|
|||||||
iteratorToArray = require('./_iteratorToArray');
|
iteratorToArray = require('./_iteratorToArray');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var enumerate = Reflect ? Reflect.enumerate : undefined,
|
var enumerate = Reflect ? Reflect.enumerate : undefined,
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
|||||||
if (object === source) {
|
if (object === source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
|
var props = (isArray(source) || isTypedArray(source))
|
||||||
|
? undefined
|
||||||
|
: keysIn(source);
|
||||||
|
|
||||||
arrayEach(props || source, function(srcValue, key) {
|
arrayEach(props || source, function(srcValue, key) {
|
||||||
if (props) {
|
if (props) {
|
||||||
key = srcValue;
|
key = srcValue;
|
||||||
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
|||||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
|
var newValue = customizer
|
||||||
|
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
assignMergeValue(object, key, stacked);
|
assignMergeValue(object, key, stacked);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
var newValue = customizer
|
||||||
isCommon = newValue === undefined;
|
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var isCommon = newValue === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||||
if (isArray(objValue)) {
|
if (isArray(objValue)) {
|
||||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
else if (isArrayLikeObject(objValue)) {
|
else if (isArrayLikeObject(objValue)) {
|
||||||
newValue = copyArray(objValue);
|
newValue = copyArray(objValue);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, !customizer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
@@ -56,10 +59,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, !customizer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -72,6 +75,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,8 @@ var arrayMap = require('./_arrayMap'),
|
|||||||
* @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 : Array(1), 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) {
|
||||||
|
|||||||
@@ -1,15 +1,47 @@
|
|||||||
var basePullAllBy = require('./_basePullAllBy');
|
var arrayMap = require('./_arrayMap'),
|
||||||
|
baseIndexOf = require('./_baseIndexOf'),
|
||||||
|
baseIndexOfWith = require('./_baseIndexOfWith'),
|
||||||
|
baseUnary = require('./_baseUnary');
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var arrayProto = Array.prototype;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var splice = arrayProto.splice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pullAll`.
|
* The base implementation of `_.pullAllBy` without support for iteratee
|
||||||
|
* shorthands.
|
||||||
*
|
*
|
||||||
* @private
|
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = basePullAll;
|
module.exports = basePullAll;
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
var arrayMap = require('./_arrayMap'),
|
|
||||||
baseIndexOf = require('./_baseIndexOf');
|
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
|
||||||
var arrayProto = global.Array.prototype;
|
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
var splice = arrayProto.splice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.pullAllBy` without support for iteratee
|
|
||||||
* shorthands.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Array} array The array to modify.
|
|
||||||
* @param {Array} values The values to remove.
|
|
||||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
||||||
* @returns {Array} Returns `array`.
|
|
||||||
*/
|
|
||||||
function basePullAllBy(array, values, iteratee) {
|
|
||||||
var index = -1,
|
|
||||||
length = values.length,
|
|
||||||
seen = array;
|
|
||||||
|
|
||||||
if (iteratee) {
|
|
||||||
seen = arrayMap(array, function(value) { return iteratee(value); });
|
|
||||||
}
|
|
||||||
while (++index < length) {
|
|
||||||
var fromIndex = 0,
|
|
||||||
value = values[index],
|
|
||||||
computed = iteratee ? iteratee(value) : value;
|
|
||||||
|
|
||||||
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
|
|
||||||
if (seen !== array) {
|
|
||||||
splice.call(seen, fromIndex, 1);
|
|
||||||
}
|
|
||||||
splice.call(array, fromIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = basePullAllBy;
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
isIndex = require('./_isIndex'),
|
isIndex = require('./_isIndex'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
parent = require('./_parent');
|
parent = require('./_parent');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = global.Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var splice = arrayProto.splice;
|
var splice = arrayProto.splice;
|
||||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
|||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
}
|
}
|
||||||
else if (!isKey(index, array)) {
|
else if (!isKey(index, array)) {
|
||||||
var path = baseToPath(index),
|
var path = baseCastPath(index),
|
||||||
object = parent(array, path);
|
object = parent(array, path);
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var assignValue = require('./_assignValue'),
|
var assignValue = require('./_assignValue'),
|
||||||
baseToPath = require('./_baseToPath'),
|
baseCastPath = require('./_baseCastPath'),
|
||||||
isIndex = require('./_isIndex'),
|
isIndex = require('./_isIndex'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
isObject = require('./isObject');
|
isObject = require('./isObject');
|
||||||
@@ -15,7 +15,7 @@ var assignValue = require('./_assignValue'),
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseSet(object, path, value, customizer) {
|
function baseSet(object, path, value, customizer) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
|
|||||||
var objValue = nested[key];
|
var objValue = nested[key];
|
||||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
newValue = objValue == null
|
||||||
|
? (isIndex(path[index + 1]) ? [] : {})
|
||||||
|
: objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assignValue(nested, key, newValue);
|
assignValue(nested, key, newValue);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function baseSortedUniqBy(array, iteratee) {
|
|||||||
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 @@ function baseSortedUniqBy(array, iteratee) {
|
|||||||
|
|
||||||
if (!eq(computed, seen)) {
|
if (!eq(computed, seen)) {
|
||||||
seen = computed;
|
seen = computed;
|
||||||
result[++resIndex] = value;
|
result[resIndex++] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function baseSum(array, iteratee) {
|
|||||||
result = result === undefined ? current : (result + current);
|
result = result === undefined ? current : (result + current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return length ? result : 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = baseSum;
|
module.exports = baseSum;
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
var isArray = require('./isArray'),
|
|
||||||
stringToPath = require('./_stringToPath');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.toPath` which only converts `value` to a
|
|
||||||
* path if it's not one.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to process.
|
|
||||||
* @returns {Array} Returns the property path array.
|
|
||||||
*/
|
|
||||||
function baseToPath(value) {
|
|
||||||
return isArray(value) ? value : stringToPath(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = baseToPath;
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
has = require('./has'),
|
has = require('./has'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
@@ -13,7 +13,7 @@ var baseToPath = require('./_baseToPath'),
|
|||||||
* @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 @@
|
|||||||
|
var baseGet = require('./_baseGet'),
|
||||||
|
baseSet = require('./_baseSet');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.update`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The object to query.
|
||||||
|
* @param {Array|string} path The path of the property to update.
|
||||||
|
* @param {Function} updater The function to produce the updated value.
|
||||||
|
* @param {Function} [customizer] The function to customize path creation.
|
||||||
|
* @returns {Object} Returns `object`.
|
||||||
|
*/
|
||||||
|
function baseUpdate(object, path, updater, customizer) {
|
||||||
|
return baseSet(object, path, updater(baseGet(object, path)), customizer);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseUpdate;
|
||||||
12
_checkGlobal.js
Normal file
12
_checkGlobal.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Checks if `value` is a global object.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {null|Object} Returns `value` if it's a global object, else `null`.
|
||||||
|
*/
|
||||||
|
function checkGlobal(value) {
|
||||||
|
return (value && value.Object === Object) ? value : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = checkGlobal;
|
||||||
16
_cloneArrayBuffer.js
Normal file
16
_cloneArrayBuffer.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
var Uint8Array = require('./_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = cloneArrayBuffer;
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
var Uint8Array = require('./_Uint8Array');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `buffer`.
|
* Creates a clone of `buffer`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {ArrayBuffer} buffer The array buffer to clone.
|
* @param {Buffer} buffer The buffer to clone.
|
||||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
|
* @returns {Buffer} Returns the cloned buffer.
|
||||||
*/
|
*/
|
||||||
function cloneBuffer(buffer) {
|
function cloneBuffer(buffer, isDeep) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ var addMapEntry = require('./_addMapEntry'),
|
|||||||
* @returns {Object} Returns the cloned map.
|
* @returns {Object} Returns the cloned map.
|
||||||
*/
|
*/
|
||||||
function cloneMap(map) {
|
function cloneMap(map) {
|
||||||
var Ctor = map.constructor;
|
return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
|
||||||
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = cloneMap;
|
module.exports = cloneMap;
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ var reFlags = /\w*$/;
|
|||||||
* @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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ var addSetEntry = require('./_addSetEntry'),
|
|||||||
* @returns {Object} Returns the cloned set.
|
* @returns {Object} Returns the cloned set.
|
||||||
*/
|
*/
|
||||||
function cloneSet(set) {
|
function cloneSet(set) {
|
||||||
var Ctor = set.constructor;
|
return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
|
||||||
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = cloneSet;
|
module.exports = cloneSet;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var Symbol = require('./_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.
|
||||||
@@ -12,7 +12,7 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|||||||
* @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)) : {};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = cloneSymbol;
|
module.exports = cloneSymbol;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var cloneBuffer = require('./_cloneBuffer');
|
var cloneArrayBuffer = require('./_cloneArrayBuffer');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `typedArray`.
|
* Creates a clone of `typedArray`.
|
||||||
@@ -9,10 +9,8 @@ var cloneBuffer = require('./_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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = cloneTypedArray;
|
module.exports = cloneTypedArray;
|
||||||
|
|||||||
@@ -9,23 +9,28 @@ var nativeMax = Math.max;
|
|||||||
* @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;
|
||||||
|
|||||||
@@ -9,18 +9,21 @@ var nativeMax = Math.max;
|
|||||||
* @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;
|
||||||
@@ -28,7 +31,9 @@ function composeArgsRight(args, partials, holders) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) {
|
|||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index],
|
var key = props[index];
|
||||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
|
||||||
|
var newValue = customizer
|
||||||
|
? customizer(object[key], source[key], key, object, source)
|
||||||
|
: source[key];
|
||||||
|
|
||||||
assignValue(object, key, newValue);
|
assignValue(object, key, newValue);
|
||||||
}
|
}
|
||||||
|
|||||||
21
_countHolders.js
Normal file
21
_countHolders.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Gets the number of `placeholder` occurrences in `array`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to inspect.
|
||||||
|
* @param {*} placeholder The placeholder to search for.
|
||||||
|
* @returns {number} Returns the placeholder count.
|
||||||
|
*/
|
||||||
|
function countHolders(array, placeholder) {
|
||||||
|
var length = array.length,
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
while (length--) {
|
||||||
|
if (array[length] === placeholder) {
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = countHolders;
|
||||||
@@ -15,7 +15,10 @@ function createAssigner(assigner) {
|
|||||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
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,4 +1,5 @@
|
|||||||
var createCtorWrapper = require('./_createCtorWrapper');
|
var createCtorWrapper = require('./_createCtorWrapper'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1;
|
var BIND_FLAG = 1;
|
||||||
@@ -18,7 +19,7 @@ function createBaseWrapper(func, bitmask, thisArg) {
|
|||||||
Ctor = createCtorWrapper(func);
|
Ctor = createCtorWrapper(func);
|
||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
|
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
||||||
return fn.apply(isBind ? thisArg : this, arguments);
|
return fn.apply(isBind ? thisArg : this, arguments);
|
||||||
}
|
}
|
||||||
return wrapper;
|
return wrapper;
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ function createCaseFirst(methodName) {
|
|||||||
return function(string) {
|
return function(string) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
|
|
||||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
var strSymbols = reHasComplexSymbol.test(string)
|
||||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
? stringToArray(string)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||||
|
|
||||||
return chr[methodName]() + trailing;
|
return chr[methodName]() + trailing;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ var apply = require('./_apply'),
|
|||||||
createCtorWrapper = require('./_createCtorWrapper'),
|
createCtorWrapper = require('./_createCtorWrapper'),
|
||||||
createHybridWrapper = require('./_createHybridWrapper'),
|
createHybridWrapper = require('./_createHybridWrapper'),
|
||||||
createRecurryWrapper = require('./_createRecurryWrapper'),
|
createRecurryWrapper = require('./_createRecurryWrapper'),
|
||||||
replaceHolders = require('./_replaceHolders');
|
getPlaceholder = require('./_getPlaceholder'),
|
||||||
|
replaceHolders = require('./_replaceHolders'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that wraps `func` to enable currying.
|
* Creates a function that wraps `func` to enable currying.
|
||||||
@@ -18,10 +20,9 @@ function createCurryWrapper(func, bitmask, arity) {
|
|||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
var length = arguments.length,
|
var length = arguments.length,
|
||||||
index = length,
|
|
||||||
args = Array(length),
|
args = Array(length),
|
||||||
fn = (this && this !== global && 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];
|
||||||
@@ -31,9 +32,13 @@ function createCurryWrapper(func, bitmask, arity) {
|
|||||||
: 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,18 +6,18 @@ var LodashWrapper = require('./_LodashWrapper'),
|
|||||||
isLaziable = require('./_isLaziable'),
|
isLaziable = require('./_isLaziable'),
|
||||||
rest = require('./rest');
|
rest = require('./rest');
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
|
||||||
var CURRY_FLAG = 8,
|
|
||||||
PARTIAL_FLAG = 32,
|
|
||||||
ARY_FLAG = 128,
|
|
||||||
REARG_FLAG = 256;
|
|
||||||
|
|
||||||
/** Used as the size to enable large array optimizations. */
|
/** 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.
|
||||||
*
|
*
|
||||||
@@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
|||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return rest(function(funcs) {
|
return rest(function(funcs) {
|
||||||
funcs = baseFlatten(funcs);
|
funcs = baseFlatten(funcs, 1);
|
||||||
|
|
||||||
var length = funcs.length,
|
var length = funcs.length,
|
||||||
index = length,
|
index = length,
|
||||||
@@ -52,7 +52,10 @@ function createFlow(fromRight) {
|
|||||||
var funcName = getFuncName(func),
|
var funcName = getFuncName(func),
|
||||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
data = funcName == 'wrapper' ? getData(func) : undefined;
|
||||||
|
|
||||||
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
if (data && isLaziable(data[0]) &&
|
||||||
|
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
|
||||||
|
!data[4].length && data[9] == 1
|
||||||
|
) {
|
||||||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||||
} else {
|
} else {
|
||||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||||
@@ -62,7 +65,8 @@ function createFlow(fromRight) {
|
|||||||
var args = arguments,
|
var args = arguments,
|
||||||
value = args[0];
|
value = args[0];
|
||||||
|
|
||||||
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
if (wrapper && args.length == 1 &&
|
||||||
|
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||||
return wrapper.plant(value).value();
|
return wrapper.plant(value).value();
|
||||||
}
|
}
|
||||||
var index = 0,
|
var index = 0,
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
var composeArgs = require('./_composeArgs'),
|
var composeArgs = require('./_composeArgs'),
|
||||||
composeArgsRight = require('./_composeArgsRight'),
|
composeArgsRight = require('./_composeArgsRight'),
|
||||||
|
countHolders = require('./_countHolders'),
|
||||||
createCtorWrapper = require('./_createCtorWrapper'),
|
createCtorWrapper = require('./_createCtorWrapper'),
|
||||||
createRecurryWrapper = require('./_createRecurryWrapper'),
|
createRecurryWrapper = require('./_createRecurryWrapper'),
|
||||||
|
getPlaceholder = require('./_getPlaceholder'),
|
||||||
reorder = require('./_reorder'),
|
reorder = require('./_reorder'),
|
||||||
replaceHolders = require('./_replaceHolders');
|
replaceHolders = require('./_replaceHolders'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
@@ -34,8 +37,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
|||||||
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);
|
||||||
|
|
||||||
@@ -47,33 +49,37 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
|||||||
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 !== global && this instanceof wrapper) {
|
if (this && this !== root && this instanceof wrapper) {
|
||||||
fn = Ctor || createCtorWrapper(fn);
|
fn = Ctor || createCtorWrapper(fn);
|
||||||
}
|
}
|
||||||
return fn.apply(thisBinding, args);
|
return fn.apply(thisBinding, args);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ var apply = require('./_apply'),
|
|||||||
*/
|
*/
|
||||||
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,5 +1,6 @@
|
|||||||
var apply = require('./_apply'),
|
var apply = require('./_apply'),
|
||||||
createCtorWrapper = require('./_createCtorWrapper');
|
createCtorWrapper = require('./_createCtorWrapper'),
|
||||||
|
root = require('./_root');
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1;
|
var BIND_FLAG = 1;
|
||||||
@@ -26,7 +27,7 @@ function createPartialWrapper(func, bitmask, thisArg, partials) {
|
|||||||
leftIndex = -1,
|
leftIndex = -1,
|
||||||
leftLength = partials.length,
|
leftLength = partials.length,
|
||||||
args = Array(leftLength + argsLength),
|
args = Array(leftLength + argsLength),
|
||||||
fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
|
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
||||||
|
|
||||||
while (++leftIndex < leftLength) {
|
while (++leftIndex < leftLength) {
|
||||||
args[leftIndex] = partials[leftIndex];
|
args[leftIndex] = partials[leftIndex];
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var BIND_FLAG = 1,
|
|||||||
* @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.
|
||||||
@@ -29,7 +29,7 @@ var BIND_FLAG = 1,
|
|||||||
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;
|
||||||
@@ -40,9 +40,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
|||||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||||
}
|
}
|
||||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
var newData = [
|
||||||
result = wrapFunc.apply(undefined, newData);
|
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||||
|
newHoldersRight, newArgPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
|
var result = wrapFunc.apply(undefined, newData);
|
||||||
if (isLaziable(func)) {
|
if (isLaziable(func)) {
|
||||||
setData(result, newData);
|
setData(result, newData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ var baseSetData = require('./_baseSetData'),
|
|||||||
setData = require('./_setData'),
|
setData = require('./_setData'),
|
||||||
toInteger = require('./toInteger');
|
toInteger = require('./toInteger');
|
||||||
|
|
||||||
|
/** Used as the `TypeError` message for "Functions" methods. */
|
||||||
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
BIND_KEY_FLAG = 2,
|
BIND_KEY_FLAG = 2,
|
||||||
@@ -16,9 +19,6 @@ var BIND_FLAG = 1,
|
|||||||
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;
|
||||||
|
|
||||||
@@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
|||||||
|
|
||||||
partials = holders = undefined;
|
partials = holders = undefined;
|
||||||
}
|
}
|
||||||
var data = isBindKey ? undefined : getData(func),
|
var data = isBindKey ? undefined : getData(func);
|
||||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
|
||||||
|
var newData = [
|
||||||
|
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||||
|
argPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mergeData(newData, data);
|
mergeData(newData, data);
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ var UNORDERED_COMPARE_FLAG = 1,
|
|||||||
* @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` for more details.
|
||||||
* @param {Object} [stack] Tracks traversed `array` and `other` objects.
|
* @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) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
var Symbol = require('./_Symbol'),
|
var Symbol = require('./_Symbol'),
|
||||||
Uint8Array = require('./_Uint8Array'),
|
Uint8Array = require('./_Uint8Array'),
|
||||||
|
equalArrays = require('./_equalArrays'),
|
||||||
mapToArray = require('./_mapToArray'),
|
mapToArray = require('./_mapToArray'),
|
||||||
setToArray = require('./_setToArray');
|
setToArray = require('./_setToArray');
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ var arrayBufferTag = '[object ArrayBuffer]';
|
|||||||
|
|
||||||
/** 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
||||||
@@ -36,11 +37,12 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|||||||
* @param {Object} other The other object to compare.
|
* @param {Object} other The other object to compare.
|
||||||
* @param {string} tag The `toStringTag` of the objects to compare.
|
* @param {string} tag The `toStringTag` of the objects 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.
|
||||||
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
||||||
*/
|
*/
|
||||||
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case arrayBufferTag:
|
case arrayBufferTag:
|
||||||
if ((object.byteLength != other.byteLength) ||
|
if ((object.byteLength != other.byteLength) ||
|
||||||
@@ -75,12 +77,21 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
|
|||||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
|
||||||
convert || (convert = setToArray);
|
convert || (convert = setToArray);
|
||||||
|
|
||||||
|
if (object.size != other.size && !isPartial) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Assume cyclic values are equal.
|
||||||
|
var stacked = stack.get(object);
|
||||||
|
if (stacked) {
|
||||||
|
return stacked == other;
|
||||||
|
}
|
||||||
// Recursively compare objects (susceptible to call stack limits).
|
// Recursively compare objects (susceptible to call stack limits).
|
||||||
return (isPartial || object.size == other.size) &&
|
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other));
|
||||||
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
|
|
||||||
|
|
||||||
case symbolTag:
|
case symbolTag:
|
||||||
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
|
if (symbolValueOf) {
|
||||||
|
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ var PARTIAL_COMPARE_FLAG = 2;
|
|||||||
* @param {Object} object The object to compare.
|
* @param {Object} object The object to compare.
|
||||||
* @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`.
|
||||||
*/
|
*/
|
||||||
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var realNames = require('./_realNames');
|
var realNames = require('./_realNames');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var isNative = require('./isNative');
|
|||||||
* @returns {*} Returns the function if it's native, else `undefined`.
|
* @returns {*} Returns the function if it's native, else `undefined`.
|
||||||
*/
|
*/
|
||||||
function getNative(object, key) {
|
function getNative(object, key) {
|
||||||
var value = object == null ? undefined : object[key];
|
var value = object[key];
|
||||||
return isNative(value) ? value : undefined;
|
return isNative(value) ? value : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
_getPlaceholder.js
Normal file
13
_getPlaceholder.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Gets the argument placeholder value for `func`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to inspect.
|
||||||
|
* @returns {*} Returns the placeholder value.
|
||||||
|
*/
|
||||||
|
function getPlaceholder(func) {
|
||||||
|
var object = func;
|
||||||
|
return object.placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getPlaceholder;
|
||||||
30
_getTag.js
30
_getTag.js
@@ -1,16 +1,18 @@
|
|||||||
var Map = require('./_Map'),
|
var Map = require('./_Map'),
|
||||||
Set = require('./_Set');
|
Set = require('./_Set'),
|
||||||
|
WeakMap = require('./_WeakMap');
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var mapTag = '[object Map]',
|
var mapTag = '[object Map]',
|
||||||
objectTag = '[object Object]',
|
objectTag = '[object Object]',
|
||||||
setTag = '[object Set]';
|
setTag = '[object Set]',
|
||||||
|
weakMapTag = '[object WeakMap]';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to resolve the decompiled source of functions. */
|
/** Used to resolve the decompiled source of functions. */
|
||||||
var funcToString = global.Function.prototype.toString;
|
var funcToString = Function.prototype.toString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||||||
@@ -18,9 +20,10 @@ var funcToString = global.Function.prototype.toString;
|
|||||||
*/
|
*/
|
||||||
var objectToString = objectProto.toString;
|
var objectToString = objectProto.toString;
|
||||||
|
|
||||||
/** Used to detect maps and sets. */
|
/** Used to detect maps, sets, and weakmaps. */
|
||||||
var mapCtorString = Map ? funcToString.call(Map) : '',
|
var mapCtorString = Map ? funcToString.call(Map) : '',
|
||||||
setCtorString = Set ? funcToString.call(Set) : '';
|
setCtorString = Set ? funcToString.call(Set) : '',
|
||||||
|
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the `toStringTag` of `value`.
|
* Gets the `toStringTag` of `value`.
|
||||||
@@ -33,19 +36,20 @@ function getTag(value) {
|
|||||||
return objectToString.call(value);
|
return objectToString.call(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for IE 11 providing `toStringTag` values for maps and sets.
|
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
|
||||||
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) {
|
if ((Map && getTag(new Map) != mapTag) ||
|
||||||
|
(Set && getTag(new Set) != setTag) ||
|
||||||
|
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||||||
getTag = function(value) {
|
getTag = function(value) {
|
||||||
var result = objectToString.call(value),
|
var result = objectToString.call(value),
|
||||||
Ctor = result == objectTag ? value.constructor : null,
|
Ctor = result == objectTag ? value.constructor : null,
|
||||||
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
|
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
|
||||||
|
|
||||||
if (ctorString) {
|
if (ctorString) {
|
||||||
if (ctorString == mapCtorString) {
|
switch (ctorString) {
|
||||||
return mapTag;
|
case mapCtorString: return mapTag;
|
||||||
}
|
case setCtorString: return setTag;
|
||||||
if (ctorString == setCtorString) {
|
case weakMapCtorString: return weakMapTag;
|
||||||
return setTag;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
isArguments = require('./isArguments'),
|
isArguments = require('./isArguments'),
|
||||||
isArray = require('./isArray'),
|
isArray = require('./isArray'),
|
||||||
isIndex = require('./_isIndex'),
|
isIndex = require('./_isIndex'),
|
||||||
@@ -23,7 +23,7 @@ function hasPath(object, path, hasFunc) {
|
|||||||
}
|
}
|
||||||
var result = hasFunc(object, path);
|
var result = hasFunc(object, path);
|
||||||
if (!result && !isKey(path)) {
|
if (!result && !isKey(path)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
path = last(path);
|
path = last(path);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ var nativeCreate = require('./_nativeCreate');
|
|||||||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var nativeCreate = require('./_nativeCreate');
|
var nativeCreate = require('./_nativeCreate');
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var cloneBuffer = require('./_cloneBuffer'),
|
var cloneArrayBuffer = require('./_cloneArrayBuffer'),
|
||||||
cloneMap = require('./_cloneMap'),
|
cloneMap = require('./_cloneMap'),
|
||||||
cloneRegExp = require('./_cloneRegExp'),
|
cloneRegExp = require('./_cloneRegExp'),
|
||||||
cloneSet = require('./_cloneSet'),
|
cloneSet = require('./_cloneSet'),
|
||||||
@@ -42,7 +42,7 @@ function initCloneByTag(object, tag, isDeep) {
|
|||||||
var Ctor = object.constructor;
|
var Ctor = object.constructor;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case arrayBufferTag:
|
case arrayBufferTag:
|
||||||
return cloneBuffer(object);
|
return cloneArrayBuffer(object);
|
||||||
|
|
||||||
case boolTag:
|
case boolTag:
|
||||||
case dateTag:
|
case dateTag:
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
var baseCreate = require('./_baseCreate'),
|
var baseCreate = require('./_baseCreate'),
|
||||||
isFunction = require('./isFunction'),
|
|
||||||
isPrototype = require('./_isPrototype');
|
isPrototype = require('./_isPrototype');
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var getPrototypeOf = Object.getPrototypeOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes an object clone.
|
* Initializes an object clone.
|
||||||
*
|
*
|
||||||
@@ -10,11 +12,9 @@ var baseCreate = require('./_baseCreate'),
|
|||||||
* @returns {Object} Returns the initialized clone.
|
* @returns {Object} Returns the initialized clone.
|
||||||
*/
|
*/
|
||||||
function initCloneObject(object) {
|
function initCloneObject(object) {
|
||||||
if (isPrototype(object)) {
|
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||||||
return {};
|
? baseCreate(getPrototypeOf(object))
|
||||||
}
|
: {};
|
||||||
var Ctor = object.constructor;
|
|
||||||
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = initCloneObject;
|
module.exports = initCloneObject;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ var eq = require('./eq'),
|
|||||||
isObject = require('./isObject');
|
isObject = require('./isObject');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the provided arguments are from an iteratee call.
|
* Checks if the given arguments are from an iteratee call.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {*} value The potential iteratee value argument.
|
* @param {*} value The potential iteratee value argument.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
function isKeyable(value) {
|
function isKeyable(value) {
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
return type == 'number' || type == 'boolean' ||
|
return type == 'number' || type == 'boolean' ||
|
||||||
(type == 'string' && value !== '__proto__') || value == null;
|
(type == 'string' && value != '__proto__') || value == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = isKeyable;
|
module.exports = isKeyable;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = global.Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is likely a prototype object.
|
* Checks if `value` is likely a prototype object.
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ function lazyValue() {
|
|||||||
resIndex = 0,
|
resIndex = 0,
|
||||||
takeCount = nativeMin(length, this.__takeCount__);
|
takeCount = nativeMin(length, this.__takeCount__);
|
||||||
|
|
||||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
|
if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
|
||||||
|
(arrLength == length && takeCount == length)) {
|
||||||
return baseWrapperValue(array, this.__actions__);
|
return baseWrapperValue(array, this.__actions__);
|
||||||
}
|
}
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ var Hash = require('./_Hash'),
|
|||||||
* @memberOf MapCache
|
* @memberOf MapCache
|
||||||
*/
|
*/
|
||||||
function mapClear() {
|
function mapClear() {
|
||||||
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
|
this.__data__ = {
|
||||||
|
'hash': new Hash,
|
||||||
|
'map': Map ? new Map : [],
|
||||||
|
'string': new Hash
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = mapClear;
|
module.exports = mapClear;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ var composeArgs = require('./_composeArgs'),
|
|||||||
copyArray = require('./_copyArray'),
|
copyArray = require('./_copyArray'),
|
||||||
replaceHolders = require('./_replaceHolders');
|
replaceHolders = require('./_replaceHolders');
|
||||||
|
|
||||||
|
/** Used as the internal argument placeholder. */
|
||||||
|
var PLACEHOLDER = '__lodash_placeholder__';
|
||||||
|
|
||||||
/** 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 @@ var BIND_FLAG = 1,
|
|||||||
ARY_FLAG = 128,
|
ARY_FLAG = 128,
|
||||||
REARG_FLAG = 256;
|
REARG_FLAG = 256;
|
||||||
|
|
||||||
/** Used as the internal argument placeholder. */
|
|
||||||
var PLACEHOLDER = '__lodash_placeholder__';
|
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeMin = Math.min;
|
var nativeMin = Math.min;
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ function mergeData(data, source) {
|
|||||||
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
|
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
|
||||||
|
|
||||||
var isCombo =
|
var isCombo =
|
||||||
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) ||
|
((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
|
||||||
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
||||||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
||||||
|
|
||||||
// Exit early if metadata can't be merged.
|
// Exit early if metadata can't be merged.
|
||||||
if (!(isCommon || isCombo)) {
|
if (!(isCommon || isCombo)) {
|
||||||
@@ -51,7 +51,7 @@ function mergeData(data, source) {
|
|||||||
if (srcBitmask & BIND_FLAG) {
|
if (srcBitmask & BIND_FLAG) {
|
||||||
data[2] = source[2];
|
data[2] = source[2];
|
||||||
// Set when currying a bound function.
|
// Set when currying a bound function.
|
||||||
newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
|
newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
|
||||||
}
|
}
|
||||||
// Compose partial arguments.
|
// Compose partial arguments.
|
||||||
var value = source[3];
|
var value = source[3];
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ var baseMerge = require('./_baseMerge'),
|
|||||||
*/
|
*/
|
||||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||||
if (isObject(objValue) && isObject(srcValue)) {
|
if (isObject(objValue) && isObject(srcValue)) {
|
||||||
stack.set(srcValue, objValue);
|
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
|
||||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
|
|
||||||
}
|
}
|
||||||
return objValue;
|
return objValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ var PLACEHOLDER = '__lodash_placeholder__';
|
|||||||
function replaceHolders(array, placeholder) {
|
function replaceHolders(array, placeholder) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
resIndex = -1,
|
resIndex = 0,
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if (array[index] === placeholder) {
|
var value = array[index];
|
||||||
|
if (value === placeholder || value === PLACEHOLDER) {
|
||||||
array[index] = PLACEHOLDER;
|
array[index] = PLACEHOLDER;
|
||||||
result[++resIndex] = index;
|
result[resIndex++] = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
41
_root.js
Normal file
41
_root.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
var checkGlobal = require('./_checkGlobal');
|
||||||
|
|
||||||
|
/** Used to determine if values are of the language type `Object`. */
|
||||||
|
var objectTypes = {
|
||||||
|
'function': true,
|
||||||
|
'object': true
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Detect free variable `exports`. */
|
||||||
|
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||||
|
? exports
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
/** Detect free variable `module`. */
|
||||||
|
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||||
|
? module
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
/** Detect free variable `global` from Node.js. */
|
||||||
|
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||||
|
|
||||||
|
/** Detect free variable `self`. */
|
||||||
|
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
||||||
|
|
||||||
|
/** Detect free variable `window`. */
|
||||||
|
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
||||||
|
|
||||||
|
/** Detect `this` as the global object. */
|
||||||
|
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used as a reference to the global object.
|
||||||
|
*
|
||||||
|
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||||
|
* restricted `window` object, otherwise the `window` object is used.
|
||||||
|
*/
|
||||||
|
var root = freeGlobal ||
|
||||||
|
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
|
||||||
|
freeSelf || thisGlobal || Function('return this')();
|
||||||
|
|
||||||
|
module.exports = root;
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
var isArrayLikeObject = require('./isArrayLikeObject');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts `value` to an array-like object if it's not one.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to process.
|
|
||||||
* @returns {Array} Returns the array-like object.
|
|
||||||
*/
|
|
||||||
function toArrayLikeObject(value) {
|
|
||||||
return isArrayLikeObject(value) ? value : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = toArrayLikeObject;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
var identity = require('./identity');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts `value` to a function if it's not one.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to process.
|
|
||||||
* @returns {Function} Returns the function.
|
|
||||||
*/
|
|
||||||
function toFunction(value) {
|
|
||||||
return typeof value == 'function' ? value : identity;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = toFunction;
|
|
||||||
3
add.js
3
add.js
@@ -14,6 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
function add(augend, addend) {
|
function add(augend, addend) {
|
||||||
var result;
|
var result;
|
||||||
|
if (augend === undefined && addend === undefined) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (augend !== undefined) {
|
if (augend !== undefined) {
|
||||||
result = augend;
|
result = augend;
|
||||||
}
|
}
|
||||||
|
|||||||
3
array.js
3
array.js
@@ -12,9 +12,9 @@ module.exports = {
|
|||||||
'fill': require('./fill'),
|
'fill': require('./fill'),
|
||||||
'findIndex': require('./findIndex'),
|
'findIndex': require('./findIndex'),
|
||||||
'findLastIndex': require('./findLastIndex'),
|
'findLastIndex': require('./findLastIndex'),
|
||||||
'flatMap': require('./flatMap'),
|
|
||||||
'flatten': require('./flatten'),
|
'flatten': require('./flatten'),
|
||||||
'flattenDeep': require('./flattenDeep'),
|
'flattenDeep': require('./flattenDeep'),
|
||||||
|
'flattenDepth': require('./flattenDepth'),
|
||||||
'fromPairs': require('./fromPairs'),
|
'fromPairs': require('./fromPairs'),
|
||||||
'head': require('./head'),
|
'head': require('./head'),
|
||||||
'indexOf': require('./indexOf'),
|
'indexOf': require('./indexOf'),
|
||||||
@@ -28,6 +28,7 @@ module.exports = {
|
|||||||
'pull': require('./pull'),
|
'pull': require('./pull'),
|
||||||
'pullAll': require('./pullAll'),
|
'pullAll': require('./pullAll'),
|
||||||
'pullAllBy': require('./pullAllBy'),
|
'pullAllBy': require('./pullAllBy'),
|
||||||
|
'pullAllWith': require('./pullAllWith'),
|
||||||
'pullAt': require('./pullAt'),
|
'pullAt': require('./pullAt'),
|
||||||
'remove': require('./remove'),
|
'remove': require('./remove'),
|
||||||
'reverse': require('./reverse'),
|
'reverse': require('./reverse'),
|
||||||
|
|||||||
27
assign.js
27
assign.js
@@ -1,7 +1,22 @@
|
|||||||
var copyObject = require('./_copyObject'),
|
var assignValue = require('./_assignValue'),
|
||||||
|
copyObject = require('./_copyObject'),
|
||||||
createAssigner = require('./_createAssigner'),
|
createAssigner = require('./_createAssigner'),
|
||||||
|
isArrayLike = require('./isArrayLike'),
|
||||||
|
isPrototype = require('./_isPrototype'),
|
||||||
keys = require('./keys');
|
keys = require('./keys');
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/** Used to check objects for own properties. */
|
||||||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||||
|
|
||||||
|
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||||
|
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns own enumerable properties of source objects to the destination
|
* Assigns own enumerable properties of source objects to the destination
|
||||||
* object. Source objects are applied from left to right. Subsequent sources
|
* object. Source objects are applied from left to right. Subsequent sources
|
||||||
@@ -33,7 +48,15 @@ var copyObject = require('./_copyObject'),
|
|||||||
* // => { 'a': 1, 'c': 3, 'e': 5 }
|
* // => { 'a': 1, 'c': 3, 'e': 5 }
|
||||||
*/
|
*/
|
||||||
var assign = createAssigner(function(object, source) {
|
var assign = createAssigner(function(object, source) {
|
||||||
copyObject(source, keys(source), object);
|
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||||
|
copyObject(source, keys(source), object);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (var key in source) {
|
||||||
|
if (hasOwnProperty.call(source, key)) {
|
||||||
|
assignValue(object, key, source[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = assign;
|
module.exports = assign;
|
||||||
|
|||||||
22
assignIn.js
22
assignIn.js
@@ -1,7 +1,19 @@
|
|||||||
var copyObject = require('./_copyObject'),
|
var assignValue = require('./_assignValue'),
|
||||||
|
copyObject = require('./_copyObject'),
|
||||||
createAssigner = require('./_createAssigner'),
|
createAssigner = require('./_createAssigner'),
|
||||||
|
isArrayLike = require('./isArrayLike'),
|
||||||
|
isPrototype = require('./_isPrototype'),
|
||||||
keysIn = require('./keysIn');
|
keysIn = require('./keysIn');
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||||
|
|
||||||
|
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||||
|
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.assign` except that it iterates over own and
|
* This method is like `_.assign` except that it iterates over own and
|
||||||
* inherited source properties.
|
* inherited source properties.
|
||||||
@@ -32,7 +44,13 @@ var copyObject = require('./_copyObject'),
|
|||||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
|
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
|
||||||
*/
|
*/
|
||||||
var assignIn = createAssigner(function(object, source) {
|
var assignIn = createAssigner(function(object, source) {
|
||||||
copyObject(source, keysIn(source), object);
|
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||||
|
copyObject(source, keysIn(source), object);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (var key in source) {
|
||||||
|
assignValue(object, key, source[key]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = assignIn;
|
module.exports = assignIn;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user