Skip to content

Instantly share code, notes, and snippets.

View fjpedrosa's full-sized avatar

F.J. Pedrosa fjpedrosa

View GitHub Profile
@fjpedrosa
fjpedrosa / blurhashDataURL.ts
Created June 16, 2024 08:59 — forked from gxvxc/blurhashDataURL.ts
Convert blurhash to a base64 DataURL string (no canvas or node-canvas)
import { decode } from "blurhash"
const cache: Record<string, string> = {}
export function blurHashToDataURL(hash: string | undefined): string | undefined {
if (!hash) return undefined
const cachedBlurDataURL = cache[hash]
if(cachedBlurDataURL) {