monocle-ts-esm
Version:
A porting of scala monocle library to TypeScript
26 lines (25 loc) • 648 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.indexArray = void 0;
/**
* @since 1.2.0
*/
const __1 = require("..");
const Array_1 = require("fp-ts-esm/Array");
const Option_1 = require("fp-ts-esm/Option");
/**
* @category constructor
* @since 1.2.0
*/
function indexArray() {
return new __1.Index((i) => new __1.Optional((as) => (0, Array_1.lookup)(i, as), (a) => (as) => {
const oas = (0, Array_1.updateAt)(i, a)(as);
if ((0, Option_1.isNone)(oas)) {
return as;
}
else {
return oas.value;
}
}));
}
exports.indexArray = indexArray;