diff --git a/lib/index.js b/lib/index.js index 4d0683c..5bf5968 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); }; diff --git a/test/index.js b/test/index.js index 13294e9..d88153a 100644 --- a/test/index.js +++ b/test/index.js @@ -129,6 +129,10 @@ describe(`Channel`, function() { }); describe(`functional interface`, async function() { + it(`shift`, async function() { + assert.equal(await Channel.shift(Channel.of(0)), 0); + }); + describe(`slice`, function() { it(`full application`, async function() { assert.deepEqual(