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

Function readFile

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

Source from the content-addressed store, hash-verified

253}
254
255export 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
274export type FileMetadata = {
275 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