( id: string | null | undefined, fetchContent: () => Promise<string | Blob>, localForage: LocalForage, isText: boolean, )
| 253 | } |
| 254 | |
| 255 | export async function readFile( |
| 256 | id: string | null | undefined, |
| 257 | fetchContent: () => Promise<string | Blob>, |
| 258 | localForage: LocalForage, |
| 259 | isText: boolean, |
| 260 | ) { |
| 261 | const key = id ? (isText ? `gh.${id}` : `gh.${id}.blob`) : null; |
| 262 | const cached = key ? await localForage.getItem<string | Blob>(key) : null; |
| 263 | if (cached) { |
| 264 | return cached; |
| 265 | } |
| 266 | |
| 267 | const content = await fetchContent(); |
| 268 | if (key) { |
| 269 | await localForage.setItem(key, content); |
| 270 | } |
| 271 | return content; |
| 272 | } |
| 273 | |
| 274 | export type FileMetadata = { |
| 275 | author: string; |
no outgoing calls
no test coverage detected