alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
23 lines (21 loc) • 554 B
JavaScript
import {
atom
} from "../../chunks/chunk-OBOPLPUQ.js";
import "../../chunks/chunk-U5RRZUYZ.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
};