@furystack/inject
Advanced tools
Comparing version 4.0.76 to 5.0.0
@@ -29,3 +29,3 @@ "use strict"; | ||
if (fails && fails.length) { | ||
console.warn(`There was an error during disposing '${fails.length}' global disposable objects`, fails); | ||
throw new Error(`There was an error during disposing '${fails.length}' global disposable objects: ${fails.map((f) => f.reason)}`); | ||
} | ||
@@ -32,0 +32,0 @@ this.cachedSingletons.clear(); |
@@ -135,2 +135,21 @@ "use strict"; | ||
}); | ||
it('Should throw if failed to dispose one or more entries', async () => { | ||
expect.assertions(1); | ||
let TestDisposableThrows = class TestDisposableThrows { | ||
dispose() { | ||
throw Error(':('); | ||
} | ||
}; | ||
TestDisposableThrows = (0, tslib_1.__decorate)([ | ||
(0, injectable_1.Injectable)({ lifetime: 'singleton' }) | ||
], TestDisposableThrows); | ||
const i = new injector_1.Injector(); | ||
i.getInstance(TestDisposableThrows); | ||
try { | ||
await i.dispose(); | ||
} | ||
catch (error) { | ||
expect(error.message).toBe("There was an error during disposing '1' global disposable objects: Error: :("); | ||
} | ||
}); | ||
it('Should dispose cached entries on dispose and tolerate non-disposable ones', (done) => { | ||
@@ -137,0 +156,0 @@ class TestDisposable { |
{ | ||
"name": "@furystack/inject", | ||
"version": "4.0.76", | ||
"version": "5.0.0", | ||
"description": "Core FuryStack package", | ||
@@ -29,3 +29,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@furystack/utils": "^1.2.46", | ||
"@furystack/utils": "^2.0.0", | ||
"tslib": "^2.3.1" | ||
@@ -37,3 +37,3 @@ }, | ||
"typings": "./dist/index.d.ts", | ||
"gitHead": "7ae73a26dde10e034bd828a5f85dbde57b514fac" | ||
"gitHead": "8a1860a227691def1a94e8de5e95a7c5067356cc" | ||
} |
@@ -113,2 +113,24 @@ import { Disposable, using, usingAsync } from '@furystack/utils' | ||
it('Should throw if failed to dispose one or more entries', async () => { | ||
expect.assertions(1) | ||
@Injectable({ lifetime: 'singleton' }) | ||
class TestDisposableThrows implements Disposable { | ||
public dispose() { | ||
throw Error(':(') | ||
} | ||
} | ||
const i = new Injector() | ||
i.getInstance(TestDisposableThrows) | ||
try { | ||
await i.dispose() | ||
} catch (error) { | ||
expect((error as Error).message).toBe( | ||
"There was an error during disposing '1' global disposable objects: Error: :(", | ||
) | ||
} | ||
}) | ||
it('Should dispose cached entries on dispose and tolerate non-disposable ones', (done) => { | ||
@@ -115,0 +137,0 @@ class TestDisposable implements Disposable { |
@@ -19,5 +19,9 @@ import { Disposable } from '@furystack/utils' | ||
const result = await Promise.allSettled(disposeRequests) | ||
const fails = result.filter((r) => r.status === 'rejected') | ||
const fails = result.filter((r) => r.status === 'rejected') as PromiseRejectedResult[] | ||
if (fails && fails.length) { | ||
console.warn(`There was an error during disposing '${fails.length}' global disposable objects`, fails) | ||
throw new Error( | ||
`There was an error during disposing '${fails.length}' global disposable objects: ${fails.map( | ||
(f) => f.reason, | ||
)}`, | ||
) | ||
} | ||
@@ -24,0 +28,0 @@ |
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
77284
988
+ Added@furystack/utils@2.1.0(transitive)
- Removed@furystack/utils@1.2.46(transitive)
Updated@furystack/utils@^2.0.0