Make slice handle case of no start provided.

This commit is contained in:
David Braun 2019-04-24 10:51:00 -04:00
parent 6b1c55cff3
commit fb598b0270
No known key found for this signature in database
GPG key ID: 87EC41ADF710B7E2
2 changed files with 11 additions and 2 deletions

View file

@ -255,7 +255,7 @@ const Channel = function(length = 0) {
return promise; return promise;
}, },
slice: (start, end = Infinity) => { slice: (start = 0, end = Infinity) => {
const output = Channel(); const output = Channel();
(async () => { (async () => {

View file

@ -399,6 +399,15 @@ describe(`Channel object`, function() {
}); });
describe(`slice`, function() { describe(`slice`, function() {
it(`no start`, async function() {
assert.deepEqual(
await Channel.of(0, 1, 2)
.slice()
.values(),
[0, 1, 2]
);
});
it(`start`, async function() { it(`start`, async function() {
assert.deepEqual( assert.deepEqual(
await Channel.of(0, 1, 2) await Channel.of(0, 1, 2)
@ -417,7 +426,7 @@ describe(`Channel object`, function() {
); );
}); });
it(`start after end of channel`, async function() { it(`starts after end of channel`, async function() {
assert.deepEqual( assert.deepEqual(
await Channel.of(0, 1, 2) await Channel.of(0, 1, 2)
.slice(10) .slice(10)