Add _.placeholder support so wrapped functions may support placeholders.

This commit is contained in:
John-David Dalton
2016-02-02 21:08:06 -08:00
parent 7f295dc6e8
commit e404d214aa
3 changed files with 26 additions and 16 deletions

View File

@@ -4122,7 +4122,7 @@
index = length,
args = Array(length),
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func,
placeholder = wrapper.placeholder;
placeholder = lodash.placeholder || wrapper.placeholder;
while (index--) {
args[index] = arguments[index];
@@ -4238,7 +4238,7 @@
args = composeArgsRight(args, partialsRight, holdersRight);
}
if (isCurry || isCurryRight) {
var placeholder = wrapper.placeholder,
var placeholder = lodash.placeholder || wrapper.placeholder,
argsHolders = replaceHolders(args, placeholder);
length -= argsHolders.length;
@@ -8345,7 +8345,9 @@
var bind = rest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, bind.placeholder);
var placeholder = lodash.placeholder || bind.placeholder,
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG;
}
return createWrapper(func, bitmask, thisArg, partials, holders);
@@ -8398,7 +8400,9 @@
var bindKey = rest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, bindKey.placeholder);
var placeholder = lodash.placeholder || bindKey.placeholder,
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG;
}
return createWrapper(key, bitmask, object, partials, holders);
@@ -8447,7 +8451,7 @@
function curry(func, arity, guard) {
arity = guard ? undefined : arity;
var result = createWrapper(func, CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curry.placeholder;
result.placeholder = lodash.placeholder || curry.placeholder;
return result;
}
@@ -8491,7 +8495,7 @@
function curryRight(func, arity, guard) {
arity = guard ? undefined : arity;
var result = createWrapper(func, CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryRight.placeholder;
result.placeholder = lodash.placeholder || curryRight.placeholder;
return result;
}
@@ -8913,7 +8917,9 @@
* // => 'hi fred'
*/
var partial = rest(function(func, partials) {
var holders = replaceHolders(partials, partial.placeholder);
var placeholder = lodash.placeholder || partial.placeholder,
holders = replaceHolders(partials, placeholder);
return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders);
});
@@ -8949,7 +8955,9 @@
* // => 'hello fred'
*/
var partialRight = rest(function(func, partials) {
var holders = replaceHolders(partials, partialRight.placeholder);
var placeholder = lodash.placeholder || partialRight.placeholder,
holders = replaceHolders(partials, placeholder);
return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
});