aws-crt
Version:
NodeJS bindings to the aws-c-* libraries
17 lines (16 loc) • 611 B
TypeScript
/**
* If you have a resource that you want typescript to enforce close is implemented
* and/or you want to use the below 'using' function, then implement this interface.
*/
export interface ResourceSafe {
close(): void;
}
/**
* Use this function to create a resource in an async context. This will make sure the
* resources are cleaned up before returning.
*
* example: await using(res = new SomeResource(), async (res) => {
* res.do_the_thing();
* });
*/
export declare function using<T extends ResourceSafe>(resource: T, func: (resource: T) => void): Promise<void>;