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