UNPKG

effect

Version:

The missing standard library for TypeScript, for writing production-grade software.

76 lines (75 loc) 2.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.match = exports.isRight = exports.isLeft = exports.isEither = exports.isBoth = exports.fromInput = exports.Right = exports.Left = exports.Either = exports.Both = void 0; var _Function = require("../../Function.js"); var OpCodes = _interopRequireWildcard(require("../opCodes/streamHaltStrategy.js")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** @internal */ const Left = exports.Left = { _tag: OpCodes.OP_LEFT }; /** @internal */ const Right = exports.Right = { _tag: OpCodes.OP_RIGHT }; /** @internal */ const Both = exports.Both = { _tag: OpCodes.OP_BOTH }; /** @internal */ const Either = exports.Either = { _tag: OpCodes.OP_EITHER }; /** @internal */ const fromInput = input => { switch (input) { case "left": return Left; case "right": return Right; case "both": return Both; case "either": return Either; default: return input; } }; /** @internal */ exports.fromInput = fromInput; const isLeft = self => self._tag === OpCodes.OP_LEFT; /** @internal */ exports.isLeft = isLeft; const isRight = self => self._tag === OpCodes.OP_RIGHT; /** @internal */ exports.isRight = isRight; const isBoth = self => self._tag === OpCodes.OP_BOTH; /** @internal */ exports.isBoth = isBoth; const isEither = self => self._tag === OpCodes.OP_EITHER; /** @internal */ exports.isEither = isEither; const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => { switch (self._tag) { case OpCodes.OP_LEFT: { return options.onLeft(); } case OpCodes.OP_RIGHT: { return options.onRight(); } case OpCodes.OP_BOTH: { return options.onBoth(); } case OpCodes.OP_EITHER: { return options.onEither(); } } }); //# sourceMappingURL=haltStrategy.js.map