Add concat.

This commit is contained in:
David Braun 2017-11-28 13:28:02 -05:00
parent 1ba41d0f53
commit 46bb4c371b
No known key found for this signature in database
GPG key ID: 5694EEC4D129BDCF
3 changed files with 36 additions and 0 deletions

View file

@ -103,6 +103,26 @@ const Channel = function(length = 0) {
const readOnly = Object.freeze(
Object.assign(Object.create(prototype), {
concat: (...args) => {
const output = Channel();
(async () => {
await readOnly.forEach(output.push);
for (let index = 0; index < args.length; index++) {
const arg = args[index];
await (Channel.isChannel(arg)
? arg.forEach(output.push)
: output.push(arg));
}
output.close();
})();
return output;
},
every: async (callbackfn, thisArg) => {
for (;;) {
const value = await readOnly.shift();