diff --git a/lib/index.js b/lib/index.js index 04d0792..210f1fd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -203,12 +203,20 @@ const Channel = function(bufferLength = 0) { slice: (start, end = Infinity) => { const output = Channel(); (async () => { - for (let index = 0; index < end; index++) { + for (let index = 0; index < start; index++) { const value = await readOnly.shift(); if (value === undefined) { break; - } else if (index >= start) { + } + } + + for (let index = start; index < end; index++) { + const value = await readOnly.shift(); + + if (value === undefined) { + break; + } else { await output.push(value); } }