mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6778141728 | ||
|
|
d9fd2bdf9c | ||
|
|
ab95e7dde7 | ||
|
|
5425ef9a59 | ||
|
|
94ac73824f | ||
|
|
28663c1e27 |
@@ -1,10 +1,10 @@
|
||||
# lodash-es v4.14.2
|
||||
# lodash-es v4.16.4
|
||||
|
||||
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):
|
||||
```bash
|
||||
```shell
|
||||
$ lodash modularize exports=es -o ./
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.14.2-es) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.16.4-es) for more details.
|
||||
|
||||
@@ -13,7 +13,8 @@ import stackSet from './_stackSet.js';
|
||||
* @param {Array} [entries] The key-value pairs to cache.
|
||||
*/
|
||||
function Stack(entries) {
|
||||
this.__data__ = new ListCache(entries);
|
||||
var data = this.__data__ = new ListCache(entries);
|
||||
this.size = data.size;
|
||||
}
|
||||
|
||||
// Add methods to `Stack`.
|
||||
|
||||
@@ -5,7 +5,7 @@ import baseIndexOf from './_baseIndexOf.js';
|
||||
* specifying an index to search from.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} [array] The array to search.
|
||||
* @param {Array} [array] The array to inspect.
|
||||
* @param {*} target The value to search for.
|
||||
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This function is like `arrayIncludes` except that it accepts a comparator.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} [array] The array to search.
|
||||
* @param {Array} [array] The array to inspect.
|
||||
* @param {*} target The value to search for.
|
||||
* @param {Function} comparator The comparator invoked per element.
|
||||
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import baseTimes from './_baseTimes.js';
|
||||
import isArguments from './isArguments.js';
|
||||
import isArray from './isArray.js';
|
||||
import isBuffer from './isBuffer.js';
|
||||
import isIndex from './_isIndex.js';
|
||||
import isString from './isString.js';
|
||||
import isTypedArray from './isTypedArray.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -19,16 +20,26 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function arrayLikeKeys(value, inherited) {
|
||||
var result = (isArray(value) || isString(value) || isArguments(value))
|
||||
? baseTimes(value.length, String)
|
||||
: [];
|
||||
|
||||
var length = result.length,
|
||||
skipIndexes = !!length;
|
||||
var isArr = isArray(value),
|
||||
isArg = !isArr && isArguments(value),
|
||||
isBuff = !isArr && !isArg && isBuffer(value),
|
||||
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
||||
skipIndexes = isArr || isArg || isBuff || isType,
|
||||
result = skipIndexes ? baseTimes(value.length, String) : [],
|
||||
length = result.length;
|
||||
|
||||
for (var key in value) {
|
||||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||||
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
||||
!(skipIndexes && (
|
||||
// Safari 9 has enumerable `arguments.length` in strict mode.
|
||||
key == 'length' ||
|
||||
// Node.js 0.10 has enumerable non-index properties on buffers.
|
||||
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
||||
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||||
// Skip index properties.
|
||||
isIndex(key, length)
|
||||
))) {
|
||||
result.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
17
_arraySampleSize.js
Normal file
17
_arraySampleSize.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import baseClamp from './_baseClamp.js';
|
||||
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), baseClamp(n, 0, array.length));
|
||||
}
|
||||
|
||||
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;
|
||||
12
_asciiSize.js
Normal file
12
_asciiSize.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import baseProperty from './_baseProperty.js';
|
||||
|
||||
/**
|
||||
* Gets the size of an ASCII `string`.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string inspect.
|
||||
* @returns {number} Returns the string size.
|
||||
*/
|
||||
var asciiSize = baseProperty('length');
|
||||
|
||||
export default asciiSize;
|
||||
12
_asciiToArray.js
Normal file
12
_asciiToArray.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Converts an ASCII `string` to an array.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the converted array.
|
||||
*/
|
||||
function asciiToArray(string) {
|
||||
return string.split('');
|
||||
}
|
||||
|
||||
export default asciiToArray;
|
||||
15
_asciiWords.js
Normal file
15
_asciiWords.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/** Used to match words composed of alphanumeric characters. */
|
||||
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
||||
|
||||
/**
|
||||
* Splits an ASCII `string` into an array of its words.
|
||||
*
|
||||
* @private
|
||||
* @param {string} The string to inspect.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
*/
|
||||
function asciiWords(string) {
|
||||
return string.match(reAsciiWord) || [];
|
||||
}
|
||||
|
||||
export default asciiWords;
|
||||
@@ -1,3 +1,4 @@
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
import eq from './eq.js';
|
||||
|
||||
/**
|
||||
@@ -11,8 +12,8 @@ import eq from './eq.js';
|
||||
*/
|
||||
function assignMergeValue(object, key, value) {
|
||||
if ((value !== undefined && !eq(object[key], value)) ||
|
||||
(typeof key == 'number' && value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
(value === undefined && !(key in object))) {
|
||||
baseAssignValue(object, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
import eq from './eq.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
@@ -20,7 +21,7 @@ function assignValue(object, key, value) {
|
||||
var objValue = object[key];
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
baseAssignValue(object, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import eq from './eq.js';
|
||||
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} key The key to search for.
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
|
||||
25
_baseAssignValue.js
Normal file
25
_baseAssignValue.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import defineProperty from './_defineProperty.js';
|
||||
|
||||
/**
|
||||
* 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 isArray from './isArray.js';
|
||||
import isBuffer from './isBuffer.js';
|
||||
import isHostObject from './_isHostObject.js';
|
||||
import isObject from './isObject.js';
|
||||
import keys from './keys.js';
|
||||
|
||||
@@ -100,9 +99,6 @@ function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||||
return cloneBuffer(value, isDeep);
|
||||
}
|
||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||
if (isHostObject(value)) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneObject(isFunc ? {} : value);
|
||||
if (!isDeep) {
|
||||
return copySymbols(value, baseAssign(result, value));
|
||||
@@ -122,9 +118,7 @@ function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
|
||||
}
|
||||
stack.set(value, result);
|
||||
|
||||
if (!isArr) {
|
||||
var props = isFull ? getAllKeys(value) : keys(value);
|
||||
}
|
||||
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
|
||||
arrayEach(props || value, function(subValue, key) {
|
||||
if (props) {
|
||||
key = subValue;
|
||||
|
||||
@@ -8,11 +8,23 @@ var objectCreate = Object.create;
|
||||
* properties to the created object.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @param {Object} proto The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(proto) {
|
||||
if (!isObject(proto)) {
|
||||
return {};
|
||||
}
|
||||
if (objectCreate) {
|
||||
return objectCreate(proto);
|
||||
}
|
||||
object.prototype = proto;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
return result;
|
||||
};
|
||||
}());
|
||||
|
||||
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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* support for iteratee shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @param {number} fromIndex The index to search from.
|
||||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* using `eachFunc`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to search.
|
||||
* @param {Array|Object} collection The collection to inspect.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||
* @returns {*} Returns the found element or its key, else `undefined`.
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
import baseFindIndex from './_baseFindIndex.js';
|
||||
import baseIsNaN from './_baseIsNaN.js';
|
||||
import strictIndexOf from './_strictIndexOf.js';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @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 baseIndexOf(array, value, fromIndex) {
|
||||
if (value !== value) {
|
||||
return baseFindIndex(array, baseIsNaN, fromIndex);
|
||||
}
|
||||
var index = fromIndex - 1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return value === value
|
||||
? strictIndexOf(array, value, fromIndex)
|
||||
: baseFindIndex(array, baseIsNaN, fromIndex);
|
||||
}
|
||||
|
||||
export default baseIndexOf;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This function is like `baseIndexOf` except that it accepts a comparator.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} value The value to search for.
|
||||
* @param {number} fromIndex The index to search from.
|
||||
* @param {Function} comparator The comparator invoked per element.
|
||||
|
||||
27
_baseIsArguments.js
Normal file
27
_baseIsArguments.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var argsTag = '[object Arguments]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isArguments`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||||
*/
|
||||
function baseIsArguments(value) {
|
||||
return isObjectLike(value) && objectToString.call(value) == argsTag;
|
||||
}
|
||||
|
||||
export default baseIsArguments;
|
||||
@@ -4,7 +4,7 @@ import equalByTag from './_equalByTag.js';
|
||||
import equalObjects from './_equalObjects.js';
|
||||
import getTag from './_getTag.js';
|
||||
import isArray from './isArray.js';
|
||||
import isHostObject from './_isHostObject.js';
|
||||
import isBuffer from './isBuffer.js';
|
||||
import isTypedArray from './isTypedArray.js';
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
@@ -50,10 +50,17 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
|
||||
othTag = getTag(other);
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||
var objIsObj = objTag == objectTag,
|
||||
othIsObj = othTag == objectTag,
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
if (isSameTag && isBuffer(object)) {
|
||||
if (!isBuffer(other)) {
|
||||
return false;
|
||||
}
|
||||
objIsArr = true;
|
||||
objIsObj = false;
|
||||
}
|
||||
if (isSameTag && !objIsObj) {
|
||||
stack || (stack = new Stack);
|
||||
return (objIsArr || isTypedArray(object))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import isFunction from './isFunction.js';
|
||||
import isHostObject from './_isHostObject.js';
|
||||
import isMasked from './_isMasked.js';
|
||||
import isObject from './isObject.js';
|
||||
import toSource from './_toSource.js';
|
||||
@@ -14,10 +13,11 @@ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||||
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
var funcProto = Function.prototype,
|
||||
objectProto = Object.prototype;
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = Function.prototype.toString;
|
||||
var funcToString = funcProto.toString;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
@@ -40,7 +40,7 @@ function baseIsNative(value) {
|
||||
if (!isObject(value) || isMasked(value)) {
|
||||
return false;
|
||||
}
|
||||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
||||
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
||||
return pattern.test(toSource(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import Stack from './_Stack.js';
|
||||
import arrayEach from './_arrayEach.js';
|
||||
import assignMergeValue from './_assignMergeValue.js';
|
||||
import baseKeysIn from './_baseKeysIn.js';
|
||||
import baseFor from './_baseFor.js';
|
||||
import baseMergeDeep from './_baseMergeDeep.js';
|
||||
import isArray from './isArray.js';
|
||||
import isObject from './isObject.js';
|
||||
import isTypedArray from './isTypedArray.js';
|
||||
import keysIn from './keysIn.js';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.merge` without support for multiple sources.
|
||||
@@ -22,14 +20,7 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
if (object === source) {
|
||||
return;
|
||||
}
|
||||
if (!(isArray(source) || isTypedArray(source))) {
|
||||
var props = baseKeysIn(source);
|
||||
}
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
srcValue = source[key];
|
||||
}
|
||||
baseFor(source, function(srcValue, key) {
|
||||
if (isObject(srcValue)) {
|
||||
stack || (stack = new Stack);
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
@@ -44,7 +35,7 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
}
|
||||
assignMergeValue(object, key, newValue);
|
||||
}
|
||||
});
|
||||
}, keysIn);
|
||||
}
|
||||
|
||||
export default baseMerge;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import assignMergeValue from './_assignMergeValue.js';
|
||||
import baseClone from './_baseClone.js';
|
||||
import cloneBuffer from './_cloneBuffer.js';
|
||||
import cloneTypedArray from './_cloneTypedArray.js';
|
||||
import copyArray from './_copyArray.js';
|
||||
import initCloneObject from './_initCloneObject.js';
|
||||
import isArguments from './isArguments.js';
|
||||
import isArray from './isArray.js';
|
||||
import isArrayLikeObject from './isArrayLikeObject.js';
|
||||
import isBuffer from './isBuffer.js';
|
||||
import isFunction from './isFunction.js';
|
||||
import isObject from './isObject.js';
|
||||
import isPlainObject from './isPlainObject.js';
|
||||
@@ -41,29 +44,37 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
var isCommon = newValue === undefined;
|
||||
|
||||
if (isCommon) {
|
||||
var isArr = isArray(srcValue),
|
||||
isBuff = !isArr && isBuffer(srcValue),
|
||||
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
||||
|
||||
newValue = srcValue;
|
||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||
if (isArr || isBuff || isTyped) {
|
||||
if (isArray(objValue)) {
|
||||
newValue = objValue;
|
||||
}
|
||||
else if (isArrayLikeObject(objValue)) {
|
||||
newValue = copyArray(objValue);
|
||||
}
|
||||
else {
|
||||
else if (isBuff) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, true);
|
||||
newValue = cloneBuffer(srcValue, true);
|
||||
}
|
||||
else if (isTyped) {
|
||||
isCommon = false;
|
||||
newValue = cloneTypedArray(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = [];
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
newValue = objValue;
|
||||
if (isArguments(objValue)) {
|
||||
newValue = toPlainObject(objValue);
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = objValue;
|
||||
newValue = initCloneObject(srcValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||
*
|
||||
@@ -17,7 +19,7 @@ function basePickBy(object, props, predicate) {
|
||||
value = object[key];
|
||||
|
||||
if (predicate(value, key)) {
|
||||
result[key] = value;
|
||||
baseAssignValue(result, key, value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
26
_baseRest.js
26
_baseRest.js
@@ -1,7 +1,6 @@
|
||||
import apply from './_apply.js';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
import identity from './identity.js';
|
||||
import overRest from './_overRest.js';
|
||||
import setToString from './_setToString.js';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function baseRest(func, start) {
|
||||
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] = array;
|
||||
return apply(func, this, otherArgs);
|
||||
};
|
||||
return setToString(overRest(func, start, identity), func + '');
|
||||
}
|
||||
|
||||
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;
|
||||
18
_baseSampleSize.js
Normal file
18
_baseSampleSize.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import baseClamp from './_baseClamp.js';
|
||||
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) {
|
||||
var array = values(collection);
|
||||
return shuffleSelf(array, baseClamp(n, 0, array.length));
|
||||
}
|
||||
|
||||
export default baseSampleSize;
|
||||
@@ -9,7 +9,7 @@ import toKey from './_toKey.js';
|
||||
* The base implementation of `_.set`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to set.
|
||||
* @param {*} value The value to set.
|
||||
* @param {Function} [customizer] The function to customize path creation.
|
||||
|
||||
@@ -2,7 +2,7 @@ import identity from './identity.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
|
||||
* @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 defineProperty from './_defineProperty.js';
|
||||
import identity from './identity.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 = !defineProperty ? identity : function(func, string) {
|
||||
return defineProperty(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,4 +1,6 @@
|
||||
import Symbol from './_Symbol.js';
|
||||
import arrayMap from './_arrayMap.js';
|
||||
import isArray from './isArray.js';
|
||||
import isSymbol from './isSymbol.js';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
@@ -21,6 +23,10 @@ function baseToString(value) {
|
||||
if (typeof value == 'string') {
|
||||
return value;
|
||||
}
|
||||
if (isArray(value)) {
|
||||
// Recursively convert values (susceptible to call stack limits).
|
||||
return arrayMap(value, baseToString) + '';
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import baseSet from './_baseSet.js';
|
||||
* The base implementation of `_.update`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to update.
|
||||
* @param {Function} updater The function to produce the updated value.
|
||||
* @param {Function} [customizer] The function to customize path creation.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Checks if a cache value for `key` exists.
|
||||
* Checks if a `cache` value for `key` exists.
|
||||
*
|
||||
* @private
|
||||
* @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`.
|
||||
*
|
||||
@@ -10,7 +25,9 @@ function cloneBuffer(buffer, isDeep) {
|
||||
if (isDeep) {
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import assignValue from './_assignValue.js';
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
|
||||
/**
|
||||
* Copies properties of `source` to `object`.
|
||||
@@ -11,6 +12,7 @@ import assignValue from './_assignValue.js';
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function copyObject(source, props, object, customizer) {
|
||||
var isNew = !object;
|
||||
object || (object = {});
|
||||
|
||||
var index = -1,
|
||||
@@ -23,7 +25,14 @@ function copyObject(source, props, object, customizer) {
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: 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;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ function countHolders(array, placeholder) {
|
||||
|
||||
while (length--) {
|
||||
if (array[length] === placeholder) {
|
||||
result++;
|
||||
++result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import castSlice from './_castSlice.js';
|
||||
import reHasComplexSymbol from './_reHasComplexSymbol.js';
|
||||
import hasUnicode from './_hasUnicode.js';
|
||||
import stringToArray from './_stringToArray.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
@@ -14,7 +14,7 @@ function createCaseFirst(methodName) {
|
||||
return function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var strSymbols = reHasComplexSymbol.test(string)
|
||||
var strSymbols = hasUnicode(string)
|
||||
? stringToArray(string)
|
||||
: undefined;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import LodashWrapper from './_LodashWrapper.js';
|
||||
import baseFlatten from './_baseFlatten.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
import flatRest from './_flatRest.js';
|
||||
import getData from './_getData.js';
|
||||
import getFuncName from './_getFuncName.js';
|
||||
import isArray from './isArray.js';
|
||||
@@ -9,7 +8,7 @@ import isLaziable from './_isLaziable.js';
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
@@ -26,9 +25,7 @@ var CURRY_FLAG = 8,
|
||||
* @returns {Function} Returns the new flow function.
|
||||
*/
|
||||
function createFlow(fromRight) {
|
||||
return baseRest(function(funcs) {
|
||||
funcs = baseFlatten(funcs, 1);
|
||||
|
||||
return flatRest(function(funcs) {
|
||||
var length = funcs.length,
|
||||
index = length,
|
||||
prereq = LodashWrapper.prototype.thru;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import apply from './_apply.js';
|
||||
import arrayMap from './_arrayMap.js';
|
||||
import baseFlatten from './_baseFlatten.js';
|
||||
import baseIteratee from './_baseIteratee.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
import baseUnary from './_baseUnary.js';
|
||||
import isArray from './isArray.js';
|
||||
import flatRest from './_flatRest.js';
|
||||
|
||||
/**
|
||||
* Creates a function like `_.over`.
|
||||
@@ -14,11 +13,8 @@ import isArray from './isArray.js';
|
||||
* @returns {Function} Returns the new over function.
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return baseRest(function(iteratees) {
|
||||
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
||||
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
||||
: arrayMap(baseFlatten(iteratees, 1), baseUnary(baseIteratee));
|
||||
|
||||
return flatRest(function(iteratees) {
|
||||
iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
|
||||
return baseRest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import baseRepeat from './_baseRepeat.js';
|
||||
import baseToString from './_baseToString.js';
|
||||
import castSlice from './_castSlice.js';
|
||||
import reHasComplexSymbol from './_reHasComplexSymbol.js';
|
||||
import hasUnicode from './_hasUnicode.js';
|
||||
import stringSize from './_stringSize.js';
|
||||
import stringToArray from './_stringToArray.js';
|
||||
|
||||
@@ -25,7 +25,7 @@ function createPadding(length, chars) {
|
||||
return charsLength ? baseRepeat(chars, length) : chars;
|
||||
}
|
||||
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
|
||||
return reHasComplexSymbol.test(chars)
|
||||
return hasUnicode(chars)
|
||||
? castSlice(stringToArray(result), 0, length).join('')
|
||||
: result.slice(0, length);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import setData from './_setData.js';
|
||||
import setWrapToString from './_setWrapToString.js';
|
||||
import toInteger from './toInteger.js';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import basePropertyOf from './_basePropertyOf.js';
|
||||
|
||||
/** Used to map latin-1 supplementary letters to basic latin letters. */
|
||||
/** Used to map Latin Unicode letters to basic Latin letters. */
|
||||
var deburredLetters = {
|
||||
// Latin-1 Supplement block.
|
||||
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
|
||||
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
|
||||
'\xc7': 'C', '\xe7': 'c',
|
||||
'\xd0': 'D', '\xf0': 'd',
|
||||
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
|
||||
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
|
||||
'\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
|
||||
'\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
|
||||
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
|
||||
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
|
||||
'\xd1': 'N', '\xf1': 'n',
|
||||
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
|
||||
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
|
||||
@@ -18,11 +19,48 @@ var deburredLetters = {
|
||||
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
|
||||
'\xc6': 'Ae', '\xe6': 'ae',
|
||||
'\xde': 'Th', '\xfe': 'th',
|
||||
'\xdf': 'ss'
|
||||
'\xdf': 'ss',
|
||||
// Latin Extended-A block.
|
||||
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
|
||||
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
|
||||
'\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
|
||||
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
|
||||
'\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
|
||||
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
|
||||
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
|
||||
'\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
|
||||
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
|
||||
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
|
||||
'\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
|
||||
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
|
||||
'\u0134': 'J', '\u0135': 'j',
|
||||
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
|
||||
'\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
|
||||
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
|
||||
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
|
||||
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
|
||||
'\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
|
||||
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
|
||||
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
|
||||
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
|
||||
'\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
|
||||
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
|
||||
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
|
||||
'\u0163': 't', '\u0165': 't', '\u0167': 't',
|
||||
'\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
|
||||
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
|
||||
'\u0174': 'W', '\u0175': 'w',
|
||||
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
|
||||
'\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
|
||||
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
|
||||
'\u0132': 'IJ', '\u0133': 'ij',
|
||||
'\u0152': 'Oe', '\u0153': 'oe',
|
||||
'\u0149': "'n", '\u017f': 's'
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
|
||||
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
|
||||
* letters to basic Latin letters.
|
||||
*
|
||||
* @private
|
||||
* @param {string} letter The matched letter to deburr.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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;
|
||||
try {
|
||||
var func = getNative(Object, 'defineProperty');
|
||||
func({}, '', {});
|
||||
return func;
|
||||
} catch (e) {}
|
||||
}());
|
||||
|
||||
export default defineProperty;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import SetCache from './_SetCache.js';
|
||||
import arraySome from './_arraySome.js';
|
||||
import cacheHas from './_cacheHas.js';
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
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).
|
||||
if (seen) {
|
||||
if (!arraySome(other, function(othValue, othIndex) {
|
||||
if (!seen.has(othIndex) &&
|
||||
if (!cacheHas(seen, othIndex) &&
|
||||
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
||||
return seen.add(othIndex);
|
||||
return seen.push(othIndex);
|
||||
}
|
||||
})) {
|
||||
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;
|
||||
|
||||
// Fallback for data views, maps, sets, and weak maps in IE 11,
|
||||
// for data views in Edge, and promises in Node.js.
|
||||
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
||||
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
||||
(Map && getTag(new Map) != mapTag) ||
|
||||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
||||
|
||||
13
_hasPath.js
13
_hasPath.js
@@ -4,7 +4,6 @@ import isArray from './isArray.js';
|
||||
import isIndex from './_isIndex.js';
|
||||
import isKey from './_isKey.js';
|
||||
import isLength from './isLength.js';
|
||||
import isString from './isString.js';
|
||||
import toKey from './_toKey.js';
|
||||
|
||||
/**
|
||||
@@ -19,9 +18,9 @@ import toKey from './_toKey.js';
|
||||
function hasPath(object, path, hasFunc) {
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var result,
|
||||
index = -1,
|
||||
length = path.length;
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
result = false;
|
||||
|
||||
while (++index < length) {
|
||||
var key = toKey(path[index]);
|
||||
@@ -30,12 +29,12 @@ function hasPath(object, path, hasFunc) {
|
||||
}
|
||||
object = object[key];
|
||||
}
|
||||
if (result) {
|
||||
if (result || ++index != length) {
|
||||
return result;
|
||||
}
|
||||
var length = object ? object.length : 0;
|
||||
length = object ? object.length : 0;
|
||||
return !!length && isLength(length) && isIndex(key, length) &&
|
||||
(isArray(object) || isString(object) || isArguments(object));
|
||||
(isArray(object) || isArguments(object));
|
||||
}
|
||||
|
||||
export default hasPath;
|
||||
|
||||
@@ -8,6 +8,17 @@ var rsAstralRange = '\\ud800-\\udfff',
|
||||
var rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
|
||||
export default reHasComplexSymbol;
|
||||
/**
|
||||
* Checks if `string` contains Unicode symbols.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to inspect.
|
||||
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
||||
*/
|
||||
function hasUnicode(string) {
|
||||
return reHasUnicode.test(string);
|
||||
}
|
||||
|
||||
export default hasUnicode;
|
||||
15
_hasUnicodeWord.js
Normal file
15
_hasUnicodeWord.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/** Used to detect strings that need a more robust regexp to match words. */
|
||||
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
||||
|
||||
/**
|
||||
* Checks if `string` contains a word composed of Unicode symbols.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to inspect.
|
||||
* @returns {boolean} Returns `true` if a word is found, else `false`.
|
||||
*/
|
||||
function hasUnicodeWord(string) {
|
||||
return reHasUnicodeWord.test(string);
|
||||
}
|
||||
|
||||
export default hasUnicodeWord;
|
||||
@@ -9,6 +9,7 @@ import nativeCreate from './_nativeCreate.js';
|
||||
*/
|
||||
function hashClear() {
|
||||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
export default hashClear;
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -15,6 +15,7 @@ var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||||
*/
|
||||
function hashSet(key, value) {
|
||||
var data = this.__data__;
|
||||
this.size += this.has(key) ? 0 : 1;
|
||||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
|
||||
* @returns {string} Returns the modified source.
|
||||
*/
|
||||
function insertWrapDetails(source, details) {
|
||||
var length = details.length,
|
||||
lastIndex = length - 1;
|
||||
|
||||
var length = details.length;
|
||||
if (!length) {
|
||||
return source;
|
||||
}
|
||||
var lastIndex = length - 1;
|
||||
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
|
||||
details = details.join(length > 2 ? ', ' : ' ');
|
||||
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() {
|
||||
this.__data__ = [];
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
export default listCacheClear;
|
||||
|
||||
@@ -28,6 +28,7 @@ function listCacheDelete(key) {
|
||||
} else {
|
||||
splice.call(data, index, 1);
|
||||
}
|
||||
--this.size;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ function listCacheSet(key, value) {
|
||||
index = assocIndexOf(data, key);
|
||||
|
||||
if (index < 0) {
|
||||
++this.size;
|
||||
data.push([key, value]);
|
||||
} else {
|
||||
data[index][1] = value;
|
||||
|
||||
@@ -10,6 +10,7 @@ import Map from './_Map.js';
|
||||
* @memberOf MapCache
|
||||
*/
|
||||
function mapCacheClear() {
|
||||
this.size = 0;
|
||||
this.__data__ = {
|
||||
'hash': new Hash,
|
||||
'map': new (Map || ListCache),
|
||||
|
||||
@@ -10,7 +10,9 @@ import getMapData from './_getMapData.js';
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -11,7 +11,11 @@ import getMapData from './_getMapData.js';
|
||||
* @returns {Object} Returns the map cache instance.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
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 now from './now.js';
|
||||
|
||||
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
||||
var HOT_COUNT = 150,
|
||||
HOT_SPAN = 16;
|
||||
import shortOut from './_shortOut.js';
|
||||
|
||||
/**
|
||||
* Sets metadata for `func`.
|
||||
@@ -19,24 +15,6 @@ var HOT_COUNT = 150,
|
||||
* @param {*} data The metadata.
|
||||
* @returns {Function} Returns `func`.
|
||||
*/
|
||||
var setData = (function() {
|
||||
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);
|
||||
};
|
||||
}());
|
||||
var setData = shortOut(baseSetData);
|
||||
|
||||
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 identity from './identity.js';
|
||||
import insertWrapDetails from './_insertWrapDetails.js';
|
||||
import setToString from './_setToString.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.
|
||||
* @returns {Function} Returns `wrapper`.
|
||||
*/
|
||||
var setWrapToString = !defineProperty ? identity : function(wrapper, reference, bitmask) {
|
||||
function setWrapToString(wrapper, reference, bitmask) {
|
||||
var source = (reference + '');
|
||||
return defineProperty(wrapper, 'toString', {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'value': constant(insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)))
|
||||
});
|
||||
};
|
||||
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
|
||||
}
|
||||
|
||||
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;
|
||||
28
_shuffleSelf.js
Normal file
28
_shuffleSelf.js
Normal file
@@ -0,0 +1,28 @@
|
||||
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 : size;
|
||||
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() {
|
||||
this.__data__ = new ListCache;
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
export default stackClear;
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
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;
|
||||
|
||||
12
_stackSet.js
12
_stackSet.js
@@ -16,16 +16,18 @@ var LARGE_ARRAY_SIZE = 200;
|
||||
* @returns {Object} Returns the stack cache instance.
|
||||
*/
|
||||
function stackSet(key, value) {
|
||||
var cache = this.__data__;
|
||||
if (cache instanceof ListCache) {
|
||||
var pairs = cache.__data__;
|
||||
var data = this.__data__;
|
||||
if (data instanceof ListCache) {
|
||||
var pairs = data.__data__;
|
||||
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||||
pairs.push([key, value]);
|
||||
this.size = ++data.size;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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,30 +1,6 @@
|
||||
import reHasComplexSymbol from './_reHasComplexSymbol.js';
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
import asciiSize from './_asciiSize.js';
|
||||
import hasUnicode from './_hasUnicode.js';
|
||||
import unicodeSize from './_unicodeSize.js';
|
||||
|
||||
/**
|
||||
* Gets the number of symbols in `string`.
|
||||
@@ -34,14 +10,9 @@ var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq,
|
||||
* @returns {number} Returns the string size.
|
||||
*/
|
||||
function stringSize(string) {
|
||||
if (!(string && reHasComplexSymbol.test(string))) {
|
||||
return string.length;
|
||||
}
|
||||
var result = reComplexSymbol.lastIndex = 0;
|
||||
while (reComplexSymbol.test(string)) {
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
return hasUnicode(string)
|
||||
? unicodeSize(string)
|
||||
: asciiSize(string);
|
||||
}
|
||||
|
||||
export default stringSize;
|
||||
|
||||
@@ -1,28 +1,6 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
import asciiToArray from './_asciiToArray.js';
|
||||
import hasUnicode from './_hasUnicode.js';
|
||||
import unicodeToArray from './_unicodeToArray.js';
|
||||
|
||||
/**
|
||||
* Converts `string` to an array.
|
||||
@@ -32,7 +10,9 @@ var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq,
|
||||
* @returns {Array} Returns the converted array.
|
||||
*/
|
||||
function stringToArray(string) {
|
||||
return string.match(reComplexSymbol);
|
||||
return hasUnicode(string)
|
||||
? unicodeToArray(string)
|
||||
: asciiToArray(string);
|
||||
}
|
||||
|
||||
export default stringToArray;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import memoize from './memoize.js';
|
||||
import memoizeCapped from './_memoizeCapped.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
@@ -15,7 +15,7 @@ var reEscapeChar = /\\(\\)?/g;
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
var stringToPath = memoize(function(string) {
|
||||
var stringToPath = memoizeCapped(function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var result = [];
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/** Used for built-in method references. */
|
||||
var funcProto = Function.prototype;
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = Function.prototype.toString;
|
||||
var funcToString = funcProto.toString;
|
||||
|
||||
/**
|
||||
* Converts `func` to its source code.
|
||||
|
||||
@@ -6,8 +6,7 @@ var htmlUnescapes = {
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'",
|
||||
'`': '`'
|
||||
''': "'"
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
42
_unicodeSize.js
Normal file
42
_unicodeSize.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
|
||||
/**
|
||||
* Gets the size of a Unicode `string`.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string inspect.
|
||||
* @returns {number} Returns the string size.
|
||||
*/
|
||||
function unicodeSize(string) {
|
||||
var result = reUnicode.lastIndex = 0;
|
||||
while (reUnicode.test(string)) {
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default unicodeSize;
|
||||
38
_unicodeToArray.js
Normal file
38
_unicodeToArray.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
|
||||
/**
|
||||
* Converts a Unicode `string` to an array.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the converted array.
|
||||
*/
|
||||
function unicodeToArray(string) {
|
||||
return string.match(reUnicode) || [];
|
||||
}
|
||||
|
||||
export default unicodeToArray;
|
||||
63
_unicodeWords.js
Normal file
63
_unicodeWords.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsDingbatRange = '\\u2700-\\u27bf',
|
||||
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
|
||||
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
|
||||
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
|
||||
rsPunctuationRange = '\\u2000-\\u206f',
|
||||
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
|
||||
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
|
||||
rsVarRange = '\\ufe0e\\ufe0f',
|
||||
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsApos = "['\u2019]",
|
||||
rsBreak = '[' + rsBreakRange + ']',
|
||||
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
|
||||
rsDigits = '\\d+',
|
||||
rsDingbat = '[' + rsDingbatRange + ']',
|
||||
rsLower = '[' + rsLowerRange + ']',
|
||||
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsUpper = '[' + rsUpperRange + ']',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
|
||||
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
|
||||
rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
|
||||
rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
|
||||
reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
||||
|
||||
/** Used to match complex or compound words. */
|
||||
var reUnicodeWord = RegExp([
|
||||
rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
|
||||
rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
|
||||
rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
|
||||
rsUpper + '+' + rsOptUpperContr,
|
||||
rsDigits,
|
||||
rsEmoji
|
||||
].join('|'), 'g');
|
||||
|
||||
/**
|
||||
* Splits a Unicode `string` into an array of its words.
|
||||
*
|
||||
* @private
|
||||
* @param {string} The string to inspect.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
*/
|
||||
function unicodeWords(string) {
|
||||
return string.match(reUnicodeWord) || [];
|
||||
}
|
||||
|
||||
export default unicodeWords;
|
||||
2
after.js
2
after.js
@@ -1,6 +1,6 @@
|
||||
import toInteger from './toInteger.js';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,12 +11,6 @@ var objectProto = Object.prototype;
|
||||
/** Used to check objects for own properties. */
|
||||
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
|
||||
* 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 }
|
||||
*/
|
||||
var assign = createAssigner(function(object, source) {
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
if (isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keys(source), object);
|
||||
return;
|
||||
}
|
||||
|
||||
7
at.js
7
at.js
@@ -1,6 +1,5 @@
|
||||
import baseAt from './_baseAt.js';
|
||||
import baseFlatten from './_baseFlatten.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
import flatRest from './_flatRest.js';
|
||||
|
||||
/**
|
||||
* 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]']);
|
||||
* // => [3, 4]
|
||||
*/
|
||||
var at = baseRest(function(object, paths) {
|
||||
return baseAt(object, baseFlatten(paths, 1));
|
||||
});
|
||||
var at = flatRest(baseAt);
|
||||
|
||||
export default at;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import toInteger from './toInteger.js';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
10
bindAll.js
10
bindAll.js
@@ -1,7 +1,7 @@
|
||||
import arrayEach from './_arrayEach.js';
|
||||
import baseFlatten from './_baseFlatten.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
import bind from './bind.js';
|
||||
import flatRest from './_flatRest.js';
|
||||
import toKey from './_toKey.js';
|
||||
|
||||
/**
|
||||
@@ -30,10 +30,10 @@ import toKey from './_toKey.js';
|
||||
* jQuery(element).on('click', view.click);
|
||||
* // => Logs 'clicked docs' when clicked.
|
||||
*/
|
||||
var bindAll = baseRest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
var bindAll = flatRest(function(object, methodNames) {
|
||||
arrayEach(methodNames, function(key) {
|
||||
key = toKey(key);
|
||||
object[key] = bind(object[key], object);
|
||||
baseAssignValue(object, key, bind(object[key], object));
|
||||
});
|
||||
return object;
|
||||
});
|
||||
|
||||
11
concat.js
11
concat.js
@@ -26,17 +26,18 @@ import isArray from './isArray.js';
|
||||
* // => [1]
|
||||
*/
|
||||
function concat() {
|
||||
var length = arguments.length,
|
||||
args = Array(length ? length - 1 : 0),
|
||||
var length = arguments.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
var args = Array(length - 1),
|
||||
array = arguments[0],
|
||||
index = length;
|
||||
|
||||
while (index--) {
|
||||
args[index - 1] = arguments[index];
|
||||
}
|
||||
return length
|
||||
? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1))
|
||||
: [];
|
||||
return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
|
||||
}
|
||||
|
||||
export default concat;
|
||||
|
||||
2
cond.js
2
cond.js
@@ -3,7 +3,7 @@ import arrayMap from './_arrayMap.js';
|
||||
import baseIteratee from './_baseIteratee.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import baseAssignValue from './_baseAssignValue.js';
|
||||
import createAggregator from './_createAggregator.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
@@ -30,7 +31,11 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* // => { '3': 2, '5': 1 }
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -2,7 +2,7 @@ import isObject from './isObject.js';
|
||||
import now from './now.js';
|
||||
import toNumber from './toNumber.js';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
|
||||
11
deburr.js
11
deburr.js
@@ -1,8 +1,8 @@
|
||||
import deburrLetter from './_deburrLetter.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
/** Used to match latin-1 supplementary letters (excluding mathematical operators). */
|
||||
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
|
||||
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
||||
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
@@ -19,8 +19,9 @@ var reComboMark = RegExp(rsCombo, 'g');
|
||||
|
||||
/**
|
||||
* Deburrs `string` by converting
|
||||
* [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
||||
* to basic latin letters and removing
|
||||
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
||||
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
|
||||
* letters to basic Latin letters and removing
|
||||
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
||||
*
|
||||
* @static
|
||||
@@ -36,7 +37,7 @@ var reComboMark = RegExp(rsCombo, 'g');
|
||||
*/
|
||||
function deburr(string) {
|
||||
string = toString(string);
|
||||
return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');
|
||||
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
|
||||
}
|
||||
|
||||
export default deburr;
|
||||
|
||||
2
defer.js
2
defer.js
@@ -17,7 +17,7 @@ import baseRest from './_baseRest.js';
|
||||
* _.defer(function(text) {
|
||||
* console.log(text);
|
||||
* }, 'deferred');
|
||||
* // => Logs 'deferred' after one or more milliseconds.
|
||||
* // => Logs 'deferred' after one millisecond.
|
||||
*/
|
||||
var defer = baseRest(function(func, 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
|
||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons. The order of result values is determined by the
|
||||
* order they occur in the first array.
|
||||
* for equality comparisons. The order and references of result values are
|
||||
* determined by the first 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
|
||||
* 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.
|
||||
* The iteratee is invoked with one argument: (value).
|
||||
* by which they're compared. The order and references of result values are
|
||||
* determined by the first array. The iteratee is invoked with one argument:
|
||||
* (value).
|
||||
*
|
||||
* **Note:** Unlike `_.pullAllBy`, this method returns a new array.
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user