fix(core): update
This commit is contained in:
17
ts/index.ts
17
ts/index.ts
@ -1,3 +1,18 @@
|
||||
import * as plugins from './smartcls.plugins';
|
||||
|
||||
export * from 'continuation-local-storage';
|
||||
export class SmartCls {
|
||||
private asyncLocalStorage = new plugins.AsyncLocalStorage();
|
||||
public run(runFunc: () => any) {
|
||||
this.asyncLocalStorage.run({}, runFunc);
|
||||
}
|
||||
|
||||
public set(keyArg: string, valueArg: any) {
|
||||
const store: any = this.asyncLocalStorage.getStore();
|
||||
store[keyArg] = valueArg;
|
||||
}
|
||||
|
||||
public get(keyArg: string) {
|
||||
const store: any = this.asyncLocalStorage.getStore();
|
||||
return store[keyArg];
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import * as cls from 'continuation-local-storage';
|
||||
// native scope
|
||||
import { AsyncLocalStorage } from 'async_hooks';
|
||||
|
||||
export { cls };
|
||||
export { AsyncLocalStorage };
|
||||
|
Reference in New Issue
Block a user