Rewrite map
.
This commit is contained in:
parent
ed06cb080e
commit
71da094422
1 changed files with 4 additions and 13 deletions
17
lib/index.js
17
lib/index.js
|
@ -182,19 +182,10 @@ const Channel = function(length = 0) {
|
|||
|
||||
join: async (separator) => (await readOnly.values()).join(separator),
|
||||
|
||||
map: (callbackfn, thisArg) => {
|
||||
const output = Channel();
|
||||
|
||||
(async () => {
|
||||
await readOnly.forEach((value) =>
|
||||
output.push(callbackfn.call(thisArg, value))
|
||||
);
|
||||
|
||||
await output.close();
|
||||
})();
|
||||
|
||||
return output;
|
||||
},
|
||||
map: (callbackfn, thisArg) =>
|
||||
readOnly.flatMap((value) =>
|
||||
Channel.of(callbackfn.call(thisArg, value))
|
||||
),
|
||||
|
||||
readOnly: () => readOnly,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue