from: Accept a callback function.

This commit is contained in:
David Braun 2017-10-21 15:31:59 -04:00
parent 8c26f23ead
commit 6b577ea6cd
No known key found for this signature in database
GPG key ID: 5694EEC4D129BDCF
3 changed files with 38 additions and 14 deletions

View file

@ -45,6 +45,12 @@ describe(`Channel`, function() {
});
describe(`from`, function() {
it(`callback`, async function() {
let counter = 0;
const callback = () => (counter < 3 ? counter++ : undefined);
assert.deepEqual(await Channel.from(callback).values(), [0, 1, 2]);
});
it(`iterable`, async function() {
assert.deepEqual(await Channel.from([0, 1, 2]).values(), [0, 1, 2]);
});