UNPKG

@meta-commons/meta-context-local-storage

Version:

Is a Node.js package that allows you to create asynchronous local storage for managing context that is scoped to the duration of an asynchronous operation.

15 lines (14 loc) 613 B
import { ClsContextNamespace } from './cls-context-namespaces'; interface Context { [key: string]: unknown; } declare class LocalStorageContext { private storage; run(next: Function): Promise<void>; setContext(namespace: ClsContextNamespace | string, context: Context): void; getContext(namespace?: ClsContextNamespace | string): Context; setContextValue(key: string, value: unknown, namespace?: ClsContextNamespace): void; getContextValue<T>(key: string, namespace?: ClsContextNamespace): T | undefined; } declare const StorageContext: LocalStorageContext; export { StorageContext };