Make slice
handle case of no start provided.
This commit is contained in:
parent
6b1c55cff3
commit
fb598b0270
2 changed files with 11 additions and 2 deletions
|
@ -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 () => {
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue