@xylabs/forget

Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Install
Using npm:
npm install {{name}}
Using yarn:
yarn add {{name}}
Using pnpm:
pnpm add {{name}}
Using bun:
bun add {{name}}
License
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
Reference
packages
forget
### .temp-typedoc
### classes
### <a id="ForgetPromise"></a>ForgetPromise
@xylabs/forget
Node.js extension of ForgetPromise that can terminate the process on exceptions or timeouts.
Extends
Constructors
Constructor
new ForgetPromise(): ForgetPromiseNode;
Returns
ForgetPromiseNode
Inherited from
ForgetPromise.constructor
Properties
activeForgets
static activeForgets: number = 0;
Number of currently active (unresolved) forgotten promises.
Inherited from
ForgetPromise.activeForgets
exceptedForgets
static exceptedForgets: number = 0;
Number of forgotten promises that threw exceptions.
Inherited from
ForgetPromise.exceptedForgets
logger
static logger: Logger = console;
Logger instance used for error and warning output.
Inherited from
ForgetPromise.logger
Accessors
active
Get Signature
get static active(): boolean;
Whether any forgotten promises are still active.
Returns
boolean
Inherited from
ForgetPromise.active
Methods
awaitInactive()
static awaitInactive(interval?, timeout?): Promise<number>;
Waits until all forgotten promises have completed.
Parameters
interval?
number = 100
Polling interval in milliseconds.
timeout?
number
Optional maximum wait time in milliseconds.
Returns
Promise<number>
The number of remaining active forgets (0 if all completed).
Inherited from
ForgetPromise.awaitInactive
exceptionHandler()
static exceptionHandler(
error,
config,
externalStackTrace?): void;
Handles exceptions, optionally terminating the process based on config.
Parameters
error
Error
config
ForgetNodeConfig
externalStackTrace?
string
Returns
void
Overrides
ForgetPromise.exceptionHandler
forget()
static forget<T>(promise, config?): void;
Forgets a promise using Node.js-specific configuration with process termination support.
Type Parameters
T
T
Parameters
promise
Promisable<T>
config?
ForgetNodeConfig<T>
Returns
void
Overrides
ForgetPromise.forget
timeoutHandler()
static timeoutHandler(
time,
config,
externalStackTrace?): void;
Handles timeouts, optionally terminating the process based on config.
Parameters
time
number
config
ForgetNodeConfig
externalStackTrace?
string
Returns
void
Overrides
ForgetPromise.timeoutHandler
### functions
### <a id="forget"></a>forget
@xylabs/forget
function forget<T>(promise, config?): void;
Node.js variant of forget that can optionally terminate the process on exceptions or timeouts.
Type Parameters
T
T
Parameters
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
### <a id="ForgetNodeConfig"></a>ForgetNodeConfig
@xylabs/forget
Node.js-specific forget configuration that extends ForgetConfig with process termination options.
Extends
Type Parameters
T
T = any
Properties
name?
optional name?: string;
Optional name for identifying the forgotten promise in logs.
Inherited from
ForgetConfig.name
onCancel?
optional onCancel?: () => void;
Called when the promise is cancelled due to timeout.
Returns
void
Inherited from
ForgetConfig.onCancel
onComplete?
optional onComplete?: (result) => void;
Called when the promise completes, with a tuple of [result, error].
Parameters
result
[T | undefined, Error | undefined]
Returns
void
Inherited from
ForgetConfig.onComplete
onException?
optional onException?: (error) => void;
Called when an exception occurs outside the promise itself.
Parameters
error
Error
Returns
void
Inherited from
ForgetConfig.onException
timeout?
optional timeout?: number;
Timeout in milliseconds after which the promise is considered timed out.
Inherited from
ForgetConfig.timeout
terminateOnException?
optional terminateOnException?: boolean;
Terminate the process on an exception that happens outside of the promise being forgotten.
terminateOnTimeout?
optional terminateOnTimeout?: boolean;
Terminate the process if the promise times out.
### variables
### <a id="defaultForgetNodeConfig"></a>defaultForgetNodeConfig
@xylabs/forget
const defaultForgetNodeConfig: ForgetNodeConfig<unknown>;
Default Node.js forget configuration with termination disabled.