/** * Simple implementation of context variables for Node.js * Provides similar functionality to Python's contextvars module */ /** * Represents a token for resetting a context variable */ export declare class Token { readonly value: T; readonly context: ContextVar; constructor(value: T, context: ContextVar); } /** * A context variable implementation */ export declare class ContextVar { private storage; private defaultValue; private identifier; /** * Create a new context variable * @param identifier Unique identifier for this context variable * @param defaultValue Optional default value */ constructor(identifier: string, defaultValue?: T); /** * Get the current value of the context variable */ get(): T | undefined; /** * Set a new value for the context variable * @param value New value * @returns A token that can be used to reset the variable to its previous value */ set(value: T): Token; /** * Reset the context variable using a token from a previous set() call * @param token The token from a previous set() call */ reset(token: Token): void; /** * Run a callback with a specific value for this context variable * @param value The value to set * @param callback The callback to run * @returns The result of the callback */ run(value: T, callback: () => R): R; }