import * as tsplus_module_1 from "@tsplus/stdlib/data/Maybe/getOrElse";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_3 from "@effect/core/io/FiberRef/operations/modify";
/**
 * Atomically modifies the `FiberRef` with the specified partial function.
 * If the function is undefined on the current value it returns the old
 * value without changing it.
 *
 * @tsplus fluent ets/FiberRef updateSomeAndGet
 */

export function updateSomeAndGet_(self, pf, __tsplusTrace) {
  return tsplus_module_3.modify_(self, v => {
    const result = tsplus_module_1.getOrElse_(pf(v), () => v);
    return tsplus_module_2.make(result, result);
  }, __tsplusTrace);
}
/**
 * Atomically modifies the `FiberRef` with the specified partial function.
 * If the function is undefined on the current value it returns the old
 * value without changing it.
 *
 * @tsplus static ets/FiberRef/Aspects updateSomeAndGet
 */

export const updateSomeAndGet = (pf, __tsplusTrace) => self => updateSomeAndGet_(self, pf, __tsplusTrace);
//# sourceMappingURL=updateSomeAndGet.mjs.map