Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
No EOL
699 B
Text
27 lines
No EOL
699 B
Text
const isPromiseLike = (value) => typeof value === 'object' && !!value && 'then' in value;
|
|
/**
|
|
* A helper function that calls `.dispose()` on the {@link IDisposable} when
|
|
* the given function (or promise returned by the function) returns.
|
|
*/
|
|
export const using = (disposable, fn) => {
|
|
let ret;
|
|
try {
|
|
ret = fn(disposable);
|
|
}
|
|
catch (e) {
|
|
disposable.dispose();
|
|
throw e;
|
|
}
|
|
if (!isPromiseLike(ret)) {
|
|
disposable.dispose();
|
|
return ret;
|
|
}
|
|
return ret.then(value => {
|
|
disposable.dispose();
|
|
return value;
|
|
}, err => {
|
|
disposable.dispose();
|
|
throw err;
|
|
});
|
|
};
|
|
//# sourceMappingURL=disposable.js.map |