mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Bump to v4.0.0.
This commit is contained in:
@@ -1,21 +1,25 @@
|
||||
import baseSetData from './baseSetData';
|
||||
import createBindWrapper from './createBindWrapper';
|
||||
import createBaseWrapper from './createBaseWrapper';
|
||||
import createCurryWrapper from './createCurryWrapper';
|
||||
import createHybridWrapper from './createHybridWrapper';
|
||||
import createPartialWrapper from './createPartialWrapper';
|
||||
import getData from './getData';
|
||||
import mergeData from './mergeData';
|
||||
import setData from './setData';
|
||||
import toInteger from '../toInteger';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
BIND_KEY_FLAG = 2,
|
||||
CURRY_FLAG = 8,
|
||||
CURRY_RIGHT_FLAG = 16,
|
||||
PARTIAL_FLAG = 32,
|
||||
PARTIAL_RIGHT_FLAG = 64;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/* 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 nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
@@ -23,8 +27,8 @@ var nativeMax = Math.max;
|
||||
* `this` binding and partially applied arguments.
|
||||
*
|
||||
* @private
|
||||
* @param {Function|string} func The function or method name to reference.
|
||||
* @param {number} bitmask The bitmask of flags.
|
||||
* @param {Function|string} func The function or method name to wrap.
|
||||
* @param {number} bitmask The bitmask of wrapper flags.
|
||||
* The bitmask may be composed of the following flags:
|
||||
* 1 - `_.bind`
|
||||
* 2 - `_.bindKey`
|
||||
@@ -53,7 +57,10 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
||||
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
|
||||
partials = holders = undefined;
|
||||
}
|
||||
length -= (holders ? holders.length : 0);
|
||||
ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
|
||||
arity = arity === undefined ? arity : toInteger(arity);
|
||||
length -= holders ? holders.length : 0;
|
||||
|
||||
if (bitmask & PARTIAL_RIGHT_FLAG) {
|
||||
var partialsRight = partials,
|
||||
holdersRight = holders;
|
||||
@@ -65,17 +72,25 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
||||
|
||||
if (data) {
|
||||
mergeData(newData, data);
|
||||
bitmask = newData[1];
|
||||
arity = newData[9];
|
||||
}
|
||||
newData[9] = arity == null
|
||||
func = newData[0];
|
||||
bitmask = newData[1];
|
||||
thisArg = newData[2];
|
||||
partials = newData[3];
|
||||
holders = newData[4];
|
||||
arity = newData[9] = newData[9] == null
|
||||
? (isBindKey ? 0 : func.length)
|
||||
: (nativeMax(arity - length, 0) || 0);
|
||||
: nativeMax(newData[9] - length, 0);
|
||||
|
||||
if (bitmask == BIND_FLAG) {
|
||||
var result = createBindWrapper(newData[0], newData[2]);
|
||||
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
|
||||
result = createPartialWrapper.apply(undefined, newData);
|
||||
if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) {
|
||||
bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG);
|
||||
}
|
||||
if (!bitmask || bitmask == BIND_FLAG) {
|
||||
var result = createBaseWrapper(func, bitmask, thisArg);
|
||||
} else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) {
|
||||
result = createCurryWrapper(func, bitmask, arity);
|
||||
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) {
|
||||
result = createPartialWrapper(func, bitmask, thisArg, partials);
|
||||
} else {
|
||||
result = createHybridWrapper.apply(undefined, newData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user