aieventjs 0.5.1 → 0.5.2

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 CHANGED
@@ -112,7 +112,8 @@ interface OnOptions {
112
112
  interface EmitterOptions {
113
113
  // Default error policy. undefined/false (default): first throw aborts dispatch.
114
114
  // true: swallow errors and continue dispatch over all handlers.
115
- // (err, type, payload) => void: callback invoked per throwing handler.
115
+ // (err, type, payload) => void: callback invoked per throwing handler
116
+ // (if the callback itself throws, that error is silently ignored and dispatch continues).
116
117
  // Per-handler OnOptions.captureErrors overrides this for individual subscriptions.
117
118
  captureHandlerErrors?: boolean | ((err: unknown, type: string, payload: unknown) => void);
118
119
  }
package/README_ZHTW.md CHANGED
@@ -87,6 +87,9 @@ bus.dispose(); // 冪等;dispose 後再呼叫拋 EmitterDisposedError
87
87
  | `dispose()` 冪等;dispose 後呼叫拋錯 | Error-event 特殊處理(Node EventEmitter 風格不做) |
88
88
  | `emit` 走訪前 snapshot handler array(reentrant 安全) | 持久化 / replay(不是它的工作) |
89
89
  | Method 可解構(`const { on, emit } = bus`) | 零配置 `emit`(每次派送需 snapshot,re-entrancy 安全所需)|
90
+ | `on('*', fn, { sampleRate })` ── 機率性派送(wildcard only)| |
91
+ | `on('*', fn, { throttleMs })` ── leading-edge throttle(wildcard only)| |
92
+ | `createEmitter({ captureHandlerErrors })` ── opt-in 錯誤策略;`OnOptions.captureErrors` 個別 handler 覆蓋 | |
90
93
 
91
94
  ---
92
95
 
@@ -101,12 +104,17 @@ type WildcardHandler<Events extends Record<string, unknown>> =
101
104
  interface OnOptions {
102
105
  signal?: AbortSignal;
103
106
  once?: boolean;
107
+ captureErrors?: boolean | ((err: unknown, type: string, payload: unknown) => void); // 僅限 typed handler
108
+ sampleRate?: number; // wildcard "*" only — 機率 (0, 1]
109
+ throttleMs?: number; // wildcard "*" only — leading-edge throttle,使用 Date.now()
104
110
  }
105
111
 
106
112
  interface EmitterOptions {
107
- // 預留給 0.2.0 ── 把拋錯的 handler 收進 AggregateError,
108
- // 不中斷派送。0.1.0 忽略此欄位。
109
- captureHandlerErrors?: boolean;
113
+ // 預設錯誤策略。undefined/false(預設):第一個拋錯即中斷派送。
114
+ // true:吞掉錯誤並繼續走完所有 handler。
115
+ // (err, type, payload) => void:每個拋錯的 handler 呼叫一次 callback(若此 callback 自身拋錯,會被靜默忽略並繼續派送)。
116
+ // OnOptions.captureErrors 可覆蓋個別 handler 的策略。
117
+ captureHandlerErrors?: boolean | ((err: unknown, type: string, payload: unknown) => void);
110
118
  }
111
119
 
112
120
  interface Emitter<Events extends Record<string, unknown>> {
@@ -139,8 +147,9 @@ function createEmitter<Events extends Record<string, unknown> = Record<string, u
139
147
  | ---------- | --------------------------------------------------------------------------------------------------------------------------------------- |
140
148
  | **0.0.1** | Scaffold 落地 ── 凍結 API surface 為 `throw` stub;完整配置 + CI 跑得起來。 |
141
149
  | **0.1.0** | 第一個 npm release。`on` / `once` / `off` / `emit` / `clear` / `dispose` 實作完;coverage ≥ 95/90/100/100;≤ 800 B gzip(strict-TS 額外負擔實測落在 ~747 B)。 |
142
- | **0.2.0** | `captureHandlerErrors` option ── 把拋錯的 handler 收進 `AggregateError`,不中斷派送。Opt-in。 |
143
- | **0.3+** | TBD ── 由整合回饋驅動。候選:typed channel group、structured-clone payload 驗證、batch `emit`。 |
150
+ | **0.3.0** | `captureHandlerErrors` + wildcard sampling/throttling。v0.2 編號跳過以配合四套件 v0.3 同步釋出。 |
151
+ | **0.4.0** | 相依整理 + 穩定凍結:移除未使用的 `tsx`、`fast-check` 對齊 `^4.8.0`、凍結 0.3.x 公開 API surface。無 runtime API 異動;bundle 與 0.3.1 完全相同。 |
152
+ | **0.6+** | Async handler 追蹤(草案)── 詳見 [STABILITY.md](STABILITY.md)。 |
144
153
 
145
154
  ---
146
155
 
package/llms-full.txt CHANGED
@@ -125,7 +125,8 @@ interface OnOptions {
125
125
  interface EmitterOptions {
126
126
  // Default error policy. undefined/false (default): first throw aborts dispatch.
127
127
  // true: swallow errors and continue dispatch over all handlers.
128
- // (err, type, payload) => void: callback invoked per throwing handler.
128
+ // (err, type, payload) => void: callback invoked per throwing handler
129
+ // (if the callback itself throws, that error is silently ignored and dispatch continues).
129
130
  // Per-handler OnOptions.captureErrors overrides this for individual subscriptions.
130
131
  captureHandlerErrors?: boolean | ((err: unknown, type: string, payload: unknown) => void);
131
132
  }
@@ -182,6 +183,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
182
183
 
183
184
  ## [Unreleased]
184
185
 
186
+ ## [0.5.2] - 2026-06-05
187
+
188
+ ### Docs
189
+
190
+ - Review-driven documentation fixes (`README.md`, `README_ZHTW.md`, `llms-full.txt`; plus repo-only `CONTRIBUTING.md`): clarity and accuracy from a cross-package code review. No runtime or API change; `dist` byte-identical to 0.5.1.
191
+
185
192
  ## [0.5.1] - 2026-06-02
186
193
 
187
194
  ### Fixed
@@ -316,7 +323,7 @@ No runtime / source / API changes. This is a CI-only patch to validate the GitHu
316
323
  # Contributing to aieventjs
317
324
 
318
325
  Thanks for taking the time to look. aieventjs is a deliberately small library
319
- (target ≤ 550 B gzip); contributions that keep the surface narrow are easier
326
+ (target ≤ 1100 B gzip); contributions that keep the surface narrow are easier
320
327
  to accept than ones that expand it.
321
328
 
322
329
  ## Quick start
@@ -349,7 +356,7 @@ pnpm check:size # gzip per subpath against the size budget
349
356
  if you need that
350
357
  - Async / promise-returning handlers — explicit non-goal (handlers are
351
358
  synchronous; resolve promises in user-land)
352
- - Anything that pushes the core gzip past 550 B
359
+ - Anything that pushes the core gzip past 1100 B
353
360
 
354
361
  ## Design principles
355
362
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aieventjs",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Small, strict, typed event emitter — on() returns an unsubscribe function, once is built-in, AbortSignal is first-class, dispose() is idempotent, wildcard '*' handlers preserved. Mitt-shaped API; ai*js conventions everywhere else.",
5
5
  "keywords": [
6
6
  "event-emitter",