Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

占位符 #303

Open
BEN13459290037 opened this issue Jun 22, 2022 · 0 comments
Open

占位符 #303

BEN13459290037 opened this issue Jun 22, 2022 · 0 comments

Comments

@BEN13459290037
Copy link

function curry(fn, params, hole) {
let fnLen = fn.length;
params = params || [];
return function (...p) {
for (let i = 0; i < params.length && p.length; i++) {
if (params[i] === hole) {
params[i] = p.shift();
}
}
let paramsAll = [...params, ...p];

if (paramsAll.filter((v) => v !== hole).length < fnLen) {
  return curry.call(this, fn, paramsAll, hole);
} else {
  return fn.apply(this, paramsAll);
}

};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant