fix(core): update

This commit is contained in:
2020-07-20 07:39:47 +00:00
parent 613e0837ad
commit 189f6623c4
17 changed files with 11218 additions and 480 deletions

View File

@ -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];
}
}

View File

@ -1,3 +1,4 @@
import * as cls from 'continuation-local-storage';
// native scope
import { AsyncLocalStorage } from 'async_hooks';
export { cls };
export { AsyncLocalStorage };