
node-async-context
This module allows you to create a asynchronouse execution context for JavaScript or TypeScript
NOTE: This module is based on async-hook, which in turn is based
on the undocumented API AsyncWrap
This is the reason why async-hook will show this warning on startup:
WARNING: 'you are using async-hook which is unstable.'
NOTE: Your contribution is highly welcome!
Introduction
To give you an idea of how node-async-context is supposed to be used:
import { ContinuationLocalStorage } from 'asyncctx';
class MyLocalStorage {
value: number;
}
let cls = new ContinuationLocalStorage<MyLocalStorage>();
process.nextTick(() => {
cls.setData({ value: 1});
process.nextTick(() => {
let curr1 = cls.getData();
cls.setData({ value: 2});
process.nextTick(() => {
let curr2 = cls.getData();
});
});
process.nextTick(() => {
let curr3 = cls.getData();
});
});
License
node-async-context is licensed under the MIT License:
LICENSE
Release Notes
Release | Notes |
---|
0.0.1 | initial version |
Downloads
