UNPKG

2.44 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/continuation-local-storage`
3
4# Summary
5This package contains type definitions for continuation-local-storage (https://github.com/othiym23/node-continuation-local-storage).
6
7# Details
8Files 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
21export type Context = {
22 [key: string]: any
23};
24
25export type BindCallbackFn<T> = (...args: any[]) => T;
26export type RunCallbackFn<T> = (context: Context) => T;
27
28export 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
47export function createNamespace(name: string): Namespace;
48export function getNamespace(name: string): Namespace | undefined;
49export function destroyNamespace(name: string): void;
50export function reset(): void;
51
52// declare namespace process {
53// var namespaces: ContinuationLocalStorage.Namespace[];
54// }
55
56````
57
58### Additional Details
59 * Last updated: Thu, 23 Dec 2021 23:34:26 GMT
60 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
61 * Global values: none
62
63# Credits
64These 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