Add concat
.
This commit is contained in:
parent
1ba41d0f53
commit
46bb4c371b
3 changed files with 36 additions and 0 deletions
20
lib/index.js
20
lib/index.js
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue