mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Bump to v4.0.0.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import arrayCopy from './arrayCopy';
|
||||
import composeArgs from './composeArgs';
|
||||
import composeArgsRight from './composeArgsRight';
|
||||
import copyArray from './copyArray';
|
||||
import replaceHolders from './replaceHolders';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
BIND_KEY_FLAG = 2,
|
||||
CURRY_BOUND_FLAG = 4,
|
||||
CURRY_FLAG = 8,
|
||||
ARY_FLAG = 128,
|
||||
@@ -13,18 +14,18 @@ var BIND_FLAG = 1,
|
||||
/** Used as the internal argument placeholder. */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/* Native 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;
|
||||
|
||||
/**
|
||||
* Merges the function metadata of `source` into `data`.
|
||||
*
|
||||
* Merging metadata reduces the number of wrappers required to invoke a function.
|
||||
* Merging metadata reduces the number of wrappers used to invoke a function.
|
||||
* This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
|
||||
* may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`
|
||||
* augment function arguments, making the order in which they are executed important,
|
||||
* modify function arguments, making the order in which they are executed important,
|
||||
* preventing the merging of metadata. However, we make an exception for a safe
|
||||
* common case where curried functions have `_.ary` and or `_.rearg` applied.
|
||||
* combined case where curried functions have `_.ary` and or `_.rearg` applied.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} data The destination metadata.
|
||||
@@ -35,12 +36,12 @@ function mergeData(data, source) {
|
||||
var bitmask = data[1],
|
||||
srcBitmask = source[1],
|
||||
newBitmask = bitmask | srcBitmask,
|
||||
isCommon = newBitmask < ARY_FLAG;
|
||||
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
|
||||
|
||||
var isCombo =
|
||||
(srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||
|
||||
(srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||
|
||||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);
|
||||
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) ||
|
||||
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
|
||||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
|
||||
|
||||
// Exit early if metadata can't be merged.
|
||||
if (!(isCommon || isCombo)) {
|
||||
@@ -56,20 +57,20 @@ function mergeData(data, source) {
|
||||
var value = source[3];
|
||||
if (value) {
|
||||
var partials = data[3];
|
||||
data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);
|
||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);
|
||||
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
|
||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
|
||||
}
|
||||
// Compose partial right arguments.
|
||||
value = source[5];
|
||||
if (value) {
|
||||
partials = data[5];
|
||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);
|
||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);
|
||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
|
||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
|
||||
}
|
||||
// Use source `argPos` if available.
|
||||
value = source[7];
|
||||
if (value) {
|
||||
data[7] = arrayCopy(value);
|
||||
data[7] = copyArray(value);
|
||||
}
|
||||
// Use source `ary` if it's smaller.
|
||||
if (srcBitmask & ARY_FLAG) {
|
||||
|
||||
Reference in New Issue
Block a user