Innovenergy_trunk/frontend/node_modules/fp-ts/lib/pipeable.js

228 lines
8.5 KiB
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pipe = exports.pipeable = exports.compose = exports.promap = exports.partitionMapWithIndex = exports.partitionWithIndex = exports.filterMapWithIndex = exports.filterWithIndex = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.alt = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = exports.reduceRight = exports.foldMap = exports.reduce = exports.extend = exports.mapLeft = exports.bimap = exports.chain = exports.ap = exports.mapWithIndex = exports.contramap = exports.map = void 0;
var Apply_1 = require("./Apply");
var Chain_1 = require("./Chain");
var function_1 = require("./function");
function map(F) {
return function (f) { return function (fa) { return F.map(fa, f); }; };
}
exports.map = map;
function contramap(F) {
return function (f) { return function (fa) { return F.contramap(fa, f); }; };
}
exports.contramap = contramap;
function mapWithIndex(F) {
return function (f) { return function (fa) { return F.mapWithIndex(fa, f); }; };
}
exports.mapWithIndex = mapWithIndex;
function ap(F) {
return function (fa) { return function (fab) { return F.ap(fab, fa); }; };
}
exports.ap = ap;
function chain(F) {
return function (f) { return function (fa) { return F.chain(fa, f); }; };
}
exports.chain = chain;
function bimap(F) {
return function (f, g) { return function (fea) { return F.bimap(fea, f, g); }; };
}
exports.bimap = bimap;
function mapLeft(F) {
return function (f) { return function (fea) { return F.mapLeft(fea, f); }; };
}
exports.mapLeft = mapLeft;
function extend(F) {
return function (f) { return function (wa) { return F.extend(wa, f); }; };
}
exports.extend = extend;
function reduce(F) {
return function (b, f) { return function (fa) { return F.reduce(fa, b, f); }; };
}
exports.reduce = reduce;
function foldMap(F) {
return function (M) {
var foldMapM = F.foldMap(M);
return function (f) { return function (fa) { return foldMapM(fa, f); }; };
};
}
exports.foldMap = foldMap;
function reduceRight(F) {
return function (b, f) { return function (fa) { return F.reduceRight(fa, b, f); }; };
}
exports.reduceRight = reduceRight;
function reduceWithIndex(F) {
return function (b, f) { return function (fa) { return F.reduceWithIndex(fa, b, f); }; };
}
exports.reduceWithIndex = reduceWithIndex;
function foldMapWithIndex(F) {
return function (M) {
var foldMapWithIndexM = F.foldMapWithIndex(M);
return function (f) { return function (fa) { return foldMapWithIndexM(fa, f); }; };
};
}
exports.foldMapWithIndex = foldMapWithIndex;
function reduceRightWithIndex(F) {
return function (b, f) { return function (fa) { return F.reduceRightWithIndex(fa, b, f); }; };
}
exports.reduceRightWithIndex = reduceRightWithIndex;
function alt(F) {
return function (that) { return function (fa) { return F.alt(fa, that); }; };
}
exports.alt = alt;
function filter(F) {
return function (predicate) { return function (fa) { return F.filter(fa, predicate); }; };
}
exports.filter = filter;
function filterMap(F) {
return function (f) { return function (fa) { return F.filterMap(fa, f); }; };
}
exports.filterMap = filterMap;
function partition(F) {
return function (f) { return function (fa) { return F.partition(fa, f); }; };
}
exports.partition = partition;
function partitionMap(F) {
return function (f) { return function (fa) { return F.partitionMap(fa, f); }; };
}
exports.partitionMap = partitionMap;
function filterWithIndex(F) {
return function (predicate) { return function (fa) { return F.filterWithIndex(fa, predicate); }; };
}
exports.filterWithIndex = filterWithIndex;
function filterMapWithIndex(F) {
return function (f) { return function (fa) { return F.filterMapWithIndex(fa, f); }; };
}
exports.filterMapWithIndex = filterMapWithIndex;
function partitionWithIndex(F) {
return function (f) { return function (fa) { return F.partitionWithIndex(fa, f); }; };
}
exports.partitionWithIndex = partitionWithIndex;
function partitionMapWithIndex(F) {
return function (f) { return function (fa) { return F.partitionMapWithIndex(fa, f); }; };
}
exports.partitionMapWithIndex = partitionMapWithIndex;
function promap(F) {
return function (f, g) { return function (fbc) { return F.promap(fbc, f, g); }; };
}
exports.promap = promap;
function compose(F) {
return function (ea) { return function (ab) { return F.compose(ab, ea); }; };
}
exports.compose = compose;
var isFunctor = function (I) { return typeof I.map === 'function'; };
var isContravariant = function (I) { return typeof I.contramap === 'function'; };
var isFunctorWithIndex = function (I) { return typeof I.mapWithIndex === 'function'; };
var isApply = function (I) { return typeof I.ap === 'function'; };
var isChain = function (I) { return typeof I.chain === 'function'; };
var isBifunctor = function (I) { return typeof I.bimap === 'function'; };
var isExtend = function (I) { return typeof I.extend === 'function'; };
var isFoldable = function (I) { return typeof I.reduce === 'function'; };
var isFoldableWithIndex = function (I) { return typeof I.reduceWithIndex === 'function'; };
var isAlt = function (I) { return typeof I.alt === 'function'; };
var isCompactable = function (I) { return typeof I.compact === 'function'; };
var isFilterable = function (I) { return typeof I.filter === 'function'; };
var isFilterableWithIndex = function (I) {
return typeof I.filterWithIndex === 'function';
};
var isProfunctor = function (I) { return typeof I.promap === 'function'; };
var isSemigroupoid = function (I) { return typeof I.compose === 'function'; };
var isMonadThrow = function (I) { return typeof I.throwError === 'function'; };
/** @deprecated */
function pipeable(I) {
var r = {};
if (isFunctor(I)) {
r.map = map(I);
}
if (isContravariant(I)) {
r.contramap = contramap(I);
}
if (isFunctorWithIndex(I)) {
r.mapWithIndex = mapWithIndex(I);
}
if (isApply(I)) {
r.ap = ap(I);
r.apFirst = (0, Apply_1.apFirst)(I);
r.apSecond = (0, Apply_1.apSecond)(I);
}
if (isChain(I)) {
r.chain = chain(I);
r.chainFirst = (0, Chain_1.chainFirst)(I);
r.flatten = r.chain(function_1.identity);
}
if (isBifunctor(I)) {
r.bimap = bimap(I);
r.mapLeft = mapLeft(I);
}
if (isExtend(I)) {
r.extend = extend(I);
r.duplicate = r.extend(function_1.identity);
}
if (isFoldable(I)) {
r.reduce = reduce(I);
r.foldMap = foldMap(I);
r.reduceRight = reduceRight(I);
}
if (isFoldableWithIndex(I)) {
r.reduceWithIndex = reduceWithIndex(I);
r.foldMapWithIndex = foldMapWithIndex(I);
r.reduceRightWithIndex = reduceRightWithIndex(I);
}
if (isAlt(I)) {
r.alt = alt(I);
}
if (isCompactable(I)) {
r.compact = I.compact;
r.separate = I.separate;
}
if (isFilterable(I)) {
r.filter = filter(I);
r.filterMap = filterMap(I);
r.partition = partition(I);
r.partitionMap = partitionMap(I);
}
if (isFilterableWithIndex(I)) {
r.filterWithIndex = filterWithIndex(I);
r.filterMapWithIndex = filterMapWithIndex(I);
r.partitionWithIndex = partitionWithIndex(I);
r.partitionMapWithIndex = partitionMapWithIndex(I);
}
if (isProfunctor(I)) {
r.promap = promap(I);
}
if (isSemigroupoid(I)) {
r.compose = compose(I);
}
if (isMonadThrow(I)) {
var fromOption = function (onNone) { return function (ma) {
return ma._tag === 'None' ? I.throwError(onNone()) : I.of(ma.value);
}; };
var fromEither = function (ma) {
return ma._tag === 'Left' ? I.throwError(ma.left) : I.of(ma.right);
};
var fromPredicate = function (predicate, onFalse) {
return function (a) {
return predicate(a) ? I.of(a) : I.throwError(onFalse(a));
};
};
var filterOrElse = function (predicate, onFalse) {
return function (ma) {
return I.chain(ma, function (a) { return (predicate(a) ? I.of(a) : I.throwError(onFalse(a))); });
};
};
r.fromOption = fromOption;
r.fromEither = fromEither;
r.fromPredicate = fromPredicate;
r.filterOrElse = filterOrElse;
}
return r;
}
exports.pipeable = pipeable;
/**
* Use [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#pipe) from `function` module instead.
*
* @since 2.0.0
* @deprecated
*/
exports.pipe = function_1.pipe;