import { getOrMakeEntry } from "@effect/core/stm/TRef/operations/_internal/getOrMakeEntry" /** * Sets the value of the `TRef` and returns the old value. * * @tsplus static effect/core/stm/TRef.Aspects getAndSet * @tsplus pipeable effect/core/stm/TRef getAndSet */ export function getAndSet(value: A) { return (self: TRef): STM => STM.Effect((journal) => { const entry = getOrMakeEntry(self, journal) const oldValue = entry.use((_) => _.unsafeGet()) entry.use((_) => _.unsafeSet(value)) return oldValue }) }