MCPcopy
hub / github.com/freshframework/fresh / hashContent

Function hashContent

packages/fresh/src/dev/dev_build_cache.ts:414–426  ·  view source on GitHub ↗
(
  // This error poppued up since TS 5.9.2 but not sure why
  // deno-lint-ignore no-explicit-any
  content: Uint8Array<any> | ReadableStream<Uint8Array>,
)

Source from the content-addressed store, hash-verified

412 `// WARNING: DO NOT EDIT THIS FILE. It is autogenerated by Fresh.`;
413
414export async function hashContent(
415 // This error poppued up since TS 5.9.2 but not sure why
416 // deno-lint-ignore no-explicit-any
417 content: Uint8Array<any> | ReadableStream<Uint8Array>,
418): Promise<string> {
419 const buffer = await new Response(content).arrayBuffer();
420
421 const hashBuf = await crypto.subtle.digest(
422 "SHA-256",
423 buffer,
424 );
425 return encodeHex(hashBuf);
426}
427
428export function getContentType(filePath: string): string {
429 const ext = path.extname(filePath);

Callers 3

resolveIdFunction · 0.85
loadFunction · 0.85
handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected