sliftutils 1.4.17 → 1.4.18

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/index.d.ts CHANGED
@@ -921,7 +921,7 @@ declare module "sliftutils/storage/BulkDatabase2/BulkDatabaseBase" {
921
921
  export declare const noopReactiveDeps: ReactiveDeps;
922
922
  export type StorageFactory = (path: string) => Promise<FileStorage>;
923
923
  export type BulkDatabase2Config = {
924
- triggerThrottleMs?: number;
924
+ maxTriggerThrottleMs?: number;
925
925
  };
926
926
  export declare class BulkDatabaseBase<T extends {
927
927
  key: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.4.17",
3
+ "version": "1.4.18",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,7 +17,7 @@ export interface ReactiveDeps {
17
17
  export declare const noopReactiveDeps: ReactiveDeps;
18
18
  export type StorageFactory = (path: string) => Promise<FileStorage>;
19
19
  export type BulkDatabase2Config = {
20
- triggerThrottleMs?: number;
20
+ maxTriggerThrottleMs?: number;
21
21
  };
22
22
  export declare class BulkDatabaseBase<T extends {
23
23
  key: string;
@@ -131,18 +131,18 @@ export type StorageFactory = (path: string) => Promise<FileStorage>;
131
131
 
132
132
  // Optional per-collection configuration.
133
133
  export type BulkDatabase2Config = {
134
- // When set (> 0), the reactive change notifications writes/loads emit are throttled and BATCHED
135
- // globally (across all keys), so a high-frequency write source doesn't re-run watchers on every single
136
- // change. The throttle RAMPS like the write-flush one: the first change after a lull notifies
137
- // immediately, then under sustained changes the delay doubles up to triggerThrottleMs, coalescing the
138
- // burst into one notification. In-memory/async reads are always current — only the OBSERVABLE
139
- // notification (the mobx re-render trigger) is delayed and merged.
140
- triggerThrottleMs?: number;
134
+ // The MAXIMUM throttle (ms) for reactive change notifications; the actual delay RAMPS UP to it, it is
135
+ // never applied all at once. When set (> 0), the notifications writes/loads emit are batched globally
136
+ // (across all keys) so a high-frequency write source doesn't re-run watchers on every single change: a
137
+ // change after a lull notifies immediately, then under sustained changes the delay doubles up to this
138
+ // ceiling, coalescing the burst into one notification. In-memory/async reads are always current — only
139
+ // the OBSERVABLE notification (the mobx re-render trigger) is delayed and merged.
140
+ maxTriggerThrottleMs?: number;
141
141
  };
142
142
 
143
143
  // Trigger-throttle ramp: the first deferred notification waits this long, then the delay doubles on each
144
- // further change up to BulkDatabase2Config.triggerThrottleMs. ~16ms ≈ one animation frame, so an isolated
145
- // burst still notifies within a frame.
144
+ // further change up to BulkDatabase2Config.maxTriggerThrottleMs. ~16ms ≈ one animation frame, so an
145
+ // isolated burst still notifies within a frame.
146
146
  const TRIGGER_THROTTLE_FIRST_STEP_MS = 16;
147
147
 
148
148
  // The load/reset lifecycle shares one signal; every sync read observes it so it re-renders when the
@@ -310,7 +310,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
310
310
  // the cache and may swap the reader) can never leave a stale entry behind.
311
311
  private dataGen = 0;
312
312
 
313
- // ---- trigger throttle (see BulkDatabase2Config.triggerThrottleMs) ----
313
+ // ---- trigger throttle (see BulkDatabase2Config.maxTriggerThrottleMs) ----
314
314
  // Signals whose notification is deferred, the pending flush timer, and the ramping delay. Data state is
315
315
  // already updated synchronously; only these observable notifications are batched/delayed.
316
316
  private pendingSignals = new Set<string>();
@@ -363,14 +363,14 @@ export class BulkDatabaseBase<T extends { key: string }> {
363
363
  return this.readerKeys?.has(key) ?? false;
364
364
  }
365
365
 
366
- // Notify observers of `signal`. With triggerThrottleMs set, notifications are batched and delayed on a
367
- // ramping schedule so a high-frequency source can't re-run watchers on every change: a change after a
366
+ // Notify observers of `signal`. With maxTriggerThrottleMs set, notifications are batched and delayed on
367
+ // a ramping schedule so a high-frequency source can't re-run watchers on every change: a change after a
368
368
  // lull notifies on the next tick (no real delay, but all of one change's signals batch together);
369
369
  // under sustained changes the delay doubles up to the max, coalescing the burst into one notification.
370
370
  // Only the OBSERVABLE notification is delayed — the underlying data was already updated, so a read in
371
371
  // the meantime still sees current values.
372
372
  private invalidateSignal(signal: string) {
373
- const maxMs = this.config.triggerThrottleMs ?? 0;
373
+ const maxMs = this.config.maxTriggerThrottleMs ?? 0;
374
374
  if (maxMs <= 0) { this.deps.invalidate(signal); return; }
375
375
  this.pendingSignals.add(signal);
376
376
  const now = Date.now();