MCPcopy Create free account
hub / github.com/decaporg/decap-cms / readFile

Function readFile

packages/decap-cms-lib-util/src/API.ts:258–275  ·  view source on GitHub ↗
(
  id: string | null | undefined,
  fetchContent: () => Promise<string | Blob>,
  localForage: LocalForage,
  isText: boolean,
)

Source from the content-addressed store, hash-verified

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

Callers 6

APIClass · 0.90
readFileMethod · 0.90
APIClass · 0.90
APIClass · 0.90
fetchFilesFunction · 0.85
getMediaAsBlobFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected