1 |
|
2 |
|
3 | import { EventEmitter } from "events";
|
4 |
|
5 | export interface Namespace<N = Record<string, any>> {
|
6 | active: any;
|
7 |
|
8 | set<K extends keyof N = keyof N>(key: K, value: N[K]): N[K];
|
9 | get<K extends keyof N = keyof N>(key: K): N[K];
|
10 | run(fn: (...args: any[]) => void): void;
|
11 | runAndReturn<T>(fn: (...args: any[]) => T): T;
|
12 | runPromise<T>(fn: (...args: any[]) => Promise<T>): Promise<T>;
|
13 | bind<F extends Function>(fn: F, context?: any): F; // eslint-disable-line @typescript-eslint/no-unsafe-function-type
|
14 | bindEmitter(emitter: EventEmitter): void;
|
15 | createContext(): any;
|
16 | enter(context: any): void;
|
17 | exit(context: any): void;
|
18 | }
|
19 |
|
20 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
21 | export function createNamespace<N = Record<string, any>>(name: string): Namespace<N>;
|
22 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
23 | export function getNamespace<N = Record<string, any>>(name: string): Namespace<N> | undefined;
|
24 | export function destroyNamespace(name: string): void;
|
25 | export function reset(): void;
|
26 |
|
\ | No newline at end of file |