reduce: Require initialValue in functional interface.

This commit is contained in:
David Braun 2017-11-28 11:39:37 -05:00
parent 366249f84f
commit 1fc2308f08
No known key found for this signature in database
GPG key ID: 5694EEC4D129BDCF
2 changed files with 8 additions and 1 deletions

View file

@ -407,9 +407,14 @@ const methods = Object.keys(channel).filter(
method => typeof channel[method] === `function`
);
const arities = {
reduce: 2,
slice: 2
};
methods.forEach(method => {
const bound = function(...args) {
const arity = method === `slice` ? 2 : channel[method].length;
const arity = arities[method] || channel[method].length;
return args.length > arity
? args[arity][method](...args.slice(0, arity))