PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/monocle-ts/lib

Просмотр файла: Iso.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Category = exports.Semigroupoid = exports.Invariant = exports.URI = exports.imap = exports.findFirstNonEmpty = exports.findFirst = exports.traverse = exports.left = exports.right = exports.some = exports.atKey = exports.key = exports.indexNonEmpty = exports.index = exports.component = exports.props = exports.prop = exports.filter = exports.fromNullable = exports.modifyF = exports.modify = exports.reverse = exports.composeTraversal = exports.composeOptional = exports.composePrism = exports.composeLens = exports.composeIso = exports.compose = exports.asTraversal = exports.asOptional = exports.asPrism = exports.asLens = exports.id = exports.iso = void 0;
var function_1 = require("fp-ts/lib/function");
var pipeable_1 = require("fp-ts/lib/pipeable");
var _ = require("./internal");
// -------------------------------------------------------------------------------------
// constructors
// -------------------------------------------------------------------------------------
/**
 * @category constructors
 * @since 2.3.8
 */
exports.iso = _.iso;
/**
 * @category constructors
 * @since 2.3.0
 */
var id = function () { return (0, exports.iso)(function_1.identity, function_1.identity); };
exports.id = id;
// -------------------------------------------------------------------------------------
// converters
// -------------------------------------------------------------------------------------
/**
 * View an `Iso` as a `Lens`.
 *
 * @category converters
 * @since 2.3.0
 */
exports.asLens = _.isoAsLens;
/**
 * View an `Iso` as a `Prism`.
 *
 * @category converters
 * @since 2.3.0
 */
exports.asPrism = _.isoAsPrism;
/**
 * View an `Iso` as a `Optional`.
 *
 * @category converters
 * @since 2.3.0
 */
exports.asOptional = _.isoAsOptional;
/**
 * View an `Iso` as a `Traversal`.
 *
 * @category converters
 * @since 2.3.0
 */
exports.asTraversal = _.isoAsTraversal;
// -------------------------------------------------------------------------------------
// compositions
// -------------------------------------------------------------------------------------
/**
 * Compose an `Iso` with an `Iso`.
 *
 * @category compositions
 * @since 2.3.0
 */
var compose = function (ab) { return function (sa) {
    return (0, exports.iso)((0, function_1.flow)(sa.get, ab.get), (0, function_1.flow)(ab.reverseGet, sa.reverseGet));
}; };
exports.compose = compose;
/**
 * Alias of `compose`.
 *
 * @category compositions
 * @since 2.3.8
 */
exports.composeIso = exports.compose;
/**
 * Compose an `Iso` with a `Lens`.
 *
 * @category compositions
 * @since 2.3.8
 */
var composeLens = function (ab) {
    return (0, function_1.flow)(exports.asLens, _.lensComposeLens(ab));
};
exports.composeLens = composeLens;
/**
 * Compose an `Iso` with a `Prism`.
 *
 * @category compositions
 * @since 2.3.8
 */
var composePrism = function (ab) {
    return (0, function_1.flow)(exports.asPrism, _.prismComposePrism(ab));
};
exports.composePrism = composePrism;
/**
 * Compose an `Iso` with a `Optional`.
 *
 * @category compositions
 * @since 2.3.8
 */
var composeOptional = function (ab) {
    return (0, function_1.flow)(exports.asOptional, _.optionalComposeOptional(ab));
};
exports.composeOptional = composeOptional;
/**
 * Compose an `Iso` with a `Traversal`.
 *
 * @category compositions
 * @since 2.3.8
 */
var composeTraversal = function (ab) {
    return (0, function_1.flow)(exports.asTraversal, _.traversalComposeTraversal(ab));
};
exports.composeTraversal = composeTraversal;
// -------------------------------------------------------------------------------------
// combinators
// -------------------------------------------------------------------------------------
/**
 * @category constructors
 * @since 2.3.0
 */
var reverse = function (sa) { return (0, exports.iso)(sa.reverseGet, sa.get); };
exports.reverse = reverse;
/**
 * @category combinators
 * @since 2.3.0
 */
var modify = function (f) { return function (sa) { return function (s) {
    return sa.reverseGet(f(sa.get(s)));
}; }; };
exports.modify = modify;
function modifyF(F) {
    return function (f) { return function (sa) { return function (s) { return (0, pipeable_1.pipe)(sa.get(s), f, function (fa) { return F.map(fa, sa.reverseGet); }); }; }; };
}
exports.modifyF = modifyF;
/**
 * Return a `Prism` from a `Iso` focused on a nullable value.
 *
 * @category combinators
 * @since 2.3.8
 */
var fromNullable = function (sa) {
    return (0, exports.composePrism)(_.prismFromNullable())(sa);
};
exports.fromNullable = fromNullable;
function filter(predicate) {
    return (0, exports.composePrism)(_.prismFromPredicate(predicate));
}
exports.filter = filter;
/**
 * Return a `Lens` from a `Iso` and a prop.
 *
 * @category combinators
 * @since 2.3.8
 */
var prop = function (prop) {
    return (0, function_1.flow)(exports.asLens, _.lensProp(prop));
};
exports.prop = prop;
/**
 * Return a `Lens` from a `Iso` and a list of props.
 *
 * @category combinators
 * @since 2.3.8
 */
var props = function () {
    var props = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        props[_i] = arguments[_i];
    }
    return (0, function_1.flow)(exports.asLens, _.lensProps.apply(_, props));
};
exports.props = props;
/**
 * Return a `Lens` from a `Iso` focused on a component of a tuple.
 *
 * @category combinators
 * @since 2.3.8
 */
var component = function (prop) { return (0, function_1.flow)(exports.asLens, _.lensComponent(prop)); };
exports.component = component;
/**
 * Return a `Optional` from a `Iso` focused on an index of a `ReadonlyArray`.
 *
 * @category combinators
 * @since 2.3.8
 */
var index = function (i) {
    return (0, function_1.flow)(exports.asOptional, _.optionalIndex(i));
};
exports.index = index;
/**
 * Return a `Optional` from a `Iso` focused on an index of a `ReadonlyNonEmptyArray`.
 *
 * @category combinators
 * @since 2.3.8
 */
var indexNonEmpty = function (i) {
    return (0, function_1.flow)(exports.asOptional, _.optionalIndexNonEmpty(i));
};
exports.indexNonEmpty = indexNonEmpty;
/**
 * Return a `Optional` from a `Iso` focused on a key of a `ReadonlyRecord`.
 *
 * @category combinators
 * @since 2.3.8
 */
var key = function (key) {
    return (0, function_1.flow)(exports.asOptional, _.optionalKey(key));
};
exports.key = key;
/**
 * Return a `Lens` from a `Iso` focused on a required key of a `ReadonlyRecord`.
 *
 * @category combinators
 * @since 2.3.8
 */
var atKey = function (key) {
    return (0, function_1.flow)(exports.asLens, _.lensAtKey(key));
};
exports.atKey = atKey;
/**
 * Return a `Prism` from a `Iso` focused on the `Some` of a `Option` type.
 *
 * @category combinators
 * @since 2.3.8
 */
exports.some = 
/*#__PURE__*/
(0, exports.composePrism)(/*#__PURE__*/ _.prismSome());
/**
 * Return a `Prism` from a `Iso` focused on the `Right` of a `Either` type.
 *
 * @category combinators
 * @since 2.3.8
 */
exports.right = 
/*#__PURE__*/
(0, exports.composePrism)(/*#__PURE__*/ _.prismRight());
/**
 * Return a `Prism` from a `Iso` focused on the `Left` of a `Either` type.
 *
 * @category combinators
 * @since 2.3.8
 */
exports.left = 
/*#__PURE__*/
(0, exports.composePrism)(/*#__PURE__*/ _.prismLeft());
/**
 * Return a `Traversal` from a `Iso` focused on a `Traversable`.
 *
 * @category combinators
 * @since 2.3.8
 */
function traverse(T) {
    return (0, function_1.flow)(exports.asTraversal, _.traversalTraverse(T));
}
exports.traverse = traverse;
function findFirst(predicate) {
    return (0, exports.composeOptional)(_.optionalFindFirst(predicate));
}
exports.findFirst = findFirst;
function findFirstNonEmpty(predicate) {
    return (0, exports.composeOptional)(_.optionalFindFirstNonEmpty(predicate));
}
exports.findFirstNonEmpty = findFirstNonEmpty;
// -------------------------------------------------------------------------------------
// pipeables
// -------------------------------------------------------------------------------------
/**
 * @category Invariant
 * @since 2.3.0
 */
var imap = function (f, g) { return function (ea) {
    return imap_(ea, f, g);
}; };
exports.imap = imap;
// -------------------------------------------------------------------------------------
// instances
// -------------------------------------------------------------------------------------
var imap_ = function (ea, ab, ba) { return (0, exports.iso)((0, function_1.flow)(ea.get, ab), (0, function_1.flow)(ba, ea.reverseGet)); };
/**
 * @category instances
 * @since 2.3.0
 */
exports.URI = 'monocle-ts/Iso';
/**
 * @category instances
 * @since 2.3.0
 */
exports.Invariant = {
    URI: exports.URI,
    imap: imap_
};
/**
 * @category instances
 * @since 2.3.8
 */
exports.Semigroupoid = {
    URI: exports.URI,
    compose: function (ab, ea) { return (0, exports.compose)(ab)(ea); }
};
/**
 * @category instances
 * @since 2.3.0
 */
exports.Category = {
    URI: exports.URI,
    compose: exports.Semigroupoid.compose,
    id: exports.id
};

Выполнить команду


Для локальной разработки. Не используйте в интернете!