INNER CODE UNIT · TypeScript

hex

gimlet-io/capacitor · bundle.ts:8

    const hex = Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
    return hex.slice(0, 8);
}

async function hashAndRenameCss(): Promise<string | null> {
    const cssDir = "bundle/styles";
    const baseName = "main.css";
    const basePath = `${cssDir}/${baseName}`;

    try {
        const cssContent = await Deno.readFile(basePath);
        const digest = await crypto.subtle.digest("SHA-256", cssContent);
        const shortHash = toShortHex(digest);
        const hashedName = `main-${shortHash}.css`;
        const hashedPath = `${cssDir}/${hashedName}`;

        // Write/overwrite hashed file
        await Deno.writeFile(hashedPath, cssContent);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…