/** * A class that implements lazy loading for synchronous values. * It defers the initialization of a value until it's first requested. * @template T The type of value to be lazily loaded */ export declare class Lazy { /** The cached instance of the lazily loaded value */ private instance; /** A function that produces the value to be lazily loaded */ private readonly supplier; /** Optional handler to clean up the instance when closed */ private readonly closeHandler?; /** * Creates a new Lazy instance * @param supplier A function that creates the lazy-loaded value * @param closeHandler Optional function to clean up the instance when closed */ constructor(supplier: () => T, closeHandler?: (instance: T) => void); /** * Retrieves the lazy-loaded value, initializing it if necessary * @returns The lazy-loaded value * @throws If the supplier function fails to initialize the value */ get(): T; /** * Closes and cleans up the lazy-loaded instance if it exists. * If a closeHandler was provided, it will be called with the instance. * The instance is set to undefined after cleanup. */ close(): void; } /** * A class that implements lazy loading for asynchronous values. * It defers the initialization of a value until it's first requested. * @template T The type of value to be lazily loaded */ export declare class AsyncLazy { /** The cached instance of the lazily loaded value */ private instance; /** A function that produces the value to be lazily loaded */ private readonly supplier; /** Optional handler to clean up the instance when closed */ private readonly closeHandler?; /** Tracks the ongoing initialization promise to prevent multiple simultaneous initializations */ private initializationPromise; /** * Creates a new AsyncLazy instance * @param supplier An async function that creates the lazy-loaded value * @param closeHandler Optional async function to clean up the instance when closed */ constructor(supplier: () => Promise, closeHandler?: (instance: T) => Promise); /** * Retrieves the lazy-loaded value, initializing it if necessary * @returns A promise that resolves to the lazy-loaded value * @throws If the supplier function fails to initialize the value */ get(): Promise; /** * Closes and cleans up the lazy-loaded instance if it exists * If a closeHandler was provided, it will be called with the instance * @returns A promise that resolves when the cleanup is complete */ close(): Promise; } //# sourceMappingURL=lazy.d.ts.map