
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
This module allows you to create an asynchronous execution context for JavaScript or TypeScript
NOTE: This module is based on async_hooks an experimental built-in node.js module introduced in v8.0.0
NOTE: This module is now deprecated in favour of AsyncLocalStorage which is available for nodejs >= 12
class ContinuationLocalStorage<T> extends AsyncLocalStorage<T> {
public getContext(): T | undefined {
return this.getStore();
}
public setContext(value: T): T {
this.enterWith(value);
return value;
}
}
To give you an idea of how asyncctx is supposed to be used:
import { ContinuationLocalStorage } from 'asyncctx';
class MyLocalStorage {
value: number;
}
let cls = new ContinuationLocalStorage<MyLocalStorage>();
cls.setRootContext({ value: 1 });
process.nextTick(() => {
let curr1 = cls.getContext(); // value is 1
cls.setContext({ value: 2 }); // value should be 2 in the current execution context and below
process.nextTick(() => {
let curr2 = cls.getContext(); // value is 2
cls.setContext({ value: 3 }); // value should be 3 in the current execution context and below
process.nextTick(() => {
let curr3 = cls.getContext(); // value is 3
});
});
process.nextTick(() => {
let curr4 = cls.getContext(); // value is 2
});
});
node-async-context (asyncctx) is licensed under the MIT License: LICENSE
FAQs
an asynchronous execution context for TypeScript/JavaScript
The npm package asyncctx receives a total of 1,104 weekly downloads. As such, asyncctx popularity was classified as popular.
We found that asyncctx demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.