antongolub/npm-registry-firewall

View on GitHub
src/main/js/als.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import {AsyncLocalStorage} from 'node:async_hooks'

export const als = new AsyncLocalStorage()
export const getCtx = () => als.getStore() || {}
export const mixCtx = (mixin) => Object.assign(getCtx(), mixin)
export const runInCtx = (ctx, cb) => als.run(ctx, cb)