MCPcopy Create free account
hub / github.com/effect-app/libs / makeContextMap

Function makeContextMap

packages/effect-app/src/Store.ts:137–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135}
136
137export const makeContextMap = () => {
138 const etags = new Map<string, string>()
139 const getEtag = (id: string) => etags.get(id)
140 const setEtag = (id: string, eTag: string | undefined) => {
141 if (eTag === undefined) {
142 etags.delete(id)
143 } else {
144 etags.set(id, eTag)
145 }
146 }
147
148 // const parsedCache = new Map<
149 // Parser<any, any, any>,
150 // Map<unknown, These.These<unknown, unknown>>
151 // >()
152
153 // const parserCache = new Map<
154 // Parser<any, any, any>,
155 // (i: any) => These.These<any, any>
156 // >()
157
158 // const setAndReturn = <I, E, A>(
159 // p: Parser<I, E, A>,
160 // np: (i: I) => These.These<E, A>
161 // ) => {
162 // parserCache.set(p, np)
163 // return np
164 // }
165
166 // const parserEnv: ParserEnv = {
167 // // TODO: lax: true would turn off refinement checks, may help on large payloads
168 // // but of course removes confirming of validation rules (which may be okay for a database owned by the app, as we write safely)
169 // lax: false,
170 // cache: {
171 // getOrSetParser: (p) => parserCache.get(p) ?? setAndReturn(p, (i) => parserEnv.cache!.getOrSet(i, p)),
172 // getOrSetParsers: (parsers) => {
173 // return Object.entries(parsers).reduce((prev, [k, v]) => {
174 // prev[k] = parserEnv.cache!.getOrSetParser(v)
175 // return prev
176 // }, {} as any)
177 // },
178 // getOrSet: (i, parse): any => {
179 // const c = parsedCache.get(parse)
180 // if (c) {
181 // const f = c.get(i)
182 // if (f) {
183 // // console.log("$$$ cache hit", i)
184 // return f
185 // } else {
186 // const nf = parse(i, parserEnv)
187 // c.set(i, nf)
188 // return nf
189 // }
190 // } else {
191 // const nf = parse(i, parserEnv)
192 // parsedCache.set(parse, new Map([[i, nf]]))
193 // return nf
194 // }

Callers 1

Store.tsFile · 0.85

Calls 5

clearMethod · 0.80
makeFunction · 0.70
getMethod · 0.65
setMethod · 0.65
withPermitsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…