Innovenergy_trunk/frontend/node_modules/monocle-ts/es6/Index/Array.js

24 lines
586 B
JavaScript
Raw Normal View History

/**
* @since 1.2.0
*/
import { Index, Optional } from '..';
import { lookup, updateAt } from 'fp-ts/es6/Array';
import { isNone } from 'fp-ts/es6/Option';
/**
* @category constructor
* @since 1.2.0
*/
export function indexArray() {
return new Index(function (i) {
return new Optional(function (as) { return lookup(i, as); }, function (a) { return function (as) {
var oas = updateAt(i, a)(as);
if (isNone(oas)) {
return as;
}
else {
return oas.value;
}
}; });
});
}