v1.0.0-alpha35
Inspired by Go & Clojure Channels, async_channels provides channels as an asynchronous communication method between asynchronous functions.
Repository
Current version released
3 years ago
Versions
- v1.0.0-rc8Latest
- 1.0.0-rc7
- v1.0.0-rc7
- 0.0.0-test1
- 1.0.0-rc6
- v1.0.0-rc6
- 1.0.0-test6
- v1.0.0-test6
- 1.0.0-test5
- v1.0.0-test5
- 1.0.0-test4
- v1.0.0-test4
- 1.0.0-test3
- v1.0.0-test3
- v1.0.0-test2
- v1.0.0-test1
- 1.0.0-rc5
- 1.0.0-rc4
- v1.0.0-rc5
- v1.0.0-rc4
- 1.0.0-rc3
- v1.0.0-rc3
- 1.0.0-rc2
- v1.0.0-rc2
- refs/heads/test-on-main
- 1.0.0-rc1
- v1.0.0-rc1
- 1.0.0-beta7
- v1.0.0-beta7
- 1.0.0-beta6
- v1.0.0-beta6
- 1.0.0-beta5
- v1.0.0-beta5
- 1.0.0-beta4
- v1.0.0-beta4
- 1.0.0-beta3
- v1.0.0-beta3
- 1.0.0-beta2
- v1.0.0-beta2
- 1.0.0-beta1
- v1.0.0-beta1
- 1.0.0-alpha66
- v1.0.0-alpha66
- 1.0.0-alpha65
- v1.0.0-alpha65
- v1.0.0-alpha64
- 1.0.0-alpha63
- v1.0.0-alpha63
- 1.0.0-alpha62
- v1.0.0-alpha62
- 1.0.0-alpha61
- v1.0.0-alpha61
- 1.0.0-alpha60
- v1.0.0-alpha60
- 1.0.0-alpha59
- v1.0.0-alpha59
- 1.0.0-alpha58
- v1.0.0-alpha58
- 1.0.0-alpha57
- v1.0.0-alpha57
- v1.0.0-alpha56
- 1.0.0-alpha55
- v1.0.0-alpha55
- 1.0.0-alpha54
- v1.0.0-alpha54
- draft-refs/pull/46/merge
- 1.0.0-alpha53
- v1.0.0-alpha53
- v1.0.0-alpha52
- v1.0.0-alpha51
- 1.0.0-alpha50
- v1.0.0-alpha50
- v1.0.0-alpha49
- v1.0.0-alpha48
- 1.0.0-alpha47
- v1.0.0-alpha47
- 1.0.0-alpha46
- v1.0.0-alpha46
- 1.0.0-alpha45
- v1.0.0-alpha45
- 1.0.0-alpha44
- v1.0.0-alpha44
- v1.0.0-alpha43
- v1.0.0-alpha42
- 1.0.0-alpha41
- v1.0.0-alpha41
- 1.0.0-alpha40
- v1.0.0-alpha40
- 1.0.0-alpha39
- v1.0.0-alpha39
- 1.0.0-alpha38
- v1.0.0-alpha38
- v1.0.0-alpha37
- v1.0.0-alpha36
- v1.0.0-alpha35
- v1.0.0-alpha34
- v1.0.0-alpha33
- v1.0.0-alpha32
- 1.0.0-alpha31
- v1.0.0-alpha31
- v1.0.0-alpha30
- 1.0.0-alpha29
- v1.0.0-alpha29
- 1.0.0-alpha28
- v1.0.0-alpha28
- 1.0.0-alpha27
- v1.0.0-alpha27
- 1.0.0-alpha26
- v1.0.0-alpha26
- 1.0.0-alpha25
- v1.0.0-alpha25
- 1.0.0-alpha24
- v1.0.0-alpha24
Async Channels
Inspired by Go
& Clojure
Channels, async_channels
provides channels as an
asynchronous communication method between asynchronous functions.
Example
import { Channel } from "https://deno.land/x/async_channels/mod.ts";
const sleep = (duration: number) =>
new Promise<void>((res) => {
setTimeout(() => res(), duration);
});
function produce(num: number) {
const ch = new Channel(0);
(async () => {
for (let i = 0; i < num; i++) {
await sleep(500); // Do some work...
await ch.add(i++);
}
ch.close();
})();
return ch;
}
sleep(200).then(() => console.log("boo"));
for await (let product of produce(5)) {
console.log({ product });
}