di-tory
Version:
Compose applications with dependency injection
21 lines (20 loc) • 581 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const async_hooks_1 = require("async_hooks");
const diAsyncStorage = new async_hooks_1.AsyncLocalStorage();
const enter = () => {
diAsyncStorage.enterWith(new WeakMap());
};
const run = (fn) => {
return diAsyncStorage.run(new WeakMap(), fn);
};
const getStore = () => { var _a; return (_a = diAsyncStorage.getStore()) !== null && _a !== void 0 ? _a : new WeakMap(); };
const exit = () => {
diAsyncStorage.exit(() => { });
};
exports.default = {
enter,
run,
getStore,
exit,
};