UNPKG

monocle-ts

Version:

A porting of scala monocle library to TypeScript

27 lines (26 loc) 686 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.atRecord = void 0; /** * @since 1.7.0 */ var __1 = require(".."); var Option_1 = require("fp-ts/lib/Option"); var R = require("fp-ts/lib/Record"); /** * @category constructor * @since 1.7.0 */ function atRecord() { return new __1.At(function (k) { return new __1.Lens(function (r) { return R.lookup(k, r); }, function (oa) { return function (r) { if ((0, Option_1.isNone)(oa)) { return R.deleteAt(k)(r); } else { return R.insertAt(k, oa.value)(r); } }; }); }); } exports.atRecord = atRecord;