mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Apply more let/const transforms.
This commit is contained in:
@@ -9,12 +9,12 @@ import replaceHolders from './_replaceHolders.js';
|
||||
import root from './_root.js';
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
var WRAP_BIND_FLAG = 1,
|
||||
WRAP_BIND_KEY_FLAG = 2,
|
||||
WRAP_CURRY_FLAG = 8,
|
||||
WRAP_CURRY_RIGHT_FLAG = 16,
|
||||
WRAP_ARY_FLAG = 128,
|
||||
WRAP_FLIP_FLAG = 512;
|
||||
const WRAP_BIND_FLAG = 1;
|
||||
const WRAP_BIND_KEY_FLAG = 2;
|
||||
const WRAP_CURRY_FLAG = 8;
|
||||
const WRAP_CURRY_RIGHT_FLAG = 16;
|
||||
const WRAP_ARY_FLAG = 128;
|
||||
const WRAP_FLIP_FLAG = 512;
|
||||
|
||||
/**
|
||||
* Creates a function that wraps `func` to invoke it with optional `this`
|
||||
@@ -36,24 +36,26 @@ var WRAP_BIND_FLAG = 1,
|
||||
* @returns {Function} Returns the new wrapped function.
|
||||
*/
|
||||
function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
|
||||
var isAry = bitmask & WRAP_ARY_FLAG,
|
||||
isBind = bitmask & WRAP_BIND_FLAG,
|
||||
isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
|
||||
isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
|
||||
isFlip = bitmask & WRAP_FLIP_FLAG,
|
||||
Ctor = isBindKey ? undefined : createCtor(func);
|
||||
const isAry = bitmask & WRAP_ARY_FLAG;
|
||||
const isBind = bitmask & WRAP_BIND_FLAG;
|
||||
const isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
|
||||
const isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
|
||||
const isFlip = bitmask & WRAP_FLIP_FLAG;
|
||||
const Ctor = isBindKey ? undefined : createCtor(func);
|
||||
|
||||
function wrapper() {
|
||||
var length = arguments.length,
|
||||
args = Array(length),
|
||||
index = length;
|
||||
let holderCount;
|
||||
let placeholder;
|
||||
let length = arguments.length;
|
||||
let args = Array(length);
|
||||
let index = length;
|
||||
|
||||
while (index--) {
|
||||
args[index] = arguments[index];
|
||||
}
|
||||
if (isCurried) {
|
||||
var placeholder = getHolder(wrapper),
|
||||
holdersCount = countHolders(args, placeholder);
|
||||
placeholder = getHolder(wrapper);
|
||||
holdersCount = countHolders(args, placeholder);
|
||||
}
|
||||
if (partials) {
|
||||
args = composeArgs(args, partials, holders, isCurried);
|
||||
@@ -63,14 +65,14 @@ function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight,
|
||||
}
|
||||
length -= holdersCount;
|
||||
if (isCurried && length < arity) {
|
||||
var newHolders = replaceHolders(args, placeholder);
|
||||
const newHolders = replaceHolders(args, placeholder);
|
||||
return createRecurry(
|
||||
func, bitmask, createHybrid, wrapper.placeholder, thisArg,
|
||||
args, newHolders, argPos, ary, arity - length
|
||||
);
|
||||
}
|
||||
var thisBinding = isBind ? thisArg : this,
|
||||
fn = isBindKey ? thisBinding[func] : func;
|
||||
const thisBinding = isBind ? thisArg : this;
|
||||
let fn = isBindKey ? thisBinding[func] : func;
|
||||
|
||||
length = args.length;
|
||||
if (argPos) {
|
||||
|
||||
Reference in New Issue
Block a user