From a51a905293dfa450c6a9ae4de6c8792d2c5a7d09 Mon Sep 17 00:00:00 2001 From: cool4zbl Date: Mon, 21 Dec 2020 21:35:26 +0800 Subject: [PATCH] fix: `implement-curry-with-placeholder` bug Whether to check `nextArgs.length` before its shift? Otherwise, the code below will get a `curriedJoin(...)(...) is not a function` error. ```js const join = (a, b, c) => { return `${a}_${b}_${c}` } const curriedJoin = curry(join) console.log(curriedJoin(_, _, _)(1)(_, 3)(2)) // '1_2_3' ``` --- 2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2.md b/2.md index 7cdbd14..1740152 100644 --- a/2.md +++ b/2.md @@ -28,7 +28,7 @@ function mergeArgs(args, nextArgs) { let result = []; args.forEach((arg, idx) => { - if(arg == curry.placeholder) { + if(arg == curry.placeholder && nextArgs.length) { result.push(nextArgs.shift()); } else { result.push(arg);