@orkestrel/test 0.0.7 → 0.0.9

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.
@@ -27,10 +27,23 @@ export declare function collectStream<T>(stream: ReadableStream<T>): Promise<rea
27
27
  /**
28
28
  * Creates values that make common object readers throw or violate their assumptions.
29
29
  *
30
- * @returns A frozen array whose six values are fresh on every call.
31
- * @remarks Every member makes a naive reader throw. A total guard survives every member without
32
- * throwing. Whether it accepts or refuses one is that guard's own contract. Membership may grow in
33
- * a release, so test the whole returned set in a loop and include the index in each failure.
30
+ * @returns A frozen array whose values are fresh on every call.
31
+ * @remarks Every member makes a naive read throw or violates a naive structural assumption. A total
32
+ * guard survives every member without throwing. Whether it accepts or refuses one is that guard's
33
+ * own contract. Membership may grow in a release, so test the whole returned set in a loop and
34
+ * include the index in each failure.
35
+ *
36
+ * - The self-referential record makes JSON record serialization throw.
37
+ * - The revoked object proxy makes reflective object access throw.
38
+ * - The property proxy makes a named property read throw.
39
+ * - The key proxy makes key enumeration throw.
40
+ * - The prototype proxy makes a prototype read throw.
41
+ * - The null-prototype record breaks a direct `hasOwnProperty` call.
42
+ * - The array-target proxy passes an array check and makes an index read throw.
43
+ * - The self-referential array makes JSON collection serialization throw.
44
+ * - The sparse array violates the assumption that every index is enumerable.
45
+ * - The hidden-key record violates the assumption that every own key is enumerable.
46
+ * - The named getter makes its property read throw.
34
47
  * @example
35
48
  * ```ts
36
49
  * import { expect } from 'vitest'
@@ -65,7 +78,43 @@ export declare function createHostileValues(): readonly unknown[];
65
78
  * @typeParam TArgs - The argument tuple to record.
66
79
  * @returns A recorder whose handler appends calls in order.
67
80
  */
68
- export declare function createRecorder<TArgs extends readonly unknown[]>(): RecorderInterface<TArgs>;
81
+ export declare function createRecorder<TArgs extends readonly unknown[] = readonly unknown[]>(): RecorderInterface<TArgs>;
82
+
83
+ /**
84
+ * Creates event recorders and subscribes them to the source.
85
+ *
86
+ * @typeParam TMap - The source's event names and delivered argument tuples.
87
+ * @typeParam TName - The requested event names.
88
+ * @param source - The source to subscribe to.
89
+ * @param events - The events to record.
90
+ * @returns A map from each requested event name to its recorder.
91
+ * @throws Thrown when a listed event has no recorder, which a well-formed events array cannot
92
+ * produce.
93
+ * @remarks A duplicate event name installs a fresh recorder for every occurrence. The returned map
94
+ * keeps the recorder installed for the last occurrence. `TName` derives from the array's element
95
+ * type. An array declared with a wider union than its contents widens `TName` beyond the listed
96
+ * events. The omitted key reads `undefined` at runtime under a non-optional type, and the guard
97
+ * reports `true` because it checks the listed events. Pass a literal array or a tuple.
98
+ */
99
+ export declare function createRecorders<TMap extends Record<string, readonly unknown[]>, TName extends keyof TMap>(source: EventSourceInterface<TMap>, events: readonly TName[]): RecorderMap<TMap, TName>;
100
+
101
+ /**
102
+ * Creates a monotonically numbered resource factory with creation and destruction records.
103
+ *
104
+ * @returns A resource factory whose recorders retain every affected id in order.
105
+ */
106
+ export declare function createResourceFactory(): ResourceFactoryInterface;
107
+
108
+ /**
109
+ * Creates a real abort controller whose signal reports its live abort listeners.
110
+ *
111
+ * @returns The controller, its instrumented signal, and the current listener tally.
112
+ * @remarks Instrumentation is installed on the created signal instance. A one-shot listener leaves
113
+ * the tally when it fires, and removal accepts the original listener supplied by the caller. A
114
+ * listener scoped by another signal leaves when that signal aborts. An already-aborted scope
115
+ * installs and records nothing.
116
+ */
117
+ export declare function createSignal(): SignalInterface;
69
118
 
70
119
  /**
71
120
  * Creates a teardown list that runs registered handlers newest-first.
@@ -74,6 +123,88 @@ export declare function createRecorder<TArgs extends readonly unknown[]>(): Reco
74
123
  */
75
124
  export declare function createTeardown(): TeardownInterface;
76
125
 
126
+ /**
127
+ * Decodes newline-delimited JSON values.
128
+ *
129
+ * @param text - The JSON Lines text to decode.
130
+ * @returns The decoded values in physical-line order.
131
+ * @throws An `Error` naming the malformed physical line, with the native `SyntaxError` as its
132
+ * `cause`.
133
+ */
134
+ export declare function decodeJSONLines(text: string): readonly unknown[];
135
+
136
+ /**
137
+ * Subscribes handlers to a typed event source.
138
+ *
139
+ * @typeParam TMap - The event names and argument tuples the source delivers.
140
+ */
141
+ export declare interface EventSourceInterface<TMap extends Record<string, readonly unknown[]>> {
142
+ /**
143
+ * Subscribes a handler to an event.
144
+ *
145
+ * @param event - The event to subscribe to.
146
+ * @param handler - The handler that receives each delivery.
147
+ */
148
+ on<K extends keyof TMap>(event: K, handler: (...args: TMap[K]) => void): void;
149
+ }
150
+
151
+ /**
152
+ * Subscribes a listener to one event source.
153
+ *
154
+ * @typeParam TArgs - The argument tuple the event delivers.
155
+ * @param listener - The listener that receives each delivery.
156
+ * @returns The cleanup that removes the listener, or `void` when the source needs none.
157
+ */
158
+ export declare type EventSubscriber<TArgs extends readonly unknown[]> = (listener: (...args: TArgs) => void) => (() => void) | void;
159
+
160
+ /**
161
+ * Normalizes headers into a frozen plain record.
162
+ *
163
+ * @param init - The platform header initializer to normalize.
164
+ * @returns A frozen record of normalized header names and values.
165
+ * @remarks Normalization follows the host `Headers` implementation, including lowercased names and
166
+ * combined values.
167
+ */
168
+ export declare function flattenHeaders(init: HeadersSource): Readonly<Record<string, string>>;
169
+
170
+ /**
171
+ * Any value the host `Headers` constructor accepts.
172
+ *
173
+ * @remarks Derived from the host constructor rather than named from a single library, so the type
174
+ * resolves in every project against that project's own `Headers` declaration. The record,
175
+ * entries-array, and `Headers` forms all satisfy it.
176
+ */
177
+ export declare type HeadersSource = NonNullable<ConstructorParameters<typeof Headers>[0]>;
178
+
179
+ /**
180
+ * Invokes an unknown method through an explicit unchecked result contract.
181
+ *
182
+ * @typeParam T - The result type claimed by the caller.
183
+ * @param target - The value used as the method's `this` argument.
184
+ * @param method - The unknown method to invoke.
185
+ * @param args - The arguments to pass.
186
+ * @returns The method's result under the caller's claimed type.
187
+ * @throws A `TypeError` when `method` is not callable.
188
+ * @remarks The caller owns the claim that the returned value has type `T`. The contained `any`
189
+ * bridges the unchecked runtime result to that caller-owned claim.
190
+ */
191
+ export declare function invokeUnchecked<T>(target: unknown, method: unknown, args: readonly unknown[]): T;
192
+
193
+ /**
194
+ * Checks whether a value contains a recorder for every listed event.
195
+ *
196
+ * @typeParam TMap - The source's event names and delivered argument tuples.
197
+ * @typeParam TName - The event names represented in the map.
198
+ * @param value - The value to inspect.
199
+ * @param events - The events the completed map must contain.
200
+ * @returns True if every listed event has a structurally valid recorder; false otherwise.
201
+ * @remarks Per-key tuple precision is the predicate's claim. The factory proves that claim by
202
+ * wiring each recorder to exactly the event where it stores that recorder. A direct caller must
203
+ * establish the same pairing before it relies on the narrowing. This guard takes the listed events
204
+ * through a reference parameter rather than using the canonical single-value guard form.
205
+ */
206
+ export declare function isRecorderMapComplete<TMap extends Record<string, readonly unknown[]>, TName extends keyof TMap>(value: unknown, events: readonly TName[]): value is RecorderMap<TMap, TName>;
207
+
77
208
  /**
78
209
  * The JSON-safe projection of a type: every member JSON preserves, mapped to itself, and every
79
210
  * member it does not, mapped to `never`.
@@ -112,6 +243,19 @@ export declare type JSONValue = string | number | boolean | null | readonly JSON
112
243
  readonly [key: string]: JSONValue;
113
244
  };
114
245
 
246
+ /**
247
+ * Reads a property from an unknown object or function.
248
+ *
249
+ * @typeParam T - The property type claimed by the caller.
250
+ * @param target - The unknown value to read.
251
+ * @param key - The property key to read.
252
+ * @returns The property value under the caller's claimed type.
253
+ * @throws A `TypeError` when `target` is neither an object nor a function.
254
+ * @remarks The caller owns the claim that the returned value has type `T`. The contained `any`
255
+ * bridges the unchecked runtime result to that caller-owned claim.
256
+ */
257
+ export declare function readProperty<T>(target: unknown, key: PropertyKey): T;
258
+
115
259
  /**
116
260
  * Records every call made to its handler.
117
261
  *
@@ -128,6 +272,16 @@ export declare interface RecorderInterface<TArgs extends readonly unknown[]> {
128
272
  clear(): void;
129
273
  }
130
274
 
275
+ /**
276
+ * Maps event names to recorders for their delivered argument tuples.
277
+ *
278
+ * @typeParam TMap - The event names and argument tuples the source delivers.
279
+ * @typeParam TName - The event names represented in the map.
280
+ */
281
+ export declare type RecorderMap<TMap extends Record<string, readonly unknown[]>, TName extends keyof TMap> = {
282
+ readonly [K in TName]: RecorderInterface<TMap[K]>;
283
+ };
284
+
131
285
  /**
132
286
  * Requires a value to be present.
133
287
  *
@@ -147,6 +301,49 @@ export declare function requireValue<T>(value: T | null | undefined, message?: s
147
301
  */
148
302
  export declare function resolveRoot(meta: ImportMeta): URL;
149
303
 
304
+ /** A numbered resource factory with records of every creation and destruction. */
305
+ export declare interface ResourceFactoryInterface {
306
+ /** The ids returned by `create`, in order. */
307
+ readonly created: RecorderInterface<readonly [id: number]>;
308
+ /** The ids passed to `destroy`, in order. */
309
+ readonly destroyed: RecorderInterface<readonly [id: number]>;
310
+ /**
311
+ * Creates a numbered resource.
312
+ *
313
+ * @returns The next monotonically increasing id.
314
+ */
315
+ create(): number;
316
+ /**
317
+ * Destroys a numbered resource.
318
+ *
319
+ * @param id - The resource id to destroy.
320
+ */
321
+ destroy(id: number): void;
322
+ }
323
+
324
+ /** Configures a bounded retry. */
325
+ export declare interface RetryOptions extends WaitOptions {
326
+ /** The maximum number of producer calls. When omitted, only the time budget bounds the retry. */
327
+ readonly attempts?: number;
328
+ }
329
+
330
+ /**
331
+ * Repeats a producer until one produced value satisfies a predicate.
332
+ *
333
+ * @typeParam T - The produced value type.
334
+ * @param description - The operation described in an exhaustion error.
335
+ * @param produce - The synchronous or asynchronous operation to repeat.
336
+ * @param satisfied - The predicate that accepts a produced value.
337
+ * @param options - The time, attempt, and abort bounds.
338
+ * @returns The first produced value the predicate accepts.
339
+ * @throws The predicate's thrown value, the abort reason, or an `Error` when a bound is invalid or
340
+ * the retry exhausts its budget or attempts.
341
+ * @remarks A producer throw counts as an unsatisfied attempt. The last producer error becomes the
342
+ * exhaustion error's `cause`. Default budget: `1000` milliseconds. Default interval: `10`
343
+ * milliseconds.
344
+ */
345
+ export declare function retryUntil<T>(description: string, produce: () => T | Promise<T>, satisfied: (value: T) => boolean, options?: RetryOptions): Promise<T>;
346
+
150
347
  /**
151
348
  * Copies a JSON value through serialization and parsing.
152
349
  *
@@ -159,6 +356,16 @@ export declare function resolveRoot(meta: ImportMeta): URL;
159
356
  */
160
357
  export declare function roundTripJSON<T>(value: T & JSONSafe<T>): T;
161
358
 
359
+ /** A real abort signal and controller instrumented with its live abort-listener tally. */
360
+ export declare interface SignalInterface {
361
+ /** The controller that owns the signal. */
362
+ readonly controller: AbortController;
363
+ /** The instrumented signal. */
364
+ readonly signal: AbortSignal;
365
+ /** The live abort-listener tally. */
366
+ readonly count: number;
367
+ }
368
+
162
369
  /** The work one teardown entry performs when the list is destroyed. */
163
370
  export declare type TeardownHandler = () => void | Promise<void>;
164
371
 
@@ -185,6 +392,30 @@ export declare interface TeardownInterface {
185
392
  destroy(): Promise<void>;
186
393
  }
187
394
 
395
+ /**
396
+ * Waits until an abort signal is aborted.
397
+ *
398
+ * @param signal - The signal to observe.
399
+ * @returns A promise that resolves when the signal is aborted.
400
+ * @remarks An already-aborted signal resolves immediately. Otherwise the wait parks on a one-shot
401
+ * abort listener without a timer or polling.
402
+ */
403
+ export declare function waitForAbort(signal: AbortSignal): Promise<void>;
404
+
405
+ /**
406
+ * Waits until a condition holds within an elapsed-time budget.
407
+ *
408
+ * @param description - The condition described in a timeout error.
409
+ * @param condition - The synchronous or asynchronous condition to read.
410
+ * @param options - The time bounds and abort signal.
411
+ * @returns A promise that resolves when the condition first returns `true`.
412
+ * @throws The condition's thrown value, the abort reason, or an `Error` when a bound is invalid or
413
+ * the condition does not hold within the budget.
414
+ * @remarks The first read is immediate. Default budget: `1000` milliseconds. Default interval: `10`
415
+ * milliseconds.
416
+ */
417
+ export declare function waitForCondition(description: string, condition: () => boolean | Promise<boolean>, options?: WaitOptions): Promise<void>;
418
+
188
419
  /**
189
420
  * Waits for a host timer to elapse.
190
421
  *
@@ -193,4 +424,35 @@ export declare interface TeardownInterface {
193
424
  */
194
425
  export declare function waitForDelay(ms?: number): Promise<void>;
195
426
 
427
+ /**
428
+ * Waits for the first delivery from an event subscription.
429
+ *
430
+ * @typeParam TArgs - The delivered argument tuple.
431
+ * @param subscribe - The function that installs the event listener and may return its cleanup.
432
+ * @param description - The event described in a timeout error.
433
+ * @param options - The time bounds and abort signal.
434
+ * @returns The first delivered argument tuple.
435
+ * @throws The subscription's thrown value, the abort reason, or an `Error` when a bound is invalid
436
+ * or the event is not delivered within the budget.
437
+ * @remarks Default budget: `1000` milliseconds. The interval is validated for consistency with the
438
+ * wait family but is not used because this helper parks on the event.
439
+ */
440
+ export declare function waitForEvent<TArgs extends readonly unknown[]>(subscribe: EventSubscriber<TArgs>, description: string, options?: WaitOptions): Promise<TArgs>;
441
+
442
+ /**
443
+ * Configures a bounded asynchronous wait.
444
+ *
445
+ * @remarks
446
+ * A default belongs to the function that reads these bounds rather than to the shape, because the
447
+ * consumers do not agree on one. Each states its own numbers in its `@remarks`.
448
+ */
449
+ export declare interface WaitOptions {
450
+ /** The elapsed-time limit in milliseconds. */
451
+ readonly budget?: number;
452
+ /** The delay between readings in milliseconds. */
453
+ readonly interval?: number;
454
+ /** The signal that aborts the wait. */
455
+ readonly signal?: AbortSignal;
456
+ }
457
+
196
458
  export { }
@@ -27,10 +27,23 @@ export declare function collectStream<T>(stream: ReadableStream<T>): Promise<rea
27
27
  /**
28
28
  * Creates values that make common object readers throw or violate their assumptions.
29
29
  *
30
- * @returns A frozen array whose six values are fresh on every call.
31
- * @remarks Every member makes a naive reader throw. A total guard survives every member without
32
- * throwing. Whether it accepts or refuses one is that guard's own contract. Membership may grow in
33
- * a release, so test the whole returned set in a loop and include the index in each failure.
30
+ * @returns A frozen array whose values are fresh on every call.
31
+ * @remarks Every member makes a naive read throw or violates a naive structural assumption. A total
32
+ * guard survives every member without throwing. Whether it accepts or refuses one is that guard's
33
+ * own contract. Membership may grow in a release, so test the whole returned set in a loop and
34
+ * include the index in each failure.
35
+ *
36
+ * - The self-referential record makes JSON record serialization throw.
37
+ * - The revoked object proxy makes reflective object access throw.
38
+ * - The property proxy makes a named property read throw.
39
+ * - The key proxy makes key enumeration throw.
40
+ * - The prototype proxy makes a prototype read throw.
41
+ * - The null-prototype record breaks a direct `hasOwnProperty` call.
42
+ * - The array-target proxy passes an array check and makes an index read throw.
43
+ * - The self-referential array makes JSON collection serialization throw.
44
+ * - The sparse array violates the assumption that every index is enumerable.
45
+ * - The hidden-key record violates the assumption that every own key is enumerable.
46
+ * - The named getter makes its property read throw.
34
47
  * @example
35
48
  * ```ts
36
49
  * import { expect } from 'vitest'
@@ -65,7 +78,43 @@ export declare function createHostileValues(): readonly unknown[];
65
78
  * @typeParam TArgs - The argument tuple to record.
66
79
  * @returns A recorder whose handler appends calls in order.
67
80
  */
68
- export declare function createRecorder<TArgs extends readonly unknown[]>(): RecorderInterface<TArgs>;
81
+ export declare function createRecorder<TArgs extends readonly unknown[] = readonly unknown[]>(): RecorderInterface<TArgs>;
82
+
83
+ /**
84
+ * Creates event recorders and subscribes them to the source.
85
+ *
86
+ * @typeParam TMap - The source's event names and delivered argument tuples.
87
+ * @typeParam TName - The requested event names.
88
+ * @param source - The source to subscribe to.
89
+ * @param events - The events to record.
90
+ * @returns A map from each requested event name to its recorder.
91
+ * @throws Thrown when a listed event has no recorder, which a well-formed events array cannot
92
+ * produce.
93
+ * @remarks A duplicate event name installs a fresh recorder for every occurrence. The returned map
94
+ * keeps the recorder installed for the last occurrence. `TName` derives from the array's element
95
+ * type. An array declared with a wider union than its contents widens `TName` beyond the listed
96
+ * events. The omitted key reads `undefined` at runtime under a non-optional type, and the guard
97
+ * reports `true` because it checks the listed events. Pass a literal array or a tuple.
98
+ */
99
+ export declare function createRecorders<TMap extends Record<string, readonly unknown[]>, TName extends keyof TMap>(source: EventSourceInterface<TMap>, events: readonly TName[]): RecorderMap<TMap, TName>;
100
+
101
+ /**
102
+ * Creates a monotonically numbered resource factory with creation and destruction records.
103
+ *
104
+ * @returns A resource factory whose recorders retain every affected id in order.
105
+ */
106
+ export declare function createResourceFactory(): ResourceFactoryInterface;
107
+
108
+ /**
109
+ * Creates a real abort controller whose signal reports its live abort listeners.
110
+ *
111
+ * @returns The controller, its instrumented signal, and the current listener tally.
112
+ * @remarks Instrumentation is installed on the created signal instance. A one-shot listener leaves
113
+ * the tally when it fires, and removal accepts the original listener supplied by the caller. A
114
+ * listener scoped by another signal leaves when that signal aborts. An already-aborted scope
115
+ * installs and records nothing.
116
+ */
117
+ export declare function createSignal(): SignalInterface;
69
118
 
70
119
  /**
71
120
  * Creates a teardown list that runs registered handlers newest-first.
@@ -74,6 +123,88 @@ export declare function createRecorder<TArgs extends readonly unknown[]>(): Reco
74
123
  */
75
124
  export declare function createTeardown(): TeardownInterface;
76
125
 
126
+ /**
127
+ * Decodes newline-delimited JSON values.
128
+ *
129
+ * @param text - The JSON Lines text to decode.
130
+ * @returns The decoded values in physical-line order.
131
+ * @throws An `Error` naming the malformed physical line, with the native `SyntaxError` as its
132
+ * `cause`.
133
+ */
134
+ export declare function decodeJSONLines(text: string): readonly unknown[];
135
+
136
+ /**
137
+ * Subscribes handlers to a typed event source.
138
+ *
139
+ * @typeParam TMap - The event names and argument tuples the source delivers.
140
+ */
141
+ export declare interface EventSourceInterface<TMap extends Record<string, readonly unknown[]>> {
142
+ /**
143
+ * Subscribes a handler to an event.
144
+ *
145
+ * @param event - The event to subscribe to.
146
+ * @param handler - The handler that receives each delivery.
147
+ */
148
+ on<K extends keyof TMap>(event: K, handler: (...args: TMap[K]) => void): void;
149
+ }
150
+
151
+ /**
152
+ * Subscribes a listener to one event source.
153
+ *
154
+ * @typeParam TArgs - The argument tuple the event delivers.
155
+ * @param listener - The listener that receives each delivery.
156
+ * @returns The cleanup that removes the listener, or `void` when the source needs none.
157
+ */
158
+ export declare type EventSubscriber<TArgs extends readonly unknown[]> = (listener: (...args: TArgs) => void) => (() => void) | void;
159
+
160
+ /**
161
+ * Normalizes headers into a frozen plain record.
162
+ *
163
+ * @param init - The platform header initializer to normalize.
164
+ * @returns A frozen record of normalized header names and values.
165
+ * @remarks Normalization follows the host `Headers` implementation, including lowercased names and
166
+ * combined values.
167
+ */
168
+ export declare function flattenHeaders(init: HeadersSource): Readonly<Record<string, string>>;
169
+
170
+ /**
171
+ * Any value the host `Headers` constructor accepts.
172
+ *
173
+ * @remarks Derived from the host constructor rather than named from a single library, so the type
174
+ * resolves in every project against that project's own `Headers` declaration. The record,
175
+ * entries-array, and `Headers` forms all satisfy it.
176
+ */
177
+ export declare type HeadersSource = NonNullable<ConstructorParameters<typeof Headers>[0]>;
178
+
179
+ /**
180
+ * Invokes an unknown method through an explicit unchecked result contract.
181
+ *
182
+ * @typeParam T - The result type claimed by the caller.
183
+ * @param target - The value used as the method's `this` argument.
184
+ * @param method - The unknown method to invoke.
185
+ * @param args - The arguments to pass.
186
+ * @returns The method's result under the caller's claimed type.
187
+ * @throws A `TypeError` when `method` is not callable.
188
+ * @remarks The caller owns the claim that the returned value has type `T`. The contained `any`
189
+ * bridges the unchecked runtime result to that caller-owned claim.
190
+ */
191
+ export declare function invokeUnchecked<T>(target: unknown, method: unknown, args: readonly unknown[]): T;
192
+
193
+ /**
194
+ * Checks whether a value contains a recorder for every listed event.
195
+ *
196
+ * @typeParam TMap - The source's event names and delivered argument tuples.
197
+ * @typeParam TName - The event names represented in the map.
198
+ * @param value - The value to inspect.
199
+ * @param events - The events the completed map must contain.
200
+ * @returns True if every listed event has a structurally valid recorder; false otherwise.
201
+ * @remarks Per-key tuple precision is the predicate's claim. The factory proves that claim by
202
+ * wiring each recorder to exactly the event where it stores that recorder. A direct caller must
203
+ * establish the same pairing before it relies on the narrowing. This guard takes the listed events
204
+ * through a reference parameter rather than using the canonical single-value guard form.
205
+ */
206
+ export declare function isRecorderMapComplete<TMap extends Record<string, readonly unknown[]>, TName extends keyof TMap>(value: unknown, events: readonly TName[]): value is RecorderMap<TMap, TName>;
207
+
77
208
  /**
78
209
  * The JSON-safe projection of a type: every member JSON preserves, mapped to itself, and every
79
210
  * member it does not, mapped to `never`.
@@ -112,6 +243,19 @@ export declare type JSONValue = string | number | boolean | null | readonly JSON
112
243
  readonly [key: string]: JSONValue;
113
244
  };
114
245
 
246
+ /**
247
+ * Reads a property from an unknown object or function.
248
+ *
249
+ * @typeParam T - The property type claimed by the caller.
250
+ * @param target - The unknown value to read.
251
+ * @param key - The property key to read.
252
+ * @returns The property value under the caller's claimed type.
253
+ * @throws A `TypeError` when `target` is neither an object nor a function.
254
+ * @remarks The caller owns the claim that the returned value has type `T`. The contained `any`
255
+ * bridges the unchecked runtime result to that caller-owned claim.
256
+ */
257
+ export declare function readProperty<T>(target: unknown, key: PropertyKey): T;
258
+
115
259
  /**
116
260
  * Records every call made to its handler.
117
261
  *
@@ -128,6 +272,16 @@ export declare interface RecorderInterface<TArgs extends readonly unknown[]> {
128
272
  clear(): void;
129
273
  }
130
274
 
275
+ /**
276
+ * Maps event names to recorders for their delivered argument tuples.
277
+ *
278
+ * @typeParam TMap - The event names and argument tuples the source delivers.
279
+ * @typeParam TName - The event names represented in the map.
280
+ */
281
+ export declare type RecorderMap<TMap extends Record<string, readonly unknown[]>, TName extends keyof TMap> = {
282
+ readonly [K in TName]: RecorderInterface<TMap[K]>;
283
+ };
284
+
131
285
  /**
132
286
  * Requires a value to be present.
133
287
  *
@@ -147,6 +301,49 @@ export declare function requireValue<T>(value: T | null | undefined, message?: s
147
301
  */
148
302
  export declare function resolveRoot(meta: ImportMeta): URL;
149
303
 
304
+ /** A numbered resource factory with records of every creation and destruction. */
305
+ export declare interface ResourceFactoryInterface {
306
+ /** The ids returned by `create`, in order. */
307
+ readonly created: RecorderInterface<readonly [id: number]>;
308
+ /** The ids passed to `destroy`, in order. */
309
+ readonly destroyed: RecorderInterface<readonly [id: number]>;
310
+ /**
311
+ * Creates a numbered resource.
312
+ *
313
+ * @returns The next monotonically increasing id.
314
+ */
315
+ create(): number;
316
+ /**
317
+ * Destroys a numbered resource.
318
+ *
319
+ * @param id - The resource id to destroy.
320
+ */
321
+ destroy(id: number): void;
322
+ }
323
+
324
+ /** Configures a bounded retry. */
325
+ export declare interface RetryOptions extends WaitOptions {
326
+ /** The maximum number of producer calls. When omitted, only the time budget bounds the retry. */
327
+ readonly attempts?: number;
328
+ }
329
+
330
+ /**
331
+ * Repeats a producer until one produced value satisfies a predicate.
332
+ *
333
+ * @typeParam T - The produced value type.
334
+ * @param description - The operation described in an exhaustion error.
335
+ * @param produce - The synchronous or asynchronous operation to repeat.
336
+ * @param satisfied - The predicate that accepts a produced value.
337
+ * @param options - The time, attempt, and abort bounds.
338
+ * @returns The first produced value the predicate accepts.
339
+ * @throws The predicate's thrown value, the abort reason, or an `Error` when a bound is invalid or
340
+ * the retry exhausts its budget or attempts.
341
+ * @remarks A producer throw counts as an unsatisfied attempt. The last producer error becomes the
342
+ * exhaustion error's `cause`. Default budget: `1000` milliseconds. Default interval: `10`
343
+ * milliseconds.
344
+ */
345
+ export declare function retryUntil<T>(description: string, produce: () => T | Promise<T>, satisfied: (value: T) => boolean, options?: RetryOptions): Promise<T>;
346
+
150
347
  /**
151
348
  * Copies a JSON value through serialization and parsing.
152
349
  *
@@ -159,6 +356,16 @@ export declare function resolveRoot(meta: ImportMeta): URL;
159
356
  */
160
357
  export declare function roundTripJSON<T>(value: T & JSONSafe<T>): T;
161
358
 
359
+ /** A real abort signal and controller instrumented with its live abort-listener tally. */
360
+ export declare interface SignalInterface {
361
+ /** The controller that owns the signal. */
362
+ readonly controller: AbortController;
363
+ /** The instrumented signal. */
364
+ readonly signal: AbortSignal;
365
+ /** The live abort-listener tally. */
366
+ readonly count: number;
367
+ }
368
+
162
369
  /** The work one teardown entry performs when the list is destroyed. */
163
370
  export declare type TeardownHandler = () => void | Promise<void>;
164
371
 
@@ -185,6 +392,30 @@ export declare interface TeardownInterface {
185
392
  destroy(): Promise<void>;
186
393
  }
187
394
 
395
+ /**
396
+ * Waits until an abort signal is aborted.
397
+ *
398
+ * @param signal - The signal to observe.
399
+ * @returns A promise that resolves when the signal is aborted.
400
+ * @remarks An already-aborted signal resolves immediately. Otherwise the wait parks on a one-shot
401
+ * abort listener without a timer or polling.
402
+ */
403
+ export declare function waitForAbort(signal: AbortSignal): Promise<void>;
404
+
405
+ /**
406
+ * Waits until a condition holds within an elapsed-time budget.
407
+ *
408
+ * @param description - The condition described in a timeout error.
409
+ * @param condition - The synchronous or asynchronous condition to read.
410
+ * @param options - The time bounds and abort signal.
411
+ * @returns A promise that resolves when the condition first returns `true`.
412
+ * @throws The condition's thrown value, the abort reason, or an `Error` when a bound is invalid or
413
+ * the condition does not hold within the budget.
414
+ * @remarks The first read is immediate. Default budget: `1000` milliseconds. Default interval: `10`
415
+ * milliseconds.
416
+ */
417
+ export declare function waitForCondition(description: string, condition: () => boolean | Promise<boolean>, options?: WaitOptions): Promise<void>;
418
+
188
419
  /**
189
420
  * Waits for a host timer to elapse.
190
421
  *
@@ -193,4 +424,35 @@ export declare interface TeardownInterface {
193
424
  */
194
425
  export declare function waitForDelay(ms?: number): Promise<void>;
195
426
 
427
+ /**
428
+ * Waits for the first delivery from an event subscription.
429
+ *
430
+ * @typeParam TArgs - The delivered argument tuple.
431
+ * @param subscribe - The function that installs the event listener and may return its cleanup.
432
+ * @param description - The event described in a timeout error.
433
+ * @param options - The time bounds and abort signal.
434
+ * @returns The first delivered argument tuple.
435
+ * @throws The subscription's thrown value, the abort reason, or an `Error` when a bound is invalid
436
+ * or the event is not delivered within the budget.
437
+ * @remarks Default budget: `1000` milliseconds. The interval is validated for consistency with the
438
+ * wait family but is not used because this helper parks on the event.
439
+ */
440
+ export declare function waitForEvent<TArgs extends readonly unknown[]>(subscribe: EventSubscriber<TArgs>, description: string, options?: WaitOptions): Promise<TArgs>;
441
+
442
+ /**
443
+ * Configures a bounded asynchronous wait.
444
+ *
445
+ * @remarks
446
+ * A default belongs to the function that reads these bounds rather than to the shape, because the
447
+ * consumers do not agree on one. Each states its own numbers in its `@remarks`.
448
+ */
449
+ export declare interface WaitOptions {
450
+ /** The elapsed-time limit in milliseconds. */
451
+ readonly budget?: number;
452
+ /** The delay between readings in milliseconds. */
453
+ readonly interval?: number;
454
+ /** The signal that aborts the wait. */
455
+ readonly signal?: AbortSignal;
456
+ }
457
+
196
458
  export { }