1 | # Installation
|
2 | > `npm install --save @types/continuation-local-storage`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for continuation-local-storage (https://github.com/othiym23/node-continuation-local-storage).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/continuation-local-storage.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/continuation-local-storage/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for continuation-local-storage 3.2
|
12 | // Project: https://github.com/othiym23/node-continuation-local-storage
|
13 | // Definitions by: Jang-Ho Hwang <https://github.com/rath>
|
14 | // Kei Son <https://github.com/heycalmdown>
|
15 | // Dmitry Kudryavtsev <https://github.com/skwee357>
|
16 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
17 | // TypeScript Version: 2.1
|
18 |
|
19 | /// <reference types="node" />
|
20 |
|
21 | export type Context = {
|
22 | [key: string]: any;
|
23 | };
|
24 |
|
25 | export type BindCallbackFn<T> = (...args: any[]) => T;
|
26 | export type RunCallbackFn<T> = (context: Context) => T;
|
27 |
|
28 | export interface Namespace {
|
29 | readonly name: string; // Note: this is readonly because changing it does not actually rename it
|
30 |
|
31 | readonly active: Context; // Note: this is readonly because changing it manually will break functionality
|
32 | createContext(): Context;
|
33 |
|
34 | set<T>(key: string, value: T): T;
|
35 | get<T>(key: string): T | undefined;
|
36 |
|
37 | run<T = void>(callback: RunCallbackFn<T>): Context;
|
38 | runAndReturn<T>(callback: RunCallbackFn<T>): T;
|
39 |
|
40 | bind<T = void>(callback: BindCallbackFn<T>, context?: Context): BindCallbackFn<T>;
|
41 | bindEmitter(emitter: NodeJS.EventEmitter): void;
|
42 |
|
43 | enter(context: Context): void;
|
44 | exit(context: Context): void;
|
45 | }
|
46 |
|
47 | export function createNamespace(name: string): Namespace;
|
48 | export function getNamespace(name: string): Namespace | undefined;
|
49 | export function destroyNamespace(name: string): void;
|
50 | export function reset(): void;
|
51 |
|
52 | // declare namespace process {
|
53 | // var namespaces: ContinuationLocalStorage.Namespace[];
|
54 | // }
|
55 |
|
56 | ````
|
57 |
|
58 | ### Additional Details
|
59 | * Last updated: Mon, 04 Sep 2023 15:41:10 GMT
|
60 | * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
61 | * Global values: none
|
62 |
|
63 | # Credits
|
64 | These definitions were written by [Jang-Ho Hwang](https://github.com/rath), [Kei Son](https://github.com/heycalmdown), and [Dmitry Kudryavtsev](https://github.com/skwee357).
|
65 |
|
\ | No newline at end of file |