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