Public
Script
March 29, 2024
1
2
3
4
5
6
7
8
9
10
import { blob } from "https://esm.town/v/std/blob";
import { ValTownBlobNotFoundError } from "https://esm.town/v/std/ValTownBlobNotFoundError";
export async function generateOnce<S>(fn: () => S | PromiseLike<S>, key): Promise<S> {
let value: any = await blob.getJSON(key);
if (value) return value;
value = await fn();
await blob.setJSON(key, value);
return value;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 29, 2024