Rewrite map.

This commit is contained in:
David 2021-02-08 16:34:29 -06:00
parent ed06cb080e
commit 71da094422

View file

@ -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,