decline-ts
Version:
Composable command-line parser for TypeScript - a (partial) porting of Scala decline using fp-ts
15 lines (14 loc) • 945 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidatedNea = void 0;
const fp_ts_1 = require("fp-ts");
const function_1 = require("fp-ts/function");
var ValidatedNea;
(function (ValidatedNea) {
ValidatedNea.right = (a) => fp_ts_1.either.right(a);
ValidatedNea.left = (e) => fp_ts_1.either.left(fp_ts_1.readonlyNonEmptyArray.of(e));
ValidatedNea.fromEither = fp_ts_1.either.mapLeft(fp_ts_1.readonlyNonEmptyArray.of);
ValidatedNea.fromOption = (onNone) => function_1.flow(fp_ts_1.either.fromOption(onNone), ValidatedNea.fromEither);
ValidatedNea.fromEmptyE = (e) => fp_ts_1.either.mapLeft(function_1.flow(fp_ts_1.readonlyNonEmptyArray.fromReadonlyArray, fp_ts_1.option.getOrElse(() => fp_ts_1.readonlyNonEmptyArray.of(e))));
ValidatedNea.fromEmptyErrors = ValidatedNea.fromEmptyE('Got empty Errors from codec');
})(ValidatedNea = exports.ValidatedNea || (exports.ValidatedNea = {}));