UNPKG

@keawade/using

Version:

Using implementation for disposable resources.

15 lines (14 loc) 766 B
import { Destroyable, DestroyableDictionary } from './Destroyable'; import { Disposable, DisposableDictionary } from './Disposable'; /** * Provides a convenient syntax that ensures the correct use of Disposable objects * * @param resource - Resource to dispose or destroy after using * @param usingFunction - Resource use context * @param options.key - Key of disposing function * @param options.throwOnError - Enable throw on error */ export declare const using: <Resource extends Destroyable | DestroyableDictionary | Disposable | DisposableDictionary, ReturnType_1 = any>(resource: Resource, usingFunction: (resource: Resource) => Promise<ReturnType_1>, options?: { key?: 'dispose' | 'destroy'; throwOnError?: boolean; }) => Promise<ReturnType_1>;