1import * as _ from 'lodash-es' 10export const jsonMemoFile = async <T = unknown,>(path : absFileDirPath, calcFn : () => Promise<T> | T, alwaysWrite = false) => { 12 if (!alwaysWrite && contents) { 13 return {cacheHit: true, jsonH: json1Parse(contents) as T} 15 const resObj = await calcFn() 17 return {cacheHit: false, jsonH: resObj} 20export const runMemoTempfile = async <T = unknown,>({cacheKeyA} : {cacheKeyA: string | string[]}, calcFn : () => Promise<T> | T): Promise<T> => { 23 return (await jsonMemoFile(cachedResPath, calcFn)).jsonH 26export const runMemoTempfileWithHit = async <T = unknown,>({cacheKeyA} : {cacheKeyA: string | string[]}, calcFn : () => Promise<T> | T) => { 29 const {cacheHit, jsonH} = await jsonMemoFile(cachedResPath, calcFn) 30 return {cacheHit, value: jsonH} 33export const readMemoTempfileIfExist = async <T = unknown,>({cacheKeyA} : {cacheKeyA: string | string[]}): Promise<T | undefined> => {