Compare commits

...

11 Commits

Author SHA1 Message Date
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
785 changed files with 8236 additions and 3815 deletions

60
LICENSE
View File

@@ -1,23 +1,47 @@
The MIT License (MIT)
Copyright jQuery Foundation and other contributors <https://jquery.org/>
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.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/>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
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 above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The following license applies to all parts of this software except as
documented below:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
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.3.0
# lodash v4.10.0
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
## Installation
@@ -12,29 +12,29 @@ $ npm i --save lodash
In Node.js:
```js
// load the full build
// Load the full build.
var _ = require('lodash');
// load the core build
// Load the core build.
var _ = require('lodash/core');
// load the fp build for immutable auto-curried iteratee-first data-last methods
var _ = require('lodash/fp');
// Load the fp build for immutable auto-curried iteratee-first data-last methods.
var fp = require('lodash/fp');
// or a method category
// Load a method category.
var array = require('lodash/array');
var object = require('lodash/fp/object');
// or method for smaller builds with browserify/rollup/webpack
// Load a single method for smaller builds with browserify/rollup/webpack.
var chunk = require('lodash/chunk');
var extend = require('lodash/fp/extend');
```
See the [package source](https://github.com/lodash/lodash/tree/4.3.0-npm) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.10.0-npm) for more details.
**Note:**<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.
## 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.<br>
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.

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;
/**
* Creates an hash object.
* Creates a hash object.
*
* @private
* @constructor
* @returns {Object} Returns the new hash object.
*/
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.
*
* @private
* @constructor
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
@@ -20,6 +21,7 @@ function LazyWrapper(value) {
this.__views__ = [];
}
// Ensure `LazyWrapper` is an instance of `baseLodash`.
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;

View File

@@ -6,7 +6,7 @@ var baseCreate = require('./_baseCreate'),
*
* @private
* @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) {
this.__wrapped__ = value;

View File

@@ -8,6 +8,7 @@ var mapClear = require('./_mapClear'),
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function MapCache(values) {
@@ -21,7 +22,7 @@ function MapCache(values) {
}
}
// Add functions to the `MapCache`.
// Add methods to `MapCache`.
MapCache.prototype.clear = mapClear;
MapCache.prototype['delete'] = mapDelete;
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.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
@@ -18,7 +19,7 @@ function SetCache(values) {
}
}
// Add functions to the `SetCache`.
// Add methods to `SetCache`.
SetCache.prototype.push = cachePush;
module.exports = SetCache;

View File

@@ -8,6 +8,7 @@ var stackClear = require('./_stackClear'),
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function Stack(values) {
@@ -21,7 +22,7 @@ function Stack(values) {
}
}
// Add functions to the `Stack` cache.
// Add methods to `Stack`.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;

View File

@@ -7,6 +7,7 @@
* @returns {Object} Returns `map`.
*/
function addMapEntry(map, pair) {
// Don't return `Map#set` because it doesn't return the map instance in IE 11.
map.set(pair[0], pair[1]);
return map;
}

View File

@@ -5,7 +5,7 @@
* @private
* @param {Function} func The function to invoke.
* @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`.
*/
function apply(func, thisArg, args) {

View File

@@ -5,7 +5,8 @@
* @private
* @param {Array} array The array to iterate over.
* @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) {
var index = -1,

View File

@@ -10,13 +10,13 @@
function arrayFilter(array, predicate) {
var index = -1,
length = array.length,
resIndex = -1,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result[++resIndex] = value;
result[resIndex++] = value;
}
}
return result;

View File

@@ -1,6 +1,5 @@
/**
* A specialized version of `_.includesWith` for arrays without support for
* specifying an index to search from.
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
* @param {Array} array The array to search.

View File

@@ -6,7 +6,8 @@
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @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.
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {

View File

@@ -6,7 +6,8 @@
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @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.
*/
function arrayReduceRight(array, iteratee, accumulator, initAccum) {

View File

@@ -5,7 +5,8 @@
* @private
* @param {Array} array The array to iterate over.
* @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) {
var index = -1,

View File

@@ -1,7 +1,8 @@
var eq = require('./eq');
/**
* This function is like `assignValue` except that it doesn't assign `undefined` values.
* This function is like `assignValue` except that it doesn't assign
* `undefined` values.
*
* @private
* @param {Object} object The object to modify.

View File

@@ -18,8 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
*/
function assignValue(object, key, value) {
var objValue = object[key];
if ((!eq(objValue, value) ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
object[key] = value;
}

View File

@@ -10,7 +10,7 @@ var splice = arrayProto.splice;
* Removes `key` and its value from the associative array.
*
* @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.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/

View File

@@ -1,8 +1,7 @@
var eq = require('./eq');
/**
* Gets the index at which the first occurrence of `key` is found in `array`
* of key-value pairs.
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to search.

View File

@@ -2,10 +2,10 @@ var Stack = require('./_Stack'),
arrayEach = require('./_arrayEach'),
assignValue = require('./_assignValue'),
baseAssign = require('./_baseAssign'),
baseForOwn = require('./_baseForOwn'),
cloneBuffer = require('./_cloneBuffer'),
copyArray = require('./_copyArray'),
copySymbols = require('./_copySymbols'),
getAllKeys = require('./_getAllKeys'),
getTag = require('./_getTag'),
initCloneArray = require('./_initCloneArray'),
initCloneByTag = require('./_initCloneByTag'),
@@ -13,7 +13,8 @@ var Stack = require('./_Stack'),
isArray = require('./isArray'),
isBuffer = require('./isBuffer'),
isHostObject = require('./_isHostObject'),
isObject = require('./isObject');
isObject = require('./isObject'),
keys = require('./keys');
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
@@ -33,6 +34,7 @@ var argsTag = '[object Arguments]',
weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]',
float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]',
@@ -46,16 +48,16 @@ var arrayBufferTag = '[object ArrayBuffer]',
/** Used to identify `toStringTag` values supported by `_.clone`. */
var cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] =
cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
cloneableTags[dateTag] = cloneableTags[float32Tag] =
cloneableTags[float64Tag] = cloneableTags[int8Tag] =
cloneableTags[int16Tag] = cloneableTags[int32Tag] =
cloneableTags[mapTag] = cloneableTags[numberTag] =
cloneableTags[objectTag] = cloneableTags[regexpTag] =
cloneableTags[setTag] = cloneableTags[stringTag] =
cloneableTags[symbolTag] = cloneableTags[uint8Tag] =
cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] =
cloneableTags[uint32Tag] = true;
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
cloneableTags[boolTag] = cloneableTags[dateTag] =
cloneableTags[float32Tag] = cloneableTags[float64Tag] =
cloneableTags[int8Tag] = cloneableTags[int16Tag] =
cloneableTags[int32Tag] = cloneableTags[mapTag] =
cloneableTags[numberTag] = cloneableTags[objectTag] =
cloneableTags[regexpTag] = cloneableTags[setTag] =
cloneableTags[stringTag] = cloneableTags[symbolTag] =
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] =
cloneableTags[weakMapTag] = false;
@@ -66,13 +68,14 @@ cloneableTags[weakMapTag] = false;
* @private
* @param {*} value The value to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @param {boolean} [isFull] Specify a clone including symbols.
* @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value.
*/
function baseClone(value, isDeep, customizer, key, object, stack) {
function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
var result;
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
@@ -105,9 +108,10 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
return copySymbols(value, baseAssign(result, value));
}
} else {
return cloneableTags[tag]
? initCloneByTag(value, tag, isDeep)
: (object ? value : {});
if (!cloneableTags[tag]) {
return object ? value : {};
}
result = initCloneByTag(value, tag, baseClone, isDeep);
}
}
// Check for circular references and return its corresponding clone.
@@ -118,11 +122,18 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
}
stack.set(value, result);
if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value);
}
// Recursively populate clone (susceptible to call stack limits).
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack));
arrayEach(props || value, function(subValue, key) {
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;

View File

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

View File

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

View File

@@ -9,8 +9,8 @@ var SetCache = require('./_SetCache'),
var LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of methods like `_.difference` without support for
* excluding multiple arrays or iteratee shorthands.
* The base implementation of methods like `_.difference` without support
* for excluding multiple arrays or iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.

View File

@@ -6,7 +6,8 @@ var baseEach = require('./_baseEach');
* @private
* @param {Array|Object} collection The collection to iterate over.
* @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) {
var result = true;

View File

@@ -7,7 +7,8 @@
* @param {Array|Object} collection The collection to search.
* @param {Function} predicate The function invoked per iteration.
* @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`.
*/
function baseFind(collection, predicate, eachFunc, retKey) {

View File

@@ -1,31 +1,30 @@
var arrayPush = require('./_arrayPush'),
isArguments = require('./isArguments'),
isArray = require('./isArray'),
isArrayLikeObject = require('./isArrayLikeObject');
isFlattenable = require('./_isFlattenable');
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
* @param {boolean} [isDeep] Specify a deep flatten.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {number} depth The maximum recursion depth.
* @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.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, isDeep, isStrict, result) {
result || (result = []);
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (isArrayLikeObject(value) &&
(isStrict || isArray(value) || isArguments(value))) {
if (isDeep) {
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, isDeep, isStrict, result);
baseFlatten(value, depth - 1, predicate, isStrict, result);
} else {
arrayPush(result, value);
}

View File

@@ -1,10 +1,9 @@
var createBaseFor = require('./_createBaseFor');
/**
* The base implementation of `baseForIn` and `baseForOwn` which iterates
* over `object` properties returned by `keysFunc` invoking `iteratee` for
* each property. Iteratee functions may exit iteration early by explicitly
* returning `false`.
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
* @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

@@ -1,4 +1,4 @@
var baseToPath = require('./_baseToPath'),
var castPath = require('./_castPath'),
isKey = require('./_isKey');
/**
@@ -10,7 +10,7 @@ var baseToPath = require('./_baseToPath'),
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path + ''] : baseToPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;

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;

View File

@@ -1,12 +1,11 @@
var getPrototype = require('./_getPrototype');
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Built-in value references. */
var getPrototypeOf = Object.getPrototypeOf;
/**
* 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
// `hasOwnProperty` checks of them.
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;

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'),
cacheHas = require('./_cacheHas');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
/**
* The base implementation of methods like `_.intersection`, without support
* for iteratee shorthands, that accepts an array of arrays to inspect.
@@ -17,9 +20,11 @@ var SetCache = require('./_SetCache'),
*/
function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length,
othIndex = othLength,
caches = Array(othLength),
maxLength = Infinity,
result = [];
while (othIndex--) {
@@ -27,26 +32,32 @@ function baseIntersection(arrays, iteratee, comparator) {
if (othIndex && iteratee) {
array = arrayMap(array, baseUnary(iteratee));
}
caches[othIndex] = !comparator && (iteratee || array.length >= 120)
maxLength = nativeMin(array.length, maxLength);
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new SetCache(othIndex && array)
: undefined;
}
array = arrays[0];
var index = -1,
length = array.length,
seen = caches[0];
outer:
while (++index < length) {
while (++index < length && result.length < maxLength) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
var othIndex = othLength;
if (!(seen
? cacheHas(seen, computed)
: includes(result, computed, comparator)
)) {
othIndex = othLength;
while (--othIndex) {
var cache = caches[othIndex];
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
if (!(cache
? cacheHas(cache, computed)
: includes(arrays[othIndex], computed, comparator))
) {
continue outer;
}
}

View File

@@ -1,5 +1,5 @@
var apply = require('./_apply'),
baseToPath = require('./_baseToPath'),
castPath = require('./_castPath'),
isKey = require('./_isKey'),
last = require('./last'),
parent = require('./_parent');
@@ -16,7 +16,7 @@ var apply = require('./_apply'),
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = baseToPath(path);
path = castPath(path);
object = parent(object, path);
path = last(path);
}

View File

@@ -31,7 +31,8 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* @param {Object} other The other object to compare.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
* for more details.
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
@@ -43,41 +44,39 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
if (!objIsArr) {
objTag = getTag(object);
if (objTag == argsTag) {
objTag = objectTag;
} else if (objTag != objectTag) {
objIsArr = isTypedArray(object);
}
objTag = objTag == argsTag ? objectTag : objTag;
}
if (!othIsArr) {
othTag = getTag(other);
if (othTag == argsTag) {
othTag = objectTag;
} else if (othTag != objectTag) {
othIsArr = isTypedArray(other);
}
othTag = othTag == argsTag ? objectTag : othTag;
}
var objIsObj = objTag == objectTag && !isHostObject(object),
othIsObj = othTag == objectTag && !isHostObject(other),
isSameTag = objTag == othTag;
if (isSameTag && !(objIsArr || objIsObj)) {
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask);
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
}
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
if (!isPartial) {
if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
if (objIsWrapped || othIsWrapped) {
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) {
return false;
}
stack || (stack = new Stack);
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack);
return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
}
module.exports = baseIsEqualDeep;

View File

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

View File

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

View File

@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
* property of prototypes or treat sparse arrays as dense.
*
* @private
* @type Function
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/

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

View File

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

View File

@@ -1,6 +1,9 @@
var baseIsEqual = require('./_baseIsEqual'),
get = require('./get'),
hasIn = require('./hasIn');
hasIn = require('./hasIn'),
isKey = require('./_isKey'),
isStrictComparable = require('./_isStrictComparable'),
matchesStrictComparable = require('./_matchesStrictComparable');
/** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1,
@@ -15,6 +18,9 @@ var UNORDERED_COMPARE_FLAG = 1,
* @returns {Function} Returns the new function.
*/
function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(path, srcValue);
}
return function(object) {
var objValue = get(object, path);
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 {number} srcIndex The index of `source`.
* @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) {
if (object === source) {
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) {
if (props) {
key = srcValue;
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
var newValue = customizer
? customizer(object[key], srcValue, (key + ''), object, source, stack)
: undefined;
if (newValue === undefined) {
newValue = srcValue;
}

View File

@@ -22,7 +22,8 @@ var assignMergeValue = require('./_assignMergeValue'),
* @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge 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) {
var objValue = object[key],
@@ -33,21 +34,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
assignMergeValue(object, key, stacked);
return;
}
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
isCommon = newValue === undefined;
var newValue = customizer
? customizer(objValue, srcValue, (key + ''), object, source, stack)
: undefined;
var isCommon = newValue === undefined;
if (isCommon) {
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArray(objValue)) {
newValue = srcIndex ? copyArray(objValue) : objValue;
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
isCommon = false;
newValue = baseClone(srcValue);
newValue = baseClone(srcValue, true);
}
}
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))) {
isCommon = false;
newValue = baseClone(srcValue);
newValue = baseClone(srcValue, true);
}
else {
newValue = srcIndex ? baseClone(objValue) : objValue;
newValue = objValue;
}
}
else {
@@ -72,6 +76,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
// Recursively merge objects and arrays (susceptible to call stack limits).
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
}
stack['delete'](srcValue);
assignMergeValue(object, key, newValue);
}

View File

@@ -2,7 +2,8 @@ var arrayMap = require('./_arrayMap'),
baseIteratee = require('./_baseIteratee'),
baseMap = require('./_baseMap'),
baseSortBy = require('./_baseSortBy'),
compareMultiple = require('./_compareMultiple');
compareMultiple = require('./_compareMultiple'),
identity = require('./identity');
/**
* The base implementation of `_.orderBy` without param guards.
@@ -14,12 +15,8 @@ var arrayMap = require('./_arrayMap'),
* @returns {Array} Returns the new sorted array.
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1,
toIteratee = baseIteratee;
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
return toIteratee(iteratee);
});
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
var result = baseMap(collection, function(value, key, collection) {
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
* property names.
* property identifiers.
*
* @private
* @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.
*/
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.
@@ -9,12 +9,19 @@ var baseForIn = require('./_baseForIn');
* @returns {Object} Returns the new object.
*/
function basePickBy(object, predicate) {
var result = {};
baseForIn(object, function(value, key) {
var index = -1,
props = getAllKeysIn(object),
length = props.length,
result = {};
while (++index < length) {
var key = props[index],
value = object[key];
if (predicate(value, key)) {
result[key] = value;
}
});
}
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
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`.
*/
function basePullAll(array, values) {
return basePullAllBy(array, values);
function basePullAll(array, values, iteratee, comparator) {
var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
index = -1,
length = values.length,
seen = array;
if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee));
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
}
module.exports = basePullAll;

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,4 +1,4 @@
var baseToPath = require('./_baseToPath'),
var castPath = require('./_castPath'),
isIndex = require('./_isIndex'),
isKey = require('./_isKey'),
last = require('./last'),
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = baseToPath(index),
var path = castPath(index),
object = parent(array, path);
if (object != null) {

View File

@@ -6,7 +6,8 @@
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @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`.
* @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,5 +1,5 @@
var assignValue = require('./_assignValue'),
baseToPath = require('./_baseToPath'),
castPath = require('./_castPath'),
isIndex = require('./_isIndex'),
isKey = require('./_isKey'),
isObject = require('./isObject');
@@ -15,7 +15,7 @@ var assignValue = require('./_assignValue'),
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path + ''] : baseToPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) {
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
newValue = objValue == null
? (isIndex(path[index + 1]) ? [] : {})
: objValue;
}
}
assignValue(nested, key, newValue);

View File

@@ -6,7 +6,8 @@ var baseEach = require('./_baseEach');
* @private
* @param {Array|Object} collection The collection to iterate over.
* @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) {
var result;

View File

@@ -1,7 +1,7 @@
/**
* The base implementation of `_.sortBy` which uses `comparer` to define
* the sort order of `array` and replaces criteria objects with their
* corresponding values.
* The base implementation of `_.sortBy` which uses `comparer` to define the
* sort order of `array` and replaces criteria objects with their corresponding
* values.
*
* @private
* @param {Array} array The array to sort.

View File

@@ -16,7 +16,8 @@ var nativeFloor = Math.floor,
* @param {*} value The value to evaluate.
* @param {Function} iteratee The iteratee invoked per element.
* @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) {
value = iteratee(value);

View File

@@ -15,7 +15,7 @@ function baseSortedUniqBy(array, iteratee) {
value = array[0],
computed = iteratee ? iteratee(value) : value,
seen = computed,
resIndex = 0,
resIndex = 1,
result = [value];
while (++index < length) {
@@ -24,7 +24,7 @@ function baseSortedUniqBy(array, iteratee) {
if (!eq(computed, seen)) {
seen = computed;
result[++resIndex] = value;
result[resIndex++] = value;
}
}
return result;

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
* @param {Array} array The array to iterate over.

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;

View File

@@ -1,4 +1,4 @@
var baseToPath = require('./_baseToPath'),
var castPath = require('./_castPath'),
has = require('./has'),
isKey = require('./_isKey'),
last = require('./last'),
@@ -13,7 +13,7 @@ var baseToPath = require('./_baseToPath'),
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path + ''] : baseToPath(path);
path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;

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`.
*
* @private
* @param {Array} props The property names.
* @param {Array} props The property identifiers.
* @param {Array} values The property values.
* @param {Function} assignFunc The function to assign values.
* @returns {Object} Returns the new object.
@@ -14,7 +14,8 @@ function baseZipObject(props, values, assignFunc) {
result = {};
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;
}

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;

View File

@@ -8,11 +8,8 @@ var Uint8Array = require('./_Uint8Array');
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function cloneArrayBuffer(arrayBuffer) {
var Ctor = arrayBuffer.constructor,
result = new Ctor(arrayBuffer.byteLength),
view = new Uint8Array(result);
view.set(new Uint8Array(arrayBuffer));
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
return result;
}

View File

@@ -10,9 +10,7 @@ function cloneBuffer(buffer, isDeep) {
if (isDeep) {
return buffer.slice();
}
var Ctor = buffer.constructor,
result = new Ctor(buffer.length);
var result = new buffer.constructor(buffer.length);
buffer.copy(result);
return result;
}

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
* @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.
*/
function cloneMap(map) {
var Ctor = map.constructor;
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
function cloneMap(map, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
return arrayReduce(array, addMapEntry, new map.constructor);
}
module.exports = cloneMap;

View File

@@ -9,9 +9,7 @@ var reFlags = /\w*$/;
* @returns {Object} Returns the cloned regexp.
*/
function cloneRegExp(regexp) {
var Ctor = regexp.constructor,
result = new Ctor(regexp.source, reFlags.exec(regexp));
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex;
return result;
}

View File

@@ -7,11 +7,13 @@ var addSetEntry = require('./_addSetEntry'),
*
* @private
* @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.
*/
function cloneSet(set) {
var Ctor = set.constructor;
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
function cloneSet(set, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
return arrayReduce(array, addSetEntry, new set.constructor);
}
module.exports = cloneSet;

View File

@@ -2,7 +2,7 @@ var Symbol = require('./_Symbol');
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/**
* Creates a clone of the `symbol` object.
@@ -12,7 +12,7 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return Symbol ? Object(symbolValueOf.call(symbol)) : {};
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
}
module.exports = cloneSymbol;

View File

@@ -9,10 +9,8 @@ var cloneArrayBuffer = require('./_cloneArrayBuffer');
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
var buffer = typedArray.buffer,
Ctor = typedArray.constructor;
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
}
module.exports = cloneTypedArray;

View File

@@ -37,7 +37,7 @@ function compareMultiple(object, other, orders) {
// for more details.
//
// 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;
}

View File

@@ -9,23 +9,28 @@ var nativeMax = Math.max;
* @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments.
*/
function composeArgs(args, partials, holders) {
var holdersLength = holders.length,
argsIndex = -1,
argsLength = nativeMax(args.length - holdersLength, 0),
function composeArgs(args, partials, holders, isCurried) {
var argsIndex = -1,
argsLength = args.length,
holdersLength = holders.length,
leftIndex = -1,
leftLength = partials.length,
result = Array(leftLength + argsLength);
rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(leftLength + rangeLength),
isUncurried = !isCurried;
while (++leftIndex < leftLength) {
result[leftIndex] = partials[leftIndex];
}
while (++argsIndex < holdersLength) {
result[holders[argsIndex]] = args[argsIndex];
if (isUncurried || argsIndex < argsLength) {
result[holders[argsIndex]] = args[argsIndex];
}
}
while (argsLength--) {
while (rangeLength--) {
result[leftIndex++] = args[argsIndex++];
}
return result;

View File

@@ -9,18 +9,21 @@ var nativeMax = Math.max;
* @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments.
*/
function composeArgsRight(args, partials, holders) {
var holdersIndex = -1,
function composeArgsRight(args, partials, holders, isCurried) {
var argsIndex = -1,
argsLength = args.length,
holdersIndex = -1,
holdersLength = holders.length,
argsIndex = -1,
argsLength = nativeMax(args.length - holdersLength, 0),
rightIndex = -1,
rightLength = partials.length,
result = Array(argsLength + rightLength);
rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(rangeLength + rightLength),
isUncurried = !isCurried;
while (++argsIndex < argsLength) {
while (++argsIndex < rangeLength) {
result[argsIndex] = args[argsIndex];
}
var offset = argsIndex;
@@ -28,7 +31,9 @@ function composeArgsRight(args, partials, holders) {
result[offset + rightIndex] = partials[rightIndex];
}
while (++holdersIndex < holdersLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++];
if (isUncurried || argsIndex < argsLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++];
}
}
return result;
}

View File

@@ -5,7 +5,7 @@ var copyObjectWith = require('./_copyObjectWith');
*
* @private
* @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.
* @returns {Object} Returns `object`.
*/

View File

@@ -6,7 +6,7 @@ var assignValue = require('./_assignValue');
*
* @private
* @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 {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
@@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) {
length = props.length;
while (++index < length) {
var key = props[index],
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}

21
_countHolders.js Normal file
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,
guard = length > 2 ? sources[2] : undefined;
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
customizer = typeof customizer == 'function'
? (length--, customizer)
: undefined;
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer;
length = 1;

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
* @param {boolean} [fromRight] Specify iterating from right to left.

View File

@@ -10,7 +10,8 @@ var BIND_FLAG = 1;
*
* @private
* @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`.
* @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');
/** 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`.
*
@@ -24,9 +14,17 @@ function createCaseFirst(methodName) {
return function(string) {
string = toString(string);
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
var strSymbols = reHasComplexSymbol.test(string)
? stringToArray(string)
: undefined;
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};

View File

@@ -11,8 +11,8 @@ var baseCreate = require('./_baseCreate'),
*/
function createCtorWrapper(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors.
// See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// Use a `switch` statement to work with class constructors. See
// http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {

View File

@@ -2,6 +2,7 @@ var apply = require('./_apply'),
createCtorWrapper = require('./_createCtorWrapper'),
createHybridWrapper = require('./_createHybridWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'),
getPlaceholder = require('./_getPlaceholder'),
replaceHolders = require('./_replaceHolders'),
root = require('./_root');
@@ -10,7 +11,8 @@ var apply = require('./_apply'),
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
* for more details.
* @param {number} arity The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
@@ -19,10 +21,9 @@ function createCurryWrapper(func, bitmask, arity) {
function wrapper() {
var length = arguments.length,
index = length,
args = Array(length),
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func,
placeholder = wrapper.placeholder;
index = length,
placeholder = getPlaceholder(wrapper);
while (index--) {
args[index] = arguments[index];
@@ -32,9 +33,13 @@ function createCurryWrapper(func, bitmask, arity) {
: replaceHolders(args, placeholder);
length -= holders.length;
return length < arity
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length)
: apply(fn, this, args);
if (length < arity) {
return createRecurryWrapper(
func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length);
}
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return apply(fn, this, args);
}
return wrapper;
}

View File

@@ -6,18 +6,18 @@ var LodashWrapper = require('./_LodashWrapper'),
isLaziable = require('./_isLaziable'),
rest = require('./rest');
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/**
* Creates a `_.flow` or `_.flowRight` function.
*
@@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
*/
function createFlow(fromRight) {
return rest(function(funcs) {
funcs = baseFlatten(funcs);
funcs = baseFlatten(funcs, 1);
var length = funcs.length,
index = length,
@@ -52,17 +52,23 @@ function createFlow(fromRight) {
var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
if (data && isLaziable(data[0]) &&
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
!data[4].length && data[9] == 1
) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
wrapper = (func.length == 1 && isLaziable(func))
? wrapper[funcName]()
: wrapper.thru(func);
}
}
return function() {
var args = arguments,
value = args[0];
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
if (wrapper && args.length == 1 &&
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
return wrapper.plant(value).value();
}
var index = 0,

View File

@@ -1,7 +1,9 @@
var composeArgs = require('./_composeArgs'),
composeArgsRight = require('./_composeArgsRight'),
countHolders = require('./_countHolders'),
createCtorWrapper = require('./_createCtorWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'),
getPlaceholder = require('./_getPlaceholder'),
reorder = require('./_reorder'),
replaceHolders = require('./_replaceHolders'),
root = require('./_root');
@@ -20,11 +22,14 @@ var BIND_FLAG = 1,
*
* @private
* @param {Function|string} func The function or method name to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
* for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
* @param {Array} [partials] The arguments to prepend to those provided to
* the new function.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [partialsRight] The arguments to append to those provided to the new function.
* @param {Array} [partialsRight] The arguments to append to those provided
* to the new function.
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
@@ -35,8 +40,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
var isAry = bitmask & ARY_FLAG,
isBind = bitmask & BIND_FLAG,
isBindKey = bitmask & BIND_KEY_FLAG,
isCurry = bitmask & CURRY_FLAG,
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
isFlip = bitmask & FLIP_FLAG,
Ctor = isBindKey ? undefined : createCtorWrapper(func);
@@ -48,30 +52,34 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
while (index--) {
args[index] = arguments[index];
}
if (isCurried) {
var placeholder = getPlaceholder(wrapper),
holdersCount = countHolders(args, placeholder);
}
if (partials) {
args = composeArgs(args, partials, holders);
args = composeArgs(args, partials, holders, isCurried);
}
if (partialsRight) {
args = composeArgsRight(args, partialsRight, holdersRight);
args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
}
if (isCurry || isCurryRight) {
var placeholder = wrapper.placeholder,
argsHolders = replaceHolders(args, placeholder);
length -= argsHolders.length;
if (length < arity) {
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
}
length -= holdersCount;
if (isCurried && length < arity) {
var newHolders = replaceHolders(args, placeholder);
return createRecurryWrapper(
func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
args, newHolders, argPos, ary, arity - length
);
}
var thisBinding = isBind ? thisArg : this,
fn = isBindKey ? thisBinding[func] : func;
length = args.length;
if (argPos) {
args = reorder(args, argPos);
} else if (isFlip && args.length > 1) {
} else if (isFlip && length > 1) {
args.reverse();
}
if (isAry && ary < args.length) {
if (isAry && ary < length) {
args.length = ary;
}
if (this && this !== root && this instanceof wrapper) {

24
_createMathOperation.js Normal file
View File

@@ -0,0 +1,24 @@
/**
* Creates a function that performs a mathematical operation on two values.
*
* @private
* @param {Function} operator The function to perform the operation.
* @returns {Function} Returns the new mathematical operation function.
*/
function createMathOperation(operator) {
return function(value, other) {
var result;
if (value === undefined && other === undefined) {
return 0;
}
if (value !== undefined) {
result = value;
}
if (other !== undefined) {
result = result === undefined ? other : operator(result, other);
}
return result;
};
}
module.exports = createMathOperation;

View File

@@ -2,6 +2,7 @@ var apply = require('./_apply'),
arrayMap = require('./_arrayMap'),
baseFlatten = require('./_baseFlatten'),
baseIteratee = require('./_baseIteratee'),
isFlattenableIteratee = require('./_isFlattenableIteratee'),
rest = require('./rest');
/**
@@ -13,7 +14,7 @@ var apply = require('./_apply'),
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseIteratee);
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {

View File

@@ -1,19 +1,8 @@
var repeat = require('./repeat'),
var baseRepeat = require('./_baseRepeat'),
castSlice = require('./_castSlice'),
reHasComplexSymbol = require('./_reHasComplexSymbol'),
stringSize = require('./_stringSize'),
stringToArray = require('./_stringToArray'),
toInteger = require('./toInteger');
/** 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 + ']');
stringToArray = require('./_stringToArray');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
@@ -23,25 +12,21 @@ var nativeCeil = Math.ceil;
* is truncated if the number of characters exceeds `length`.
*
* @private
* @param {string} string The string to create padding for.
* @param {number} [length=0] The padding length.
* @param {number} length The padding length.
* @param {string} [chars=' '] The string used as padding.
* @returns {string} Returns the padding for `string`.
*/
function createPadding(string, length, chars) {
length = toInteger(length);
var strLength = stringSize(string);
if (!length || strLength >= length) {
return '';
}
var padLength = length - strLength;
function createPadding(length, chars) {
chars = chars === undefined ? ' ' : (chars + '');
var result = repeat(chars, nativeCeil(padLength / stringSize(chars)));
var charsLength = chars.length;
if (charsLength < 2) {
return charsLength ? baseRepeat(chars, length) : chars;
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
? stringToArray(result).slice(0, padLength).join('')
: result.slice(0, padLength);
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}
module.exports = createPadding;

View File

@@ -6,15 +6,16 @@ var apply = require('./_apply'),
var BIND_FLAG = 1;
/**
* Creates a function that wraps `func` to invoke it with the optional `this`
* binding of `thisArg` and the `partials` prepended to those provided to
* the wrapper.
* Creates a function that wraps `func` to invoke it with the `this` binding
* of `thisArg` and `partials` prepended to the arguments it receives.
*
* @private
* @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 {Array} partials The arguments to prepend to those provided to the new function.
* @param {Array} partials The arguments to prepend to those provided to
* the new function.
* @returns {Function} Returns the new wrapped function.
*/
function createPartialWrapper(func, bitmask, thisArg, partials) {

View File

@@ -15,11 +15,13 @@ var BIND_FLAG = 1,
*
* @private
* @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
* for more details.
* @param {Function} wrapFunc The function to create the `func` wrapper.
* @param {*} placeholder The placeholder to replace.
* @param {*} placeholder The placeholder value.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
* @param {Array} [partials] The arguments to prepend to those provided to
* the new function.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
@@ -29,7 +31,7 @@ var BIND_FLAG = 1,
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined,
newsHolders = isCurry ? holders : undefined,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
newPartialsRight = isCurry ? undefined : partials;
@@ -40,9 +42,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
if (!(bitmask & CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
}
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
result = wrapFunc.apply(undefined, newData);
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);
if (isLaziable(func)) {
setData(result, newData);
}

View File

@@ -8,6 +8,9 @@ var baseSetData = require('./_baseSetData'),
setData = require('./_setData'),
toInteger = require('./toInteger');
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
BIND_KEY_FLAG = 2,
@@ -16,9 +19,6 @@ var BIND_FLAG = 1,
PARTIAL_FLAG = 32,
PARTIAL_RIGHT_FLAG = 64;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
@@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
partials = holders = undefined;
}
var data = isBindKey ? undefined : getData(func),
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
var data = isBindKey ? undefined : getData(func);
var newData = [
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
argPos, ary, arity
];
if (data) {
mergeData(newData, data);

View File

@@ -12,9 +12,10 @@ var UNORDERED_COMPARE_FLAG = 1,
* @param {Array} array The array to compare.
* @param {Array} other The other array to compare.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {Object} [stack] Tracks traversed `array` and `other` objects.
* @param {Function} customizer The function to customize comparisons.
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
* for more details.
* @param {Object} stack Tracks traversed `array` and `other` objects.
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
@@ -55,12 +56,16 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
// Recursively compare arrays (susceptible to call stack limits).
if (isUnordered) {
if (!arraySome(other, function(othValue) {
return arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack);
return arrValue === othValue ||
equalFunc(arrValue, othValue, customizer, bitmask, stack);
})) {
result = false;
break;
}
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
} else if (!(
arrValue === othValue ||
equalFunc(arrValue, othValue, customizer, bitmask, stack)
)) {
result = false;
break;
}

View File

@@ -1,5 +1,6 @@
var Symbol = require('./_Symbol'),
Uint8Array = require('./_Uint8Array'),
equalArrays = require('./_equalArrays'),
mapToArray = require('./_mapToArray'),
setToArray = require('./_setToArray');
@@ -18,11 +19,12 @@ var boolTag = '[object Boolean]',
stringTag = '[object String]',
symbolTag = '[object Symbol]';
var arrayBufferTag = '[object ArrayBuffer]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]';
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/**
* A specialized version of `baseIsEqualDeep` for comparing objects of
@@ -36,12 +38,22 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
* @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
* for more details.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
switch (tag) {
case dataViewTag:
if ((object.byteLength != other.byteLength) ||
(object.byteOffset != other.byteOffset)) {
return false;
}
object = object.buffer;
other = other.buffer;
case arrayBufferTag:
if ((object.byteLength != other.byteLength) ||
!equalFunc(new Uint8Array(object), new Uint8Array(other))) {
@@ -51,8 +63,9 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
case boolTag:
case dateTag:
// Coerce dates and booleans to numbers, dates to milliseconds and booleans
// to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
// Coerce dates and booleans to numbers, dates to milliseconds and
// booleans to `1` or `0` treating invalid dates coerced to `NaN` as
// not equal.
return +object == +other;
case errorTag:
@@ -64,8 +77,9 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings primitives and string
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
// Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
// for more details.
return object == (other + '');
case mapTag:
@@ -75,12 +89,24 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
convert || (convert = setToArray);
if (object.size != other.size && !isPartial) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked) {
return stacked == other;
}
bitmask |= UNORDERED_COMPARE_FLAG;
stack.set(object, other);
// Recursively compare objects (susceptible to call stack limits).
return (isPartial || object.size == other.size) &&
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
case symbolTag:
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
if (symbolValueOf) {
return symbolValueOf.call(object) == symbolValueOf.call(other);
}
}
return false;
}

View File

@@ -12,9 +12,10 @@ var PARTIAL_COMPARE_FLAG = 2;
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
* @param {Function} customizer The function to customize comparisons.
* @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
* for more details.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {

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