1 | export interface Context {
|
2 | /**
|
3 | * Get a value from the context.
|
4 | *
|
5 | * @param key key which identifies a context value
|
6 | */
|
7 | getValue(key: symbol): unknown;
|
8 | /**
|
9 | * Create a new context which inherits from this context and has
|
10 | * the given key set to the given value.
|
11 | *
|
12 | * @param key context key for which to set the value
|
13 | * @param value value to set for the given key
|
14 | */
|
15 | setValue(key: symbol, value: unknown): Context;
|
16 | /**
|
17 | * Return a new context which inherits from this context but does
|
18 | * not contain a value for the given key.
|
19 | *
|
20 | * @param key context key for which to clear a value
|
21 | */
|
22 | deleteValue(key: symbol): Context;
|
23 | }
|
24 | export interface ContextManager {
|
25 | /**
|
26 | * Get the current active context
|
27 | */
|
28 | active(): Context;
|
29 | /**
|
30 | * Run the fn callback with object set as the current active context
|
31 | * @param context Any object to set as the current active context
|
32 | * @param fn A callback to be immediately run within a specific context
|
33 | * @param thisArg optional receiver to be used for calling fn
|
34 | * @param args optional arguments forwarded to fn
|
35 | */
|
36 | with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
37 | /**
|
38 | * Bind an object as the current context (or a specific one)
|
39 | * @param [context] Optionally specify the context which you want to assign
|
40 | * @param target Any object to which a context need to be set
|
41 | */
|
42 | bind<T>(context: Context, target: T): T;
|
43 | /**
|
44 | * Enable context management
|
45 | */
|
46 | enable(): this;
|
47 | /**
|
48 | * Disable context management
|
49 | */
|
50 | disable(): this;
|
51 | }
|
52 | //# sourceMappingURL=types.d.ts.map |
\ | No newline at end of file |