Compare commits

..

17 Commits

Author SHA1 Message Date
John-David Dalton
ddde027fd9 Bump to v4.11.2. 2016-04-21 07:09:17 -07:00
John-David Dalton
e93cb815c3 Bump to v4.11.1. 2016-04-13 21:06:51 -07:00
John-David Dalton
63ba93dcb3 Bump to v4.11.0. 2016-04-13 10:23:46 -07:00
John-David Dalton
be0bf2681b Bump to v4.10.0. 2016-04-10 23:01:56 -07:00
John-David Dalton
7d39d58e43 Bump to v4.9.0. 2016-04-08 01:35:02 -07:00
John-David Dalton
7c17af79c7 Bump to v4.8.2. 2016-04-04 14:31:04 -07:00
John-David Dalton
3f407aa255 Bump to v4.8.1. 2016-04-04 14:30:27 -07:00
John-David Dalton
ee6ec2f672 Bump to v4.8.0. 2016-04-04 14:22:57 -07:00
John-David Dalton
18d0f1d873 Bump to v4.7.0. 2016-03-31 08:47:39 -07:00
John-David Dalton
501d6b1d41 Bump to v4.6.1. 2016-03-01 22:17:42 -08:00
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
804 changed files with 9710 additions and 4403 deletions

29
LICENSE
View File

@@ -1,7 +1,17 @@
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> Copyright jQuery Foundation and other contributors <https://jquery.org/>
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
Based on Underscore.js, copyright Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/lodash/lodash
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including "Software"), to deal in the Software without restriction, including
@@ -20,3 +30,18 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code displayed within the prose of the
documentation.
CC0: http://creativecommons.org/publicdomain/zero/1.0/
====
Files located in the node_modules and vendor directories are externally
maintained libraries used by this software which have their own
licenses; we recommend you read them, as their terms may differ from the
terms above.

View File

@@ -1,6 +1,6 @@
# lodash v4.2.0 # lodash v4.11.2
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.
## Installation ## Installation
@@ -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 fp = 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.2.0-npm) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.11.2-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 available in a variety of other builds & module formats.
* [lodash](https://www.npmjs.com/package/lodash) & [per method packages](https://www.npmjs.com/browse/keyword/lodash-modularized)
* [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 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. Tested in Chrome 48-49, Firefox 44-45, 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.

7
_DataView.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 DataView = getNative(root, 'DataView');
module.exports = DataView;

View File

@@ -4,9 +4,10 @@ var nativeCreate = require('./_nativeCreate');
var objectProto = Object.prototype; var objectProto = Object.prototype;
/** /**
* Creates an hash object. * Creates a 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

@@ -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) {
@@ -20,6 +21,7 @@ function LazyWrapper(value) {
this.__views__ = []; this.__views__ = [];
} }
// Ensure `LazyWrapper` is an instance of `baseLodash`.
LazyWrapper.prototype = baseCreate(baseLodash.prototype); LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper; LazyWrapper.prototype.constructor = LazyWrapper;

View File

@@ -6,7 +6,7 @@ var baseCreate = require('./_baseCreate'),
* *
* @private * @private
* @param {*} value The value to wrap. * @param {*} value The value to wrap.
* @param {boolean} [chainAll] Enable chaining for all wrapper methods. * @param {boolean} [chainAll] Enable explicit method chain sequences.
*/ */
function LodashWrapper(value, chainAll) { function LodashWrapper(value, chainAll) {
this.__wrapped__ = value; this.__wrapped__ = value;

View File

@@ -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) {
@@ -21,7 +22,7 @@ function MapCache(values) {
} }
} }
// Add functions to the `MapCache`. // Add methods to `MapCache`.
MapCache.prototype.clear = mapClear; MapCache.prototype.clear = mapClear;
MapCache.prototype['delete'] = mapDelete; MapCache.prototype['delete'] = mapDelete;
MapCache.prototype.get = mapGet; MapCache.prototype.get = mapGet;

7
_Promise.js Normal file
View File

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

View File

@@ -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) {
@@ -18,7 +19,7 @@ function SetCache(values) {
} }
} }
// Add functions to the `SetCache`. // Add methods to `SetCache`.
SetCache.prototype.push = cachePush; SetCache.prototype.push = cachePush;
module.exports = SetCache; module.exports = SetCache;

View File

@@ -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) {
@@ -21,7 +22,7 @@ function Stack(values) {
} }
} }
// Add functions to the `Stack` cache. // Add methods to `Stack`.
Stack.prototype.clear = stackClear; Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete; Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet; Stack.prototype.get = stackGet;

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,7 +5,7 @@
* @private * @private
* @param {Function} func The function to invoke. * @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`. * @param {*} thisArg The `this` binding of `func`.
* @param {...*} args The arguments to invoke `func` with. * @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`. * @returns {*} Returns the result of `func`.
*/ */
function apply(func, thisArg, args) { function apply(func, thisArg, args) {

View File

@@ -5,7 +5,8 @@
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} array The array to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. * @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
*/ */
function arrayEvery(array, predicate) { function arrayEvery(array, predicate) {
var index = -1, var index = -1,

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,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

@@ -6,7 +6,8 @@
* @param {Array} array The array to iterate over. * @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value. * @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as the initial value. * @param {boolean} [initAccum] Specify using the first element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value. * @returns {*} Returns the accumulated value.
*/ */
function arrayReduce(array, iteratee, accumulator, initAccum) { function arrayReduce(array, iteratee, accumulator, initAccum) {

View File

@@ -6,7 +6,8 @@
* @param {Array} array The array to iterate over. * @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value. * @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the last element of `array` as the initial value. * @param {boolean} [initAccum] Specify using the last element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value. * @returns {*} Returns the accumulated value.
*/ */
function arrayReduceRight(array, iteratee, accumulator, initAccum) { function arrayReduceRight(array, iteratee, accumulator, initAccum) {

View File

@@ -5,7 +5,8 @@
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} array The array to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. * @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/ */
function arraySome(array, predicate) { function arraySome(array, predicate) {
var index = -1, var index = -1,

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

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

@@ -10,7 +10,7 @@ var splice = arrayProto.splice;
* Removes `key` and its value from the associative array. * Removes `key` and its value from the associative array.
* *
* @private * @private
* @param {Array} array The array to query. * @param {Array} array The array to modify.
* @param {string} key The key of the value to remove. * @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */

View File

@@ -1,8 +1,7 @@
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 `key` is found in `array` of key-value pairs.
* of key-value pairs.
* *
* @private * @private
* @param {Array} array The array to search. * @param {Array} array The array to search.

View File

@@ -2,16 +2,19 @@ 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'), cloneBuffer = require('./_cloneBuffer'),
copyArray = require('./_copyArray'), copyArray = require('./_copyArray'),
copySymbols = require('./_copySymbols'), copySymbols = require('./_copySymbols'),
getAllKeys = require('./_getAllKeys'),
getTag = require('./_getTag'), getTag = require('./_getTag'),
initCloneArray = require('./_initCloneArray'), initCloneArray = require('./_initCloneArray'),
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'),
keys = require('./keys');
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var argsTag = '[object Arguments]', var argsTag = '[object Arguments]',
@@ -31,6 +34,7 @@ var argsTag = '[object Arguments]',
weakMapTag = '[object WeakMap]'; weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]', var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]',
float32Tag = '[object Float32Array]', float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]', float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]', int8Tag = '[object Int8Array]',
@@ -44,16 +48,16 @@ var arrayBufferTag = '[object ArrayBuffer]',
/** Used to identify `toStringTag` values supported by `_.clone`. */ /** Used to identify `toStringTag` values supported by `_.clone`. */
var cloneableTags = {}; var cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[argsTag] = cloneableTags[arrayTag] =
cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[boolTag] = cloneableTags[dateTag] =
cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] =
cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] =
cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[int32Tag] = cloneableTags[mapTag] =
cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[numberTag] = cloneableTags[objectTag] =
cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[regexpTag] = cloneableTags[setTag] =
cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[stringTag] = cloneableTags[symbolTag] =
cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
cloneableTags[uint32Tag] = true; cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[errorTag] = cloneableTags[funcTag] =
cloneableTags[weakMapTag] = false; cloneableTags[weakMapTag] = false;
@@ -64,13 +68,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,6 +96,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 +108,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, baseClone, isDeep);
} }
} }
// Check for circular references and return its corresponding clone. // Check for circular references and return its corresponding clone.
@@ -113,11 +122,18 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
} }
stack.set(value, result); stack.set(value, result);
if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value);
}
// Recursively populate clone (susceptible to call stack limits). // Recursively populate clone (susceptible to call stack limits).
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { arrayEach(props || value, function(subValue, key) {
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack)); if (props) {
key = subValue;
subValue = value[key];
}
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
}); });
return isArr ? result : copySymbols(value, result); return result;
} }
module.exports = baseClone; module.exports = baseClone;

View File

@@ -21,7 +21,8 @@ function baseConforms(source) {
predicate = source[key], predicate = source[key],
value = object[key]; value = object[key];
if ((value === undefined && !(key in Object(object))) || !predicate(value)) { if ((value === undefined &&
!(key in Object(object))) || !predicate(value)) {
return false; return false;
} }
} }

View File

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

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

@@ -9,8 +9,8 @@ var SetCache = require('./_SetCache'),
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
/** /**
* The base implementation of methods like `_.difference` without support for * The base implementation of methods like `_.difference` without support
* excluding multiple arrays or iteratee shorthands. * for excluding multiple arrays or iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to inspect. * @param {Array} array The array to inspect.
@@ -47,6 +47,7 @@ function baseDifference(array, values, iteratee, comparator) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) { if (isCommon && computed === computed) {
var valuesIndex = valuesLength; var valuesIndex = valuesLength;
while (valuesIndex--) { while (valuesIndex--) {

View File

@@ -6,7 +6,8 @@ var baseEach = require('./_baseEach');
* @private * @private
* @param {Array|Object} collection The collection to iterate over. * @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check, else `false` * @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`
*/ */
function baseEvery(collection, predicate) { function baseEvery(collection, predicate) {
var result = true; var result = true;

View File

@@ -1,3 +1,5 @@
var isSymbol = require('./isSymbol');
/** /**
* The base implementation of methods like `_.max` and `_.min` which accepts a * The base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value. * `comparator` to determine the extremum value.
@@ -17,7 +19,7 @@ function baseExtremum(array, iteratee, comparator) {
current = iteratee(value); current = iteratee(value);
if (current != null && (computed === undefined if (current != null && (computed === undefined
? current === current ? (current === current && !isSymbol(current))
: comparator(current, computed) : comparator(current, computed)
)) { )) {
var computed = current, var computed = current,

View File

@@ -7,7 +7,8 @@
* @param {Array|Object} collection The collection to search. * @param {Array|Object} collection The collection to search.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @param {Function} eachFunc The function to iterate over `collection`. * @param {Function} eachFunc The function to iterate over `collection`.
* @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself. * @param {boolean} [retKey] Specify returning the key of the found element
* instead of the element itself.
* @returns {*} Returns the found element or its key, else `undefined`. * @returns {*} Returns the found element or its key, else `undefined`.
*/ */
function baseFind(collection, predicate, eachFunc, retKey) { function baseFind(collection, predicate, eachFunc, retKey) {

View File

@@ -1,31 +1,30 @@
var arrayPush = require('./_arrayPush'), var arrayPush = require('./_arrayPush'),
isArguments = require('./isArguments'), isFlattenable = require('./_isFlattenable');
isArray = require('./isArray'),
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} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @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, predicate, isStrict, result) {
result || (result = []);
var index = -1, var index = -1,
length = array.length; length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (isArrayLikeObject(value) && if (depth > 0 && predicate(value)) {
(isStrict || isArray(value) || isArguments(value))) { if (depth > 1) {
if (isDeep) {
// 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, predicate, isStrict, result);
} else { } else {
arrayPush(result, value); arrayPush(result, value);
} }

View File

@@ -1,10 +1,9 @@
var createBaseFor = require('./_createBaseFor'); var createBaseFor = require('./_createBaseFor');
/** /**
* The base implementation of `baseForIn` and `baseForOwn` which iterates * The base implementation of `baseForOwn` which iterates over `object`
* over `object` properties returned by `keysFunc` invoking `iteratee` for * properties returned by `keysFunc` and invokes `iteratee` for each property.
* each property. Iteratee functions may exit iteration early by explicitly * Iteratee functions may exit iteration early by explicitly returning `false`.
* returning `false`.
* *
* @private * @private
* @param {Object} object The object to iterate over. * @param {Object} object The object to iterate over.

View File

@@ -1,16 +0,0 @@
var baseFor = require('./_baseFor'),
keysIn = require('./keysIn');
/**
* The base implementation of `_.forIn` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns `object`.
*/
function baseForIn(object, iteratee) {
return object == null ? object : baseFor(object, iteratee, keysIn);
}
module.exports = baseForIn;

View File

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

View File

@@ -1,5 +1,6 @@
var baseToPath = require('./_baseToPath'), var castPath = require('./_castPath'),
isKey = require('./_isKey'); isKey = require('./_isKey'),
toKey = require('./_toKey');
/** /**
* The base implementation of `_.get` without support for default values. * The base implementation of `_.get` without support for default values.
@@ -10,13 +11,13 @@ 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] : castPath(path);
var index = 0, var index = 0,
length = path.length; length = path.length;
while (object != null && index < length) { while (object != null && index < length) {
object = object[path[index++]]; object = object[toKey(path[index++])];
} }
return (index && index == length) ? object : undefined; return (index && index == length) ? object : undefined;
} }

22
_baseGetAllKeys.js Normal file
View File

@@ -0,0 +1,22 @@
var arrayPush = require('./_arrayPush'),
isArray = require('./isArray');
/**
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Function} keysFunc The function to get the keys of `object`.
* @param {Function} symbolsFunc The function to get the symbols of `object`.
* @returns {Array} Returns the array of property names and symbols.
*/
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object);
return isArray(object)
? result
: arrayPush(result, symbolsFunc(object));
}
module.exports = baseGetAllKeys;

14
_baseGt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.gt` which doesn't coerce arguments to numbers.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
*/
function baseGt(value, other) {
return value > other;
}
module.exports = baseGt;

View File

@@ -1,12 +1,11 @@
var getPrototype = require('./_getPrototype');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = 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;
/** Built-in value references. */
var getPrototypeOf = Object.getPrototypeOf;
/** /**
* The base implementation of `_.has` without support for deep paths. * The base implementation of `_.has` without support for deep paths.
* *
@@ -20,7 +19,7 @@ function baseHas(object, key) {
// that are composed entirely of index properties, return `false` for // that are composed entirely of index properties, return `false` for
// `hasOwnProperty` checks of them. // `hasOwnProperty` checks of them.
return hasOwnProperty.call(object, key) || return hasOwnProperty.call(object, key) ||
(typeof object == 'object' && key in object && getPrototypeOf(object) === null); (typeof object == 'object' && key in object && getPrototype(object) === null);
} }
module.exports = baseHas; module.exports = baseHas;

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

@@ -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,33 @@ 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))) { value = (comparator || value !== 0) ? value : 0;
var othIndex = othLength; if (!(seen
? 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;
} }
} }

View File

@@ -1,8 +1,9 @@
var apply = require('./_apply'), var apply = require('./_apply'),
baseToPath = require('./_baseToPath'), castPath = require('./_castPath'),
isKey = require('./_isKey'), isKey = require('./_isKey'),
last = require('./last'), last = require('./last'),
parent = require('./_parent'); parent = require('./_parent'),
toKey = require('./_toKey');
/** /**
* The base implementation of `_.invoke` without support for individual * The base implementation of `_.invoke` without support for individual
@@ -16,11 +17,11 @@ 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 = castPath(path);
object = parent(object, path); object = parent(object, path);
path = last(path); path = last(path);
} }
var func = object == null ? object : object[path]; var func = object == null ? object : object[toKey(path)];
return func == null ? undefined : apply(func, object, args); return func == null ? undefined : apply(func, object, args);
} }

View File

@@ -31,7 +31,8 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* @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`.
*/ */
@@ -43,41 +44,39 @@ 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) {
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); var objUnwrapped = objIsWrapped ? object.value() : object,
othUnwrapped = othIsWrapped ? other.value() : other;
stack || (stack = new Stack);
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
} }
} }
if (!isSameTag) { if (!isSameTag) {
return false; return false;
} }
stack || (stack = new Stack); stack || (stack = new Stack);
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
} }
module.exports = baseIsEqualDeep; module.exports = baseIsEqualDeep;

View File

@@ -44,9 +44,10 @@ function baseIsMatch(object, source, matchData, customizer) {
return false; return false;
} }
} else { } else {
var stack = new Stack, var stack = new Stack;
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined; if (customizer) {
var result = customizer(objValue, srcValue, key, object, source, stack);
}
if (!(result === undefined if (!(result === undefined
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
: result : result

View File

@@ -12,14 +12,15 @@ var baseMatches = require('./_baseMatches'),
* @returns {Function} Returns the iteratee. * @returns {Function} Returns the iteratee.
*/ */
function baseIteratee(value) { function baseIteratee(value) {
var type = typeof value; // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
if (type == 'function') { // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
if (typeof value == 'function') {
return value; return value;
} }
if (value == null) { if (value == null) {
return identity; return identity;
} }
if (type == 'object') { if (typeof value == 'object') {
return isArray(value) return isArray(value)
? baseMatchesProperty(value[0], value[1]) ? baseMatchesProperty(value[0], value[1])
: baseMatches(value); : baseMatches(value);

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,5 +1,5 @@
/** /**
* The function whose prototype all chaining wrappers inherit from. * The function whose prototype chain sequence wrappers inherit from.
* *
* @private * @private
*/ */

14
_baseLt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.lt` which doesn't coerce arguments to numbers.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
*/
function baseLt(value, other) {
return value < other;
}
module.exports = baseLt;

View File

@@ -1,5 +1,6 @@
var baseIsMatch = require('./_baseIsMatch'), var baseIsMatch = require('./_baseIsMatch'),
getMatchData = require('./_getMatchData'); getMatchData = require('./_getMatchData'),
matchesStrictComparable = require('./_matchesStrictComparable');
/** /**
* The base implementation of `_.matches` which doesn't clone `source`. * The base implementation of `_.matches` which doesn't clone `source`.
@@ -11,16 +12,7 @@ var baseIsMatch = require('./_baseIsMatch'),
function baseMatches(source) { function baseMatches(source) {
var matchData = getMatchData(source); var matchData = getMatchData(source);
if (matchData.length == 1 && matchData[0][2]) { if (matchData.length == 1 && matchData[0][2]) {
var key = matchData[0][0], return matchesStrictComparable(matchData[0][0], matchData[0][1]);
value = matchData[0][1];
return function(object) {
if (object == null) {
return false;
}
return object[key] === value &&
(value !== undefined || (key in Object(object)));
};
} }
return function(object) { return function(object) {
return object === source || baseIsMatch(object, source, matchData); return object === source || baseIsMatch(object, source, matchData);

View File

@@ -1,6 +1,10 @@
var baseIsEqual = require('./_baseIsEqual'), var baseIsEqual = require('./_baseIsEqual'),
get = require('./get'), get = require('./get'),
hasIn = require('./hasIn'); hasIn = require('./hasIn'),
isKey = require('./_isKey'),
isStrictComparable = require('./_isStrictComparable'),
matchesStrictComparable = require('./_matchesStrictComparable'),
toKey = require('./_toKey');
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1, var UNORDERED_COMPARE_FLAG = 1,
@@ -15,6 +19,9 @@ var UNORDERED_COMPARE_FLAG = 1,
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
*/ */
function baseMatchesProperty(path, srcValue) { function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(toKey(path), srcValue);
}
return function(object) { return function(object) {
var objValue = get(object, path); var objValue = get(object, path);
return (objValue === undefined && objValue === srcValue) return (objValue === undefined && objValue === srcValue)

20
_baseMean.js Normal file
View File

@@ -0,0 +1,20 @@
var baseSum = require('./_baseSum');
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/**
* The base implementation of `_.mean` and `_.meanBy` without support for
* iteratee shorthands.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {number} Returns the mean.
*/
function baseMean(array, iteratee) {
var length = array ? array.length : 0;
return length ? (baseSum(array, iteratee) / length) : NAN;
}
module.exports = baseMean;

View File

@@ -15,13 +15,16 @@ var Stack = require('./_Stack'),
* @param {Object} source The source object. * @param {Object} source The source object.
* @param {number} srcIndex The index of `source`. * @param {number} srcIndex The index of `source`.
* @param {Function} [customizer] The function to customize merged values. * @param {Function} [customizer] The function to customize merged values.
* @param {Object} [stack] Tracks traversed source values and their merged counterparts. * @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/ */
function baseMerge(object, source, srcIndex, customizer, stack) { function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) { if (object === source) {
return; return;
} }
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source); if (!(isArray(source) || isTypedArray(source))) {
var props = keysIn(source);
}
arrayEach(props || source, function(srcValue, key) { arrayEach(props || source, function(srcValue, key) {
if (props) { if (props) {
key = srcValue; key = srcValue;
@@ -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

@@ -22,7 +22,8 @@ var assignMergeValue = require('./_assignMergeValue'),
* @param {number} srcIndex The index of `source`. * @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge values. * @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize assigned values. * @param {Function} [customizer] The function to customize assigned values.
* @param {Object} [stack] Tracks traversed source values and their merged counterparts. * @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/ */
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = object[key], var objValue = object[key],
@@ -33,21 +34,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
assignMergeValue(object, key, stacked); assignMergeValue(object, key, stacked);
return; return;
} }
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined, var newValue = customizer
isCommon = newValue === undefined; ? customizer(objValue, srcValue, (key + ''), object, source, stack)
: undefined;
var isCommon = newValue === undefined;
if (isCommon) { if (isCommon) {
newValue = srcValue; newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) { if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArray(objValue)) { if (isArray(objValue)) {
newValue = srcIndex ? copyArray(objValue) : objValue; newValue = objValue;
} }
else if (isArrayLikeObject(objValue)) { else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue); newValue = copyArray(objValue);
} }
else { else {
isCommon = false; isCommon = false;
newValue = baseClone(srcValue); newValue = baseClone(srcValue, true);
} }
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -56,10 +60,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
} }
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false; isCommon = false;
newValue = baseClone(srcValue); newValue = baseClone(srcValue, true);
} }
else { else {
newValue = srcIndex ? baseClone(objValue) : objValue; newValue = objValue;
} }
} }
else { else {
@@ -72,6 +76,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);
} }

20
_baseNth.js Normal file
View File

@@ -0,0 +1,20 @@
var isIndex = require('./_isIndex');
/**
* The base implementation of `_.nth` which doesn't coerce `n` to an integer.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
module.exports = baseNth;

View File

@@ -2,7 +2,9 @@ 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'); baseUnary = require('./_baseUnary'),
compareMultiple = require('./_compareMultiple'),
identity = require('./identity');
/** /**
* The base implementation of `_.orderBy` without param guards. * The base implementation of `_.orderBy` without param guards.
@@ -14,12 +16,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 : [identity], baseUnary(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

@@ -2,11 +2,11 @@ var arrayReduce = require('./_arrayReduce');
/** /**
* The base implementation of `_.pick` without support for individual * The base implementation of `_.pick` without support for individual
* property names. * property identifiers.
* *
* @private * @private
* @param {Object} object The source object. * @param {Object} object The source object.
* @param {string[]} props The property names to pick. * @param {string[]} props The property identifiers to pick.
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function basePick(object, props) { function basePick(object, props) {

View File

@@ -1,4 +1,4 @@
var baseForIn = require('./_baseForIn'); var getAllKeysIn = require('./_getAllKeysIn');
/** /**
* The base implementation of `_.pickBy` without support for iteratee shorthands. * The base implementation of `_.pickBy` without support for iteratee shorthands.
@@ -9,12 +9,19 @@ var baseForIn = require('./_baseForIn');
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function basePickBy(object, predicate) { function basePickBy(object, predicate) {
var result = {}; var index = -1,
baseForIn(object, function(value, key) { props = getAllKeysIn(object),
length = props.length,
result = {};
while (++index < length) {
var key = props[index],
value = object[key];
if (predicate(value, key)) { if (predicate(value, key)) {
result[key] = value; result[key] = value;
} }
}); }
return result; return result;
} }

View File

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

View File

@@ -1,43 +0,0 @@
var arrayMap = require('./_arrayMap'),
baseIndexOf = require('./_baseIndexOf');
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* The base implementation of `_.pullAllBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns `array`.
*/
function basePullAllBy(array, values, iteratee) {
var index = -1,
length = values.length,
seen = array;
if (iteratee) {
seen = arrayMap(array, function(value) { return iteratee(value); });
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
}
module.exports = basePullAllBy;

View File

@@ -1,8 +1,9 @@
var baseToPath = require('./_baseToPath'), var castPath = require('./_castPath'),
isIndex = require('./_isIndex'), isIndex = require('./_isIndex'),
isKey = require('./_isKey'), isKey = require('./_isKey'),
last = require('./last'), last = require('./last'),
parent = require('./_parent'); parent = require('./_parent'),
toKey = require('./_toKey');
/** Used for built-in method references. */ /** Used for built-in method references. */
var arrayProto = Array.prototype; var arrayProto = Array.prototype;
@@ -25,21 +26,21 @@ function basePullAt(array, indexes) {
while (length--) { while (length--) {
var index = indexes[length]; var index = indexes[length];
if (lastIndex == length || index != previous) { if (length == lastIndex || index !== previous) {
var previous = index; var previous = index;
if (isIndex(index)) { if (isIndex(index)) {
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 = castPath(index),
object = parent(array, path); object = parent(array, path);
if (object != null) { if (object != null) {
delete object[last(path)]; delete object[toKey(last(path))];
} }
} }
else { else {
delete array[index]; delete array[toKey(index)];
} }
} }
} }

View File

@@ -6,7 +6,8 @@
* @param {Array|Object} collection The collection to iterate over. * @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @param {*} accumulator The initial value. * @param {*} accumulator The initial value.
* @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value. * @param {boolean} initAccum Specify using the first or last element of
* `collection` as the initial value.
* @param {Function} eachFunc The function to iterate over `collection`. * @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the accumulated value. * @returns {*} Returns the accumulated value.
*/ */

35
_baseRepeat.js Normal file
View File

@@ -0,0 +1,35 @@
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeFloor = Math.floor;
/**
* The base implementation of `_.repeat` which doesn't coerce arguments.
*
* @private
* @param {string} string The string to repeat.
* @param {number} n The number of times to repeat the string.
* @returns {string} Returns the repeated string.
*/
function baseRepeat(string, n) {
var result = '';
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
return result;
}
// Leverage the exponentiation by squaring algorithm for a faster repeat.
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
do {
if (n % 2) {
result += string;
}
n = nativeFloor(n / 2);
if (n) {
string += string;
}
} while (n);
return result;
}
module.exports = baseRepeat;

View File

@@ -1,8 +1,9 @@
var assignValue = require('./_assignValue'), var assignValue = require('./_assignValue'),
baseToPath = require('./_baseToPath'), castPath = require('./_castPath'),
isIndex = require('./_isIndex'), isIndex = require('./_isIndex'),
isKey = require('./_isKey'), isKey = require('./_isKey'),
isObject = require('./isObject'); isObject = require('./isObject'),
toKey = require('./_toKey');
/** /**
* The base implementation of `_.set`. * The base implementation of `_.set`.
@@ -15,7 +16,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] : castPath(path);
var index = -1, var index = -1,
length = path.length, length = path.length,
@@ -23,14 +24,16 @@ function baseSet(object, path, value, customizer) {
nested = object; nested = object;
while (nested != null && ++index < length) { while (nested != null && ++index < length) {
var key = path[index]; var key = toKey(path[index]);
if (isObject(nested)) { if (isObject(nested)) {
var newValue = value; var newValue = value;
if (index != lastIndex) { if (index != lastIndex) {
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

@@ -6,7 +6,8 @@ var baseEach = require('./_baseEach');
* @private * @private
* @param {Array|Object} collection The collection to iterate over. * @param {Array|Object} collection The collection to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. * @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/ */
function baseSome(collection, predicate) { function baseSome(collection, predicate) {
var result; var result;

View File

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

View File

@@ -1,5 +1,6 @@
var baseSortedIndexBy = require('./_baseSortedIndexBy'), var baseSortedIndexBy = require('./_baseSortedIndexBy'),
identity = require('./identity'); identity = require('./identity'),
isSymbol = require('./isSymbol');
/** 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,
@@ -26,7 +27,8 @@ function baseSortedIndex(array, value, retHighest) {
var mid = (low + high) >>> 1, var mid = (low + high) >>> 1,
computed = array[mid]; computed = array[mid];
if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) { if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1; low = mid + 1;
} else { } else {
high = mid; high = mid;

View File

@@ -1,3 +1,5 @@
var isSymbol = require('./isSymbol');
/** 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,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
@@ -16,7 +18,8 @@ var nativeFloor = Math.floor,
* @param {*} value The value to evaluate. * @param {*} value The value to evaluate.
* @param {Function} iteratee The iteratee invoked per element. * @param {Function} iteratee The iteratee invoked per element.
* @param {boolean} [retHighest] Specify returning the highest qualified index. * @param {boolean} [retHighest] Specify returning the highest qualified index.
* @returns {number} Returns the index at which `value` should be inserted into `array`. * @returns {number} Returns the index at which `value` should be inserted
* into `array`.
*/ */
function baseSortedIndexBy(array, value, iteratee, retHighest) { function baseSortedIndexBy(array, value, iteratee, retHighest) {
value = iteratee(value); value = iteratee(value);
@@ -25,21 +28,26 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
high = array ? array.length : 0, high = array ? array.length : 0,
valIsNaN = value !== value, valIsNaN = value !== value,
valIsNull = value === null, valIsNull = value === null,
valIsUndef = value === undefined; valIsSymbol = isSymbol(value),
valIsUndefined = value === undefined;
while (low < high) { while (low < high) {
var mid = nativeFloor((low + high) / 2), var mid = nativeFloor((low + high) / 2),
computed = iteratee(array[mid]), computed = iteratee(array[mid]),
isDef = computed !== undefined, othIsDefined = computed !== undefined,
isReflexive = computed === computed; othIsNull = computed === null,
othIsReflexive = computed === computed,
othIsSymbol = isSymbol(computed);
if (valIsNaN) { if (valIsNaN) {
var setLow = isReflexive || retHighest; var setLow = retHighest || othIsReflexive;
} else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined);
} else if (valIsNull) { } else if (valIsNull) {
setLow = isReflexive && isDef && (retHighest || computed != null); setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
} else if (valIsUndef) { } else if (valIsSymbol) {
setLow = isReflexive && (retHighest || isDef); setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
} else if (computed == null) { } else if (othIsNull || othIsSymbol) {
setLow = false; setLow = false;
} else { } else {
setLow = retHighest ? (computed <= value) : (computed < value); setLow = retHighest ? (computed <= value) : (computed < value);

View File

@@ -1,14 +1,30 @@
var baseSortedUniqBy = require('./_baseSortedUniqBy'); var eq = require('./eq');
/** /**
* The base implementation of `_.sortedUniq`. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
* support for iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to inspect. * @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array. * @returns {Array} Returns the new duplicate free array.
*/ */
function baseSortedUniq(array) { function baseSortedUniq(array, iteratee) {
return baseSortedUniqBy(array); var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!index || !eq(computed, seen)) {
var seen = computed;
result[resIndex++] = value === 0 ? 0 : value;
}
}
return result;
} }
module.exports = baseSortedUniq; module.exports = baseSortedUniq;

View File

@@ -1,33 +0,0 @@
var eq = require('./eq');
/**
* The base implementation of `_.sortedUniqBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseSortedUniqBy(array, iteratee) {
var index = 0,
length = array.length,
value = array[0],
computed = iteratee ? iteratee(value) : value,
seen = computed,
resIndex = 0,
result = [value];
while (++index < length) {
value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!eq(computed, seen)) {
seen = computed;
result[++resIndex] = value;
}
}
return result;
}
module.exports = baseSortedUniqBy;

View File

@@ -1,5 +1,6 @@
/** /**
* The base implementation of `_.sum` without support for iteratee shorthands. * The base implementation of `_.sum` and `_.sumBy` without support for
* iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} array The array to iterate over.

24
_baseToNumber.js Normal file
View File

@@ -0,0 +1,24 @@
var isSymbol = require('./isSymbol');
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/**
* The base implementation of `_.toNumber` which doesn't ensure correct
* conversions of binary, hexadecimal, or octal string values.
*
* @private
* @param {*} value The value to process.
* @returns {number} Returns the number.
*/
function baseToNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
return +value;
}
module.exports = baseToNumber;

View File

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

31
_baseToString.js Normal file
View File

@@ -0,0 +1,31 @@
var Symbol = require('./_Symbol'),
isSymbol = require('./isSymbol');
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
module.exports = baseToString;

View File

@@ -46,6 +46,7 @@ function baseUniq(array, iteratee, comparator) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) { if (isCommon && computed === computed) {
var seenIndex = seen.length; var seenIndex = seen.length;
while (seenIndex--) { while (seenIndex--) {

View File

@@ -1,8 +1,9 @@
var baseToPath = require('./_baseToPath'), var baseHas = require('./_baseHas'),
has = require('./has'), castPath = require('./_castPath'),
isKey = require('./_isKey'), isKey = require('./_isKey'),
last = require('./last'), last = require('./last'),
parent = require('./_parent'); parent = require('./_parent'),
toKey = require('./_toKey');
/** /**
* The base implementation of `_.unset`. * The base implementation of `_.unset`.
@@ -13,10 +14,11 @@ 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] : castPath(path);
object = parent(object, path); object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true; var key = toKey(last(path));
return !(object != null && baseHas(object, key)) || delete object[key];
} }
module.exports = baseUnset; module.exports = baseUnset;

18
_baseUpdate.js Normal file
View 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;

View File

@@ -2,7 +2,7 @@
* This base implementation of `_.zipObject` which assigns values using `assignFunc`. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
* *
* @private * @private
* @param {Array} props The property names. * @param {Array} props The property identifiers.
* @param {Array} values The property values. * @param {Array} values The property values.
* @param {Function} assignFunc The function to assign values. * @param {Function} assignFunc The function to assign values.
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
@@ -14,7 +14,8 @@ function baseZipObject(props, values, assignFunc) {
result = {}; result = {};
while (++index < length) { while (++index < length) {
assignFunc(result, props[index], index < valsLength ? values[index] : undefined); var value = index < valsLength ? values[index] : undefined;
assignFunc(result, props[index], value);
} }
return result; return result;
} }

14
_castArrayLikeObject.js Normal file
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|Object} Returns the cast array-like object.
*/
function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
module.exports = castArrayLikeObject;

14
_castFunction.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 {Function} Returns cast function.
*/
function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
module.exports = castFunction;

15
_castPath.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 castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
module.exports = castPath;

18
_castSlice.js Normal file
View File

@@ -0,0 +1,18 @@
var baseSlice = require('./_baseSlice');
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
module.exports = castSlice;

16
_cloneArrayBuffer.js Normal file
View 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;

View File

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

16
_cloneDataView.js Normal file
View File

@@ -0,0 +1,16 @@
var cloneArrayBuffer = require('./_cloneArrayBuffer');
/**
* Creates a clone of `dataView`.
*
* @private
* @param {Object} dataView The data view to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned data view.
*/
function cloneDataView(dataView, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
}
module.exports = cloneDataView;

View File

@@ -7,11 +7,13 @@ var addMapEntry = require('./_addMapEntry'),
* *
* @private * @private
* @param {Object} map The map to clone. * @param {Object} map The map to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned map. * @returns {Object} Returns the cloned map.
*/ */
function cloneMap(map) { function cloneMap(map, isDeep, cloneFunc) {
var Ctor = map.constructor; var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
return arrayReduce(mapToArray(map), addMapEntry, new Ctor); return arrayReduce(array, addMapEntry, new map.constructor);
} }
module.exports = cloneMap; module.exports = cloneMap;

View File

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

View File

@@ -7,11 +7,13 @@ var addSetEntry = require('./_addSetEntry'),
* *
* @private * @private
* @param {Object} set The set to clone. * @param {Object} set The set to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned set. * @returns {Object} Returns the cloned set.
*/ */
function cloneSet(set) { function cloneSet(set, isDeep, cloneFunc) {
var Ctor = set.constructor; var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
return arrayReduce(setToArray(set), addSetEntry, new Ctor); return arrayReduce(array, addSetEntry, new set.constructor);
} }
module.exports = cloneSet; module.exports = cloneSet;

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
var isSymbol = require('./isSymbol');
/** /**
* Compares values to sort them in ascending order. * Compares values to sort them in ascending order.
* *
@@ -8,22 +10,28 @@
*/ */
function compareAscending(value, other) { function compareAscending(value, other) {
if (value !== other) { if (value !== other) {
var valIsNull = value === null, var valIsDefined = value !== undefined,
valIsUndef = value === undefined, valIsNull = value === null,
valIsReflexive = value === value; valIsReflexive = value === value,
valIsSymbol = isSymbol(value);
var othIsNull = other === null, var othIsDefined = other !== undefined,
othIsUndef = other === undefined, othIsNull = other === null,
othIsReflexive = other === other; othIsReflexive = other === other,
othIsSymbol = isSymbol(other);
if ((value > other && !othIsNull) || !valIsReflexive || if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
(valIsNull && !othIsUndef && othIsReflexive) || (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
(valIsUndef && othIsReflexive)) { (valIsNull && othIsDefined && othIsReflexive) ||
(!valIsDefined && othIsReflexive) ||
!valIsReflexive) {
return 1; return 1;
} }
if ((value < other && !valIsNull) || !othIsReflexive || if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
(othIsNull && !valIsUndef && valIsReflexive) || (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
(othIsUndef && valIsReflexive)) { (othIsNull && valIsDefined && valIsReflexive) ||
(!othIsDefined && valIsReflexive) ||
!othIsReflexive) {
return -1; return -1;
} }
} }

View File

@@ -37,7 +37,7 @@ function compareMultiple(object, other, orders) {
// for more details. // for more details.
// //
// This also ensures a stable sort in V8 and other engines. // This also ensures a stable sort in V8 and other engines.
// See https://code.google.com/p/v8/issues/detail?id=90 for more details. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
return object.index - other.index; return object.index - other.index;
} }

View File

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

View File

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

View File

@@ -1,16 +1,31 @@
var copyObjectWith = require('./_copyObjectWith'); var assignValue = require('./_assignValue');
/** /**
* Copies properties of `source` to `object`. * Copies properties of `source` to `object`.
* *
* @private * @private
* @param {Object} source The object to copy properties from. * @param {Object} source The object to copy properties from.
* @param {Array} props The property names to copy. * @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to. * @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function copyObject(source, props, object) { function copyObject(source, props, object, customizer) {
return copyObjectWith(source, props, object); object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
} }
module.exports = copyObject; module.exports = copyObject;

View File

@@ -1,29 +0,0 @@
var assignValue = require('./_assignValue');
/**
* This function is like `copyObject` except that it accepts a function to
* customize copied values.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property names to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObjectWith(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index],
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
assignValue(object, key, newValue);
}
return object;
}
module.exports = copyObjectWith;

21
_countHolders.js Normal file
View 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;

View File

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

View File

@@ -1,5 +1,5 @@
/** /**
* Creates a base function for methods like `_.forIn`. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
* *
* @private * @private
* @param {boolean} [fromRight] Specify iterating from right to left. * @param {boolean} [fromRight] Specify iterating from right to left.

View File

@@ -10,7 +10,8 @@ var BIND_FLAG = 1;
* *
* @private * @private
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
* for more details.
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */

View File

@@ -1,18 +1,8 @@
var stringToArray = require('./_stringToArray'), var castSlice = require('./_castSlice'),
reHasComplexSymbol = require('./_reHasComplexSymbol'),
stringToArray = require('./_stringToArray'),
toString = require('./toString'); toString = require('./toString');
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/** /**
* Creates a function like `_.lowerFirst`. * Creates a function like `_.lowerFirst`.
* *
@@ -24,9 +14,17 @@ 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)
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1); : undefined;
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing; return chr[methodName]() + trailing;
}; };

View File

@@ -2,6 +2,12 @@ var arrayReduce = require('./_arrayReduce'),
deburr = require('./deburr'), deburr = require('./deburr'),
words = require('./words'); words = require('./words');
/** Used to compose unicode capture groups. */
var rsApos = "['\u2019]";
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/** /**
* Creates a function like `_.camelCase`. * Creates a function like `_.camelCase`.
* *
@@ -11,7 +17,7 @@ var arrayReduce = require('./_arrayReduce'),
*/ */
function createCompounder(callback) { function createCompounder(callback) {
return function(string) { return function(string) {
return arrayReduce(words(deburr(string)), callback, ''); return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
}; };
} }

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