UNPKG

monocle-ts-esm

Version:

A porting of scala monocle library to TypeScript

27 lines (26 loc) 752 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.indexNonEmptyArray = void 0; /** * @since 1.5.0 */ const __1 = require(".."); const NonEmptyArray_1 = require("fp-ts-esm/NonEmptyArray"); const Array_1 = require("fp-ts-esm/Array"); const Option_1 = require("fp-ts-esm/Option"); /** * @category constructor * @since 1.5.0 */ function indexNonEmptyArray() { return new __1.Index((i) => new __1.Optional((s) => (0, Array_1.lookup)(i, s), (a) => (nea) => { const onea = (0, NonEmptyArray_1.updateAt)(i, a)(nea); if ((0, Option_1.isNone)(onea)) { return nea; } else { return onea.value; } })); } exports.indexNonEmptyArray = indexNonEmptyArray;