alinea
Version:
Headless git-based CMS
22 lines (20 loc) • 550 B
JavaScript
import {
atom
} from "../../chunks/chunk-WJ67RR7S.js";
import "../../chunks/chunk-NZLE2WMY.js";
// src/dashboard/util/Atoms.ts
var cached = /* @__PURE__ */ new WeakMap();
function peek(readable) {
if (cached.has(readable)) return cached.get(readable);
const currentAtom = atom(void 0);
const resultAtom = atom(
(get) => get(currentAtom) || get(readable),
(get, set) => set(currentAtom, get(readable))
);
resultAtom.onMount = (dispatch) => dispatch();
cached.set(readable, resultAtom);
return resultAtom;
}
export {
peek
};