"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.to_ = exports.to = void 0
// tracing: off
const done_1 = require("../Promise/done")
const core_1 = require("./core")
const interruption_1 = require("./interruption")
/**
 * Returns an effect that keeps or breaks a promise based on the result of
 * this effect. Synchronizes interruption, so if this effect is interrupted,
 * the specified promise will be interrupted, too.
 *
 * @dataFirst to_
 */
function to(p, __trace) {
  return (effect) => to_(effect, p, __trace)
}
exports.to = to
/**
 * Returns an effect that keeps or breaks a promise based on the result of
 * this effect. Synchronizes interruption, so if this effect is interrupted,
 * the specified promise will be interrupted, too.
 */
function to_(effect, p, __trace) {
  return (0, interruption_1.uninterruptibleMask)(
    ({ restore }) =>
      (0, core_1.chain_)((0, core_1.result)(restore(effect)), (x) =>
        (0, done_1.done)(x)(p)
      ),
    __trace
  )
}
exports.to_ = to_
//# sourceMappingURL=to.js.map
