Packages

Lazily initialised constants for Gleam

Current section

Files

Jump to
lazy_const src lazy_const_ffi.mjs
Raw

src/lazy_const_ffi.mjs

const cache = new Map();
export default function(outer, inner) {
let value = cache.get(outer);
if (value === undefined) {
value = inner();
cache.set(outer, value);
}
return value;
}