mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Compare commits
11 Commits
4.17.3-es
...
4.17.14-es
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15421d13b7 | ||
|
|
078664194c | ||
|
|
51c827ffd9 | ||
|
|
349273409f | ||
|
|
cc483eda91 | ||
|
|
f73db1f02c | ||
|
|
546e924be3 | ||
|
|
b5a07bdc4b | ||
|
|
ae7044c0d3 | ||
|
|
edff3e8d25 | ||
|
|
528e134995 |
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright JS Foundation and other contributors <https://js.foundation/>
|
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||||
|
|
||||||
Based on Underscore.js, copyright Jeremy Ashkenas,
|
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# lodash-es v4.17.3
|
# lodash-es v4.17.14
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
|||||||
$ lodash modularize exports=es -o ./
|
$ lodash modularize exports=es -o ./
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.17.3-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.17.14-es) for more details.
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ 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 isMap from './isMap.js';
|
||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
|
import isSet from './isSet.js';
|
||||||
import keys from './keys.js';
|
import keys from './keys.js';
|
||||||
|
|
||||||
/** Used to compose bitmasks for cloning. */
|
/** Used to compose bitmasks for cloning. */
|
||||||
@@ -123,7 +125,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
|
|||||||
if (!cloneableTags[tag]) {
|
if (!cloneableTags[tag]) {
|
||||||
return object ? value : {};
|
return object ? value : {};
|
||||||
}
|
}
|
||||||
result = initCloneByTag(value, tag, baseClone, isDeep);
|
result = initCloneByTag(value, tag, isDeep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for circular references and return its corresponding clone.
|
// Check for circular references and return its corresponding clone.
|
||||||
@@ -134,6 +136,16 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
|
|||||||
}
|
}
|
||||||
stack.set(value, result);
|
stack.set(value, result);
|
||||||
|
|
||||||
|
if (isSet(value)) {
|
||||||
|
value.forEach(function(subValue) {
|
||||||
|
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
||||||
|
});
|
||||||
|
} else if (isMap(value)) {
|
||||||
|
value.forEach(function(subValue, key) {
|
||||||
|
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var keysFunc = isFull
|
var keysFunc = isFull
|
||||||
? (isFlat ? getAllKeysIn : getAllKeys)
|
? (isFlat ? getAllKeysIn : getAllKeys)
|
||||||
: (isFlat ? keysIn : keys);
|
: (isFlat ? keysIn : keys);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import baseFor from './_baseFor.js';
|
|||||||
import baseMergeDeep from './_baseMergeDeep.js';
|
import baseMergeDeep from './_baseMergeDeep.js';
|
||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
import keysIn from './keysIn.js';
|
import keysIn from './keysIn.js';
|
||||||
|
import safeGet from './_safeGet.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.merge` without support for multiple sources.
|
* The base implementation of `_.merge` without support for multiple sources.
|
||||||
@@ -21,13 +22,13 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
baseFor(source, function(srcValue, key) {
|
baseFor(source, function(srcValue, key) {
|
||||||
|
stack || (stack = new Stack);
|
||||||
if (isObject(srcValue)) {
|
if (isObject(srcValue)) {
|
||||||
stack || (stack = new Stack);
|
|
||||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var newValue = customizer
|
var newValue = customizer
|
||||||
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import isFunction from './isFunction.js';
|
|||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
import isPlainObject from './isPlainObject.js';
|
import isPlainObject from './isPlainObject.js';
|
||||||
import isTypedArray from './isTypedArray.js';
|
import isTypedArray from './isTypedArray.js';
|
||||||
|
import safeGet from './_safeGet.js';
|
||||||
import toPlainObject from './toPlainObject.js';
|
import toPlainObject from './toPlainObject.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,8 +30,8 @@ import toPlainObject from './toPlainObject.js';
|
|||||||
* counterparts.
|
* counterparts.
|
||||||
*/
|
*/
|
||||||
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
||||||
var objValue = object[key],
|
var objValue = safeGet(object, key),
|
||||||
srcValue = source[key],
|
srcValue = safeGet(source, key),
|
||||||
stacked = stack.get(srcValue);
|
stacked = stack.get(srcValue);
|
||||||
|
|
||||||
if (stacked) {
|
if (stacked) {
|
||||||
@@ -73,7 +74,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
if (isArguments(objValue)) {
|
if (isArguments(objValue)) {
|
||||||
newValue = toPlainObject(objValue);
|
newValue = toPlainObject(objValue);
|
||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || isFunction(objValue)) {
|
||||||
newValue = initCloneObject(srcValue);
|
newValue = initCloneObject(srcValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import root from './_root.js';
|
||||||
import toInteger from './toInteger.js';
|
import toInteger from './toInteger.js';
|
||||||
import toNumber from './toNumber.js';
|
import toNumber from './toNumber.js';
|
||||||
import toString from './toString.js';
|
import toString from './toString.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. */
|
||||||
var nativeMin = Math.min;
|
var nativeIsFinite = root.isFinite,
|
||||||
|
nativeMin = Math.min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function like `_.round`.
|
* Creates a function like `_.round`.
|
||||||
@@ -17,7 +19,7 @@ function createRound(methodName) {
|
|||||||
return function(number, precision) {
|
return function(number, precision) {
|
||||||
number = toNumber(number);
|
number = toNumber(number);
|
||||||
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
||||||
if (precision) {
|
if (precision && nativeIsFinite(number)) {
|
||||||
// Shift with exponential notation to avoid floating-point issues.
|
// Shift with exponential notation to avoid floating-point issues.
|
||||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||||
var pair = (toString(number) + 'e').split('e'),
|
var pair = (toString(number) + 'e').split('e'),
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import isPlainObject from './isPlainObject.js';
|
|||||||
* @param {string} key The key of the property to inspect.
|
* @param {string} key The key of the property to inspect.
|
||||||
* @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
|
* @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
|
||||||
*/
|
*/
|
||||||
function customOmitClone(value, key) {
|
function customOmitClone(value) {
|
||||||
return (key !== undefined && isPlainObject(value)) ? undefined : value;
|
return isPlainObject(value) ? undefined : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default customOmitClone;
|
export default customOmitClone;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/** Used to detect strings that need a more robust regexp to match words. */
|
/** 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 ]/;
|
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.
|
* Checks if `string` contains a word composed of Unicode symbols.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
*/
|
*/
|
||||||
function initCloneArray(array) {
|
function initCloneArray(array) {
|
||||||
var length = array.length,
|
var length = array.length,
|
||||||
result = array.constructor(length);
|
result = new array.constructor(length);
|
||||||
|
|
||||||
// Add properties assigned by `RegExp#exec`.
|
// Add properties assigned by `RegExp#exec`.
|
||||||
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import cloneArrayBuffer from './_cloneArrayBuffer.js';
|
import cloneArrayBuffer from './_cloneArrayBuffer.js';
|
||||||
import cloneDataView from './_cloneDataView.js';
|
import cloneDataView from './_cloneDataView.js';
|
||||||
import cloneMap from './_cloneMap.js';
|
|
||||||
import cloneRegExp from './_cloneRegExp.js';
|
import cloneRegExp from './_cloneRegExp.js';
|
||||||
import cloneSet from './_cloneSet.js';
|
|
||||||
import cloneSymbol from './_cloneSymbol.js';
|
import cloneSymbol from './_cloneSymbol.js';
|
||||||
import cloneTypedArray from './_cloneTypedArray.js';
|
import cloneTypedArray from './_cloneTypedArray.js';
|
||||||
|
|
||||||
@@ -32,16 +30,15 @@ var arrayBufferTag = '[object ArrayBuffer]',
|
|||||||
* Initializes an object clone based on its `toStringTag`.
|
* Initializes an object clone based on its `toStringTag`.
|
||||||
*
|
*
|
||||||
* **Note:** This function only supports cloning values with tags of
|
* **Note:** This function only supports cloning values with tags of
|
||||||
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} object The object to clone.
|
* @param {Object} object The object to clone.
|
||||||
* @param {string} tag The `toStringTag` of the object to clone.
|
* @param {string} tag The `toStringTag` of the object to clone.
|
||||||
* @param {Function} cloneFunc The function to clone values.
|
|
||||||
* @param {boolean} [isDeep] Specify a deep clone.
|
* @param {boolean} [isDeep] Specify a deep clone.
|
||||||
* @returns {Object} Returns the initialized clone.
|
* @returns {Object} Returns the initialized clone.
|
||||||
*/
|
*/
|
||||||
function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
function initCloneByTag(object, tag, isDeep) {
|
||||||
var Ctor = object.constructor;
|
var Ctor = object.constructor;
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case arrayBufferTag:
|
case arrayBufferTag:
|
||||||
@@ -60,7 +57,7 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
|||||||
return cloneTypedArray(object, isDeep);
|
return cloneTypedArray(object, isDeep);
|
||||||
|
|
||||||
case mapTag:
|
case mapTag:
|
||||||
return cloneMap(object, isDeep, cloneFunc);
|
return new Ctor;
|
||||||
|
|
||||||
case numberTag:
|
case numberTag:
|
||||||
case stringTag:
|
case stringTag:
|
||||||
@@ -70,7 +67,7 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
|||||||
return cloneRegExp(object);
|
return cloneRegExp(object);
|
||||||
|
|
||||||
case setTag:
|
case setTag:
|
||||||
return cloneSet(object, isDeep, cloneFunc);
|
return new Ctor;
|
||||||
|
|
||||||
case symbolTag:
|
case symbolTag:
|
||||||
return cloneSymbol(object);
|
return cloneSymbol(object);
|
||||||
|
|||||||
@@ -13,10 +13,13 @@ var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|||||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||||
*/
|
*/
|
||||||
function isIndex(value, length) {
|
function isIndex(value, length) {
|
||||||
|
var type = typeof value;
|
||||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
||||||
|
|
||||||
return !!length &&
|
return !!length &&
|
||||||
(typeof value == 'number' || reIsUint.test(value)) &&
|
(type == 'number' ||
|
||||||
(value > -1 && value % 1 == 0 && value < length);
|
(type != 'symbol' && reIsUint.test(value))) &&
|
||||||
|
(value > -1 && value % 1 == 0 && value < length);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isIndex;
|
export default isIndex;
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ var freeProcess = moduleExports && freeGlobal.process;
|
|||||||
/** Used to access faster Node.js helpers. */
|
/** Used to access faster Node.js helpers. */
|
||||||
var nodeUtil = (function() {
|
var nodeUtil = (function() {
|
||||||
try {
|
try {
|
||||||
|
// Use `util.types` for Node.js 10+.
|
||||||
|
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
||||||
|
|
||||||
|
if (types) {
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy `process.binding('util')` for Node.js < 10.
|
||||||
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}());
|
}());
|
||||||
|
|||||||
21
_safeGet.js
Normal file
21
_safeGet.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Gets the value at `key`, unless `key` is "__proto__" or "constructor".
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The object to query.
|
||||||
|
* @param {string} key The key of the property to get.
|
||||||
|
* @returns {*} Returns the property value.
|
||||||
|
*/
|
||||||
|
function safeGet(object, key) {
|
||||||
|
if (key === 'constructor' && typeof object[key] === 'function') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == '__proto__') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return object[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default safeGet;
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import memoizeCapped from './_memoizeCapped.js';
|
import memoizeCapped from './_memoizeCapped.js';
|
||||||
|
|
||||||
/** Used to match property names within property paths. */
|
/** Used to match property names within property paths. */
|
||||||
var reLeadingDot = /^\./,
|
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||||||
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
||||||
|
|
||||||
/** Used to match backslashes in property paths. */
|
/** Used to match backslashes in property paths. */
|
||||||
var reEscapeChar = /\\(\\)?/g;
|
var reEscapeChar = /\\(\\)?/g;
|
||||||
@@ -16,11 +15,11 @@ var reEscapeChar = /\\(\\)?/g;
|
|||||||
*/
|
*/
|
||||||
var stringToPath = memoizeCapped(function(string) {
|
var stringToPath = memoizeCapped(function(string) {
|
||||||
var result = [];
|
var result = [];
|
||||||
if (reLeadingDot.test(string)) {
|
if (string.charCodeAt(0) === 46 /* . */) {
|
||||||
result.push('');
|
result.push('');
|
||||||
}
|
}
|
||||||
string.replace(rePropName, function(match, number, quote, string) {
|
string.replace(rePropName, function(match, number, quote, subString) {
|
||||||
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
|
|||||||
reOptMod = rsModifier + '?',
|
reOptMod = rsModifier + '?',
|
||||||
rsOptVar = '[' + rsVarRange + ']?',
|
rsOptVar = '[' + rsVarRange + ']?',
|
||||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||||
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
|
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
|
||||||
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
|
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
|
||||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||||
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
||||||
|
|
||||||
|
|||||||
@@ -108,9 +108,11 @@ function debounce(func, wait, options) {
|
|||||||
function remainingWait(time) {
|
function remainingWait(time) {
|
||||||
var timeSinceLastCall = time - lastCallTime,
|
var timeSinceLastCall = time - lastCallTime,
|
||||||
timeSinceLastInvoke = time - lastInvokeTime,
|
timeSinceLastInvoke = time - lastInvokeTime,
|
||||||
result = wait - timeSinceLastCall;
|
timeWaiting = wait - timeSinceLastCall;
|
||||||
|
|
||||||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
return maxing
|
||||||
|
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
||||||
|
: timeWaiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldInvoke(time) {
|
function shouldInvoke(time) {
|
||||||
@@ -171,6 +173,7 @@ function debounce(func, wait, options) {
|
|||||||
}
|
}
|
||||||
if (maxing) {
|
if (maxing) {
|
||||||
// Handle invocations in a tight loop.
|
// Handle invocations in a tight loop.
|
||||||
|
clearTimeout(timerId);
|
||||||
timerId = setTimeout(timerExpired, wait);
|
timerId = setTimeout(timerExpired, wait);
|
||||||
return invokeFunc(lastCallTime);
|
return invokeFunc(lastCallTime);
|
||||||
}
|
}
|
||||||
|
|||||||
44
defaults.js
44
defaults.js
@@ -1,7 +1,13 @@
|
|||||||
import apply from './_apply.js';
|
|
||||||
import assignInWith from './assignInWith.js';
|
|
||||||
import baseRest from './_baseRest.js';
|
import baseRest from './_baseRest.js';
|
||||||
import customDefaultsAssignIn from './_customDefaultsAssignIn.js';
|
import eq from './eq.js';
|
||||||
|
import isIterateeCall from './_isIterateeCall.js';
|
||||||
|
import keysIn from './keysIn.js';
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/** Used to check objects for own properties. */
|
||||||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns own and inherited enumerable string keyed properties of source
|
* Assigns own and inherited enumerable string keyed properties of source
|
||||||
@@ -24,9 +30,35 @@ import customDefaultsAssignIn from './_customDefaultsAssignIn.js';
|
|||||||
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
||||||
* // => { 'a': 1, 'b': 2 }
|
* // => { 'a': 1, 'b': 2 }
|
||||||
*/
|
*/
|
||||||
var defaults = baseRest(function(args) {
|
var defaults = baseRest(function(object, sources) {
|
||||||
args.push(undefined, customDefaultsAssignIn);
|
object = Object(object);
|
||||||
return apply(assignInWith, undefined, args);
|
|
||||||
|
var index = -1;
|
||||||
|
var length = sources.length;
|
||||||
|
var guard = length > 2 ? sources[2] : undefined;
|
||||||
|
|
||||||
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||||
|
length = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (++index < length) {
|
||||||
|
var source = sources[index];
|
||||||
|
var props = keysIn(source);
|
||||||
|
var propsIndex = -1;
|
||||||
|
var propsLength = props.length;
|
||||||
|
|
||||||
|
while (++propsIndex < propsLength) {
|
||||||
|
var key = props[propsIndex];
|
||||||
|
var value = object[key];
|
||||||
|
|
||||||
|
if (value === undefined ||
|
||||||
|
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
|
||||||
|
object[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default defaults;
|
export default defaults;
|
||||||
|
|||||||
15
invert.js
15
invert.js
@@ -2,6 +2,16 @@ import constant from './constant.js';
|
|||||||
import createInverter from './_createInverter.js';
|
import createInverter from './_createInverter.js';
|
||||||
import identity from './identity.js';
|
import identity from './identity.js';
|
||||||
|
|
||||||
|
/** 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 nativeObjectToString = objectProto.toString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an object composed of the inverted keys and values of `object`.
|
* Creates an object composed of the inverted keys and values of `object`.
|
||||||
* If `object` contains duplicate values, subsequent values overwrite
|
* If `object` contains duplicate values, subsequent values overwrite
|
||||||
@@ -21,6 +31,11 @@ import identity from './identity.js';
|
|||||||
* // => { '1': 'c', '2': 'b' }
|
* // => { '1': 'c', '2': 'b' }
|
||||||
*/
|
*/
|
||||||
var invert = createInverter(function(result, value, key) {
|
var invert = createInverter(function(result, value, key) {
|
||||||
|
if (value != null &&
|
||||||
|
typeof value.toString != 'function') {
|
||||||
|
value = nativeObjectToString.call(value);
|
||||||
|
}
|
||||||
|
|
||||||
result[value] = key;
|
result[value] = key;
|
||||||
}, constant(identity));
|
}, constant(identity));
|
||||||
|
|
||||||
|
|||||||
12
invertBy.js
12
invertBy.js
@@ -7,6 +7,13 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to resolve the
|
||||||
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||||
|
* of values.
|
||||||
|
*/
|
||||||
|
var nativeObjectToString = objectProto.toString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.invert` except that the inverted object is generated
|
* This method is like `_.invert` except that the inverted object is generated
|
||||||
* from the results of running each element of `object` thru `iteratee`. The
|
* from the results of running each element of `object` thru `iteratee`. The
|
||||||
@@ -34,6 +41,11 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
|
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
|
||||||
*/
|
*/
|
||||||
var invertBy = createInverter(function(result, value, key) {
|
var invertBy = createInverter(function(result, value, key) {
|
||||||
|
if (value != null &&
|
||||||
|
typeof value.toString != 'function') {
|
||||||
|
value = nativeObjectToString.call(value);
|
||||||
|
}
|
||||||
|
|
||||||
if (hasOwnProperty.call(result, value)) {
|
if (hasOwnProperty.call(result, value)) {
|
||||||
result[value].push(key);
|
result[value].push(key);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @license
|
* @license
|
||||||
* Lodash (Custom Build) <https://lodash.com/>
|
* Lodash (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modularize exports="es" -o ./`
|
* Build: `lodash modularize exports="es" -o ./`
|
||||||
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||||
* Released under MIT license <https://lodash.com/license>
|
* Released under MIT license <https://lodash.com/license>
|
||||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||||
@@ -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.17.3';
|
var VERSION = '4.17.14';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
var WRAP_BIND_KEY_FLAG = 2;
|
var WRAP_BIND_KEY_FLAG = 2;
|
||||||
@@ -606,10 +606,11 @@ arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(method
|
|||||||
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
||||||
var lodashFunc = lodash[methodName];
|
var lodashFunc = lodash[methodName];
|
||||||
if (lodashFunc) {
|
if (lodashFunc) {
|
||||||
var key = (lodashFunc.name + ''),
|
var key = lodashFunc.name + '';
|
||||||
names = realNames[key] || (realNames[key] = []);
|
if (!hasOwnProperty.call(realNames, key)) {
|
||||||
|
realNames[key] = [];
|
||||||
names.push({ 'name': methodName, 'func': lodashFunc });
|
}
|
||||||
|
realNames[key].push({ 'name': methodName, 'func': lodashFunc });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @license
|
* @license
|
||||||
* Lodash (Custom Build) <https://lodash.com/>
|
* Lodash (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modularize exports="es" -o ./`
|
* Build: `lodash modularize exports="es" -o ./`
|
||||||
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||||
* Released under MIT license <https://lodash.com/license>
|
* Released under MIT license <https://lodash.com/license>
|
||||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-es",
|
"name": "lodash-es",
|
||||||
"version": "4.17.3",
|
"version": "4.17.14",
|
||||||
"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",
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
"jsnext:main": "lodash.js",
|
"jsnext:main": "lodash.js",
|
||||||
"main": "lodash.js",
|
"main": "lodash.js",
|
||||||
"module": "lodash.js",
|
"module": "lodash.js",
|
||||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
"sideEffects": false,
|
||||||
|
"author": "John-David Dalton <john.david.dalton@gmail.com>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
"John-David Dalton <john.david.dalton@gmail.com>",
|
||||||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)",
|
"Mathias Bynens <mathias@qiwi.be>"
|
||||||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
|
||||||
],
|
],
|
||||||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }
|
"scripts": { "test": "echo \"See https://travis-ci.org/lodash-archive/lodash-cli for testing details.\"" }
|
||||||
}
|
}
|
||||||
|
|||||||
19
template.js
19
template.js
@@ -27,6 +27,12 @@ var reNoMatch = /($^)/;
|
|||||||
/** Used to match unescaped characters in compiled string literals. */
|
/** Used to match unescaped characters in compiled string literals. */
|
||||||
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var objectProto = Object.prototype;
|
||||||
|
|
||||||
|
/** Used to check objects for own properties. */
|
||||||
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a compiled template function that can interpolate data properties
|
* Creates a compiled template function that can interpolate data properties
|
||||||
* in "interpolate" delimiters, HTML-escape interpolated data properties in
|
* in "interpolate" delimiters, HTML-escape interpolated data properties in
|
||||||
@@ -162,7 +168,14 @@ function template(string, options, guard) {
|
|||||||
, 'g');
|
, 'g');
|
||||||
|
|
||||||
// Use a sourceURL for easier debugging.
|
// Use a sourceURL for easier debugging.
|
||||||
var sourceURL = 'sourceURL' in options ? '//# sourceURL=' + options.sourceURL + '\n' : '';
|
// The sourceURL gets injected into the source that's eval-ed, so be careful
|
||||||
|
// with lookup (in case of e.g. prototype pollution), and strip newlines if any.
|
||||||
|
// A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
|
||||||
|
var sourceURL = hasOwnProperty.call(options, 'sourceURL')
|
||||||
|
? ('//# sourceURL=' +
|
||||||
|
(options.sourceURL + '').replace(/[\r\n]/g, ' ') +
|
||||||
|
'\n')
|
||||||
|
: '';
|
||||||
|
|
||||||
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
||||||
interpolateValue || (interpolateValue = esTemplateValue);
|
interpolateValue || (interpolateValue = esTemplateValue);
|
||||||
@@ -193,7 +206,9 @@ function template(string, options, guard) {
|
|||||||
|
|
||||||
// If `variable` is not specified wrap a with-statement around the generated
|
// If `variable` is not specified wrap a with-statement around the generated
|
||||||
// code to add the data object to the top of the scope chain.
|
// code to add the data object to the top of the scope chain.
|
||||||
var variable = options.variable;
|
// Like with sourceURL, we take care to not check the option's prototype,
|
||||||
|
// as this configuration is a code injection vector.
|
||||||
|
var variable = hasOwnProperty.call(options, 'variable') && options.variable;
|
||||||
if (!variable) {
|
if (!variable) {
|
||||||
source = 'with (obj) {\n' + source + '\n}\n';
|
source = 'with (obj) {\n' + source + '\n}\n';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user