Contexty

Asynchronous “thread-local storage” for Node.js

Home ···· Cheap Watch · do-not-zip.js · npm2git.sh · Defiler · Cheap TS · Memor · Contexty ···· Sites · Other

on → Git | GitHub | GitLab | Bitbucket | npm

npm install git+https://chor.date/contexty#semver:*

CONTEXTY is a probably overly simplistic "thread-local storage" implementation for the actually single-threaded Node.js.
It uses brand new features of Node.js and is not very well tested.

At any point, you can declare a new context, and then anywhere later within that asynchronous call or in any descendent asynchronous call you can access that same context object.
From anywhere, you can assign or retrieve values on the context object, and these are kept throughout that conceptual asynchronous thingy, but are kept separate in different asynchronous thingies. This is a bit hard to explain.
One reasonably concrete and likely common place to apply this is in a web server, for attaching additional information to each request of the server.

Don't use this library for anything important, of course.