Very small utility for at-most-once evaluation. It is useful for defining a fetch that may be expensive for a value that won't change.
Example of using the once function:
// getThing has type () => Thing
const getThing = once<Thing>(() => {
return ...; // This will run at most once
});It is fine if the fetch is asynchronous. This works too:
// getThing has type () => Promise<Thing>
const getThing = once<Promise<Thing>>(async () => {
return ...;
});