@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
28 lines • 1 kB
JavaScript
/**
* @module ExecutionContext
*/
import { AsyncLocalStorage } from "node:async_hooks";
import {} from "../../../../execution-context/contracts/_module.js";
import {} from "../../../../utilities/_module.js";
/**
* IMPORT_PATH: `"@daiso-tech/core/execution-context/als-execution-context-adapter"`
*
* Execution context adapter using Node.js AsyncLocalStorage.
*
* This adapter implements context storage using Node.js's AsyncLocalStorage API,
* which provides automatic context propagation across async boundaries.
* It ensures context values are maintained correctly through promises, callbacks,
* and other asynchronous operations.
*
* Recommended for Node.js environments where async context isolation is needed.
*/
export class AlsExecutionContextAdapter {
als = new AsyncLocalStorage();
get() {
return this.als.getStore() ?? null;
}
run(context, fn) {
return this.als.run(context, fn);
}
}
//# sourceMappingURL=als-execution-context-adapter.js.map