mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab95e7dde7 | ||
|
|
5425ef9a59 | ||
|
|
94ac73824f |
@@ -1,10 +1,10 @@
|
|||||||
# lodash-es v4.15.0
|
# lodash-es v4.16.2
|
||||||
|
|
||||||
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
|
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
|
||||||
|
|
||||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||||
```bash
|
```shell
|
||||||
$ lodash modularize exports=es -o ./
|
$ lodash modularize exports=es -o ./
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.15.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.16.2-es) for more details.
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ import stackSet from './_stackSet.js';
|
|||||||
* @param {Array} [entries] The key-value pairs to cache.
|
* @param {Array} [entries] The key-value pairs to cache.
|
||||||
*/
|
*/
|
||||||
function Stack(entries) {
|
function Stack(entries) {
|
||||||
this.__data__ = new ListCache(entries);
|
var data = this.__data__ = new ListCache(entries);
|
||||||
|
this.size = data.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add methods to `Stack`.
|
// Add methods to `Stack`.
|
||||||
|
|||||||
15
_arraySample.js
Normal file
15
_arraySample.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import baseRandom from './_baseRandom.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.sample` for arrays.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to sample.
|
||||||
|
* @returns {*} Returns the random element.
|
||||||
|
*/
|
||||||
|
function arraySample(array) {
|
||||||
|
var length = array.length;
|
||||||
|
return length ? array[baseRandom(0, length - 1)] : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default arraySample;
|
||||||
16
_arraySampleSize.js
Normal file
16
_arraySampleSize.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import copyArray from './_copyArray.js';
|
||||||
|
import shuffleSelf from './_shuffleSelf.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.sampleSize` for arrays.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to sample.
|
||||||
|
* @param {number} n The number of elements to sample.
|
||||||
|
* @returns {Array} Returns the random elements.
|
||||||
|
*/
|
||||||
|
function arraySampleSize(array, n) {
|
||||||
|
return shuffleSelf(copyArray(array), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default arraySampleSize;
|
||||||
15
_arrayShuffle.js
Normal file
15
_arrayShuffle.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import copyArray from './_copyArray.js';
|
||||||
|
import shuffleSelf from './_shuffleSelf.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.shuffle` for arrays.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to shuffle.
|
||||||
|
* @returns {Array} Returns the new shuffled array.
|
||||||
|
*/
|
||||||
|
function arrayShuffle(array) {
|
||||||
|
return shuffleSelf(copyArray(array));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default arrayShuffle;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import eq from './eq.js';
|
import eq from './eq.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +13,7 @@ import eq from './eq.js';
|
|||||||
function assignMergeValue(object, key, value) {
|
function assignMergeValue(object, key, value) {
|
||||||
if ((value !== undefined && !eq(object[key], value)) ||
|
if ((value !== undefined && !eq(object[key], value)) ||
|
||||||
(typeof key == 'number' && value === undefined && !(key in object))) {
|
(typeof key == 'number' && value === undefined && !(key in object))) {
|
||||||
object[key] = value;
|
baseAssignValue(object, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import eq from './eq.js';
|
import eq from './eq.js';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
@@ -20,7 +21,7 @@ function assignValue(object, key, value) {
|
|||||||
var objValue = object[key];
|
var objValue = object[key];
|
||||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||||
(value === undefined && !(key in object))) {
|
(value === undefined && !(key in object))) {
|
||||||
object[key] = value;
|
baseAssignValue(object, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
_baseAssignValue.js
Normal file
26
_baseAssignValue.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/** Built-in value references. */
|
||||||
|
var defineProperty = Object.defineProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `assignValue` and `assignMergeValue` without
|
||||||
|
* value checks.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The object to modify.
|
||||||
|
* @param {string} key The key of the property to assign.
|
||||||
|
* @param {*} value The value to assign.
|
||||||
|
*/
|
||||||
|
function baseAssignValue(object, key, value) {
|
||||||
|
if (key == '__proto__' && defineProperty) {
|
||||||
|
defineProperty(object, key, {
|
||||||
|
'configurable': true,
|
||||||
|
'enumerable': true,
|
||||||
|
'value': value,
|
||||||
|
'writable': true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
object[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseAssignValue;
|
||||||
@@ -12,7 +12,6 @@ import initCloneByTag from './_initCloneByTag.js';
|
|||||||
import initCloneObject from './_initCloneObject.js';
|
import initCloneObject from './_initCloneObject.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import isBuffer from './isBuffer.js';
|
import isBuffer from './isBuffer.js';
|
||||||
import isHostObject from './_isHostObject.js';
|
|
||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
import keys from './keys.js';
|
import keys from './keys.js';
|
||||||
|
|
||||||
@@ -100,9 +99,6 @@ function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
|||||||
return cloneBuffer(value, isDeep);
|
return cloneBuffer(value, isDeep);
|
||||||
}
|
}
|
||||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||||
if (isHostObject(value)) {
|
|
||||||
return object ? value : {};
|
|
||||||
}
|
|
||||||
result = initCloneObject(isFunc ? {} : value);
|
result = initCloneObject(isFunc ? {} : value);
|
||||||
if (!isDeep) {
|
if (!isDeep) {
|
||||||
return copySymbols(value, baseAssign(result, value));
|
return copySymbols(value, baseAssign(result, value));
|
||||||
|
|||||||
@@ -8,11 +8,23 @@ var objectCreate = Object.create;
|
|||||||
* properties to the created object.
|
* properties to the created object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} prototype The object to inherit from.
|
* @param {Object} proto The object to inherit from.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
function baseCreate(proto) {
|
var baseCreate = (function() {
|
||||||
return isObject(proto) ? objectCreate(proto) : {};
|
function object() {}
|
||||||
}
|
return function(proto) {
|
||||||
|
if (!isObject(proto)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (objectCreate) {
|
||||||
|
return objectCreate(proto);
|
||||||
|
}
|
||||||
|
object.prototype = prototype;
|
||||||
|
var result = new object;
|
||||||
|
object.prototype = undefined;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
export default baseCreate;
|
export default baseCreate;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import baseFindIndex from './_baseFindIndex.js';
|
import baseFindIndex from './_baseFindIndex.js';
|
||||||
import baseIsNaN from './_baseIsNaN.js';
|
import baseIsNaN from './_baseIsNaN.js';
|
||||||
|
import strictIndexOf from './_strictIndexOf.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||||||
@@ -11,18 +12,9 @@ import baseIsNaN from './_baseIsNaN.js';
|
|||||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||||
*/
|
*/
|
||||||
function baseIndexOf(array, value, fromIndex) {
|
function baseIndexOf(array, value, fromIndex) {
|
||||||
if (value !== value) {
|
return value === value
|
||||||
return baseFindIndex(array, baseIsNaN, fromIndex);
|
? strictIndexOf(array, value, fromIndex)
|
||||||
}
|
: baseFindIndex(array, baseIsNaN, fromIndex);
|
||||||
var index = fromIndex - 1,
|
|
||||||
length = array.length;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
if (array[index] === value) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseIndexOf;
|
export default baseIndexOf;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import equalByTag from './_equalByTag.js';
|
|||||||
import equalObjects from './_equalObjects.js';
|
import equalObjects from './_equalObjects.js';
|
||||||
import getTag from './_getTag.js';
|
import getTag from './_getTag.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
import isHostObject from './_isHostObject.js';
|
|
||||||
import isTypedArray from './isTypedArray.js';
|
import isTypedArray from './isTypedArray.js';
|
||||||
|
|
||||||
/** Used to compose bitmasks for comparison styles. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
@@ -50,8 +49,8 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
|||||||
othTag = getTag(other);
|
othTag = getTag(other);
|
||||||
othTag = othTag == argsTag ? objectTag : othTag;
|
othTag = othTag == argsTag ? objectTag : othTag;
|
||||||
}
|
}
|
||||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
var objIsObj = objTag == objectTag,
|
||||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
othIsObj = othTag == objectTag,
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
if (isSameTag && !objIsObj) {
|
if (isSameTag && !objIsObj) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import isFunction from './isFunction.js';
|
import isFunction from './isFunction.js';
|
||||||
import isHostObject from './_isHostObject.js';
|
|
||||||
import isMasked from './_isMasked.js';
|
import isMasked from './_isMasked.js';
|
||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
import toSource from './_toSource.js';
|
import toSource from './_toSource.js';
|
||||||
@@ -41,7 +40,7 @@ function baseIsNative(value) {
|
|||||||
if (!isObject(value) || isMasked(value)) {
|
if (!isObject(value) || isMasked(value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
||||||
return pattern.test(toSource(value));
|
return pattern.test(toSource(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||||
*
|
*
|
||||||
@@ -17,7 +19,7 @@ function basePickBy(object, props, predicate) {
|
|||||||
value = object[key];
|
value = object[key];
|
||||||
|
|
||||||
if (predicate(value, key)) {
|
if (predicate(value, key)) {
|
||||||
result[key] = value;
|
baseAssignValue(result, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
26
_baseRest.js
26
_baseRest.js
@@ -1,7 +1,6 @@
|
|||||||
import apply from './_apply.js';
|
import identity from './identity.js';
|
||||||
|
import overRest from './_overRest.js';
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
import setToString from './_setToString.js';
|
||||||
var nativeMax = Math.max;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
||||||
@@ -12,24 +11,7 @@ var nativeMax = Math.max;
|
|||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
*/
|
*/
|
||||||
function baseRest(func, start) {
|
function baseRest(func, start) {
|
||||||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
return setToString(overRest(func, start, identity), func + '');
|
||||||
return function() {
|
|
||||||
var args = arguments,
|
|
||||||
index = -1,
|
|
||||||
length = nativeMax(args.length - start, 0),
|
|
||||||
array = Array(length);
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
array[index] = args[start + index];
|
|
||||||
}
|
|
||||||
index = -1;
|
|
||||||
var otherArgs = Array(start + 1);
|
|
||||||
while (++index < start) {
|
|
||||||
otherArgs[index] = args[index];
|
|
||||||
}
|
|
||||||
otherArgs[start] = array;
|
|
||||||
return apply(func, this, otherArgs);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseRest;
|
export default baseRest;
|
||||||
|
|||||||
15
_baseSample.js
Normal file
15
_baseSample.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import arraySample from './_arraySample.js';
|
||||||
|
import values from './values.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.sample`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array|Object} collection The collection to sample.
|
||||||
|
* @returns {*} Returns the random element.
|
||||||
|
*/
|
||||||
|
function baseSample(collection) {
|
||||||
|
return arraySample(values(collection));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseSample;
|
||||||
16
_baseSampleSize.js
Normal file
16
_baseSampleSize.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import shuffleSelf from './_shuffleSelf.js';
|
||||||
|
import values from './values.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.sampleSize` without param guards.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array|Object} collection The collection to sample.
|
||||||
|
* @param {number} n The number of elements to sample.
|
||||||
|
* @returns {Array} Returns the random elements.
|
||||||
|
*/
|
||||||
|
function baseSampleSize(collection, n) {
|
||||||
|
return shuffleSelf(values(collection), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseSampleSize;
|
||||||
@@ -2,7 +2,7 @@ import identity from './identity.js';
|
|||||||
import metaMap from './_metaMap.js';
|
import metaMap from './_metaMap.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `setData` without support for hot loop detection.
|
* The base implementation of `setData` without support for hot loop shorting.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} func The function to associate metadata with.
|
* @param {Function} func The function to associate metadata with.
|
||||||
|
|||||||
22
_baseSetToString.js
Normal file
22
_baseSetToString.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import constant from './constant.js';
|
||||||
|
import identity from './identity.js';
|
||||||
|
import nativeDefineProperty from './_nativeDefineProperty.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `setToString` without support for hot loop shorting.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to modify.
|
||||||
|
* @param {Function} string The `toString` result.
|
||||||
|
* @returns {Function} Returns `func`.
|
||||||
|
*/
|
||||||
|
var baseSetToString = !nativeDefineProperty ? identity : function(func, string) {
|
||||||
|
return nativeDefineProperty(func, 'toString', {
|
||||||
|
'configurable': true,
|
||||||
|
'enumerable': false,
|
||||||
|
'value': constant(string),
|
||||||
|
'writable': true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default baseSetToString;
|
||||||
15
_baseShuffle.js
Normal file
15
_baseShuffle.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import shuffleSelf from './_shuffleSelf.js';
|
||||||
|
import values from './values.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.shuffle`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array|Object} collection The collection to shuffle.
|
||||||
|
* @returns {Array} Returns the new shuffled array.
|
||||||
|
*/
|
||||||
|
function baseShuffle(collection) {
|
||||||
|
return shuffleSelf(values(collection));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default baseShuffle;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Checks if a cache value for `key` exists.
|
* Checks if a `cache` value for `key` exists.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} cache The cache to query.
|
* @param {Object} cache The cache to query.
|
||||||
|
|||||||
14
_castRest.js
Normal file
14
_castRest.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import baseRest from './_baseRest.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `baseRest` alias which can be replaced with `identity` by module
|
||||||
|
* replacement plugins.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @type {Function}
|
||||||
|
* @param {Function} func The function to apply a rest parameter to.
|
||||||
|
* @returns {Function} Returns the new function.
|
||||||
|
*/
|
||||||
|
var castRest = baseRest;
|
||||||
|
|
||||||
|
export default castRest;
|
||||||
@@ -1,3 +1,18 @@
|
|||||||
|
import root from './_root.js';
|
||||||
|
|
||||||
|
/** Detect free variable `exports`. */
|
||||||
|
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
||||||
|
|
||||||
|
/** Detect free variable `module`. */
|
||||||
|
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
||||||
|
|
||||||
|
/** Detect the popular CommonJS extension `module.exports`. */
|
||||||
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var Buffer = moduleExports ? root.Buffer : undefined,
|
||||||
|
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `buffer`.
|
* Creates a clone of `buffer`.
|
||||||
*
|
*
|
||||||
@@ -10,7 +25,9 @@ function cloneBuffer(buffer, isDeep) {
|
|||||||
if (isDeep) {
|
if (isDeep) {
|
||||||
return buffer.slice();
|
return buffer.slice();
|
||||||
}
|
}
|
||||||
var result = new buffer.constructor(buffer.length);
|
var length = buffer.length,
|
||||||
|
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||||||
|
|
||||||
buffer.copy(result);
|
buffer.copy(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import assignValue from './_assignValue.js';
|
import assignValue from './_assignValue.js';
|
||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies properties of `source` to `object`.
|
* Copies properties of `source` to `object`.
|
||||||
@@ -11,6 +12,7 @@ import assignValue from './_assignValue.js';
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function copyObject(source, props, object, customizer) {
|
function copyObject(source, props, object, customizer) {
|
||||||
|
var isNew = !object;
|
||||||
object || (object = {});
|
object || (object = {});
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -23,7 +25,14 @@ function copyObject(source, props, object, customizer) {
|
|||||||
? customizer(object[key], source[key], key, object, source)
|
? customizer(object[key], source[key], key, object, source)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
assignValue(object, key, newValue === undefined ? source[key] : newValue);
|
if (newValue === undefined) {
|
||||||
|
newValue = source[key];
|
||||||
|
}
|
||||||
|
if (isNew) {
|
||||||
|
baseAssignValue(object, key, newValue);
|
||||||
|
} else {
|
||||||
|
assignValue(object, key, newValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function countHolders(array, placeholder) {
|
|||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
if (array[length] === placeholder) {
|
if (array[length] === placeholder) {
|
||||||
result++;
|
++result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import LodashWrapper from './_LodashWrapper.js';
|
import LodashWrapper from './_LodashWrapper.js';
|
||||||
import baseFlatten from './_baseFlatten.js';
|
import flatRest from './_flatRest.js';
|
||||||
import baseRest from './_baseRest.js';
|
|
||||||
import getData from './_getData.js';
|
import getData from './_getData.js';
|
||||||
import getFuncName from './_getFuncName.js';
|
import getFuncName from './_getFuncName.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
@@ -9,7 +8,7 @@ import isLaziable from './_isLaziable.js';
|
|||||||
/** Used as the size to enable large array optimizations. */
|
/** Used as the size to enable large array optimizations. */
|
||||||
var LARGE_ARRAY_SIZE = 200;
|
var LARGE_ARRAY_SIZE = 200;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
@@ -26,9 +25,7 @@ var CURRY_FLAG = 8,
|
|||||||
* @returns {Function} Returns the new flow function.
|
* @returns {Function} Returns the new flow function.
|
||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return baseRest(function(funcs) {
|
return flatRest(function(funcs) {
|
||||||
funcs = baseFlatten(funcs, 1);
|
|
||||||
|
|
||||||
var length = funcs.length,
|
var length = funcs.length,
|
||||||
index = length,
|
index = length,
|
||||||
prereq = LodashWrapper.prototype.thru;
|
prereq = LodashWrapper.prototype.thru;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import apply from './_apply.js';
|
import apply from './_apply.js';
|
||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseFlatten from './_baseFlatten.js';
|
|
||||||
import baseIteratee from './_baseIteratee.js';
|
import baseIteratee from './_baseIteratee.js';
|
||||||
import baseRest from './_baseRest.js';
|
import baseRest from './_baseRest.js';
|
||||||
import baseUnary from './_baseUnary.js';
|
import baseUnary from './_baseUnary.js';
|
||||||
import isArray from './isArray.js';
|
import flatRest from './_flatRest.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function like `_.over`.
|
* Creates a function like `_.over`.
|
||||||
@@ -14,11 +13,8 @@ import isArray from './isArray.js';
|
|||||||
* @returns {Function} Returns the new over function.
|
* @returns {Function} Returns the new over function.
|
||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return baseRest(function(iteratees) {
|
return flatRest(function(iteratees) {
|
||||||
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
|
||||||
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
|
||||||
: arrayMap(baseFlatten(iteratees, 1), baseUnary(baseIteratee));
|
|
||||||
|
|
||||||
return baseRest(function(args) {
|
return baseRest(function(args) {
|
||||||
var thisArg = this;
|
var thisArg = this;
|
||||||
return arrayFunc(iteratees, function(iteratee) {
|
return arrayFunc(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import setData from './_setData.js';
|
|||||||
import setWrapToString from './_setWrapToString.js';
|
import setWrapToString from './_setWrapToString.js';
|
||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ var deburredLetters = {
|
|||||||
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
|
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
|
||||||
'\u0132': 'IJ', '\u0133': 'ij',
|
'\u0132': 'IJ', '\u0133': 'ij',
|
||||||
'\u0152': 'Oe', '\u0153': 'oe',
|
'\u0152': 'Oe', '\u0153': 'oe',
|
||||||
'\u0149': "'n", '\u017f': 'ss'
|
'\u0149': "'n", '\u017f': 's'
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import getNative from './_getNative.js';
|
|
||||||
|
|
||||||
/* Used to set `toString` methods. */
|
|
||||||
var defineProperty = (function() {
|
|
||||||
var func = getNative(Object, 'defineProperty'),
|
|
||||||
name = getNative.name;
|
|
||||||
|
|
||||||
return (name && name.length > 2) ? func : undefined;
|
|
||||||
}());
|
|
||||||
|
|
||||||
export default defineProperty;
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import SetCache from './_SetCache.js';
|
import SetCache from './_SetCache.js';
|
||||||
import arraySome from './_arraySome.js';
|
import arraySome from './_arraySome.js';
|
||||||
|
import cacheHas from './_cacheHas.js';
|
||||||
|
|
||||||
/** Used to compose bitmasks for comparison styles. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
var UNORDERED_COMPARE_FLAG = 1,
|
var UNORDERED_COMPARE_FLAG = 1,
|
||||||
@@ -59,9 +60,9 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
|||||||
// Recursively compare arrays (susceptible to call stack limits).
|
// Recursively compare arrays (susceptible to call stack limits).
|
||||||
if (seen) {
|
if (seen) {
|
||||||
if (!arraySome(other, function(othValue, othIndex) {
|
if (!arraySome(other, function(othValue, othIndex) {
|
||||||
if (!seen.has(othIndex) &&
|
if (!cacheHas(seen, othIndex) &&
|
||||||
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
||||||
return seen.add(othIndex);
|
return seen.push(othIndex);
|
||||||
}
|
}
|
||||||
})) {
|
})) {
|
||||||
result = false;
|
result = false;
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ var htmlEscapes = {
|
|||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>',
|
'>': '>',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
"'": ''',
|
"'": '''
|
||||||
'`': '`'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
16
_flatRest.js
Normal file
16
_flatRest.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import flatten from './flatten.js';
|
||||||
|
import overRest from './_overRest.js';
|
||||||
|
import setToString from './_setToString.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `baseRest` which flattens the rest array.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to apply a rest parameter to.
|
||||||
|
* @returns {Function} Returns the new function.
|
||||||
|
*/
|
||||||
|
function flatRest(func) {
|
||||||
|
return setToString(overRest(func, undefined, flatten), func + '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export default flatRest;
|
||||||
@@ -41,8 +41,7 @@ var dataViewCtorString = toSource(DataView),
|
|||||||
*/
|
*/
|
||||||
var getTag = baseGetTag;
|
var getTag = baseGetTag;
|
||||||
|
|
||||||
// Fallback for data views, maps, sets, and weak maps in IE 11,
|
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
||||||
// for data views in Edge < 14, and promises in Node.js.
|
|
||||||
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
||||||
(Map && getTag(new Map) != mapTag) ||
|
(Map && getTag(new Map) != mapTag) ||
|
||||||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
||||||
|
|||||||
10
_hasPath.js
10
_hasPath.js
@@ -18,9 +18,9 @@ import toKey from './_toKey.js';
|
|||||||
function hasPath(object, path, hasFunc) {
|
function hasPath(object, path, hasFunc) {
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
|
|
||||||
var result,
|
var index = -1,
|
||||||
index = -1,
|
length = path.length,
|
||||||
length = path.length;
|
result = false;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = toKey(path[index]);
|
var key = toKey(path[index]);
|
||||||
@@ -29,10 +29,10 @@ function hasPath(object, path, hasFunc) {
|
|||||||
}
|
}
|
||||||
object = object[key];
|
object = object[key];
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result || ++index != length) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
var length = object ? object.length : 0;
|
length = object ? object.length : 0;
|
||||||
return !!length && isLength(length) && isIndex(key, length) &&
|
return !!length && isLength(length) && isIndex(key, length) &&
|
||||||
(isArray(object) || isArguments(object));
|
(isArray(object) || isArguments(object));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import nativeCreate from './_nativeCreate.js';
|
|||||||
*/
|
*/
|
||||||
function hashClear() {
|
function hashClear() {
|
||||||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||||||
|
this.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default hashClear;
|
export default hashClear;
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||||
*/
|
*/
|
||||||
function hashDelete(key) {
|
function hashDelete(key) {
|
||||||
return this.has(key) && delete this.__data__[key];
|
var result = this.has(key) && delete this.__data__[key];
|
||||||
|
this.size -= result ? 1 : 0;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default hashDelete;
|
export default hashDelete;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|||||||
*/
|
*/
|
||||||
function hashSet(key, value) {
|
function hashSet(key, value) {
|
||||||
var data = this.__data__;
|
var data = this.__data__;
|
||||||
|
this.size += this.has(key) ? 0 : 1;
|
||||||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
|
|||||||
* @returns {string} Returns the modified source.
|
* @returns {string} Returns the modified source.
|
||||||
*/
|
*/
|
||||||
function insertWrapDetails(source, details) {
|
function insertWrapDetails(source, details) {
|
||||||
var length = details.length,
|
var length = details.length;
|
||||||
lastIndex = length - 1;
|
if (!length) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
var lastIndex = length - 1;
|
||||||
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
|
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
|
||||||
details = details.join(length > 2 ? ', ' : ' ');
|
details = details.join(length > 2 ? ', ' : ' ');
|
||||||
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
|
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* Checks if `value` is a host object in IE < 9.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to check.
|
|
||||||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
|
||||||
*/
|
|
||||||
function isHostObject(value) {
|
|
||||||
// Many host objects are `Object` objects that can coerce to strings
|
|
||||||
// despite having improperly defined `toString` methods.
|
|
||||||
var result = false;
|
|
||||||
if (value != null && typeof value.toString != 'function') {
|
|
||||||
try {
|
|
||||||
result = !!(value + '');
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default isHostObject;
|
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
function listCacheClear() {
|
function listCacheClear() {
|
||||||
this.__data__ = [];
|
this.__data__ = [];
|
||||||
|
this.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default listCacheClear;
|
export default listCacheClear;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ function listCacheDelete(key) {
|
|||||||
} else {
|
} else {
|
||||||
splice.call(data, index, 1);
|
splice.call(data, index, 1);
|
||||||
}
|
}
|
||||||
|
--this.size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ function listCacheSet(key, value) {
|
|||||||
index = assocIndexOf(data, key);
|
index = assocIndexOf(data, key);
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
|
++this.size;
|
||||||
data.push([key, value]);
|
data.push([key, value]);
|
||||||
} else {
|
} else {
|
||||||
data[index][1] = value;
|
data[index][1] = value;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Map from './_Map.js';
|
|||||||
* @memberOf MapCache
|
* @memberOf MapCache
|
||||||
*/
|
*/
|
||||||
function mapCacheClear() {
|
function mapCacheClear() {
|
||||||
|
this.size = 0;
|
||||||
this.__data__ = {
|
this.__data__ = {
|
||||||
'hash': new Hash,
|
'hash': new Hash,
|
||||||
'map': new (Map || ListCache),
|
'map': new (Map || ListCache),
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import getMapData from './_getMapData.js';
|
|||||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||||
*/
|
*/
|
||||||
function mapCacheDelete(key) {
|
function mapCacheDelete(key) {
|
||||||
return getMapData(this, key)['delete'](key);
|
var result = getMapData(this, key)['delete'](key);
|
||||||
|
this.size -= result ? 1 : 0;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default mapCacheDelete;
|
export default mapCacheDelete;
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ import getMapData from './_getMapData.js';
|
|||||||
* @returns {Object} Returns the map cache instance.
|
* @returns {Object} Returns the map cache instance.
|
||||||
*/
|
*/
|
||||||
function mapCacheSet(key, value) {
|
function mapCacheSet(key, value) {
|
||||||
getMapData(this, key).set(key, value);
|
var data = getMapData(this, key),
|
||||||
|
size = data.size;
|
||||||
|
|
||||||
|
data.set(key, value);
|
||||||
|
this.size += data.size == size ? 0 : 1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
_memoizeCapped.js
Normal file
26
_memoizeCapped.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import memoize from './memoize.js';
|
||||||
|
|
||||||
|
/** Used as the maximum memoize cache size. */
|
||||||
|
var MAX_MEMOIZE_SIZE = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.memoize` which clears the memoized function's
|
||||||
|
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to have its output memoized.
|
||||||
|
* @returns {Function} Returns the new memoized function.
|
||||||
|
*/
|
||||||
|
function memoizeCapped(func) {
|
||||||
|
var result = memoize(func, function(key) {
|
||||||
|
if (cache.size === MAX_MEMOIZE_SIZE) {
|
||||||
|
cache.clear();
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
});
|
||||||
|
|
||||||
|
var cache = result.cache;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default memoizeCapped;
|
||||||
6
_nativeDefineProperty.js
Normal file
6
_nativeDefineProperty.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import getNative from './_getNative.js';
|
||||||
|
|
||||||
|
/* Built-in method references that are verified to be native. */
|
||||||
|
var nativeDefineProperty = getNative(Object, 'defineProperty');
|
||||||
|
|
||||||
|
export default nativeDefineProperty;
|
||||||
36
_overRest.js
Normal file
36
_overRest.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import apply from './_apply.js';
|
||||||
|
|
||||||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeMax = Math.max;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `baseRest` which transforms the rest array.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to apply a rest parameter to.
|
||||||
|
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||||||
|
* @param {Function} transform The rest array transform.
|
||||||
|
* @returns {Function} Returns the new function.
|
||||||
|
*/
|
||||||
|
function overRest(func, start, transform) {
|
||||||
|
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||||||
|
return function() {
|
||||||
|
var args = arguments,
|
||||||
|
index = -1,
|
||||||
|
length = nativeMax(args.length - start, 0),
|
||||||
|
array = Array(length);
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
array[index] = args[start + index];
|
||||||
|
}
|
||||||
|
index = -1;
|
||||||
|
var otherArgs = Array(start + 1);
|
||||||
|
while (++index < start) {
|
||||||
|
otherArgs[index] = args[index];
|
||||||
|
}
|
||||||
|
otherArgs[start] = transform(array);
|
||||||
|
return apply(func, this, otherArgs);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default overRest;
|
||||||
26
_setData.js
26
_setData.js
@@ -1,9 +1,5 @@
|
|||||||
import baseSetData from './_baseSetData.js';
|
import baseSetData from './_baseSetData.js';
|
||||||
import now from './now.js';
|
import shortOut from './_shortOut.js';
|
||||||
|
|
||||||
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
|
||||||
var HOT_COUNT = 150,
|
|
||||||
HOT_SPAN = 16;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets metadata for `func`.
|
* Sets metadata for `func`.
|
||||||
@@ -19,24 +15,6 @@ var HOT_COUNT = 150,
|
|||||||
* @param {*} data The metadata.
|
* @param {*} data The metadata.
|
||||||
* @returns {Function} Returns `func`.
|
* @returns {Function} Returns `func`.
|
||||||
*/
|
*/
|
||||||
var setData = (function() {
|
var setData = shortOut(baseSetData);
|
||||||
var count = 0,
|
|
||||||
lastCalled = 0;
|
|
||||||
|
|
||||||
return function(key, value) {
|
|
||||||
var stamp = now(),
|
|
||||||
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
||||||
|
|
||||||
lastCalled = stamp;
|
|
||||||
if (remaining > 0) {
|
|
||||||
if (++count >= HOT_COUNT) {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
return baseSetData(key, value);
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
export default setData;
|
export default setData;
|
||||||
|
|||||||
14
_setToString.js
Normal file
14
_setToString.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import baseSetToString from './_baseSetToString.js';
|
||||||
|
import shortOut from './_shortOut.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the `toString` method of `func` to return `string`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to modify.
|
||||||
|
* @param {Function} string The `toString` result.
|
||||||
|
* @returns {Function} Returns `func`.
|
||||||
|
*/
|
||||||
|
var setToString = shortOut(baseSetToString);
|
||||||
|
|
||||||
|
export default setToString;
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import constant from './constant.js';
|
|
||||||
import defineProperty from './_defineProperty.js';
|
|
||||||
import getWrapDetails from './_getWrapDetails.js';
|
import getWrapDetails from './_getWrapDetails.js';
|
||||||
import identity from './identity.js';
|
|
||||||
import insertWrapDetails from './_insertWrapDetails.js';
|
import insertWrapDetails from './_insertWrapDetails.js';
|
||||||
|
import setToString from './_setToString.js';
|
||||||
import updateWrapDetails from './_updateWrapDetails.js';
|
import updateWrapDetails from './_updateWrapDetails.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,13 +13,9 @@ import updateWrapDetails from './_updateWrapDetails.js';
|
|||||||
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
|
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
|
||||||
* @returns {Function} Returns `wrapper`.
|
* @returns {Function} Returns `wrapper`.
|
||||||
*/
|
*/
|
||||||
var setWrapToString = !defineProperty ? identity : function(wrapper, reference, bitmask) {
|
function setWrapToString(wrapper, reference, bitmask) {
|
||||||
var source = (reference + '');
|
var source = (reference + '');
|
||||||
return defineProperty(wrapper, 'toString', {
|
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
|
||||||
'configurable': true,
|
}
|
||||||
'enumerable': false,
|
|
||||||
'value': constant(insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)))
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default setWrapToString;
|
export default setWrapToString;
|
||||||
|
|||||||
37
_shortOut.js
Normal file
37
_shortOut.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
||||||
|
var HOT_COUNT = 500,
|
||||||
|
HOT_SPAN = 16;
|
||||||
|
|
||||||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeNow = Date.now;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a function that'll short out and invoke `identity` instead
|
||||||
|
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
||||||
|
* milliseconds.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to restrict.
|
||||||
|
* @returns {Function} Returns the new shortable function.
|
||||||
|
*/
|
||||||
|
function shortOut(func) {
|
||||||
|
var count = 0,
|
||||||
|
lastCalled = 0;
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
var stamp = nativeNow(),
|
||||||
|
remaining = HOT_SPAN - (stamp - lastCalled);
|
||||||
|
|
||||||
|
lastCalled = stamp;
|
||||||
|
if (remaining > 0) {
|
||||||
|
if (++count >= HOT_COUNT) {
|
||||||
|
return arguments[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
return func.apply(undefined, arguments);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default shortOut;
|
||||||
29
_shuffleSelf.js
Normal file
29
_shuffleSelf.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import baseClamp from './_baseClamp.js';
|
||||||
|
import baseRandom from './_baseRandom.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to shuffle.
|
||||||
|
* @param {number} [size=array.length] The size of `array`.
|
||||||
|
* @returns {Array} Returns `array`.
|
||||||
|
*/
|
||||||
|
function shuffleSelf(array, size) {
|
||||||
|
var index = -1,
|
||||||
|
length = array.length,
|
||||||
|
lastIndex = length - 1;
|
||||||
|
|
||||||
|
size = size === undefined ? length : baseClamp(size, 0, length);
|
||||||
|
while (++index < size) {
|
||||||
|
var rand = baseRandom(index, lastIndex),
|
||||||
|
value = array[rand];
|
||||||
|
|
||||||
|
array[rand] = array[index];
|
||||||
|
array[index] = value;
|
||||||
|
}
|
||||||
|
array.length = size;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default shuffleSelf;
|
||||||
@@ -9,6 +9,7 @@ import ListCache from './_ListCache.js';
|
|||||||
*/
|
*/
|
||||||
function stackClear() {
|
function stackClear() {
|
||||||
this.__data__ = new ListCache;
|
this.__data__ = new ListCache;
|
||||||
|
this.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default stackClear;
|
export default stackClear;
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||||
*/
|
*/
|
||||||
function stackDelete(key) {
|
function stackDelete(key) {
|
||||||
return this.__data__['delete'](key);
|
var data = this.__data__,
|
||||||
|
result = data['delete'](key);
|
||||||
|
|
||||||
|
this.size = data.size;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default stackDelete;
|
export default stackDelete;
|
||||||
|
|||||||
12
_stackSet.js
12
_stackSet.js
@@ -16,16 +16,18 @@ var LARGE_ARRAY_SIZE = 200;
|
|||||||
* @returns {Object} Returns the stack cache instance.
|
* @returns {Object} Returns the stack cache instance.
|
||||||
*/
|
*/
|
||||||
function stackSet(key, value) {
|
function stackSet(key, value) {
|
||||||
var cache = this.__data__;
|
var data = this.__data__;
|
||||||
if (cache instanceof ListCache) {
|
if (data instanceof ListCache) {
|
||||||
var pairs = cache.__data__;
|
var pairs = data.__data__;
|
||||||
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||||||
pairs.push([key, value]);
|
pairs.push([key, value]);
|
||||||
|
this.size = ++data.size;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
cache = this.__data__ = new MapCache(pairs);
|
data = this.__data__ = new MapCache(pairs);
|
||||||
}
|
}
|
||||||
cache.set(key, value);
|
data.set(key, value);
|
||||||
|
this.size = data.size;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
_strictIndexOf.js
Normal file
23
_strictIndexOf.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* A specialized version of `_.indexOf` which performs strict equality
|
||||||
|
* comparisons of values, i.e. `===`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to inspect.
|
||||||
|
* @param {*} value The value to search for.
|
||||||
|
* @param {number} fromIndex The index to search from.
|
||||||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||||
|
*/
|
||||||
|
function strictIndexOf(array, value, fromIndex) {
|
||||||
|
var index = fromIndex - 1,
|
||||||
|
length = array.length;
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
if (array[index] === value) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default strictIndexOf;
|
||||||
21
_strictLastIndexOf.js
Normal file
21
_strictLastIndexOf.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* A specialized version of `_.lastIndexOf` which performs strict equality
|
||||||
|
* comparisons of values, i.e. `===`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Array} array The array to inspect.
|
||||||
|
* @param {*} value The value to search for.
|
||||||
|
* @param {number} fromIndex The index to search from.
|
||||||
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||||
|
*/
|
||||||
|
function strictLastIndexOf(array, value, fromIndex) {
|
||||||
|
var index = fromIndex + 1;
|
||||||
|
while (index--) {
|
||||||
|
if (array[index] === value) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default strictLastIndexOf;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import memoize from './memoize.js';
|
import memoizeCapped from './_memoizeCapped.js';
|
||||||
import toString from './toString.js';
|
import toString from './toString.js';
|
||||||
|
|
||||||
/** Used to match property names within property paths. */
|
/** Used to match property names within property paths. */
|
||||||
@@ -15,7 +15,7 @@ var reEscapeChar = /\\(\\)?/g;
|
|||||||
* @param {string} string The string to convert.
|
* @param {string} string The string to convert.
|
||||||
* @returns {Array} Returns the property path array.
|
* @returns {Array} Returns the property path array.
|
||||||
*/
|
*/
|
||||||
var stringToPath = memoize(function(string) {
|
var stringToPath = memoizeCapped(function(string) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ var htmlUnescapes = {
|
|||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>',
|
'>': '>',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
''': "'",
|
''': "'"
|
||||||
'`': '`'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
|||||||
function unicodeSize(string) {
|
function unicodeSize(string) {
|
||||||
var result = reUnicode.lastIndex = 0;
|
var result = reUnicode.lastIndex = 0;
|
||||||
while (reUnicode.test(string)) {
|
while (reUnicode.test(string)) {
|
||||||
result++;
|
++result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
2
after.js
2
after.js
@@ -1,6 +1,6 @@
|
|||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,12 +11,6 @@ var objectProto = Object.prototype;
|
|||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
||||||
|
|
||||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
|
||||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns own enumerable string keyed properties of source objects to the
|
* Assigns own enumerable string keyed properties of source objects to the
|
||||||
* destination object. Source objects are applied from left to right.
|
* destination object. Source objects are applied from left to right.
|
||||||
@@ -50,7 +44,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
var assign = createAssigner(function(object, source) {
|
var assign = createAssigner(function(object, source) {
|
||||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
if (isPrototype(source) || isArrayLike(source)) {
|
||||||
copyObject(source, keys(source), object);
|
copyObject(source, keys(source), object);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
7
at.js
7
at.js
@@ -1,6 +1,5 @@
|
|||||||
import baseAt from './_baseAt.js';
|
import baseAt from './_baseAt.js';
|
||||||
import baseFlatten from './_baseFlatten.js';
|
import flatRest from './_flatRest.js';
|
||||||
import baseRest from './_baseRest.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of values corresponding to `paths` of `object`.
|
* Creates an array of values corresponding to `paths` of `object`.
|
||||||
@@ -19,8 +18,6 @@ import baseRest from './_baseRest.js';
|
|||||||
* _.at(object, ['a[0].b.c', 'a[1]']);
|
* _.at(object, ['a[0].b.c', 'a[1]']);
|
||||||
* // => [3, 4]
|
* // => [3, 4]
|
||||||
*/
|
*/
|
||||||
var at = baseRest(function(object, paths) {
|
var at = flatRest(baseAt);
|
||||||
return baseAt(object, baseFlatten(paths, 1));
|
|
||||||
});
|
|
||||||
|
|
||||||
export default at;
|
export default at;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
10
bindAll.js
10
bindAll.js
@@ -1,7 +1,7 @@
|
|||||||
import arrayEach from './_arrayEach.js';
|
import arrayEach from './_arrayEach.js';
|
||||||
import baseFlatten from './_baseFlatten.js';
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import baseRest from './_baseRest.js';
|
|
||||||
import bind from './bind.js';
|
import bind from './bind.js';
|
||||||
|
import flatRest from './_flatRest.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,10 +30,10 @@ import toKey from './_toKey.js';
|
|||||||
* jQuery(element).on('click', view.click);
|
* jQuery(element).on('click', view.click);
|
||||||
* // => Logs 'clicked docs' when clicked.
|
* // => Logs 'clicked docs' when clicked.
|
||||||
*/
|
*/
|
||||||
var bindAll = baseRest(function(object, methodNames) {
|
var bindAll = flatRest(function(object, methodNames) {
|
||||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
arrayEach(methodNames, function(key) {
|
||||||
key = toKey(key);
|
key = toKey(key);
|
||||||
object[key] = bind(object[key], object);
|
baseAssignValue(object, key, bind(object[key], object));
|
||||||
});
|
});
|
||||||
return object;
|
return object;
|
||||||
});
|
});
|
||||||
|
|||||||
11
concat.js
11
concat.js
@@ -26,17 +26,18 @@ import isArray from './isArray.js';
|
|||||||
* // => [1]
|
* // => [1]
|
||||||
*/
|
*/
|
||||||
function concat() {
|
function concat() {
|
||||||
var length = arguments.length,
|
var length = arguments.length;
|
||||||
args = Array(length ? length - 1 : 0),
|
if (!length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var args = Array(length - 1),
|
||||||
array = arguments[0],
|
array = arguments[0],
|
||||||
index = length;
|
index = length;
|
||||||
|
|
||||||
while (index--) {
|
while (index--) {
|
||||||
args[index - 1] = arguments[index];
|
args[index - 1] = arguments[index];
|
||||||
}
|
}
|
||||||
return length
|
return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
|
||||||
? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1))
|
|
||||||
: [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default concat;
|
export default concat;
|
||||||
|
|||||||
2
cond.js
2
cond.js
@@ -3,7 +3,7 @@ import arrayMap from './_arrayMap.js';
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
import baseIteratee from './_baseIteratee.js';
|
||||||
import baseRest from './_baseRest.js';
|
import baseRest from './_baseRest.js';
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import createAggregator from './_createAggregator.js';
|
import createAggregator from './_createAggregator.js';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
@@ -30,7 +31,11 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* // => { '3': 2, '5': 1 }
|
* // => { '3': 2, '5': 1 }
|
||||||
*/
|
*/
|
||||||
var countBy = createAggregator(function(result, value, key) {
|
var countBy = createAggregator(function(result, value, key) {
|
||||||
hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
|
if (hasOwnProperty.call(result, key)) {
|
||||||
|
++result[key];
|
||||||
|
} else {
|
||||||
|
baseAssignValue(result, key, 1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default countBy;
|
export default countBy;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import isObject from './isObject.js';
|
|||||||
import now from './now.js';
|
import now from './now.js';
|
||||||
import toNumber from './toNumber.js';
|
import toNumber from './toNumber.js';
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
|||||||
2
defer.js
2
defer.js
@@ -17,7 +17,7 @@ import baseRest from './_baseRest.js';
|
|||||||
* _.defer(function(text) {
|
* _.defer(function(text) {
|
||||||
* console.log(text);
|
* console.log(text);
|
||||||
* }, 'deferred');
|
* }, 'deferred');
|
||||||
* // => Logs 'deferred' after one or more milliseconds.
|
* // => Logs 'deferred' after one millisecond.
|
||||||
*/
|
*/
|
||||||
var defer = baseRest(function(func, args) {
|
var defer = baseRest(function(func, args) {
|
||||||
return baseDelay(func, 1, args);
|
return baseDelay(func, 1, args);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import isArrayLikeObject from './isArrayLikeObject.js';
|
|||||||
/**
|
/**
|
||||||
* Creates an array of `array` values not included in the other given arrays
|
* Creates an array of `array` values not included in the other given arrays
|
||||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||||
* for equality comparisons. The order of result values is determined by the
|
* for equality comparisons. The order and references of result values are
|
||||||
* order they occur in the first array.
|
* determined by the first array.
|
||||||
*
|
*
|
||||||
* **Note:** Unlike `_.pullAll`, this method returns a new array.
|
* **Note:** Unlike `_.pullAll`, this method returns a new array.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import last from './last.js';
|
|||||||
/**
|
/**
|
||||||
* This method is like `_.difference` except that it accepts `iteratee` which
|
* This method is like `_.difference` except that it accepts `iteratee` which
|
||||||
* is invoked for each element of `array` and `values` to generate the criterion
|
* is invoked for each element of `array` and `values` to generate the criterion
|
||||||
* by which they're compared. Result values are chosen from the first array.
|
* by which they're compared. The order and references of result values are
|
||||||
* The iteratee is invoked with one argument: (value).
|
* determined by the first array. The iteratee is invoked with one argument:
|
||||||
|
* (value).
|
||||||
*
|
*
|
||||||
* **Note:** Unlike `_.pullAllBy`, this method returns a new array.
|
* **Note:** Unlike `_.pullAllBy`, this method returns a new array.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import last from './last.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.difference` except that it accepts `comparator`
|
* This method is like `_.difference` except that it accepts `comparator`
|
||||||
* which is invoked to compare elements of `array` to `values`. Result values
|
* which is invoked to compare elements of `array` to `values`. The order and
|
||||||
* are chosen from the first array. The comparator is invoked with two arguments:
|
* references of result values are determined by the first array. The comparator
|
||||||
* (arrVal, othVal).
|
* is invoked with two arguments: (arrVal, othVal).
|
||||||
*
|
*
|
||||||
* **Note:** Unlike `_.pullAllWith`, this method returns a new array.
|
* **Note:** Unlike `_.pullAllWith`, this method returns a new array.
|
||||||
*
|
*
|
||||||
|
|||||||
12
escape.js
12
escape.js
@@ -2,12 +2,12 @@ import escapeHtmlChar from './_escapeHtmlChar.js';
|
|||||||
import toString from './toString.js';
|
import toString from './toString.js';
|
||||||
|
|
||||||
/** Used to match HTML entities and HTML characters. */
|
/** Used to match HTML entities and HTML characters. */
|
||||||
var reUnescapedHtml = /[&<>"'`]/g,
|
var reUnescapedHtml = /[&<>"']/g,
|
||||||
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
|
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
||||||
* their corresponding HTML entities.
|
* corresponding HTML entities.
|
||||||
*
|
*
|
||||||
* **Note:** No other characters are escaped. To escape additional
|
* **Note:** No other characters are escaped. To escape additional
|
||||||
* characters use a third-party library like [_he_](https://mths.be/he).
|
* characters use a third-party library like [_he_](https://mths.be/he).
|
||||||
@@ -18,12 +18,6 @@ var reUnescapedHtml = /[&<>"'`]/g,
|
|||||||
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
||||||
* (under "semi-related fun fact") for more details.
|
* (under "semi-related fun fact") for more details.
|
||||||
*
|
*
|
||||||
* Backticks are escaped because in IE < 9, they can break out of
|
|
||||||
* attribute values or HTML comments. See [#59](https://html5sec.org/#59),
|
|
||||||
* [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
|
|
||||||
* [#133](https://html5sec.org/#133) of the
|
|
||||||
* [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
|
|
||||||
*
|
|
||||||
* When working with HTML you should always
|
* When working with HTML you should always
|
||||||
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
|
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
|
||||||
* XSS vectors.
|
* XSS vectors.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import isArray from './isArray.js';
|
|||||||
* @see _.forEachRight
|
* @see _.forEachRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _([1, 2]).forEach(function(value) {
|
* _.forEach([1, 2], function(value) {
|
||||||
* console.log(value);
|
* console.log(value);
|
||||||
* });
|
* });
|
||||||
* // => Logs `1` then `2`.
|
* // => Logs `1` then `2`.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import createAggregator from './_createAggregator.js';
|
import createAggregator from './_createAggregator.js';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
@@ -34,7 +35,7 @@ var groupBy = createAggregator(function(result, value, key) {
|
|||||||
if (hasOwnProperty.call(result, key)) {
|
if (hasOwnProperty.call(result, key)) {
|
||||||
result[key].push(value);
|
result[key].push(value);
|
||||||
} else {
|
} else {
|
||||||
result[key] = [value];
|
baseAssignValue(result, key, [value]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import castArrayLikeObject from './_castArrayLikeObject.js';
|
|||||||
/**
|
/**
|
||||||
* Creates an array of unique values that are included in all given arrays
|
* Creates an array of unique values that are included in all given arrays
|
||||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||||
* for equality comparisons. The order of result values is determined by the
|
* for equality comparisons. The order and references of result values are
|
||||||
* order they occur in the first array.
|
* determined by the first array.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import last from './last.js';
|
|||||||
/**
|
/**
|
||||||
* This method is like `_.intersection` except that it accepts `iteratee`
|
* This method is like `_.intersection` except that it accepts `iteratee`
|
||||||
* which is invoked for each element of each `arrays` to generate the criterion
|
* which is invoked for each element of each `arrays` to generate the criterion
|
||||||
* by which they're compared. Result values are chosen from the first array.
|
* by which they're compared. The order and references of result values are
|
||||||
* The iteratee is invoked with one argument: (value).
|
* determined by the first array. The iteratee is invoked with one argument:
|
||||||
|
* (value).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import last from './last.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.intersection` except that it accepts `comparator`
|
* This method is like `_.intersection` except that it accepts `comparator`
|
||||||
* which is invoked to compare elements of `arrays`. Result values are chosen
|
* which is invoked to compare elements of `arrays`. The order and references
|
||||||
* from the first array. The comparator is invoked with two arguments:
|
* of result values are determined by the first array. The comparator is
|
||||||
* (arrVal, othVal).
|
* invoked with two arguments: (arrVal, othVal).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import isPlainObject from './isPlainObject.js';
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isElement(value) {
|
function isElement(value) {
|
||||||
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
return value != null && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isElement;
|
export default isElement;
|
||||||
|
|||||||
@@ -16,12 +16,6 @@ var objectProto = Object.prototype;
|
|||||||
/** Used to check objects for own properties. */
|
/** Used to check objects for own properties. */
|
||||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
|
||||||
|
|
||||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
|
||||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is an empty object, collection, map, or set.
|
* Checks if `value` is an empty object, collection, map, or set.
|
||||||
*
|
*
|
||||||
@@ -65,7 +59,7 @@ function isEmpty(value) {
|
|||||||
if (tag == mapTag || tag == setTag) {
|
if (tag == mapTag || tag == setTag) {
|
||||||
return !value.size;
|
return !value.size;
|
||||||
}
|
}
|
||||||
if (nonEnumShadows || isPrototype(value)) {
|
if (isPrototype(value)) {
|
||||||
return !nativeKeys(value).length;
|
return !nativeKeys(value).length;
|
||||||
}
|
}
|
||||||
for (var key in value) {
|
for (var key in value) {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import baseIsNative from './_baseIsNative.js';
|
import baseIsNative from './_baseIsNative.js';
|
||||||
import isMaskable from './_isMaskable.js';
|
import isMaskable from './_isMaskable.js';
|
||||||
|
|
||||||
|
/** Error message constants. */
|
||||||
|
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is a pristine native function.
|
* Checks if `value` is a pristine native function.
|
||||||
*
|
*
|
||||||
@@ -29,7 +32,7 @@ import isMaskable from './_isMaskable.js';
|
|||||||
*/
|
*/
|
||||||
function isNative(value) {
|
function isNative(value) {
|
||||||
if (isMaskable(value)) {
|
if (isMaskable(value)) {
|
||||||
throw new Error('This method is not supported with core-js. Try https://github.com/es-shims.');
|
throw new Error(CORE_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return baseIsNative(value);
|
return baseIsNative(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
function isObject(value) {
|
function isObject(value) {
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
return !!value && (type == 'object' || type == 'function');
|
return value != null && (type == 'object' || type == 'function');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isObject;
|
export default isObject;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isObjectLike(value) {
|
function isObjectLike(value) {
|
||||||
return !!value && typeof value == 'object';
|
return value != null && typeof value == 'object';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isObjectLike;
|
export default isObjectLike;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import getPrototype from './_getPrototype.js';
|
import getPrototype from './_getPrototype.js';
|
||||||
import isHostObject from './_isHostObject.js';
|
|
||||||
import isObjectLike from './isObjectLike.js';
|
import isObjectLike from './isObjectLike.js';
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
@@ -54,8 +53,7 @@ var objectToString = objectProto.toString;
|
|||||||
* // => true
|
* // => true
|
||||||
*/
|
*/
|
||||||
function isPlainObject(value) {
|
function isPlainObject(value) {
|
||||||
if (!isObjectLike(value) ||
|
if (!isObjectLike(value) || objectToString.call(value) != objectTag) {
|
||||||
objectToString.call(value) != objectTag || isHostObject(value)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var proto = getPrototype(value);
|
var proto = getPrototype(value);
|
||||||
|
|||||||
3
keyBy.js
3
keyBy.js
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import createAggregator from './_createAggregator.js';
|
import createAggregator from './_createAggregator.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +31,7 @@ import createAggregator from './_createAggregator.js';
|
|||||||
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
|
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
|
||||||
*/
|
*/
|
||||||
var keyBy = createAggregator(function(result, value, key) {
|
var keyBy = createAggregator(function(result, value, key) {
|
||||||
result[key] = value;
|
baseAssignValue(result, key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default keyBy;
|
export default keyBy;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import baseFindIndex from './_baseFindIndex.js';
|
import baseFindIndex from './_baseFindIndex.js';
|
||||||
import baseIsNaN from './_baseIsNaN.js';
|
import baseIsNaN from './_baseIsNaN.js';
|
||||||
|
import strictLastIndexOf from './_strictLastIndexOf.js';
|
||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
@@ -35,21 +36,11 @@ function lastIndexOf(array, value, fromIndex) {
|
|||||||
var index = length;
|
var index = length;
|
||||||
if (fromIndex !== undefined) {
|
if (fromIndex !== undefined) {
|
||||||
index = toInteger(fromIndex);
|
index = toInteger(fromIndex);
|
||||||
index = (
|
index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
|
||||||
index < 0
|
|
||||||
? nativeMax(length + index, 0)
|
|
||||||
: nativeMin(index, length - 1)
|
|
||||||
) + 1;
|
|
||||||
}
|
}
|
||||||
if (value !== value) {
|
return value === value
|
||||||
return baseFindIndex(array, baseIsNaN, index - 1, true);
|
? strictLastIndexOf(array, value, index)
|
||||||
}
|
: baseFindIndex(array, baseIsNaN, index, true);
|
||||||
while (index--) {
|
|
||||||
if (array[index] === value) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default lastIndexOf;
|
export default lastIndexOf;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import toInteger from './toInteger.js';
|
|||||||
import lodash from './wrapperLodash.js';
|
import lodash from './wrapperLodash.js';
|
||||||
|
|
||||||
/** Used as the semantic version number. */
|
/** Used as the semantic version number. */
|
||||||
var VERSION = '4.15.0';
|
var VERSION = '4.16.2';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
var BIND_KEY_FLAG = 2;
|
var BIND_KEY_FLAG = 2;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
import baseIteratee from './_baseIteratee.js';
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ function mapKeys(object, iteratee) {
|
|||||||
iteratee = baseIteratee(iteratee, 3);
|
iteratee = baseIteratee(iteratee, 3);
|
||||||
|
|
||||||
baseForOwn(object, function(value, key, object) {
|
baseForOwn(object, function(value, key, object) {
|
||||||
result[iteratee(value, key, object)] = value;
|
baseAssignValue(result, iteratee(value, key, object), value);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseAssignValue from './_baseAssignValue.js';
|
||||||
import baseForOwn from './_baseForOwn.js';
|
import baseForOwn from './_baseForOwn.js';
|
||||||
import baseIteratee from './_baseIteratee.js';
|
import baseIteratee from './_baseIteratee.js';
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ function mapValues(object, iteratee) {
|
|||||||
iteratee = baseIteratee(iteratee, 3);
|
iteratee = baseIteratee(iteratee, 3);
|
||||||
|
|
||||||
baseForOwn(object, function(value, key, object) {
|
baseForOwn(object, function(value, key, object) {
|
||||||
result[key] = iteratee(value, key, object);
|
baseAssignValue(result, key, iteratee(value, key, object));
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import MapCache from './_MapCache.js';
|
import MapCache from './_MapCache.js';
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,14 +60,14 @@ function memoize(func, resolver) {
|
|||||||
return cache.get(key);
|
return cache.get(key);
|
||||||
}
|
}
|
||||||
var result = func.apply(this, args);
|
var result = func.apply(this, args);
|
||||||
memoized.cache = cache.set(key, result);
|
memoized.cache = cache.set(key, result) || cache;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
memoized.cache = new (memoize.Cache || MapCache);
|
memoized.cache = new (memoize.Cache || MapCache);
|
||||||
return memoized;
|
return memoized;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign cache to `_.memoize`.
|
// Expose `MapCache`.
|
||||||
memoize.Cache = MapCache;
|
memoize.Cache = MapCache;
|
||||||
|
|
||||||
export default memoize;
|
export default memoize;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import createAssigner from './_createAssigner.js';
|
|||||||
* This method is like `_.merge` except that it accepts `customizer` which
|
* This method is like `_.merge` except that it accepts `customizer` which
|
||||||
* is invoked to produce the merged values of the destination and source
|
* is invoked to produce the merged values of the destination and source
|
||||||
* properties. If `customizer` returns `undefined`, merging is handled by the
|
* properties. If `customizer` returns `undefined`, merging is handled by the
|
||||||
* method instead. The `customizer` is invoked with seven arguments:
|
* method instead. The `customizer` is invoked with six arguments:
|
||||||
* (objValue, srcValue, key, object, source, stack).
|
* (objValue, srcValue, key, object, source, stack).
|
||||||
*
|
*
|
||||||
* **Note:** This method mutates `object`.
|
* **Note:** This method mutates `object`.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
7
omit.js
7
omit.js
@@ -1,8 +1,7 @@
|
|||||||
import arrayMap from './_arrayMap.js';
|
import arrayMap from './_arrayMap.js';
|
||||||
import baseDifference from './_baseDifference.js';
|
import baseDifference from './_baseDifference.js';
|
||||||
import baseFlatten from './_baseFlatten.js';
|
|
||||||
import basePick from './_basePick.js';
|
import basePick from './_basePick.js';
|
||||||
import baseRest from './_baseRest.js';
|
import flatRest from './_flatRest.js';
|
||||||
import getAllKeysIn from './_getAllKeysIn.js';
|
import getAllKeysIn from './_getAllKeysIn.js';
|
||||||
import toKey from './_toKey.js';
|
import toKey from './_toKey.js';
|
||||||
|
|
||||||
@@ -25,11 +24,11 @@ import toKey from './_toKey.js';
|
|||||||
* _.omit(object, ['a', 'c']);
|
* _.omit(object, ['a', 'c']);
|
||||||
* // => { 'b': '2' }
|
* // => { 'b': '2' }
|
||||||
*/
|
*/
|
||||||
var omit = baseRest(function(object, props) {
|
var omit = flatRest(function(object, props) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
props = arrayMap(baseFlatten(props, 1), toKey);
|
props = arrayMap(props, toKey);
|
||||||
return basePick(object, baseDifference(getAllKeysIn(object), props));
|
return basePick(object, baseDifference(getAllKeysIn(object), props));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import baseFlatten from './_baseFlatten.js';
|
|||||||
import baseIteratee from './_baseIteratee.js';
|
import baseIteratee from './_baseIteratee.js';
|
||||||
import baseRest from './_baseRest.js';
|
import baseRest from './_baseRest.js';
|
||||||
import baseUnary from './_baseUnary.js';
|
import baseUnary from './_baseUnary.js';
|
||||||
|
import castRest from './_castRest.js';
|
||||||
import isArray from './isArray.js';
|
import isArray from './isArray.js';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
@@ -40,7 +41,7 @@ var nativeMin = Math.min;
|
|||||||
* func(10, 5);
|
* func(10, 5);
|
||||||
* // => [100, 10]
|
* // => [100, 10]
|
||||||
*/
|
*/
|
||||||
var overArgs = baseRest(function(func, transforms) {
|
var overArgs = castRest(function(func, transforms) {
|
||||||
transforms = (transforms.length == 1 && isArray(transforms[0]))
|
transforms = (transforms.length == 1 && isArray(transforms[0]))
|
||||||
? arrayMap(transforms[0], baseUnary(baseIteratee))
|
? arrayMap(transforms[0], baseUnary(baseIteratee))
|
||||||
: arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee));
|
: arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-es",
|
"name": "lodash-es",
|
||||||
"version": "4.15.0",
|
"version": "4.16.2",
|
||||||
"description": "Lodash exported as ES modules.",
|
"description": "Lodash exported as ES modules.",
|
||||||
"keywords": "es6, modules, stdlib, util",
|
"keywords": "es6, modules, stdlib, util",
|
||||||
"homepage": "https://lodash.com/custom-builds",
|
"homepage": "https://lodash.com/custom-builds",
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"jsnext:main": "lodash.js",
|
"jsnext:main": "lodash.js",
|
||||||
"main": "lodash.js",
|
"main": "lodash.js",
|
||||||
|
"module": "lodash.js",
|
||||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||||
|
|||||||
10
parseInt.js
10
parseInt.js
@@ -2,10 +2,7 @@ import root from './_root.js';
|
|||||||
import toString from './toString.js';
|
import toString from './toString.js';
|
||||||
|
|
||||||
/** Used to match leading and trailing whitespace. */
|
/** Used to match leading and trailing whitespace. */
|
||||||
var reTrim = /^\s+|\s+$/g;
|
var reTrimStart = /^\s+/;
|
||||||
|
|
||||||
/** Used to detect hexadecimal string values. */
|
|
||||||
var reHasHexPrefix = /^0x/i;
|
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeParseInt = root.parseInt;
|
var nativeParseInt = root.parseInt;
|
||||||
@@ -35,15 +32,12 @@ var nativeParseInt = root.parseInt;
|
|||||||
* // => [6, 8, 10]
|
* // => [6, 8, 10]
|
||||||
*/
|
*/
|
||||||
function parseInt(string, radix, guard) {
|
function parseInt(string, radix, guard) {
|
||||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
|
||||||
// See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details.
|
|
||||||
if (guard || radix == null) {
|
if (guard || radix == null) {
|
||||||
radix = 0;
|
radix = 0;
|
||||||
} else if (radix) {
|
} else if (radix) {
|
||||||
radix = +radix;
|
radix = +radix;
|
||||||
}
|
}
|
||||||
string = toString(string).replace(reTrim, '');
|
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
|
||||||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default parseInt;
|
export default parseInt;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user