@wixc3/patterns
Advanced tools
Comparing version 15.2.0 to 15.3.0
@@ -25,3 +25,3 @@ "use strict"; | ||
else { | ||
throw new Error(`Disposal failed: "${details.name}"`, { cause: e }); | ||
throw new Error(`Disposal failed: "${details.name}"\nCause: ${e}`, { cause: e }); | ||
} | ||
@@ -28,0 +28,0 @@ } |
export interface IDisposable { | ||
/** | ||
* disposes the instance removing all event listeners | ||
* starts instance disposal | ||
* @return a promise that resolves when disposal is done | ||
*/ | ||
dispose(): void; | ||
dispose(): Promise<void>; | ||
/** | ||
* is the instance disposed | ||
* is the instance disposed (or is disposing) | ||
*/ | ||
isDisposed(): boolean; | ||
} | ||
/** | ||
* | ||
* @param value | ||
* @returns true if value is IDisposable | ||
*/ | ||
export declare function isDisposable(value: any): value is IDisposable; | ||
//# sourceMappingURL=types.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isDisposable = void 0; | ||
/** | ||
* | ||
* @param value | ||
* @returns true if value is IDisposable | ||
*/ | ||
function isDisposable(value) { | ||
return ('dispose' in value && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
typeof value.dispose === 'function' && | ||
'isDisposed' in value && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
typeof value.isDisposed === 'function'); | ||
} | ||
exports.isDisposable = isDisposable; | ||
//# sourceMappingURL=types.js.map |
@@ -22,3 +22,3 @@ import { timeout } from 'promise-assist'; | ||
else { | ||
throw new Error(`Disposal failed: "${details.name}"`, { cause: e }); | ||
throw new Error(`Disposal failed: "${details.name}"\nCause: ${e}`, { cause: e }); | ||
} | ||
@@ -25,0 +25,0 @@ } |
export interface IDisposable { | ||
/** | ||
* disposes the instance removing all event listeners | ||
* starts instance disposal | ||
* @return a promise that resolves when disposal is done | ||
*/ | ||
dispose(): void; | ||
dispose(): Promise<void>; | ||
/** | ||
* is the instance disposed | ||
* is the instance disposed (or is disposing) | ||
*/ | ||
isDisposed(): boolean; | ||
} | ||
/** | ||
* | ||
* @param value | ||
* @returns true if value is IDisposable | ||
*/ | ||
export declare function isDisposable(value: any): value is IDisposable; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,14 @@ | ||
export {}; | ||
/** | ||
* | ||
* @param value | ||
* @returns true if value is IDisposable | ||
*/ | ||
export function isDisposable(value) { | ||
return ('dispose' in value && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
typeof value.dispose === 'function' && | ||
'isDisposed' in value && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
typeof value.isDisposed === 'function'); | ||
} | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@wixc3/patterns", | ||
"version": "15.2.0", | ||
"version": "15.3.0", | ||
"description": "A utility for saving objects to be disposed", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -19,3 +19,3 @@ import { timeout } from 'promise-assist'; | ||
} else { | ||
throw new Error(`Disposal failed: "${details.name}"`, { cause: e }); | ||
throw new Error(`Disposal failed: "${details.name}"\nCause: ${e}`, { cause: e }); | ||
} | ||
@@ -22,0 +22,0 @@ } |
export interface IDisposable { | ||
/** | ||
* disposes the instance removing all event listeners | ||
* starts instance disposal | ||
* @return a promise that resolves when disposal is done | ||
*/ | ||
dispose(): void; | ||
dispose(): Promise<void>; | ||
/** | ||
* is the instance disposed | ||
* is the instance disposed (or is disposing) | ||
*/ | ||
isDisposed(): boolean; | ||
} | ||
/** | ||
* | ||
* @param value | ||
* @returns true if value is IDisposable | ||
*/ | ||
export function isDisposable(value: any): value is IDisposable { | ||
return ( | ||
'dispose' in value && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
typeof value.dispose === 'function' && | ||
'isDisposed' in value && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
typeof value.isDisposed === 'function' | ||
); | ||
} |
@@ -69,3 +69,3 @@ import { expect, use } from 'chai'; | ||
expect(error).to.be.instanceOf(Error); | ||
expect(error.message).to.eql('Disposal failed: "[test]: disposing with error"'); | ||
expect(error.message).to.eql('Disposal failed: "[test]: disposing with error"\nCause: Error: failed!'); | ||
expect(error.cause).to.be.instanceOf(Error); | ||
@@ -72,0 +72,0 @@ expect((error.cause as Error).message).to.eql('failed!'); |
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
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
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
260926
5048