@interncom/diplomatic 0.2.5 → 0.2.7
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/dist/cli/index.mjs +3 -3
- package/dist/cli/shared/events.d.ts +2 -0
- package/dist/cli/shared/singleton.d.ts +1 -0
- package/dist/cli/shared/types.d.ts +18 -2
- package/dist/web/client.d.ts +19 -2
- package/dist/web/coalesce.d.ts +24 -0
- package/dist/web/index.mjs +1 -1
- package/dist/web/shared/events.d.ts +2 -0
- package/dist/web/shared/singleton.d.ts +1 -0
- package/dist/web/shared/types.d.ts +18 -2
- package/dist/web/state.d.ts +4 -2
- package/dist/web/sync.d.ts +20 -5
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coalesce concurrent async work into a single in-flight drain, with one
|
|
3
|
+
* trailing pass when more work is requested while a pass is running.
|
|
4
|
+
*
|
|
5
|
+
* Policy:
|
|
6
|
+
* - At most one `work()` runs at a time (no overlapping executions).
|
|
7
|
+
* - Concurrent `run()` callers share one Promise and get the same result.
|
|
8
|
+
* - If `run()` is called during an in-flight pass, `again` is set so that
|
|
9
|
+
* after the current pass finishes we run **one** more pass (trailing edge).
|
|
10
|
+
* Further calls during that trailing pass can request yet another, etc.
|
|
11
|
+
* - N stampeding callers during a pass → 1 current pass + ≤1 trailing pass
|
|
12
|
+
* per generation, not N serial full runs.
|
|
13
|
+
* - Errors from `work()` reject the shared Promise; the runner unlocks so a
|
|
14
|
+
* later `run()` can start fresh. A trailing request that only set `again`
|
|
15
|
+
* before the failure is not auto-retried unless a new `run()` arrives.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CoalesceTail<T> {
|
|
18
|
+
private inflight;
|
|
19
|
+
private again;
|
|
20
|
+
run(work: () => Promise<T>): Promise<T>;
|
|
21
|
+
/** Wait for any in-flight drain to finish (does not request a new pass). */
|
|
22
|
+
flush(): Promise<void>;
|
|
23
|
+
private drain;
|
|
24
|
+
}
|