continuation-local-variable
Variables scoped by a chain of asynchrounous calls
How it works
const Variable = ; const User = Variable; User; ; // User name will be 'Larry' for the chain of async operations // starting with `setTimeout` User; sets ; // User name is 'Curly' for the async chain starting with the next `setTimeout` User; ;
Requirements
NodeJS 8.9 or above
API Reference
Variable.create(variableName)
Creates a new async scoped variable
Variable.find(variableName)
Finds an existing variable
Variable.set(value)
Sets the value of the variable. This value will hold for the duration of the next asynchronous call chain.
Variable.get()
Returns the value of this variable.