Add context util

This commit is contained in:
Jon Staab
2024-03-25 15:02:29 -07:00
parent 54e0775453
commit eb9c778a66
2 changed files with 14 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
const ctx = new Map<string, any>()
export const getContext = (k: string) => ctx.get(k)
export const setContext = (k: string, d: any) => ctx.set(k, d)
export const withContext = (k: string, d: any, f: () => void) => {
const o = ctx.get(k)
ctx.set(k, d)
f()
ctx.set(k, o)
}
+1
View File
@@ -1,3 +1,4 @@
export * from './Context'
export * from './Deferred' export * from './Deferred'
export * from './Emitter' export * from './Emitter'
export * from './Fluent' export * from './Fluent'