https://github.com/cgqaq/asynceventgenerator
Converts events to async iterable iterators(aka. async generators)
https://github.com/cgqaq/asynceventgenerator
asyncgenerator events for-await-of
Last synced: 25 days ago
JSON representation
Converts events to async iterable iterators(aka. async generators)
- Host: GitHub
- URL: https://github.com/cgqaq/asynceventgenerator
- Owner: CGQAQ
- Created: 2023-02-28T07:31:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T09:00:34.000Z (over 2 years ago)
- Last Synced: 2025-05-06T19:05:20.290Z (27 days ago)
- Topics: asyncgenerator, events, for-await-of
- Language: TypeScript
- Homepage:
- Size: 6.84 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Converts events to async iterable iterators(aka. async generators)
将 `Eventlistener` 形式的 events 转换成 `AsyncGenerator`
Take `Eventlistener` form events, and transform into `AsyncGenerator` which can
be then consume by `for await of````ts
// 将
// take
foo.on((event) => console.log(event));// 变成
// and transform into
for await (const event of foo) {
console.log(event);
}
```## 示例
```console
deno run mod.tstick 1
tick 2
received tick: 1
tick 3
received tick: 2
tick 4
received tick: 3
received tick: 4
```