Skip to content

withComparators

function withComparators<T>(registry, fn): T;

Defined in: comparators.ts:116

Run fn with registry layered over the global default for the duration of the (synchronous) call. Instance entries take precedence over global ones. Restores the previous scope in a finally, so nesting and throws are safe.

Relies on evaluation being fully synchronous between the scope set and its use — there is no await inside the evaluator — so this acts as a poor-man’s dynamic scope without leaking across async boundaries.

Type Parameter
T
Parameter Type
registry | ComparatorRegistry | undefined
fn () => T

T