@whatwg-node/disposablestack
Advanced tools
Comparing version 0.0.5 to 0.0.6-alpha-20250225102211-278c6478ea45ec6f3c81c9f91295113accf29346
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PonyfillAsyncDisposableStack = void 0; | ||
const promise_helpers_1 = require("@whatwg-node/promise-helpers"); | ||
const SupressedError_js_1 = require("./SupressedError.js"); | ||
@@ -46,15 +47,6 @@ const symbols_js_1 = require("./symbols.js"); | ||
if (cb) { | ||
try { | ||
const res$ = cb(); | ||
if (res$?.then) { | ||
return res$.then(() => this._iterateCallbacks(), error => { | ||
this._error = this._error ? new SuppressedError(error, this._error) : error; | ||
return this._iterateCallbacks(); | ||
}); | ||
} | ||
} | ||
catch (error) { | ||
return (0, promise_helpers_1.handleMaybePromiseLike)(cb, () => this._iterateCallbacks(), error => { | ||
this._error = this._error ? new SuppressedError(error, this._error) : error; | ||
} | ||
return this._iterateCallbacks(); | ||
return this._iterateCallbacks(); | ||
}); | ||
} | ||
@@ -61,0 +53,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { handleMaybePromiseLike } from '@whatwg-node/promise-helpers'; | ||
import { PonyfillSuppressedError } from './SupressedError.js'; | ||
@@ -43,15 +44,6 @@ import { DisposableSymbols } from './symbols.js'; | ||
if (cb) { | ||
try { | ||
const res$ = cb(); | ||
if (res$?.then) { | ||
return res$.then(() => this._iterateCallbacks(), error => { | ||
this._error = this._error ? new SuppressedError(error, this._error) : error; | ||
return this._iterateCallbacks(); | ||
}); | ||
} | ||
} | ||
catch (error) { | ||
return handleMaybePromiseLike(cb, () => this._iterateCallbacks(), error => { | ||
this._error = this._error ? new SuppressedError(error, this._error) : error; | ||
} | ||
return this._iterateCallbacks(); | ||
return this._iterateCallbacks(); | ||
}); | ||
} | ||
@@ -58,0 +50,0 @@ } |
{ | ||
"name": "@whatwg-node/disposablestack", | ||
"version": "0.0.5", | ||
"version": "0.0.6-alpha-20250225102211-278c6478ea45ec6f3c81c9f91295113accf29346", | ||
"description": "Cross Platform Smart DisposableStack API Ponyfill", | ||
"sideEffects": false, | ||
"dependencies": { | ||
"@whatwg-node/promise-helpers": "0.0.1-alpha-20250225102211-278c6478ea45ec6f3c81c9f91295113accf29346", | ||
"tslib": "^2.6.3" | ||
@@ -8,0 +9,0 @@ }, |
@@ -0,3 +1,3 @@ | ||
import { MaybePromiseLike } from '@whatwg-node/promise-helpers'; | ||
import { DisposableSymbols } from './symbols.js'; | ||
import { MaybePromise } from './utils.js'; | ||
export declare class PonyfillAsyncDisposableStack implements AsyncDisposableStack { | ||
@@ -7,4 +7,4 @@ private callbacks; | ||
use<T extends AsyncDisposable | Disposable | null | undefined>(value: T): T; | ||
adopt<T>(value: T, onDisposeAsync: (value: T) => MaybePromise<void>): T; | ||
defer(onDisposeAsync: () => MaybePromise<void>): void; | ||
adopt<T>(value: T, onDisposeAsync: (value: T) => MaybePromiseLike<void>): T; | ||
defer(onDisposeAsync: () => MaybePromiseLike<void>): void; | ||
move(): AsyncDisposableStack; | ||
@@ -11,0 +11,0 @@ disposeAsync(): Promise<void>; |
export declare function isSyncDisposable(obj: any): obj is Disposable; | ||
export declare function isAsyncDisposable(obj: any): obj is AsyncDisposable; | ||
export type MaybePromise<T> = T | PromiseLike<T>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17634
2
407