import * as tsplus_module_1 from "@effect/core/io/Effect/operations/whenEffect";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/unit";
import * as tsplus_module_3 from "@effect/core/io/Ref/operations/make";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/map";
/**
 * Returns an effect that will be executed at most once, even if it is
 * evaluated multiple times.
 *
 * @tsplus fluent ets/Effect once
 */

export function once(self, __tsplusTrace) {
  return tsplus_module_4.map_(tsplus_module_3.makeRef(() => true, __tsplusTrace), ref => tsplus_module_2.unit_(tsplus_module_1.whenEffect(() => ref.getAndSet(false, __tsplusTrace), () => self, __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=once.mjs.map