Function scopedCapture

Source
scopedCapture<T>(fn: () => Promise<T>, obj: unknown): Promise<T>

Execute an async closure fn, and guarantee that obj will not be garbage-collected, until the promise is resolved.