Compare commits

...

9 Commits

Author SHA1 Message Date
John-David Dalton
ddf9328c67 Bump to v4.6.0. 2016-03-01 19:18:30 -08:00
John-David Dalton
7eeb5ebd61 Bump to v4.5.1. 2016-02-21 21:12:51 -08:00
John-David Dalton
0dd6798d8b Bump to v4.5.0. 2016-02-16 23:28:06 -08:00
John-David Dalton
91d3468c81 Bump to v4.4.0. 2016-02-15 23:05:17 -08:00
John-David Dalton
e2aef0def9 Bump to v4.3.0. 2016-02-08 00:43:24 -08:00
John-David Dalton
bd7f722175 Bulk update. 2016-02-03 23:26:07 -08:00
John-David Dalton
d8bc95999f Bump to v4.2.1. 2016-02-03 01:09:45 -08:00
John-David Dalton
24a4285b70 Bump to v4.2.0. 2016-02-02 00:06:39 -08:00
John-David Dalton
bbd78fee4d Bump to v4.1.0. 2016-01-29 08:30:29 -08:00
854 changed files with 5088 additions and 2775 deletions

33
LICENSE
View File

@@ -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.

View File

@@ -1,13 +1,7 @@
# lodash v4.0.1 # lodash v4.6.0
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.
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
```bash
$ lodash modularize exports=node -o ./
$ lodash -d -o ./lodash.js
```
## Installation ## Installation
Using npm: Using npm:
@@ -18,41 +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 // 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');
// or a method (great for smaller builds with browserify/webpack) var object = require('lodash/fp/object');
// 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');
``` ```
See the [package source](https://github.com/lodash/lodash/tree/4.0.1-npm) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.6.0-npm) for more details.
**Note:**<br> **Note:**<br>
Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br> Dont 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)
## 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.x, 0.12.x, 4.x, & 5.x, & 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.

View File

@@ -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() {}

View File

@@ -1,5 +1,5 @@
var baseCreate = require('./baseCreate'), var baseCreate = require('./_baseCreate'),
baseLodash = require('./baseLodash'); baseLodash = require('./_baseLodash');
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295; var MAX_ARRAY_LENGTH = 4294967295;
@@ -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) {

View File

@@ -1,5 +1,5 @@
var baseCreate = require('./baseCreate'), var baseCreate = require('./_baseCreate'),
baseLodash = require('./baseLodash'); baseLodash = require('./_baseLodash');
/** /**
* The base constructor for creating `lodash` wrapper objects. * The base constructor for creating `lodash` wrapper objects.

7
_Map.js Normal file
View File

@@ -0,0 +1,7 @@
var getNative = require('./_getNative'),
root = require('./_root');
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map');
module.exports = Map;

View File

@@ -1,13 +1,14 @@
var mapClear = require('./mapClear'), var mapClear = require('./_mapClear'),
mapDelete = require('./mapDelete'), mapDelete = require('./_mapDelete'),
mapGet = require('./mapGet'), mapGet = require('./_mapGet'),
mapHas = require('./mapHas'), mapHas = require('./_mapHas'),
mapSet = require('./mapSet'); mapSet = require('./_mapSet');
/** /**
* Creates a map cache object to store key-value pairs. * Creates a map cache object to store key-value pairs.
* *
* @private * @private
* @constructor
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
function MapCache(values) { function MapCache(values) {

View File

@@ -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;

7
_Set.js Normal file
View File

@@ -0,0 +1,7 @@
var getNative = require('./_getNative'),
root = require('./_root');
/* Built-in method references that are verified to be native. */
var Set = getNative(root, 'Set');
module.exports = Set;

View File

@@ -1,11 +1,12 @@
var MapCache = require('./MapCache'), var MapCache = require('./_MapCache'),
cachePush = require('./cachePush'); cachePush = require('./_cachePush');
/** /**
* *
* Creates a set cache object to store unique values. * Creates a set cache object to store unique values.
* *
* @private * @private
* @constructor
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
function SetCache(values) { function SetCache(values) {

View File

@@ -1,13 +1,14 @@
var stackClear = require('./stackClear'), var stackClear = require('./_stackClear'),
stackDelete = require('./stackDelete'), stackDelete = require('./_stackDelete'),
stackGet = require('./stackGet'), stackGet = require('./_stackGet'),
stackHas = require('./stackHas'), stackHas = require('./_stackHas'),
stackSet = require('./stackSet'); stackSet = require('./_stackSet');
/** /**
* Creates a stack cache object to store key-value pairs. * Creates a stack cache object to store key-value pairs.
* *
* @private * @private
* @constructor
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
function Stack(values) { function Stack(values) {

View File

@@ -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;

6
_Uint8Array.js Normal file
View File

@@ -0,0 +1,6 @@
var root = require('./_root');
/** Built-in value references. */
var Uint8Array = root.Uint8Array;
module.exports = Uint8Array;

7
_WeakMap.js Normal file
View File

@@ -0,0 +1,7 @@
var getNative = require('./_getNative'),
root = require('./_root');
/* Built-in method references that are verified to be native. */
var WeakMap = getNative(root, 'WeakMap');
module.exports = WeakMap;

View File

@@ -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;
} }

View File

@@ -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]);

22
_arrayAggregator.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
module.exports = arrayAggregator;

View File

@@ -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;

View File

@@ -1,4 +1,4 @@
var baseIndexOf = require('./baseIndexOf'); var baseIndexOf = require('./_baseIndexOf');
/** /**
* A specialized version of `_.includes` for arrays without support for * A specialized version of `_.includes` for arrays without support for

View File

@@ -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.

View File

@@ -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;

View File

@@ -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.

View File

@@ -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;
} }

View File

@@ -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;

View File

@@ -1,4 +1,4 @@
var assocIndexOf = require('./assocIndexOf'); var assocIndexOf = require('./_assocIndexOf');
/** /**
* Gets the associative array value for `key`. * Gets the associative array value for `key`.

View File

@@ -1,4 +1,4 @@
var assocIndexOf = require('./assocIndexOf'); var assocIndexOf = require('./_assocIndexOf');
/** /**
* Checks if an associative array value for `key` exists. * Checks if an associative array value for `key` exists.

View File

@@ -1,4 +1,4 @@
var eq = require('../eq'); var eq = require('./eq');
/** /**
* Gets the index at which the first occurrence of `key` is found in `array` * Gets the index at which the first occurrence of `key` is found in `array`

View File

@@ -1,4 +1,4 @@
var assocIndexOf = require('./assocIndexOf'); var assocIndexOf = require('./_assocIndexOf');
/** /**
* Sets the associative array `key` to `value`. * Sets the associative array `key` to `value`.

21
_baseAggregator.js Normal file
View File

@@ -0,0 +1,21 @@
var baseEach = require('./_baseEach');
/**
* Aggregates elements of `collection` on `accumulator` with keys transformed
* by `iteratee` and values set by `setter`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function baseAggregator(collection, setter, iteratee, accumulator) {
baseEach(collection, function(value, key, collection) {
setter(accumulator, value, iteratee(value), collection);
});
return accumulator;
}
module.exports = baseAggregator;

View File

@@ -1,5 +1,5 @@
var copyObject = require('./copyObject'), var copyObject = require('./_copyObject'),
keys = require('../keys'); keys = require('./keys');
/** /**
* The base implementation of `_.assign` without support for multiple sources * The base implementation of `_.assign` without support for multiple sources

View File

@@ -1,4 +1,4 @@
var get = require('../get'); var get = require('./get');
/** /**
* The base implementation of `_.at` without support for individual paths. * The base implementation of `_.at` without support for individual paths.

View 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
View 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
View 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;

View File

@@ -1,17 +1,19 @@
var Stack = require('./Stack'), var Stack = require('./_Stack'),
arrayEach = require('./arrayEach'), arrayEach = require('./_arrayEach'),
assignValue = require('./assignValue'), assignValue = require('./_assignValue'),
baseAssign = require('./baseAssign'), baseAssign = require('./_baseAssign'),
baseForOwn = require('./baseForOwn'), baseForOwn = require('./_baseForOwn'),
copyArray = require('./copyArray'), cloneBuffer = require('./_cloneBuffer'),
copySymbols = require('./copySymbols'), copyArray = require('./_copyArray'),
getTag = require('./getTag'), copySymbols = require('./_copySymbols'),
initCloneArray = require('./initCloneArray'), getTag = require('./_getTag'),
initCloneByTag = require('./initCloneByTag'), initCloneArray = require('./_initCloneArray'),
initCloneObject = require('./initCloneObject'), initCloneByTag = require('./_initCloneByTag'),
isArray = require('../isArray'), initCloneObject = require('./_initCloneObject'),
isHostObject = require('./isHostObject'), isArray = require('./isArray'),
isObject = require('../isObject'); isBuffer = require('./isBuffer'),
isHostObject = require('./_isHostObject'),
isObject = require('./isObject');
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var argsTag = '[object Arguments]', var argsTag = '[object Arguments]',
@@ -91,6 +93,9 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
var tag = getTag(value), var tag = getTag(value),
isFunc = tag == funcTag || tag == genTag; isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) {
return cloneBuffer(value, isDeep);
}
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
if (isHostObject(value)) { if (isHostObject(value)) {
return object ? value : {}; return object ? value : {};
@@ -100,9 +105,10 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
return copySymbols(value, baseAssign(result, value)); return copySymbols(value, baseAssign(result, value));
} }
} else { } else {
return cloneableTags[tag] if (!cloneableTags[tag]) {
? initCloneByTag(value, tag, isDeep) return object ? value : {};
: (object ? value : {}); }
result = initCloneByTag(value, tag, isDeep);
} }
} }
// Check for circular references and return its corresponding clone. // Check for circular references and return its corresponding clone.

View File

@@ -1,4 +1,4 @@
var keys = require('../keys'); var keys = require('./keys');
/** /**
* The base implementation of `_.conforms` which doesn't clone `source`. * The base implementation of `_.conforms` which doesn't clone `source`.

18
_baseCreate.js Normal file
View File

@@ -0,0 +1,18 @@
var isObject = require('./isObject');
/** Built-in value references. */
var objectCreate = Object.create;
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
function baseCreate(proto) {
return isObject(proto) ? objectCreate(proto) : {};
}
module.exports = baseCreate;

View File

@@ -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) {

View File

@@ -1,9 +1,9 @@
var SetCache = require('./SetCache'), var SetCache = require('./_SetCache'),
arrayIncludes = require('./arrayIncludes'), arrayIncludes = require('./_arrayIncludes'),
arrayIncludesWith = require('./arrayIncludesWith'), arrayIncludesWith = require('./_arrayIncludesWith'),
arrayMap = require('./arrayMap'), arrayMap = require('./_arrayMap'),
baseUnary = require('./baseUnary'), baseUnary = require('./_baseUnary'),
cacheHas = require('./cacheHas'); cacheHas = require('./_cacheHas');
/** 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;

View File

@@ -1,5 +1,5 @@
var baseForOwn = require('./baseForOwn'), var baseForOwn = require('./_baseForOwn'),
createBaseEach = require('./createBaseEach'); createBaseEach = require('./_createBaseEach');
/** /**
* The base implementation of `_.forEach` without support for iteratee shorthands. * The base implementation of `_.forEach` without support for iteratee shorthands.

View File

@@ -1,5 +1,5 @@
var baseForOwnRight = require('./baseForOwnRight'), var baseForOwnRight = require('./_baseForOwnRight'),
createBaseEach = require('./createBaseEach'); createBaseEach = require('./_createBaseEach');
/** /**
* The base implementation of `_.forEachRight` without support for iteratee shorthands. * The base implementation of `_.forEachRight` without support for iteratee shorthands.

View File

@@ -1,4 +1,4 @@
var baseEach = require('./baseEach'); var baseEach = require('./_baseEach');
/** /**
* The base implementation of `_.every` without support for iteratee shorthands. * The base implementation of `_.every` without support for iteratee shorthands.

View File

@@ -1,5 +1,5 @@
var toInteger = require('../toInteger'), var toInteger = require('./toInteger'),
toLength = require('../toLength'); toLength = require('./toLength');
/** /**
* The base implementation of `_.fill` without an iteratee call guard. * The base implementation of `_.fill` without an iteratee call guard.

View File

@@ -1,4 +1,4 @@
var baseEach = require('./baseEach'); var baseEach = require('./_baseEach');
/** /**
* The base implementation of `_.filter` without support for iteratee shorthands. * The base implementation of `_.filter` without support for iteratee shorthands.

View File

@@ -1,19 +1,19 @@
var arrayPush = require('./arrayPush'), var arrayPush = require('./_arrayPush'),
isArguments = require('../isArguments'), isArguments = require('./isArguments'),
isArray = require('../isArray'), isArray = require('./isArray'),
isArrayLikeObject = require('../isArrayLikeObject'); isArrayLikeObject = require('./isArrayLikeObject');
/** /**
* The base implementation of `_.flatten` with support for restricting flattening. * The base implementation of `_.flatten` with support for restricting flattening.
* *
* @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);
} }

View File

@@ -1,4 +1,4 @@
var createBaseFor = require('./createBaseFor'); var createBaseFor = require('./_createBaseFor');
/** /**
* The base implementation of `baseForIn` and `baseForOwn` which iterates * The base implementation of `baseForIn` and `baseForOwn` which iterates

View File

@@ -1,5 +1,5 @@
var baseFor = require('./baseFor'), var baseFor = require('./_baseFor'),
keysIn = require('../keysIn'); keysIn = require('./keysIn');
/** /**
* The base implementation of `_.forIn` without support for iteratee shorthands. * The base implementation of `_.forIn` without support for iteratee shorthands.

View File

@@ -1,5 +1,5 @@
var baseFor = require('./baseFor'), var baseFor = require('./_baseFor'),
keys = require('../keys'); keys = require('./keys');
/** /**
* The base implementation of `_.forOwn` without support for iteratee shorthands. * The base implementation of `_.forOwn` without support for iteratee shorthands.

View File

@@ -1,5 +1,5 @@
var baseForRight = require('./baseForRight'), var baseForRight = require('./_baseForRight'),
keys = require('../keys'); keys = require('./keys');
/** /**
* The base implementation of `_.forOwnRight` without support for iteratee shorthands. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.

View File

@@ -1,4 +1,4 @@
var createBaseFor = require('./createBaseFor'); var createBaseFor = require('./_createBaseFor');
/** /**
* This function is like `baseFor` except that it iterates over properties * This function is like `baseFor` except that it iterates over properties

View File

@@ -1,9 +1,9 @@
var arrayFilter = require('./arrayFilter'), var arrayFilter = require('./_arrayFilter'),
isFunction = require('../isFunction'); isFunction = require('./isFunction');
/** /**
* The base implementation of `_.functions` which creates an array of * The base implementation of `_.functions` which creates an array of
* `object` function property names filtered from those provided. * `object` function property names filtered from `props`.
* *
* @private * @private
* @param {Object} object The object to inspect. * @param {Object} object The object to inspect.

View File

@@ -1,5 +1,5 @@
var baseToPath = require('./baseToPath'), var baseCastPath = require('./_baseCastPath'),
isKey = require('./isKey'); isKey = require('./_isKey');
/** /**
* The base implementation of `_.get` without support for default values. * The base implementation of `_.get` without support for default values.
@@ -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;

View File

@@ -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;

View File

@@ -1,4 +1,4 @@
var indexOfNaN = require('./indexOfNaN'); var indexOfNaN = require('./_indexOfNaN');
/** /**
* The base implementation of `_.indexOf` without `fromIndex` bounds checks. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.

23
_baseIndexOfWith.js Normal file
View 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;

View File

@@ -1,9 +1,12 @@
var SetCache = require('./SetCache'), var SetCache = require('./_SetCache'),
arrayIncludes = require('./arrayIncludes'), arrayIncludes = require('./_arrayIncludes'),
arrayIncludesWith = require('./arrayIncludesWith'), arrayIncludesWith = require('./_arrayIncludesWith'),
arrayMap = require('./arrayMap'), arrayMap = require('./_arrayMap'),
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
@@ -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;
} }
} }

21
_baseInverter.js Normal file
View File

@@ -0,0 +1,21 @@
var baseForOwn = require('./_baseForOwn');
/**
* The base implementation of `_.invert` and `_.invertBy` which inverts
* `object` with values transformed by `iteratee` and set by `setter`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform values.
* @param {Object} accumulator The initial inverted object.
* @returns {Function} Returns `accumulator`.
*/
function baseInverter(object, setter, iteratee, accumulator) {
baseForOwn(object, function(value, key, object) {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
}
module.exports = baseInverter;

View File

@@ -1,8 +1,8 @@
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');
/** /**
* The base implementation of `_.invoke` without support for individual * The base implementation of `_.invoke` without support for individual
@@ -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);
} }

View File

@@ -1,6 +1,6 @@
var baseIsEqualDeep = require('./baseIsEqualDeep'), var baseIsEqualDeep = require('./_baseIsEqualDeep'),
isObject = require('../isObject'), isObject = require('./isObject'),
isObjectLike = require('../isObjectLike'); isObjectLike = require('./isObjectLike');
/** /**
* The base implementation of `_.isEqual` which supports partial comparisons * The base implementation of `_.isEqual` which supports partial comparisons

View File

@@ -1,11 +1,11 @@
var Stack = require('./Stack'), var Stack = require('./_Stack'),
equalArrays = require('./equalArrays'), equalArrays = require('./_equalArrays'),
equalByTag = require('./equalByTag'), equalByTag = require('./_equalByTag'),
equalObjects = require('./equalObjects'), equalObjects = require('./_equalObjects'),
getTag = require('./getTag'), getTag = require('./_getTag'),
isArray = require('../isArray'), isArray = require('./isArray'),
isHostObject = require('./isHostObject'), isHostObject = require('./_isHostObject'),
isTypedArray = require('../isTypedArray'); isTypedArray = require('./isTypedArray');
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var PARTIAL_COMPARE_FLAG = 2; var PARTIAL_COMPARE_FLAG = 2;
@@ -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;

View File

@@ -1,5 +1,5 @@
var Stack = require('./Stack'), var Stack = require('./_Stack'),
baseIsEqual = require('./baseIsEqual'); baseIsEqual = require('./_baseIsEqual');
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1, var UNORDERED_COMPARE_FLAG = 1,

View File

@@ -1,8 +1,8 @@
var baseMatches = require('./baseMatches'), var baseMatches = require('./_baseMatches'),
baseMatchesProperty = require('./baseMatchesProperty'), baseMatchesProperty = require('./_baseMatchesProperty'),
identity = require('../identity'), identity = require('./identity'),
isArray = require('../isArray'), isArray = require('./isArray'),
property = require('../property'); property = require('./property');
/** /**
* The base implementation of `_.iteratee`. * The base implementation of `_.iteratee`.

View File

@@ -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.
*/ */

View File

@@ -1,8 +1,8 @@
var Reflect = require('./Reflect'), 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,

View File

@@ -1,5 +1,5 @@
var baseEach = require('./baseEach'), var baseEach = require('./_baseEach'),
isArrayLike = require('../isArrayLike'); isArrayLike = require('./isArrayLike');
/** /**
* The base implementation of `_.map` without support for iteratee shorthands. * The base implementation of `_.map` without support for iteratee shorthands.

View File

@@ -1,5 +1,5 @@
var baseIsMatch = require('./baseIsMatch'), var baseIsMatch = require('./_baseIsMatch'),
getMatchData = require('./getMatchData'); getMatchData = require('./_getMatchData');
/** /**
* The base implementation of `_.matches` which doesn't clone `source`. * The base implementation of `_.matches` which doesn't clone `source`.

View File

@@ -1,6 +1,6 @@
var baseIsEqual = require('./baseIsEqual'), var baseIsEqual = require('./_baseIsEqual'),
get = require('../get'), get = require('./get'),
hasIn = require('../hasIn'); hasIn = require('./hasIn');
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1, var UNORDERED_COMPARE_FLAG = 1,

View File

@@ -1,11 +1,11 @@
var Stack = require('./Stack'), var Stack = require('./_Stack'),
arrayEach = require('./arrayEach'), arrayEach = require('./_arrayEach'),
assignMergeValue = require('./assignMergeValue'), assignMergeValue = require('./_assignMergeValue'),
baseMergeDeep = require('./baseMergeDeep'), baseMergeDeep = require('./_baseMergeDeep'),
isArray = require('../isArray'), isArray = require('./isArray'),
isObject = require('../isObject'), isObject = require('./isObject'),
isTypedArray = require('../isTypedArray'), isTypedArray = require('./isTypedArray'),
keysIn = require('../keysIn'); keysIn = require('./keysIn');
/** /**
* The base implementation of `_.merge` without support for multiple sources. * The base implementation of `_.merge` without support for multiple sources.
@@ -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;
} }

View File

@@ -1,14 +1,14 @@
var assignMergeValue = require('./assignMergeValue'), var assignMergeValue = require('./_assignMergeValue'),
baseClone = require('./baseClone'), baseClone = require('./_baseClone'),
copyArray = require('./copyArray'), copyArray = require('./_copyArray'),
isArguments = require('../isArguments'), isArguments = require('./isArguments'),
isArray = require('../isArray'), isArray = require('./isArray'),
isArrayLikeObject = require('../isArrayLikeObject'), isArrayLikeObject = require('./isArrayLikeObject'),
isFunction = require('../isFunction'), isFunction = require('./isFunction'),
isObject = require('../isObject'), isObject = require('./isObject'),
isPlainObject = require('../isPlainObject'), isPlainObject = require('./isPlainObject'),
isTypedArray = require('../isTypedArray'), isTypedArray = require('./isTypedArray'),
toPlainObject = require('../toPlainObject'); toPlainObject = require('./toPlainObject');
/** /**
* A specialized version of `baseMerge` for arrays and objects which performs * A specialized version of `baseMerge` for arrays and objects which performs
@@ -27,26 +27,30 @@ var assignMergeValue = require('./assignMergeValue'),
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = object[key], var objValue = object[key],
srcValue = source[key], srcValue = source[key],
stacked = stack.get(srcValue) || stack.get(objValue); stacked = stack.get(srcValue);
if (stacked) { if (stacked) {
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 {
newValue = baseClone(srcValue); isCommon = false;
newValue = baseClone(srcValue, !customizer);
} }
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -54,10 +58,11 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
newValue = toPlainObject(objValue); newValue = toPlainObject(objValue);
} }
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
newValue = baseClone(srcValue); isCommon = false;
newValue = baseClone(srcValue, !customizer);
} }
else { else {
newValue = srcIndex ? baseClone(objValue) : objValue; newValue = objValue;
} }
} }
else { else {
@@ -70,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);
} }

View File

@@ -1,8 +1,8 @@
var arrayMap = require('./arrayMap'), var arrayMap = require('./_arrayMap'),
baseIteratee = require('./baseIteratee'), baseIteratee = require('./_baseIteratee'),
baseMap = require('./baseMap'), baseMap = require('./_baseMap'),
baseSortBy = require('./baseSortBy'), baseSortBy = require('./_baseSortBy'),
compareMultiple = require('./compareMultiple'); compareMultiple = require('./_compareMultiple');
/** /**
* The base implementation of `_.orderBy` without param guards. * The base implementation of `_.orderBy` without param guards.
@@ -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) {

View File

@@ -1,4 +1,4 @@
var arrayReduce = require('./arrayReduce'); var arrayReduce = require('./_arrayReduce');
/** /**
* The base implementation of `_.pick` without support for individual * The base implementation of `_.pick` without support for individual

View File

@@ -1,4 +1,4 @@
var baseForIn = require('./baseForIn'); var baseForIn = require('./_baseForIn');
/** /**
* The base implementation of `_.pickBy` without support for iteratee shorthands. * The base implementation of `_.pickBy` without support for iteratee shorthands.

View File

@@ -1,4 +1,4 @@
var baseGet = require('./baseGet'); var baseGet = require('./_baseGet');
/** /**
* A specialized version of `baseProperty` which supports deep paths. * A specialized version of `baseProperty` which supports deep paths.

View File

@@ -1,8 +1,10 @@
var arrayMap = require('./arrayMap'), var arrayMap = require('./_arrayMap'),
baseIndexOf = require('./baseIndexOf'); baseIndexOf = require('./_baseIndexOf'),
baseIndexOfWith = require('./_baseIndexOfWith'),
baseUnary = require('./_baseUnary');
/** 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;
@@ -15,22 +17,24 @@ var splice = arrayProto.splice;
* @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} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function basePullAllBy(array, values, iteratee) { function basePullAll(array, values, iteratee, comparator) {
var index = -1, var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
index = -1,
length = values.length, length = values.length,
seen = array; seen = array;
if (iteratee) { if (iteratee) {
seen = arrayMap(array, function(value) { return iteratee(value); }); seen = arrayMap(array, baseUnary(iteratee));
} }
while (++index < length) { while (++index < length) {
var fromIndex = 0, var fromIndex = 0,
value = values[index], value = values[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) { while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) { if (seen !== array) {
splice.call(seen, fromIndex, 1); splice.call(seen, fromIndex, 1);
} }
@@ -40,4 +44,4 @@ function basePullAllBy(array, values, iteratee) {
return array; return array;
} }
module.exports = basePullAllBy; module.exports = basePullAll;

View File

@@ -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) {

View File

@@ -1,8 +1,8 @@
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');
/** /**
* The base implementation of `_.set`. * The base implementation of `_.set`.
@@ -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);

View File

@@ -1,5 +1,5 @@
var identity = require('../identity'), var identity = require('./identity'),
metaMap = require('./metaMap'); metaMap = require('./_metaMap');
/** /**
* The base implementation of `setData` without support for hot loop detection. * The base implementation of `setData` without support for hot loop detection.

View File

@@ -1,4 +1,4 @@
var baseEach = require('./baseEach'); var baseEach = require('./_baseEach');
/** /**
* The base implementation of `_.some` without support for iteratee shorthands. * The base implementation of `_.some` without support for iteratee shorthands.

Some files were not shown because too many files have changed in this diff Show More