Skip to content

resources-dedupe.ts#

View Markdown

Source

4 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

4 symbols 3 functions 1 modules 9 parameters 3 returns

Reference#

fnhashResourceFile(filePath: string, ext: string, store: ResourceDedupeStore, reuseKey: string): Promise<string>SHA-256 of emitted bytes plus a NUL and the serving extension so the same paylo…

SHA-256 of emitted bytes plus a NUL and the serving extension so the same payload cannot be served under an incompatible media type.

Signature

export async function hashResourceFile(filePath: string, ext: string, store: ResourceDedupeStore, reuseKey: string): Promise<string>

View source

Parameters

  • filePath string
  • ext string
  • store ResourceDedupeStore
  • reuseKey string

Returns

Promise<string>
fnlinkOrCopyAlias(canonical: string, alias: string, linker: typeof fs.link = fs.link): Promise<"link" | "copy">Prefer a hard link at the original output path. link failure removes any stale…

Prefer a hard link at the original output path. link failure removes any stale alias and copies so a shared inode is never overwritten.

Signature

export async function linkOrCopyAlias(canonical: string, alias: string, linker: typeof fs.link = fs.link): Promise<"link" | "copy">

View source

Parameters

  • canonical string
  • alias string
  • linker typeof fs.link

    optional · default: fs.link

Returns

Promise<"link" | "copy">
moduleresources-dedupeSite-wide content-addressed emit for identical page-resource bytes. Hashing streams the file. The first digest+extensio…

Site-wide content-addressed emit for identical page-resource bytes.

Hashing streams the file. The first digest+extension pair writes once; later pages reuse that path. Image decode is never used here.

View source

fnrewriteToCanonicalUrl(originalSrc: string, canonicalPath: string): stringKeep leftover search/hash; drop consumed transform params.

Keep leftover search/hash; drop consumed transform params.

Signature

export function rewriteToCanonicalUrl(originalSrc: string, canonicalPath: string): string

View source

Parameters

  • originalSrc string
  • canonicalPath string

Returns

string