StaticgetRetrieves the current store.
The current store or undefined if there is no store.
StaticgetRetrieves a value from the store by key.
The value associated with the key, or undefined if the key does not exist.
StaticsetSets a value in the store by key.
StaticrunRuns a function within a new store context.
Optionaldefaults: Dictionary<any, any>The result of the function.
StaticexitExperimentalExits the current store context and runs a function. Marked experimental as it depends on AsyncLocalStorage#exit
The result of the function.
StaticbindStaticenterExperimentalEnters a new store context with the given default values. Marked experimental as it depends on AsyncLocalStorage#enterWith
Optionaldefaults: Dictionary<any, any>Runs a function within a new store context.
The function to run.
Optionaldefaults: Dictionary<any, any>The default values to initialize the store with.
The result of the function.
ExperimentalExits the current store context and runs a function. Marked experimental as it depends on AsyncLocalStorage#exit
The function to run.
The result of the function.
ExperimentalDisables the instance of ALS and its underlying AsyncLocalStorage instance. See AsyncLocalStorage#disable for implications. Marked experimental as it depends on AsyncLocalStorage#disable
ExperimentalBinds a function to the current store context. Marked experimental as it depends on AsyncLocalStorage.bind
The function to bind.
The bound function.
ExperimentalEnters a new store context with the given default values. Marked experimental as it depends on AsyncLocalStorage#enterWith
Optionaldefaults: Dictionary<any, any>The default values to initialize the store with.
Retrieves the current store.
The current store or undefined if there is no store.
Retrieves a value from the store by key.
The key to retrieve the value for.
The value associated with the key, or undefined if the key does not exist.
Sets a value in the store by key.
The key to set the value for.
The value to set.
An extension of ALS that also acts as a singleton instance through same-named static methods. The singleton pattern is convenient for basic applications that don't need multiple stores.
Example
Template: K
The type of keys in the store.
Template: V
The type of values in the store.