"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.locally = void 0;
// ets_tracing: off
const bracket_1 = require("../Effect/bracket");
const core_1 = require("../Effect/core");
const Function_1 = require("../Function");
const get_1 = require("./get");
const set_1 = require("./set");
/**
 * Returns an `IO` that runs with `value` bound to the current fiber.
 *
 * Guarantees that fiber data is properly restored via `bracket`.
 */
const locally = (value) => (use) => (fiberRef) => ((0, core_1.chain)((oldValue) => (0, bracket_1.bracket_)((0, set_1.set)(value)(fiberRef), () => use, () => (0, set_1.set)(oldValue)(fiberRef)))((0, get_1.get)(fiberRef)));
exports.locally = locally;
//# sourceMappingURL=locally.js.map