UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

23 lines (21 loc) 554 B
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 };