map: Return a buffered channel if appropriate.

This commit is contained in:
David Braun 2018-02-20 14:20:34 -05:00
parent e8c27056de
commit 4a4a2db7ed
2 changed files with 10 additions and 7 deletions

View file

@ -269,12 +269,14 @@ describe(`Channel object`, function() {
});
it(`map`, async function() {
assert.deepEqual(
await Channel.of(`a`, `b`, `c`)
.map(value => value.toUpperCase())
.values(),
[`A`, `B`, `C`]
);
const channel = Channel(3);
await channel.push(`a`);
await channel.push(`b`);
await channel.push(`c`);
await channel.close();
const mapped = channel.map(value => value.toUpperCase());
assert.equal(mapped.length, channel.length);
assert.deepEqual(await mapped.values(), [`A`, `B`, `C`]);
});
describe(`push`, function() {