Functional API: Fix off-by-one bug.

This commit is contained in:
David Braun 2017-10-17 20:18:38 -04:00
parent 10f06d08fd
commit 1b1192c0e7
2 changed files with 7 additions and 3 deletions

View file

@ -361,10 +361,10 @@ const methods = Object.keys(channel).concat(Object.keys(channel.readOnly()));
methods.forEach(method => {
const bound = function(...args) {
const arity = method === `slice` ? 3 : channel[method].length;
const arity = method === `slice` ? 2 : channel[method].length;
return args.length >= arity
? args[arity - 1][method](...args.slice(0, arity - 1))
return args.length > arity
? args[arity][method](...args.slice(0, arity))
: bound.bind(this, ...args);
};