Stop map
from returning buffered channels.
This commit is contained in:
parent
b426d67411
commit
3d17e23338
2 changed files with 2 additions and 3 deletions
|
@ -197,14 +197,14 @@ const Channel = function(length = 0) {
|
||||||
},
|
},
|
||||||
|
|
||||||
map: (callbackfn, thisArg) => {
|
map: (callbackfn, thisArg) => {
|
||||||
const output = Channel(length);
|
const output = Channel();
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await readOnly.forEach(value =>
|
await readOnly.forEach(value =>
|
||||||
output.push(callbackfn.call(thisArg, value))
|
output.push(callbackfn.call(thisArg, value))
|
||||||
);
|
);
|
||||||
|
|
||||||
output.close();
|
await output.close();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
|
@ -271,7 +271,6 @@ describe(`Channel object`, function() {
|
||||||
await channel.push(`c`);
|
await channel.push(`c`);
|
||||||
await channel.close();
|
await channel.close();
|
||||||
const mapped = channel.map(value => value.toUpperCase());
|
const mapped = channel.map(value => value.toUpperCase());
|
||||||
assert.equal(mapped.length, channel.length);
|
|
||||||
assert.deepEqual(await mapped.values(), [`A`, `B`, `C`]);
|
assert.deepEqual(await mapped.values(), [`A`, `B`, `C`]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue