Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@furystack/inject

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@furystack/inject - npm Package Compare versions

Comparing version 4.0.76 to 5.0.0

2

dist/injector.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc