Function
parseJSONUncached
(json: string, shouldLogError: boolean)
Source from the content-addressed store, hash-verified
| 29 | const PARSE_CACHE_MAX_KEY_BYTES = 8 * 1024 |
| 30 | |
| 31 | function parseJSONUncached(json: string, shouldLogError: boolean): CachedParse { |
| 32 | try { |
| 33 | return { ok: true, value: JSON.parse(stripBOM(json)) } |
| 34 | } catch (e) { |
| 35 | if (shouldLogError) { |
| 36 | logError(e) |
| 37 | } |
| 38 | return { ok: false } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | const parseJSONCached = memoizeWithLRU(parseJSONUncached, json => json, 50) |
| 43 | |
Tested by
no test coverage detected