You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- No EventTarget. Listeners are plain functions, invoked as `listener.call(signal)` with no Event object.
23
-
- No `onabort` property, no options (`once`, `signal`) to `addEventListener`, no `dispatchEvent`.
23
+
- No `onabort` property, no options (`once`, `signal`, `capture`, et c.) to `addEventListener`, no `dispatchEvent`.
24
24
- After the first abort we clear listeners to save memory; manual re‑dispatch isn’t supported. Effectively behaves like `{ once: true }` because an abort happens at most once and listeners are removed.
25
+
- Listeners removed during an abort are not invoked; this matches the behavior of DOM event dispatch. But listeners added during an abort may be invoked if added before we finish invoking existing listeners, this differs from DOM behavior.
25
26
26
27
- Errors and `reason`
27
28
- We use lightweight `Error` subclasses (`AbortError`, `TimeoutError`), not `DOMException`.
28
29
-`throwIfAborted()` throws the stored `reason` as‑is; avoid relying on `instanceof DOMException`. Prefer checking by name (e.g., `err instanceof Error && err.name === 'AbortError'`).
29
30
30
31
-`AbortSignalLite.any(iterable)` memory semantics
31
32
- Immediate: if any input is already aborted, the result aborts immediately with that `reason`.
32
-
-Standard engines maintain internal weak source/dependent lists so combined signals don’t keep inputs alive and vice‑versa.
33
+
-Native engines maintain internal weak source/dependent lists so combined signals don’t keep inputs alive and vice‑versa.
33
34
- In pure JS we can’t mirror that precisely: we must attach strong listeners to each source and close over the combined signal. We intentionally avoid `WeakRef`/`FinalizationRegistry` to keep size/complexity low.
34
35
- Consequence: if you drop all references to the combined signal before any source aborts, the sources still hold listeners that keep the combined signal (and its captured array) alive. Cleanup only happens when one source aborts.
35
36
- Practical guidance: use `any()` for short‑lived operations; avoid creating many long‑lived combined signals.
@@ -43,7 +44,7 @@ Not a drop‑in polyfill. It’s intentionally smaller and simpler. Key differen
43
44
44
45
- Types and modules
45
46
- ESM‑only package. Use import syntax; `require()` isn’t supported.
46
-
- Public types are `AbortControllerLike` and `AbortSignalLike`; they’re compatible with the standard’s surface you typically use (properties/methods listed in typings).
47
+
- Public types are `AbortControllerLike` and `AbortSignalLike` — lightweight subsets of the standard API. Anything that accepts an `AbortSignalLike` will also accept a standard `AbortSignal`.
47
48
- TypeScript flags direct construction (`new AbortSignalLite()`) as a type error, but nothing prevents it at runtime. The web standard throws here; we rely on discipline — stick to signals from the controller or the static helpers for the intended lifecycle.
48
49
49
50
If you need exact spec behavior (DOMException types, EventTarget, GC semantics of `any`, timer unref, etc.), use the platform’s built‑ins where available.
0 commit comments