// @ts-check import fs from "node:fs"; import { fsCachePath } from "../../utils/runtimeChecks.js"; export async function getCachedBuffer(hash, image) { const cacheFilePath = fsCachePath + hash; if (fs.existsSync(cacheFilePath)) { return fs.promises.readFile(cacheFilePath); } const buffer = await image.clone().toBuffer(); await fs.promises.writeFile(cacheFilePath, buffer); return buffer; }