mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Bump to v4.7.0.
This commit is contained in:
60
LICENSE
60
LICENSE
@@ -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.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# lodash v4.6.1
|
||||
# lodash v4.7.0
|
||||
|
||||
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
|
||||
|
||||
@@ -17,7 +17,7 @@ var _ = require('lodash');
|
||||
// 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');
|
||||
var fp = require('lodash/fp');
|
||||
|
||||
// Load a method category.
|
||||
var array = require('lodash/array');
|
||||
@@ -28,7 +28,7 @@ var chunk = require('lodash/chunk');
|
||||
var extend = require('lodash/fp/extend');
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.6.1-npm) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.7.0-npm) for more details.
|
||||
|
||||
**Note:**<br>
|
||||
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
||||
@@ -36,5 +36,5 @@ Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash b
|
||||
|
||||
## 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
7
_DataView.js
Normal 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;
|
||||
@@ -21,6 +21,7 @@ function LazyWrapper(value) {
|
||||
this.__views__ = [];
|
||||
}
|
||||
|
||||
// Ensure `LazyWrapper` is an instance of `baseLodash`.
|
||||
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
||||
LazyWrapper.prototype.constructor = LazyWrapper;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -22,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
7
_Promise.js
Normal 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;
|
||||
@@ -19,7 +19,7 @@ function SetCache(values) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add functions to the `SetCache`.
|
||||
// Add methods to `SetCache`.
|
||||
SetCache.prototype.push = cachePush;
|
||||
|
||||
module.exports = SetCache;
|
||||
|
||||
@@ -22,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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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`.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -5,7 +5,7 @@ var isArrayLikeObject = require('./isArrayLikeObject');
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the array-like object.
|
||||
* @returns {Array|Object} Returns the cast array-like object.
|
||||
*/
|
||||
function baseCastArrayLikeObject(value) {
|
||||
return isArrayLikeObject(value) ? value : [];
|
||||
|
||||
@@ -5,7 +5,7 @@ var identity = require('./identity');
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the array-like object.
|
||||
* @returns {Function} Returns cast function.
|
||||
*/
|
||||
function baseCastFunction(value) {
|
||||
return typeof value == 'function' ? value : identity;
|
||||
|
||||
14
_baseCastKey.js
Normal file
14
_baseCastKey.js
Normal file
@@ -0,0 +1,14 @@
|
||||
var isSymbol = require('./isSymbol');
|
||||
|
||||
/**
|
||||
* Casts `value` to a string if it's not a string or symbol.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {string|symbol} Returns the cast key.
|
||||
*/
|
||||
function baseCastKey(key) {
|
||||
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
|
||||
}
|
||||
|
||||
module.exports = baseCastKey;
|
||||
@@ -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;
|
||||
|
||||
@@ -103,14 +105,13 @@ function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||||
}
|
||||
result = initCloneObject(isFunc ? {} : value);
|
||||
if (!isDeep) {
|
||||
result = baseAssign(result, value);
|
||||
return isFull ? copySymbols(value, result) : result;
|
||||
return copySymbols(value, baseAssign(result, value));
|
||||
}
|
||||
} else {
|
||||
if (!cloneableTags[tag]) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneByTag(value, tag, isDeep);
|
||||
result = initCloneByTag(value, tag, baseClone, isDeep);
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
@@ -121,11 +122,18 @@ function baseClone(value, isDeep, isFull, 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) {
|
||||
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 (isFull && !isArr) ? copySymbols(value, result) : result;
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = baseClone;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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` invoking `iteratee` for each property.
|
||||
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to iterate over.
|
||||
|
||||
@@ -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;
|
||||
@@ -10,7 +10,7 @@ var baseCastPath = require('./_baseCastPath'),
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function baseGet(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
|
||||
22
_baseGetAllKeys.js
Normal file
22
_baseGetAllKeys.js
Normal 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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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`.
|
||||
*/
|
||||
@@ -64,8 +65,11 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
||||
|
||||
if (objIsWrapped || othIsWrapped) {
|
||||
var objUnwrapped = objIsWrapped ? object.value() : object,
|
||||
othUnwrapped = othIsWrapped ? other.value() : other;
|
||||
|
||||
stack || (stack = new Stack);
|
||||
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
|
||||
return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
|
||||
}
|
||||
}
|
||||
if (!isSameTag) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* The function whose prototype all chaining wrappers inherit from.
|
||||
* The function whose prototype chain sequence wrappers inherit from.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
20
_baseMean.js
Normal file
20
_baseMean.js
Normal 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;
|
||||
@@ -15,16 +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;
|
||||
|
||||
@@ -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],
|
||||
@@ -50,7 +51,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
}
|
||||
else {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, !customizer);
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
@@ -59,7 +60,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, !customizer);
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = objValue;
|
||||
|
||||
@@ -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.
|
||||
@@ -15,7 +16,7 @@ var arrayMap = require('./_arrayMap'),
|
||||
*/
|
||||
function baseOrderBy(collection, iteratees, orders) {
|
||||
var index = -1;
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), baseIteratee);
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
|
||||
|
||||
var result = baseMap(collection, function(value, key, collection) {
|
||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
35
_baseRepeat.js
Normal 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;
|
||||
@@ -15,7 +15,7 @@ var assignValue = require('./_assignValue'),
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseSet(object, path, value, customizer) {
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -13,7 +13,7 @@ var baseCastPath = require('./_baseCastPath'),
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
*/
|
||||
function baseUnset(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
var key = last(path);
|
||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
16
_cloneDataView.js
Normal file
16
_cloneDataView.js
Normal 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;
|
||||
@@ -7,10 +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) {
|
||||
return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
|
||||
function cloneMap(map, isDeep, cloneFunc) {
|
||||
var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
|
||||
return arrayReduce(array, addMapEntry, new map.constructor);
|
||||
}
|
||||
|
||||
module.exports = cloneMap;
|
||||
|
||||
@@ -7,10 +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) {
|
||||
return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
|
||||
function cloneSet(set, isDeep, cloneFunc) {
|
||||
var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
|
||||
return arrayReduce(array, addSetEntry, new set.constructor);
|
||||
}
|
||||
|
||||
module.exports = cloneSet;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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`.
|
||||
*/
|
||||
|
||||
@@ -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`.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -11,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.
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,9 @@ function createFlow(fromRight) {
|
||||
) {
|
||||
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() {
|
||||
|
||||
@@ -22,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`.
|
||||
|
||||
24
_createMathOperation.js
Normal file
24
_createMathOperation.js
Normal 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;
|
||||
@@ -1,7 +1,6 @@
|
||||
var repeat = require('./repeat'),
|
||||
var baseRepeat = require('./_baseRepeat'),
|
||||
stringSize = require('./_stringSize'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
toInteger = require('./toInteger');
|
||||
stringToArray = require('./_stringToArray');
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
@@ -23,25 +22,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);
|
||||
? stringToArray(result).slice(0, length).join('')
|
||||
: result.slice(0, length);
|
||||
}
|
||||
|
||||
module.exports = createPadding;
|
||||
|
||||
@@ -12,9 +12,11 @@ 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`.
|
||||
* @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) {
|
||||
|
||||
@@ -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 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`.
|
||||
|
||||
@@ -13,7 +13,8 @@ var UNORDERED_COMPARE_FLAG = 1,
|
||||
* @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 {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`.
|
||||
*/
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ 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,
|
||||
@@ -38,12 +39,21 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
* @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 {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, 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))) {
|
||||
@@ -53,8 +63,9 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
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:
|
||||
@@ -66,8 +77,8 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||
|
||||
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 https://es5.github.io/#x15.10.6.4 for more details.
|
||||
return object == (other + '');
|
||||
|
||||
case mapTag:
|
||||
@@ -85,8 +96,11 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
|
||||
if (stacked) {
|
||||
return stacked == other;
|
||||
}
|
||||
bitmask |= UNORDERED_COMPARE_FLAG;
|
||||
stack.set(object, other);
|
||||
|
||||
// Recursively compare objects (susceptible to call stack limits).
|
||||
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other));
|
||||
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
|
||||
|
||||
case symbolTag:
|
||||
if (symbolValueOf) {
|
||||
|
||||
@@ -13,7 +13,8 @@ var PARTIAL_COMPARE_FLAG = 2;
|
||||
* @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`.
|
||||
*/
|
||||
|
||||
16
_getAllKeys.js
Normal file
16
_getAllKeys.js
Normal file
@@ -0,0 +1,16 @@
|
||||
var baseGetAllKeys = require('./_baseGetAllKeys'),
|
||||
getSymbols = require('./_getSymbols'),
|
||||
keys = require('./keys');
|
||||
|
||||
/**
|
||||
* Creates an array of own enumerable property names and symbols of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names and symbols.
|
||||
*/
|
||||
function getAllKeys(object) {
|
||||
return baseGetAllKeys(object, keys, getSymbols);
|
||||
}
|
||||
|
||||
module.exports = getAllKeys;
|
||||
17
_getAllKeysIn.js
Normal file
17
_getAllKeysIn.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var baseGetAllKeys = require('./_baseGetAllKeys'),
|
||||
getSymbolsIn = require('./_getSymbolsIn'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* Creates an array of own and inherited enumerable property names and
|
||||
* symbols of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names and symbols.
|
||||
*/
|
||||
function getAllKeysIn(object) {
|
||||
return baseGetAllKeys(object, keysIn, getSymbolsIn);
|
||||
}
|
||||
|
||||
module.exports = getAllKeysIn;
|
||||
@@ -3,8 +3,9 @@ var baseProperty = require('./_baseProperty');
|
||||
/**
|
||||
* Gets the "length" property value of `object`.
|
||||
*
|
||||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
|
||||
* that affects Safari on at least iOS 8.1-8.3 ARM64.
|
||||
* **Note:** This function is used to avoid a
|
||||
* [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
|
||||
* Safari on at least iOS 8.1-8.3 ARM64.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
|
||||
15
_getPrototype.js
Normal file
15
_getPrototype.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeGetPrototype = Object.getPrototypeOf;
|
||||
|
||||
/**
|
||||
* Gets the `[[Prototype]]` of `value`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to query.
|
||||
* @returns {null|Object} Returns the `[[Prototype]]`.
|
||||
*/
|
||||
function getPrototype(value) {
|
||||
return nativeGetPrototype(Object(value));
|
||||
}
|
||||
|
||||
module.exports = getPrototype;
|
||||
@@ -2,14 +2,23 @@
|
||||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
|
||||
/**
|
||||
* Creates an array of the own symbol properties of `object`.
|
||||
* Creates an array of the own enumerable symbol properties of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of symbols.
|
||||
*/
|
||||
var getSymbols = getOwnPropertySymbols || function() {
|
||||
function getSymbols(object) {
|
||||
// Coerce `object` to an object to avoid non-object errors in V8.
|
||||
// See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details.
|
||||
return getOwnPropertySymbols(Object(object));
|
||||
}
|
||||
|
||||
// Fallback for IE < 11.
|
||||
if (!getOwnPropertySymbols) {
|
||||
getSymbols = function() {
|
||||
return [];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = getSymbols;
|
||||
|
||||
25
_getSymbolsIn.js
Normal file
25
_getSymbolsIn.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var arrayPush = require('./_arrayPush'),
|
||||
getPrototype = require('./_getPrototype'),
|
||||
getSymbols = require('./_getSymbols');
|
||||
|
||||
/** Built-in value references. */
|
||||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
|
||||
/**
|
||||
* Creates an array of the own and inherited enumerable symbol properties
|
||||
* of `object`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of symbols.
|
||||
*/
|
||||
var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) {
|
||||
var result = [];
|
||||
while (object) {
|
||||
arrayPush(result, getSymbols(object));
|
||||
object = getPrototype(object);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = getSymbolsIn;
|
||||
20
_getTag.js
20
_getTag.js
@@ -1,13 +1,18 @@
|
||||
var Map = require('./_Map'),
|
||||
var DataView = require('./_DataView'),
|
||||
Map = require('./_Map'),
|
||||
Promise = require('./_Promise'),
|
||||
Set = require('./_Set'),
|
||||
WeakMap = require('./_WeakMap');
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
objectTag = '[object Object]',
|
||||
promiseTag = '[object Promise]',
|
||||
setTag = '[object Set]',
|
||||
weakMapTag = '[object WeakMap]';
|
||||
|
||||
var dataViewTag = '[object DataView]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
@@ -21,7 +26,9 @@ var funcToString = Function.prototype.toString;
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/** Used to detect maps, sets, and weakmaps. */
|
||||
var mapCtorString = Map ? funcToString.call(Map) : '',
|
||||
var dataViewCtorString = DataView ? (DataView + '') : '',
|
||||
mapCtorString = Map ? funcToString.call(Map) : '',
|
||||
promiseCtorString = Promise ? funcToString.call(Promise) : '',
|
||||
setCtorString = Set ? funcToString.call(Set) : '',
|
||||
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
|
||||
|
||||
@@ -36,8 +43,11 @@ function getTag(value) {
|
||||
return objectToString.call(value);
|
||||
}
|
||||
|
||||
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
|
||||
if ((Map && getTag(new Map) != mapTag) ||
|
||||
// Fallback for data views, maps, sets, and weak maps in IE 11,
|
||||
// for data views in Edge, and promises in Node.js.
|
||||
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
||||
(Map && getTag(new Map) != mapTag) ||
|
||||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
||||
(Set && getTag(new Set) != setTag) ||
|
||||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||||
getTag = function(value) {
|
||||
@@ -47,7 +57,9 @@ if ((Map && getTag(new Map) != mapTag) ||
|
||||
|
||||
if (ctorString) {
|
||||
switch (ctorString) {
|
||||
case dataViewCtorString: return dataViewTag;
|
||||
case mapCtorString: return mapTag;
|
||||
case promiseCtorString: return promiseTag;
|
||||
case setCtorString: return setTag;
|
||||
case weakMapCtorString: return weakMapTag;
|
||||
}
|
||||
|
||||
18
_hasPath.js
18
_hasPath.js
@@ -4,9 +4,7 @@ var baseCastPath = require('./_baseCastPath'),
|
||||
isIndex = require('./_isIndex'),
|
||||
isKey = require('./_isKey'),
|
||||
isLength = require('./isLength'),
|
||||
isString = require('./isString'),
|
||||
last = require('./last'),
|
||||
parent = require('./_parent');
|
||||
isString = require('./isString');
|
||||
|
||||
/**
|
||||
* Checks if `path` exists on `object`.
|
||||
@@ -24,10 +22,16 @@ function hasPath(object, path, hasFunc) {
|
||||
var result = hasFunc(object, path);
|
||||
if (!result && !isKey(path)) {
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
if (object != null) {
|
||||
path = last(path);
|
||||
result = hasFunc(object, path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length;
|
||||
|
||||
while (object != null && ++index < length) {
|
||||
var key = path[index];
|
||||
if (!(result = hasFunc(object, key))) {
|
||||
break;
|
||||
}
|
||||
object = object[key];
|
||||
}
|
||||
}
|
||||
var length = object ? object.length : undefined;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var cloneArrayBuffer = require('./_cloneArrayBuffer'),
|
||||
cloneDataView = require('./_cloneDataView'),
|
||||
cloneMap = require('./_cloneMap'),
|
||||
cloneRegExp = require('./_cloneRegExp'),
|
||||
cloneSet = require('./_cloneSet'),
|
||||
@@ -16,6 +17,7 @@ var boolTag = '[object Boolean]',
|
||||
symbolTag = '[object Symbol]';
|
||||
|
||||
var arrayBufferTag = '[object ArrayBuffer]',
|
||||
dataViewTag = '[object DataView]',
|
||||
float32Tag = '[object Float32Array]',
|
||||
float64Tag = '[object Float64Array]',
|
||||
int8Tag = '[object Int8Array]',
|
||||
@@ -35,10 +37,11 @@ var arrayBufferTag = '[object ArrayBuffer]',
|
||||
* @private
|
||||
* @param {Object} object The object to clone.
|
||||
* @param {string} tag The `toStringTag` of the object to clone.
|
||||
* @param {Function} cloneFunc The function to clone values.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @returns {Object} Returns the initialized clone.
|
||||
*/
|
||||
function initCloneByTag(object, tag, isDeep) {
|
||||
function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||||
var Ctor = object.constructor;
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
@@ -48,13 +51,16 @@ function initCloneByTag(object, tag, isDeep) {
|
||||
case dateTag:
|
||||
return new Ctor(+object);
|
||||
|
||||
case dataViewTag:
|
||||
return cloneDataView(object, isDeep);
|
||||
|
||||
case float32Tag: case float64Tag:
|
||||
case int8Tag: case int16Tag: case int32Tag:
|
||||
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
|
||||
return cloneTypedArray(object, isDeep);
|
||||
|
||||
case mapTag:
|
||||
return cloneMap(object);
|
||||
return cloneMap(object, isDeep, cloneFunc);
|
||||
|
||||
case numberTag:
|
||||
case stringTag:
|
||||
@@ -64,7 +70,7 @@ function initCloneByTag(object, tag, isDeep) {
|
||||
return cloneRegExp(object);
|
||||
|
||||
case setTag:
|
||||
return cloneSet(object);
|
||||
return cloneSet(object, isDeep, cloneFunc);
|
||||
|
||||
case symbolTag:
|
||||
return cloneSymbol(object);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
var baseCreate = require('./_baseCreate'),
|
||||
getPrototype = require('./_getPrototype'),
|
||||
isPrototype = require('./_isPrototype');
|
||||
|
||||
/** Built-in value references. */
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
|
||||
/**
|
||||
* Initializes an object clone.
|
||||
*
|
||||
@@ -13,7 +11,7 @@ var getPrototypeOf = Object.getPrototypeOf;
|
||||
*/
|
||||
function initCloneObject(object) {
|
||||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||||
? baseCreate(getPrototypeOf(object))
|
||||
? baseCreate(getPrototype(object))
|
||||
: {};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ var eq = require('./eq'),
|
||||
* @param {*} value The potential iteratee value argument.
|
||||
* @param {*} index The potential iteratee index or key argument.
|
||||
* @param {*} object The potential iteratee object argument.
|
||||
* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
|
||||
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
||||
* else `false`.
|
||||
*/
|
||||
function isIterateeCall(value, index, object) {
|
||||
if (!isObject(object)) {
|
||||
@@ -19,7 +20,8 @@ function isIterateeCall(value, index, object) {
|
||||
var type = typeof index;
|
||||
if (type == 'number'
|
||||
? (isArrayLike(object) && isIndex(index, object.length))
|
||||
: (type == 'string' && index in object)) {
|
||||
: (type == 'string' && index in object)
|
||||
) {
|
||||
return eq(object[index], value);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var isArray = require('./isArray');
|
||||
var isArray = require('./isArray'),
|
||||
isSymbol = require('./isSymbol');
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
||||
@@ -13,11 +14,12 @@ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
||||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||||
*/
|
||||
function isKey(value, object) {
|
||||
if (typeof value == 'number') {
|
||||
var type = typeof value;
|
||||
if (type == 'number' || type == 'symbol') {
|
||||
return true;
|
||||
}
|
||||
return !isArray(value) &&
|
||||
(reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||
(isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||
(object != null && value in Object(object)));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ var LazyWrapper = require('./_LazyWrapper'),
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to check.
|
||||
* @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.
|
||||
* @returns {boolean} Returns `true` if `func` has a lazy counterpart,
|
||||
* else `false`.
|
||||
*/
|
||||
function isLaziable(func) {
|
||||
var funcName = getFuncName(func),
|
||||
|
||||
@@ -11,7 +11,7 @@ var Map = require('./_Map'),
|
||||
* @memberOf MapCache
|
||||
* @param {string} key The key of the value to set.
|
||||
* @param {*} value The value to set.
|
||||
* @returns {Object} Returns the map cache object.
|
||||
* @returns {Object} Returns the map cache instance.
|
||||
*/
|
||||
function mapSet(key, value) {
|
||||
var data = this.__data__;
|
||||
|
||||
@@ -22,10 +22,11 @@ var nativeMin = Math.min;
|
||||
*
|
||||
* Merging metadata reduces the number of wrappers used to invoke a function.
|
||||
* This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
|
||||
* may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`
|
||||
* modify function arguments, making the order in which they are executed important,
|
||||
* preventing the merging of metadata. However, we make an exception for a safe
|
||||
* combined case where curried functions have `_.ary` and or `_.rearg` applied.
|
||||
* may be applied regardless of execution order. Methods like `_.ary` and
|
||||
* `_.rearg` modify function arguments, making the order in which they are
|
||||
* executed important, preventing the merging of metadata. However, we make
|
||||
* an exception for a safe combined case where curried functions have `_.ary`
|
||||
* and or `_.rearg` applied.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} data The destination metadata.
|
||||
|
||||
@@ -10,7 +10,8 @@ var baseMerge = require('./_baseMerge'),
|
||||
* @param {string} key The key of the property to merge.
|
||||
* @param {Object} object The parent object of `objValue`.
|
||||
* @param {Object} source The parent object of `srcValue`.
|
||||
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
|
||||
* @param {Object} [stack] Tracks traversed source values and their merged
|
||||
* counterparts.
|
||||
* @returns {*} Returns the value to assign.
|
||||
*/
|
||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var baseSlice = require('./_baseSlice'),
|
||||
get = require('./get');
|
||||
var baseGet = require('./_baseGet'),
|
||||
baseSlice = require('./_baseSlice');
|
||||
|
||||
/**
|
||||
* Gets the parent value at `path` of `object`.
|
||||
@@ -10,7 +10,7 @@ var baseSlice = require('./_baseSlice'),
|
||||
* @returns {*} Returns the parent value.
|
||||
*/
|
||||
function parent(object, path) {
|
||||
return path.length == 1 ? object : get(object, baseSlice(path, 0, -1));
|
||||
return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
||||
}
|
||||
|
||||
module.exports = parent;
|
||||
|
||||
@@ -9,8 +9,9 @@ var HOT_COUNT = 150,
|
||||
* Sets metadata for `func`.
|
||||
*
|
||||
* **Note:** If this function becomes hot, i.e. is invoked a lot in a short
|
||||
* period of time, it will trip its breaker and transition to an identity function
|
||||
* to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)
|
||||
* period of time, it will trip its breaker and transition to an identity
|
||||
* function to avoid garbage collection pauses in V8. See
|
||||
* [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
|
||||
* for more details.
|
||||
*
|
||||
* @private
|
||||
|
||||
@@ -12,7 +12,7 @@ var LARGE_ARRAY_SIZE = 200;
|
||||
* @memberOf Stack
|
||||
* @param {string} key The key of the value to set.
|
||||
* @param {*} value The value to set.
|
||||
* @returns {Object} Returns the stack cache object.
|
||||
* @returns {Object} Returns the stack cache instance.
|
||||
*/
|
||||
function stackSet(key, value) {
|
||||
var data = this.__data__,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var toString = require('./toString');
|
||||
var memoize = require('./memoize'),
|
||||
toString = require('./toString');
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
|
||||
@@ -13,12 +14,12 @@ var reEscapeChar = /\\(\\)?/g;
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
function stringToPath(string) {
|
||||
var stringToPath = memoize(function(string) {
|
||||
var result = [];
|
||||
toString(string).replace(rePropName, function(match, number, quote, string) {
|
||||
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = stringToPath;
|
||||
|
||||
19
add.js
19
add.js
@@ -1,8 +1,11 @@
|
||||
var createMathOperation = require('./_createMathOperation');
|
||||
|
||||
/**
|
||||
* Adds two numbers.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.4.0
|
||||
* @category Math
|
||||
* @param {number} augend The first number in an addition.
|
||||
* @param {number} addend The second number in an addition.
|
||||
@@ -12,18 +15,8 @@
|
||||
* _.add(6, 4);
|
||||
* // => 10
|
||||
*/
|
||||
function add(augend, addend) {
|
||||
var result;
|
||||
if (augend === undefined && addend === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (augend !== undefined) {
|
||||
result = augend;
|
||||
}
|
||||
if (addend !== undefined) {
|
||||
result = result === undefined ? addend : (result + addend);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var add = createMathOperation(function(augend, addend) {
|
||||
return augend + addend;
|
||||
});
|
||||
|
||||
module.exports = add;
|
||||
|
||||
3
after.js
3
after.js
@@ -9,6 +9,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {number} n The number of calls before `func` is invoked.
|
||||
* @param {Function} func The function to restrict.
|
||||
@@ -24,7 +25,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
* _.forEach(saves, function(type) {
|
||||
* asyncSave({ 'type': type, 'complete': done });
|
||||
* });
|
||||
* // => logs 'done saving!' after the two async saves have completed
|
||||
* // => Logs 'done saving!' after the two async saves have completed.
|
||||
*/
|
||||
function after(n, func) {
|
||||
if (typeof func != 'function') {
|
||||
|
||||
3
ary.js
3
ary.js
@@ -9,10 +9,11 @@ var ARY_FLAG = 128;
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to cap arguments for.
|
||||
* @param {number} [n=func.length] The arity cap.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
|
||||
@@ -18,15 +18,16 @@ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
|
||||
/**
|
||||
* Assigns own enumerable properties of source objects to the destination
|
||||
* object. Source objects are applied from left to right. Subsequent sources
|
||||
* overwrite property assignments of previous sources.
|
||||
* Assigns own enumerable string keyed properties of source objects to the
|
||||
* destination object. Source objects are applied from left to right.
|
||||
* Subsequent sources overwrite property assignments of previous sources.
|
||||
*
|
||||
* **Note:** This method mutates `object` and is loosely based on
|
||||
* [`Object.assign`](https://mdn.io/Object/assign).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.10.0
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
|
||||
@@ -22,6 +22,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @alias extend
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
|
||||
@@ -3,15 +3,16 @@ var copyObjectWith = require('./_copyObjectWith'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* This method is like `_.assignIn` except that it accepts `customizer` which
|
||||
* is invoked to produce the assigned values. If `customizer` returns `undefined`
|
||||
* assignment is handled by the method instead. The `customizer` is invoked
|
||||
* with five arguments: (objValue, srcValue, key, object, source).
|
||||
* This method is like `_.assignIn` except that it accepts `customizer`
|
||||
* which is invoked to produce the assigned values. If `customizer` returns
|
||||
* `undefined` assignment is handled by the method instead. The `customizer`
|
||||
* is invoked with five arguments: (objValue, srcValue, key, object, source).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @alias extendWith
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
|
||||
@@ -3,15 +3,16 @@ var copyObjectWith = require('./_copyObjectWith'),
|
||||
keys = require('./keys');
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it accepts `customizer` which
|
||||
* is invoked to produce the assigned values. If `customizer` returns `undefined`
|
||||
* assignment is handled by the method instead. The `customizer` is invoked
|
||||
* with five arguments: (objValue, srcValue, key, object, source).
|
||||
* This method is like `_.assign` except that it accepts `customizer`
|
||||
* which is invoked to produce the assigned values. If `customizer` returns
|
||||
* `undefined` assignment is handled by the method instead. The `customizer`
|
||||
* is invoked with five arguments: (objValue, srcValue, key, object, source).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} sources The source objects.
|
||||
|
||||
1
at.js
1
at.js
@@ -7,6 +7,7 @@ var baseAt = require('./_baseAt'),
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 1.0.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {...(string|string[])} [paths] The property paths of elements to pick,
|
||||
|
||||
@@ -8,8 +8,10 @@ var apply = require('./_apply'),
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Util
|
||||
* @param {Function} func The function to attempt.
|
||||
* @param {...*} [args] The arguments to invoke `func` with.
|
||||
* @returns {*} Returns the `func` result or error object.
|
||||
* @example
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Function
|
||||
* @param {number} n The number of calls at which `func` is no longer invoked.
|
||||
* @param {Function} func The function to restrict.
|
||||
|
||||
1
bind.js
1
bind.js
@@ -20,6 +20,7 @@ var BIND_FLAG = 1,
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to bind.
|
||||
* @param {*} thisArg The `this` binding of `func`.
|
||||
|
||||
@@ -10,6 +10,7 @@ var arrayEach = require('./_arrayEach'),
|
||||
* **Note:** This method doesn't set the "length" property of bound functions.
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {Object} object The object to bind and assign the bound methods to.
|
||||
@@ -27,7 +28,7 @@ var arrayEach = require('./_arrayEach'),
|
||||
*
|
||||
* _.bindAll(view, 'onClick');
|
||||
* jQuery(element).on('click', view.onClick);
|
||||
* // => logs 'clicked docs' when clicked
|
||||
* // => Logs 'clicked docs' when clicked.
|
||||
*/
|
||||
var bindAll = rest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
|
||||
@@ -13,8 +13,8 @@ var BIND_FLAG = 1,
|
||||
* any additional `_.bindKey` arguments to those provided to the bound function.
|
||||
*
|
||||
* This method differs from `_.bind` by allowing bound functions to reference
|
||||
* methods that may be redefined or don't yet exist.
|
||||
* See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
|
||||
* methods that may be redefined or don't yet exist. See
|
||||
* [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
|
||||
* for more details.
|
||||
*
|
||||
* The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
|
||||
@@ -22,6 +22,7 @@ var BIND_FLAG = 1,
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.10.0
|
||||
* @category Function
|
||||
* @param {Object} object The object to invoke the method on.
|
||||
* @param {string} key The key of the method.
|
||||
|
||||
@@ -6,6 +6,7 @@ var capitalize = require('./capitalize'),
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the camel cased string.
|
||||
@@ -14,10 +15,10 @@ var capitalize = require('./capitalize'),
|
||||
* _.camelCase('Foo Bar');
|
||||
* // => 'fooBar'
|
||||
*
|
||||
* _.camelCase('--foo-bar');
|
||||
* _.camelCase('--foo-bar--');
|
||||
* // => 'fooBar'
|
||||
*
|
||||
* _.camelCase('__foo_bar__');
|
||||
* _.camelCase('__FOO_BAR__');
|
||||
* // => 'fooBar'
|
||||
*/
|
||||
var camelCase = createCompounder(function(result, word, index) {
|
||||
|
||||
@@ -7,6 +7,7 @@ var toString = require('./toString'),
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to capitalize.
|
||||
* @returns {string} Returns the capitalized string.
|
||||
|
||||
@@ -5,6 +5,7 @@ var isArray = require('./isArray');
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.4.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast array.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user