@wixc3/create-disposables
Advanced tools
Comparing version 1.1.1 to 2.0.0
export declare function createDisposables(): { | ||
dispose(): Promise<void>; | ||
add<T extends { | ||
dispose(): unknown; | ||
} | (() => unknown)>(disposable: T): T; | ||
add(disposable: Disposable): void; | ||
}; | ||
export declare type DisposeFunction = () => unknown; | ||
export declare type Disposable = { | ||
dispose: DisposeFunction; | ||
} | DisposeFunction; | ||
export declare type Disposables = ReturnType<typeof createDisposables>; | ||
//# sourceMappingURL=create-disposables.d.ts.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
async dispose() { | ||
const toDispose = new Set(Array.from(disposables).reverse()); | ||
const toDispose = Array.from(disposables).reverse(); | ||
disposables.clear(); | ||
@@ -22,3 +22,2 @@ for (const dispose of toDispose) { | ||
} | ||
return disposable; | ||
}, | ||
@@ -25,0 +24,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
{ | ||
"name": "@wixc3/create-disposables", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "A utility for saving objects to be disposed", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,3 +6,3 @@ export function createDisposables() { | ||
async dispose() { | ||
const toDispose = new Set(Array.from(disposables).reverse()); | ||
const toDispose = Array.from(disposables).reverse(); | ||
disposables.clear(); | ||
@@ -13,3 +13,3 @@ for (const dispose of toDispose) { | ||
}, | ||
add<T extends { dispose(): unknown } | (() => unknown)>(disposable: T): T { | ||
add(disposable: Disposable) { | ||
if (typeof disposable === 'function') { | ||
@@ -20,5 +20,8 @@ disposables.add(disposable); | ||
} | ||
return disposable; | ||
}, | ||
}; | ||
} | ||
export type DisposeFunction = () => unknown; | ||
export type Disposable = { dispose: DisposeFunction } | DisposeFunction; | ||
export type Disposables = ReturnType<typeof createDisposables>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5552
81