@open-wa/hyperemitter 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @open-wa/hyperemitter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@open-wa/hyperemitter` is a typed event emitter used by Open-WA packages. It supports exact event names, `+` and `#` wildcard subscriptions, one-time listeners, catch-all listeners, and listener cleanup with an `AbortSignal`.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Use
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```typescript
|
|
8
|
+
import { HyperEmitter } from '@open-wa/hyperemitter';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type Events = {
|
|
11
|
+
'message.received': { id: string; body: string };
|
|
12
|
+
'session.state.changed': { state: string };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const events = new HyperEmitter<Events>();
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- `--ci` to suppress console tables
|
|
17
|
+
events.on('message.received', (message) => {
|
|
18
|
+
console.log(message.id, message.body);
|
|
19
|
+
});
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
events.emit('message.received', { id: 'message-id', body: 'Hello' });
|
|
22
|
+
```
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
The repository also contains a benchmark runner for comparing other emitter libraries. Its results are measurements from that runner, not a performance guarantee.
|
|
21
25
|
|
|
22
|
-
##
|
|
26
|
+
## License
|
|
23
27
|
|
|
24
|
-
-
|
|
25
|
-
- Adapters for `EventTarget`, Node `EventEmitter`, and worker threads.
|
|
26
|
-
- Optional plugins (TTL/maxListeners/tracing) kept out of the hot path.
|
|
27
|
-
- CI will enforce performance budgets after HyperEmitter arrives. The targets are a 5% tseep envelope for exact events and 10x EE2 for wildcards.
|
|
28
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-wa/hyperemitter",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "HyperEmitter: high-performance, schema-driven event emitter for the open-wa v5 stack.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"types": "dist/index.d.cts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@open-wa/logger": "5.
|
|
27
|
+
"@open-wa/logger": "5.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"emittery": "^2.1.0",
|