A lightweight library for managing async context in Node.js using the experimental async_hooks API. It provides a namespace-based approach to create, get, and delete contexts, as well as a default context for simpler use cases. Key features include scope-based execution, get/set value storage, and explicit enable/destroy lifecycle control. Current stable version is 6.0.9, released under MIT license. Release cadence is sporadic, with major version bumps often indicating breaking changes. Differentiators from similar packages (e.g., cls-hooked, async_hooks) include a simpler API with namespaces and direct context.get/set methods, but note reliance on the experimental async_hooks API which may change in future Node.js versions.
npm install appolo-contextNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of the default context: initialize, set, get, and scope.
Call context.initialize() or namespace.create().initialize() before any read/write operations.
Always await the promise returned by context.scope() or use async/await inside the callback.
Use string names for namespaces: namespace.create('myContext').Explicitly call context.destroy() after the scope ends, or reuse the context carefully.
Use ES module imports with named exports: import { context, namespace } from 'appolo-context'.Use named import: import { context } from 'appolo-context'Use ES module imports or use .default for CJS interop: const context = require('appolo-context').context;Add call to context.initialize() before any use.
No dependency data recorded yet.