mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Reorg data merged by mergeData and remove dead code.
This commit is contained in:
54
lodash.js
54
lodash.js
@@ -22,8 +22,8 @@
|
|||||||
CURRY_RIGHT_FLAG = 16,
|
CURRY_RIGHT_FLAG = 16,
|
||||||
PARTIAL_FLAG = 32,
|
PARTIAL_FLAG = 32,
|
||||||
PARTIAL_RIGHT_FLAG = 64,
|
PARTIAL_RIGHT_FLAG = 64,
|
||||||
ARY_FLAG = 128,
|
REARG_FLAG = 128,
|
||||||
REARG_FLAG = 256;
|
ARY_FLAG = 256;
|
||||||
|
|
||||||
/** Used as default options for `_.trunc`. */
|
/** Used as default options for `_.trunc`. */
|
||||||
var DEFAULT_TRUNC_LENGTH = 30,
|
var DEFAULT_TRUNC_LENGTH = 30,
|
||||||
@@ -2947,11 +2947,11 @@
|
|||||||
* @param {Array} [partialsRight] The arguments to append to those provided to the new function.
|
* @param {Array} [partialsRight] The arguments to append to those provided to the new function.
|
||||||
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
|
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
|
||||||
* @param {Array} [argPos] The argument positions of the new function.
|
* @param {Array} [argPos] The argument positions of the new function.
|
||||||
* @param {number} [arity] The arity of `func`.
|
|
||||||
* @param {number} [ary] The arity cap of `func`.
|
* @param {number} [ary] The arity cap of `func`.
|
||||||
|
* @param {number} [arity] The arity of `func`.
|
||||||
* @returns {Function} Returns the new wrapped function.
|
* @returns {Function} Returns the new wrapped function.
|
||||||
*/
|
*/
|
||||||
function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity, ary) {
|
function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
|
||||||
var isAry = bitmask & ARY_FLAG,
|
var isAry = bitmask & ARY_FLAG,
|
||||||
isBind = bitmask & BIND_FLAG,
|
isBind = bitmask & BIND_FLAG,
|
||||||
isBindKey = bitmask & BIND_KEY_FLAG,
|
isBindKey = bitmask & BIND_KEY_FLAG,
|
||||||
@@ -2997,7 +2997,7 @@
|
|||||||
if (!isCurryBound) {
|
if (!isCurryBound) {
|
||||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||||
}
|
}
|
||||||
var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, newArity, ary);
|
var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity);
|
||||||
result.placeholder = placeholder;
|
result.placeholder = placeholder;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -3091,17 +3091,17 @@
|
|||||||
* 16 - `_.curryRight`
|
* 16 - `_.curryRight`
|
||||||
* 32 - `_.partial`
|
* 32 - `_.partial`
|
||||||
* 64 - `_.partialRight`
|
* 64 - `_.partialRight`
|
||||||
* 128 - `_.ary`
|
* 128 - `_.rearg`
|
||||||
* 256 - `_.rearg`
|
* 256 - `_.ary`
|
||||||
* @param {*} [thisArg] The `this` binding of `func`.
|
* @param {*} [thisArg] The `this` binding of `func`.
|
||||||
* @param {Array} [partials] The arguments to be partially applied.
|
* @param {Array} [partials] The arguments to be partially applied.
|
||||||
* @param {Array} [holders] The `partials` placeholder indexes.
|
* @param {Array} [holders] The `partials` placeholder indexes.
|
||||||
* @param {Array} [argPos] The argument positions of the new function.
|
* @param {Array} [argPos] The argument positions of the new function.
|
||||||
* @param {number} [arity] The arity of `func`.
|
|
||||||
* @param {number} [ary] The arity cap of `func`.
|
* @param {number} [ary] The arity cap of `func`.
|
||||||
|
* @param {number} [arity] The arity of `func`.
|
||||||
* @returns {Function} Returns the new wrapped function.
|
* @returns {Function} Returns the new wrapped function.
|
||||||
*/
|
*/
|
||||||
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, arity, ary) {
|
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
|
||||||
var isBindKey = bitmask & BIND_KEY_FLAG;
|
var isBindKey = bitmask & BIND_KEY_FLAG;
|
||||||
if (!isBindKey && !isFunction(func)) {
|
if (!isBindKey && !isFunction(func)) {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
@@ -3121,14 +3121,14 @@
|
|||||||
partials = holders = null;
|
partials = holders = null;
|
||||||
}
|
}
|
||||||
var data = !isBindKey && getData(func),
|
var data = !isBindKey && getData(func),
|
||||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity, ary];
|
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
||||||
|
|
||||||
if (data && data !== true) {
|
if (data && data !== true) {
|
||||||
mergeData(newData, data);
|
mergeData(newData, data);
|
||||||
}
|
}
|
||||||
newData[8] = newData[8] == null
|
newData[9] = newData[9] == null
|
||||||
? (isBindKey ? 0 : newData[0].length)
|
? (isBindKey ? 0 : newData[0].length)
|
||||||
: (nativeMax(newData[8] - length, 0) || 0);
|
: (nativeMax(newData[9] - length, 0) || 0);
|
||||||
|
|
||||||
bitmask = newData[1];
|
bitmask = newData[1];
|
||||||
if (bitmask == BIND_FLAG) {
|
if (bitmask == BIND_FLAG) {
|
||||||
@@ -3535,11 +3535,11 @@
|
|||||||
argPos = (isRearg ? data : source)[7],
|
argPos = (isRearg ? data : source)[7],
|
||||||
ary = (isAry ? data : source)[9];
|
ary = (isAry ? data : source)[9];
|
||||||
|
|
||||||
var isCommon = !(bitmask >= ARY_FLAG && srcBitmask > bindFlags) &&
|
var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) &&
|
||||||
!(bitmask > bindFlags && srcBitmask >= ARY_FLAG);
|
!(bitmask > bindFlags && srcBitmask >= REARG_FLAG);
|
||||||
|
|
||||||
var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) &&
|
var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) &&
|
||||||
(bitmask < ARY_FLAG || ((isRearg || isAry) && argPos[0].length <= ary));
|
(bitmask < REARG_FLAG || ((isRearg || isAry) && argPos[0].length <= ary));
|
||||||
|
|
||||||
// Exit early if metadata can't be merged.
|
// Exit early if metadata can't be merged.
|
||||||
if (!(isCommon || isCombo)) {
|
if (!(isCommon || isCombo)) {
|
||||||
@@ -3565,22 +3565,18 @@
|
|||||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : baseSlice(value);
|
data[5] = partials ? composeArgsRight(partials, value, source[6]) : baseSlice(value);
|
||||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : baseSlice(source[6]);
|
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : baseSlice(source[6]);
|
||||||
}
|
}
|
||||||
// Append argument positions.
|
// Use source `argPos` if available.
|
||||||
value = source[7];
|
value = source[7];
|
||||||
if (value) {
|
if (value) {
|
||||||
argPos = data[7];
|
data[7] = baseSlice(value);
|
||||||
value = data[7] = baseSlice(value);
|
|
||||||
if (argPos) {
|
|
||||||
push.apply(value, argPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Use source `arity` if one is not provided.
|
|
||||||
if (data[8] == null) {
|
|
||||||
data[8] = source[8];
|
|
||||||
}
|
}
|
||||||
// Use source `ary` if it's smaller.
|
// Use source `ary` if it's smaller.
|
||||||
if (srcBitmask & ARY_FLAG) {
|
if (srcBitmask & ARY_FLAG) {
|
||||||
data[9] = data[9] == null ? source[9] : nativeMin(data[9], source[9]);
|
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
|
||||||
|
}
|
||||||
|
// Use source `arity` if one is not provided.
|
||||||
|
if (data[9] == null) {
|
||||||
|
data[9] = source[9];
|
||||||
}
|
}
|
||||||
// Use source `func` and merge bitmasks.
|
// Use source `func` and merge bitmasks.
|
||||||
data[0] = source[0];
|
data[0] = source[0];
|
||||||
@@ -6462,7 +6458,7 @@
|
|||||||
n = null;
|
n = null;
|
||||||
}
|
}
|
||||||
n = n == null ? func.length : (+n || 0);
|
n = n == null ? func.length : (+n || 0);
|
||||||
return createWrapper(func, ARY_FLAG, null, null, null, null, null, n);
|
return createWrapper(func, ARY_FLAG, null, null, null, null, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6681,7 +6677,7 @@
|
|||||||
if (guard && isIterateeCall(func, arity, guard)) {
|
if (guard && isIterateeCall(func, arity, guard)) {
|
||||||
arity = null;
|
arity = null;
|
||||||
}
|
}
|
||||||
var result = createWrapper(func, CURRY_FLAG, null, null, null, null, arity);
|
var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity);
|
||||||
result.placeholder = curry.placeholder;
|
result.placeholder = curry.placeholder;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -6727,7 +6723,7 @@
|
|||||||
if (guard && isIterateeCall(func, arity, guard)) {
|
if (guard && isIterateeCall(func, arity, guard)) {
|
||||||
arity = null;
|
arity = null;
|
||||||
}
|
}
|
||||||
var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, guard ? null : arity);
|
var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity);
|
||||||
result.placeholder = curryRight.placeholder;
|
result.placeholder = curryRight.placeholder;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user