/** * A container that aggregates disposable resources and disposes them, in reverse (last-in-first-out) order, when the stack itself is disposed. * * The class satisfies the platform `DisposableStack` interface by construction - the `implements` clause below binds it to `globalThis.DisposableStack`, so the * compiler enforces that the name's promise (the platform contract) is kept at the definition site. * * @category Utilities */ export declare class DisposableStack implements InstanceType { #private; readonly [Symbol.toStringTag] = "DisposableStack"; /** * Whether this stack has been disposed. */ get disposed(): boolean; /** * Register a {@link Disposable} whose `[Symbol.dispose]()` runs when this stack is disposed, returning the value unchanged. * * `null` and `undefined` pass through without being registered. The dispose method is captured at registration time and invoked with the value as its receiver, so * a later mutation of `value[Symbol.dispose]` cannot change what runs. * * @param value - The resource to register, or `null`/`undefined` to skip registration. * @returns The provided `value`. */ use(value: T): T; /** * Register a value together with an explicit disposal callback, returning the value unchanged. The callback is invoked with the value as its first argument when * this stack is disposed. * * @param value - The value to associate with the callback. * @param onDispose - The disposal callback, invoked with `value`. * @returns The provided `value`. */ adopt(value: T, onDispose: (value: T) => void): T; /** * Register a callback to run when this stack is disposed. * * @param onDispose - The callback to run on disposal. */ defer(onDispose: () => void): void; /** * Move every pending disposer out of this stack into a fresh {@link DisposableStack}, preserving registration order, and mark this stack disposed without running * anything. This is the "commit" primitive: after a successful acquire sequence, moving the disposers away disarms this stack's scope-bound cleanup while handing * responsibility for those resources to the returned stack. * * @returns A new stack owning the transferred disposers. */ move(): DisposableStack; /** * Dispose every registered resource in reverse (last-in-first-out) order. A second call is a no-op. Every disposer runs even when an earlier one throws: a single * failure is rethrown after the sweep completes, and multiple failures chain through `SuppressedError` (the newest failure wrapping the accumulated one). */ dispose(): void; /** * Dispose this stack. Enables `using` semantics by delegating to {@link dispose}. */ [Symbol.dispose](): void; } //# sourceMappingURL=disposable-stack.d.ts.map