@furystack/core
Advanced tools
Comparing version 15.0.1 to 15.0.2
@@ -27,3 +27,3 @@ import { Injector } from '@furystack/inject'; | ||
disposeOnProcessExit(i); | ||
await exitHandler(); | ||
exitHandler(); | ||
expect(i[Symbol.asyncDispose]).toBeCalled(); | ||
@@ -30,0 +30,0 @@ globalDisposables.delete(i); |
@@ -9,21 +9,19 @@ import { isAsyncDisposable, isDisposable } from '@furystack/utils'; | ||
*/ | ||
export const exitHandler = (() => { | ||
Promise.allSettled([...globalDisposables].map(async (d) => { | ||
if (isAsyncDisposable(d)) { | ||
await d[Symbol.asyncDispose](); | ||
} | ||
if (isDisposable(d)) { | ||
d[Symbol.dispose](); | ||
} | ||
})) | ||
.then((result) => { | ||
const fails = result.filter((r) => r.status === 'rejected'); | ||
if (fails && fails.length) { | ||
console.warn(`There was an error during disposing '${fails.length}' global disposable objects`, fails); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error('Error during disposing global disposables', error); | ||
}); | ||
}).bind(null); | ||
export const exitHandler = (() => Promise.allSettled([...globalDisposables].map(async (d) => { | ||
if (isAsyncDisposable(d)) { | ||
await d[Symbol.asyncDispose](); | ||
} | ||
if (isDisposable(d)) { | ||
d[Symbol.dispose](); | ||
} | ||
})) | ||
.then((result) => { | ||
const fails = result.filter((r) => r.status === 'rejected'); | ||
if (fails && fails.length) { | ||
console.warn(`There was an error during disposing '${fails.length}' global disposable objects`, fails); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error('Error during disposing global disposables', error); | ||
})).bind(null); | ||
// do something when app is closing | ||
@@ -33,3 +31,3 @@ globalThis.process?.on?.('exit', exitHandler); | ||
globalThis.process?.on?.('SIGINT', exitHandler); | ||
globalThis.process?.on?.('SIGTERM', () => exitHandler); | ||
globalThis.process?.on?.('SIGTERM', exitHandler); | ||
// catches "kill pid" (for example: nodemon restart) | ||
@@ -40,3 +38,4 @@ globalThis.process?.on?.('SIGUSR1', exitHandler); | ||
globalThis.process?.on?.('uncaughtException', exitHandler); | ||
// Browser environment | ||
globalThis.window?.addEventListener('beforeunload', exitHandler); | ||
//# sourceMappingURL=global-disposables.js.map |
@@ -44,3 +44,3 @@ import { Injector } from '@furystack/inject'; | ||
const MockStore = class extends InMemoryStore { | ||
[Symbol.asyncDispose] = () => Promise.reject(':('); | ||
[Symbol.asyncDispose] = () => Promise.reject(new Error(':(')); | ||
}; | ||
@@ -47,0 +47,0 @@ sm.addStore(new MockStore({ |
{ | ||
"name": "@furystack/core", | ||
"version": "15.0.1", | ||
"version": "15.0.2", | ||
"description": "Core FuryStack package", | ||
@@ -43,11 +43,11 @@ "type": "module", | ||
"devDependencies": { | ||
"@types/node": "^20.14.11", | ||
"typescript": "^5.5.3", | ||
"vitest": "^2.0.3" | ||
"@types/node": "^22.2.0", | ||
"typescript": "^5.5.4", | ||
"vitest": "^2.0.5" | ||
}, | ||
"dependencies": { | ||
"@furystack/inject": "^12.0.1", | ||
"@furystack/utils": "^8.0.1" | ||
"@furystack/inject": "^12.0.2", | ||
"@furystack/utils": "^8.0.2" | ||
}, | ||
"gitHead": "1045d854bfd8c475b7035471d130d401417a2321" | ||
} |
@@ -30,3 +30,3 @@ import { Injector } from '@furystack/inject' | ||
disposeOnProcessExit(i) | ||
await exitHandler() | ||
exitHandler() | ||
expect(i[Symbol.asyncDispose]).toBeCalled() | ||
@@ -33,0 +33,0 @@ globalDisposables.delete(i) |
@@ -11,3 +11,3 @@ import { isAsyncDisposable, isDisposable } from '@furystack/utils' | ||
*/ | ||
export const exitHandler = (() => { | ||
export const exitHandler = (() => | ||
Promise.allSettled( | ||
@@ -31,4 +31,3 @@ [...globalDisposables].map(async (d) => { | ||
console.error('Error during disposing global disposables', error) | ||
}) | ||
}).bind(null) | ||
})).bind(null) as () => void | ||
@@ -41,3 +40,3 @@ // do something when app is closing | ||
globalThis.process?.on?.('SIGTERM', () => exitHandler) | ||
globalThis.process?.on?.('SIGTERM', exitHandler) | ||
@@ -52,2 +51,2 @@ // catches "kill pid" (for example: nodemon restart) | ||
// Browser environment | ||
;(globalThis as any).window?.addEventListener('beforeunload', exitHandler) | ||
globalThis.window?.addEventListener('beforeunload', exitHandler) |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
import type { Constructable } from '@furystack/inject' | ||
@@ -119,3 +121,3 @@ import { EventHub } from '@furystack/utils' | ||
case '$regex': | ||
if (!new RegExp(filterValue).test(itemValue.toString())) { | ||
if (!new RegExp(filterValue as string).test((itemValue as string).toString())) { | ||
return false | ||
@@ -135,3 +137,3 @@ } | ||
case '$like': | ||
if (!this.evaluateLike(itemValue, filterValue)) { | ||
if (!this.evaluateLike(itemValue as string, filterValue as string)) { | ||
return false | ||
@@ -188,3 +190,3 @@ } | ||
if (!this.cache.has(id)) { | ||
throw Error(`Entity not found with id '${id}', cannot update!`) | ||
throw Error(`Entity not found with id '${id as string}', cannot update!`) | ||
} | ||
@@ -191,0 +193,0 @@ this.cache.set(id, { |
@@ -60,3 +60,3 @@ import { Injector } from '@furystack/inject' | ||
const MockStore = class extends InMemoryStore<any, any> { | ||
public [Symbol.asyncDispose] = () => Promise.reject(':(') | ||
public [Symbol.asyncDispose] = () => Promise.reject(new Error(':(')) | ||
} | ||
@@ -63,0 +63,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
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
210288
Updated@furystack/inject@^12.0.2
Updated@furystack/utils@^8.0.2