@xylabs/forget
v5.0.90
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Readme
@xylabs/forget
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Reference
@xylabs/forget
Classes
| Class | Description | | ------ | ------ | | ForgetPromise | Node.js extension of ForgetPromise that can terminate the process on exceptions or timeouts. |
Interfaces
| Interface | Description | | ------ | ------ | | ForgetNodeConfig | Node.js-specific forget configuration that extends ForgetConfig with process termination options. |
Variables
| Variable | Description | | ------ | ------ | | defaultForgetNodeConfig | Default Node.js forget configuration with termination disabled. |
Functions
| Function | Description | | ------ | ------ | | forget | Node.js variant of forget that can optionally terminate the process on exceptions or timeouts. |
classes
ForgetPromise
Node.js extension of ForgetPromise that can terminate the process on exceptions or timeouts.
Extends
ForgetPromise
Constructors
Constructor
new ForgetPromise(): ForgetPromiseNode;Returns
ForgetPromiseNode
Inherited from
ForgetPromise.constructorProperties
| Property | Modifier | Type | Default value | Description | Inherited from |
| ------ | ------ | ------ | ------ | ------ | ------ |
| activeForgets | static | number | 0 | Number of currently active (unresolved) forgotten promises. | ForgetPromise.activeForgets |
| exceptedForgets | static | number | 0 | Number of forgotten promises that threw exceptions. | ForgetPromise.exceptedForgets |
| logger | static | Logger | console | Logger instance used for error and warning output. | ForgetPromise.logger |
Accessors
active
Get Signature
get static active(): boolean;Whether any forgotten promises are still active.
Returns
boolean
Inherited from
ForgetPromise.activeMethods
awaitInactive()
static awaitInactive(interval?: number, timeout?: number): Promise<number>;Waits until all forgotten promises have completed.
Parameters
| Parameter | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| interval | number | 100 | Polling interval in milliseconds. |
| timeout? | number | undefined | Optional maximum wait time in milliseconds. |
Returns
Promise<number>
The number of remaining active forgets (0 if all completed).
Inherited from
ForgetPromise.awaitInactiveexceptionHandler()
static exceptionHandler(
error: Error,
config: ForgetNodeConfig,
externalStackTrace?: string): void;Handles exceptions, optionally terminating the process based on config.
Parameters
| Parameter | Type |
| ------ | ------ |
| error | Error |
| config | ForgetNodeConfig |
| externalStackTrace? | string |
Returns
void
Overrides
ForgetPromise.exceptionHandlerforget()
static forget<T>(promise: Promisable<T>, config?: ForgetNodeConfig<T>): void;Forgets a promise using Node.js-specific configuration with process termination support.
Type Parameters
| Type Parameter |
| ------ |
| T |
Parameters
| Parameter | Type |
| ------ | ------ |
| promise | Promisable<T> |
| config? | ForgetNodeConfig<T> |
Returns
void
Overrides
ForgetPromise.forgettimeoutHandler()
static timeoutHandler(
time: number,
config: ForgetNodeConfig,
externalStackTrace?: string): void;Handles timeouts, optionally terminating the process based on config.
Parameters
| Parameter | Type |
| ------ | ------ |
| time | number |
| config | ForgetNodeConfig |
| externalStackTrace? | string |
Returns
void
Overrides
ForgetPromise.timeoutHandlerfunctions
forget
function forget<T>(promise: Promisable<T>, config?: ForgetNodeConfig<T>): void;Node.js variant of forget that can optionally terminate the process on exceptions or timeouts.
Type Parameters
| Type Parameter |
| ------ |
| T |
Parameters
| Parameter | Type | Description |
| ------ | ------ | ------ |
| promise | Promisable<T> | The promise or promisable value to forget. |
| config? | ForgetNodeConfig<T> | Optional Node.js-specific configuration including process termination options. |
Returns
void
interfaces
ForgetNodeConfig
Node.js-specific forget configuration that extends ForgetConfig with process termination options.
Extends
ForgetConfig<T>
Type Parameters
| Type Parameter | Default type |
| ------ | ------ |
| T | any |
Properties
| Property | Type | Description | Inherited from |
| ------ | ------ | ------ | ------ |
| name? | string | Optional name for identifying the forgotten promise in logs. | ForgetConfig.name |
| onCancel? | () => void | Called when the promise is cancelled due to timeout. | ForgetConfig.onCancel |
| onComplete? | (result: [T | undefined, Error | undefined]) => void | Called when the promise completes, with a tuple of [result, error]. | ForgetConfig.onComplete |
| onException? | (error: Error) => void | Called when an exception occurs outside the promise itself. | ForgetConfig.onException |
| timeout? | number | Timeout in milliseconds after which the promise is considered timed out. | ForgetConfig.timeout |
| terminateOnException? | boolean | Terminate the process on an exception that happens outside of the promise being forgotten. | - |
| terminateOnTimeout? | boolean | Terminate the process if the promise times out. | - |
variables
defaultForgetNodeConfig
const defaultForgetNodeConfig: ForgetNodeConfig<unknown>;Default Node.js forget configuration with termination disabled.
Part of sdk-js
Maintainers
License
See the LICENSE file for license details
