veffect
Version:
powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha
512 lines (511 loc) • 15.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.stripSomeDefects = exports.stripFailures = exports.squashWith = exports.squash = exports.size = exports.sequential = exports.reduceWithContext = exports.reduce = exports.pretty = exports.parallel = exports.originalError = exports.match = exports.map = exports.linearize = exports.keepDefects = exports.isUnknownException = exports.isSequentialType = exports.isRuntimeException = exports.isParallelType = exports.isNoSuchElementException = exports.isInterruptedOnly = exports.isInterruptedException = exports.isInterrupted = exports.isInterruptType = exports.isIllegalArgumentException = exports.isFailure = exports.isFailType = exports.isEmptyType = exports.isEmpty = exports.isDieType = exports.isDie = exports.isCause = exports.interruptors = exports.interruptOption = exports.interrupt = exports.flipCauseOption = exports.flatten = exports.flatMap = exports.find = exports.filter = exports.failures = exports.failureOrCause = exports.failureOption = exports.fail = exports.empty = exports.dieOption = exports.die = exports.defects = exports.contains = exports.as = exports.andThen = exports.YieldableError = exports.UnknownExceptionTypeId = exports.UnknownException = exports.TimeoutExceptionTypeId = exports.TimeoutException = exports.RuntimeExceptionTypeId = exports.RuntimeException = exports.NoSuchElementExceptionTypeId = exports.NoSuchElementException = exports.InvalidPubSubCapacityExceptionTypeId = exports.InterruptedExceptionTypeId = exports.InterruptedException = exports.IllegalArgumentExceptionTypeId = exports.IllegalArgumentException = exports.CauseTypeId = void 0;
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/cause.js"));
var core = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/core.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;
}
/**
* @since 2.0.0
* @category symbols
*/
const CauseTypeId = exports.CauseTypeId = internal.CauseTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const RuntimeExceptionTypeId = exports.RuntimeExceptionTypeId = core.RuntimeExceptionTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const InterruptedExceptionTypeId = exports.InterruptedExceptionTypeId = core.InterruptedExceptionTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const IllegalArgumentExceptionTypeId = exports.IllegalArgumentExceptionTypeId = core.IllegalArgumentExceptionTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const NoSuchElementExceptionTypeId = exports.NoSuchElementExceptionTypeId = core.NoSuchElementExceptionTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const InvalidPubSubCapacityExceptionTypeId = exports.InvalidPubSubCapacityExceptionTypeId = core.InvalidPubSubCapacityExceptionTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const TimeoutExceptionTypeId = exports.TimeoutExceptionTypeId = core.TimeoutExceptionTypeId;
/**
* @since 2.0.0
* @category symbols
*/
const UnknownExceptionTypeId = exports.UnknownExceptionTypeId = core.UnknownExceptionTypeId;
/**
* Represents a generic checked exception which occurs at runtime.
*
* @since 2.0.0
* @category errors
*/
const YieldableError = exports.YieldableError = core.YieldableError;
/**
* Constructs a new `Empty` cause.
*
* @since 2.0.0
* @category constructors
*/
const empty = exports.empty = internal.empty;
/**
* Constructs a new `Fail` cause from the specified `error`.
*
* @since 2.0.0
* @category constructors
*/
const fail = exports.fail = internal.fail;
/**
* Constructs a new `Die` cause from the specified `defect`.
*
* @since 2.0.0
* @category constructors
*/
const die = exports.die = internal.die;
/**
* Constructs a new `Interrupt` cause from the specified `fiberId`.
*
* @since 2.0.0
* @category constructors
*/
const interrupt = exports.interrupt = internal.interrupt;
/**
* Constructs a new `Parallel` cause from the specified `left` and `right`
* causes.
*
* @since 2.0.0
* @category constructors
*/
const parallel = exports.parallel = internal.parallel;
/**
* Constructs a new `Sequential` cause from the specified pecified `left` and
* `right` causes.
*
* @since 2.0.0
* @category constructors
*/
const sequential = exports.sequential = internal.sequential;
/**
* Returns `true` if the specified value is a `Cause`, `false` otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isCause = exports.isCause = internal.isCause;
/**
* Returns `true` if the specified `Cause` is an `Empty` type, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isEmptyType = exports.isEmptyType = internal.isEmptyType;
/**
* Returns `true` if the specified `Cause` is a `Fail` type, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isFailType = exports.isFailType = internal.isFailType;
/**
* Returns `true` if the specified `Cause` is a `Die` type, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isDieType = exports.isDieType = internal.isDieType;
/**
* Returns `true` if the specified `Cause` is an `Interrupt` type, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isInterruptType = exports.isInterruptType = internal.isInterruptType;
/**
* Returns `true` if the specified `Cause` is a `Sequential` type, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isSequentialType = exports.isSequentialType = internal.isSequentialType;
/**
* Returns `true` if the specified `Cause` is a `Parallel` type, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isParallelType = exports.isParallelType = internal.isParallelType;
/**
* Returns the size of the cause, calculated as the number of individual `Cause`
* nodes found in the `Cause` semiring structure.
*
* @since 2.0.0
* @category getters
*/
const size = exports.size = internal.size;
/**
* Returns `true` if the specified cause is empty, `false` otherwise.
*
* @since 2.0.0
* @category getters
*/
const isEmpty = exports.isEmpty = internal.isEmpty;
/**
* Returns `true` if the specified cause contains a failure, `false` otherwise.
*
* @since 2.0.0
* @category getters
*/
const isFailure = exports.isFailure = internal.isFailure;
/**
* Returns `true` if the specified cause contains a defect, `false` otherwise.
*
* @since 2.0.0
* @category getters
*/
const isDie = exports.isDie = internal.isDie;
/**
* Returns `true` if the specified cause contains an interruption, `false`
* otherwise.
*
* @since 2.0.0
* @category getters
*/
const isInterrupted = exports.isInterrupted = internal.isInterrupted;
/**
* Returns `true` if the specified cause contains only interruptions (without
* any `Die` or `Fail` causes), `false` otherwise.
*
* @since 2.0.0
* @category getters
*/
const isInterruptedOnly = exports.isInterruptedOnly = internal.isInterruptedOnly;
/**
* Returns a `List` of all recoverable errors of type `E` in the specified
* cause.
*
* @since 2.0.0
* @category getters
*/
const failures = exports.failures = internal.failures;
/**
* Returns a `List` of all unrecoverable defects in the specified cause.
*
* @since 2.0.0
* @category getters
*/
const defects = exports.defects = internal.defects;
/**
* Returns a `HashSet` of `FiberId`s for all fibers that interrupted the fiber
* described by the specified cause.
*
* @since 2.0.0
* @category getters
*/
const interruptors = exports.interruptors = internal.interruptors;
/**
* Returns the `E` associated with the first `Fail` in this `Cause`, if one
* exists.
*
* @since 2.0.0
* @category getters
*/
const failureOption = exports.failureOption = internal.failureOption;
/**
* Returns the first checked error on the `Left` if available, if there are
* no checked errors return the rest of the `Cause` that is known to contain
* only `Die` or `Interrupt` causes.
*
* @since 2.0.0
* @category getters
*/
const failureOrCause = exports.failureOrCause = internal.failureOrCause;
/**
* Converts the specified `Cause<Option<E>>` to an `Option<Cause<E>>` by
* recursively stripping out any failures with the error `None`.
*
* @since 2.0.0
* @category getters
*/
const flipCauseOption = exports.flipCauseOption = internal.flipCauseOption;
/**
* Returns the defect associated with the first `Die` in this `Cause`, if one
* exists.
*
* @since 2.0.0
* @category getters
*/
const dieOption = exports.dieOption = internal.dieOption;
/**
* Returns the `FiberId` associated with the first `Interrupt` in the specified
* cause, if one exists.
*
* @since 2.0.0
* @category getters
*/
const interruptOption = exports.interruptOption = internal.interruptOption;
/**
* Remove all `Fail` and `Interrupt` nodes from the specified cause, and return
* a cause containing only `Die` cause/finalizer defects.
*
* @since 2.0.0
* @category getters
*/
const keepDefects = exports.keepDefects = internal.keepDefects;
/**
* Linearizes the specified cause into a `HashSet` of parallel causes where each
* parallel cause contains a linear sequence of failures.
*
* @since 2.0.0
* @category getters
*/
const linearize = exports.linearize = internal.linearize;
/**
* Remove all `Fail` and `Interrupt` nodes from the specified cause, and return
* a cause containing only `Die` cause/finalizer defects.
*
* @since 2.0.0
* @category getters
*/
const stripFailures = exports.stripFailures = internal.stripFailures;
/**
* Remove all `Die` causes that the specified partial function is defined at,
* returning `Some` with the remaining causes or `None` if there are no
* remaining causes.
*
* @since 2.0.0
* @category getters
*/
const stripSomeDefects = exports.stripSomeDefects = internal.stripSomeDefects;
/**
* @since 2.0.0
* @category mapping
*/
const as = exports.as = internal.as;
/**
* @since 2.0.0
* @category mapping
*/
const map = exports.map = internal.map;
/**
* @since 2.0.0
* @category sequencing
*/
const flatMap = exports.flatMap = internal.flatMap;
/**
* Executes a sequence of two `Cause`s. The second `Cause` can be dependent on the result of the first `Cause`.
*
* @since 2.0.0
* @category sequencing
*/
const andThen = exports.andThen = internal.andThen;
/**
* @since 2.0.0
* @category sequencing
*/
const flatten = exports.flatten = internal.flatten;
/**
* Returns `true` if the `self` cause contains or is equal to `that` cause,
* `false` otherwise.
*
* @since 2.0.0
* @category elements
*/
const contains = exports.contains = internal.contains;
/**
* Squashes a `Cause` down to a single defect, chosen to be the "most important"
* defect.
*
* @since 2.0.0
* @category destructors
*/
const squash = exports.squash = core.causeSquash;
/**
* Squashes a `Cause` down to a single defect, chosen to be the "most important"
* defect. If a recoverable error is found, the provided function will be used
* to map the error a defect, and the resulting value will be returned.
*
* @since 2.0.0
* @category destructors
*/
const squashWith = exports.squashWith = core.causeSquashWith;
/**
* Uses the provided partial function to search the specified cause and attempt
* to extract information from it.
*
* @since 2.0.0
* @category elements
*/
const find = exports.find = internal.find;
/**
* Filters causes which match the provided predicate out of the specified cause.
*
* @since 2.0.0
* @category filtering
*/
const filter = exports.filter = internal.filter;
/**
* Folds the specified cause into a value of type `Z`.
*
* @since 2.0.0
* @category folding
*/
const match = exports.match = internal.match;
/**
* Reduces the specified cause into a value of type `Z`, beginning with the
* provided `zero` value.
*
* @since 2.0.0
* @category folding
*/
const reduce = exports.reduce = internal.reduce;
/**
* Reduces the specified cause into a value of type `Z` using a `Cause.Reducer`.
* Also allows for accessing the provided context during reduction.
*
* @since 2.0.0
* @category folding
*/
const reduceWithContext = exports.reduceWithContext = internal.reduceWithContext;
/**
* Represents a checked exception which occurs when a `Fiber` is interrupted.
*
* @since 2.0.0
* @category errors
*/
const InterruptedException = exports.InterruptedException = core.InterruptedException;
/**
* Returns `true` if the specified value is an `InterruptedException`, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isInterruptedException = exports.isInterruptedException = core.isInterruptedException;
/**
* Represents a checked exception which occurs when an invalid argument is
* provided to a method.
*
* @since 2.0.0
* @category errors
*/
const IllegalArgumentException = exports.IllegalArgumentException = core.IllegalArgumentException;
/**
* Returns `true` if the specified value is an `IllegalArgumentException`, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isIllegalArgumentException = exports.isIllegalArgumentException = core.isIllegalArgumentException;
/**
* Represents a checked exception which occurs when an expected element was
* unable to be found.
*
* @since 2.0.0
* @category errors
*/
const NoSuchElementException = exports.NoSuchElementException = core.NoSuchElementException;
/**
* Returns `true` if the specified value is an `NoSuchElementException`, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isNoSuchElementException = exports.isNoSuchElementException = core.isNoSuchElementException;
/**
* Represents a generic checked exception which occurs at runtime.
*
* @since 2.0.0
* @category errors
*/
const RuntimeException = exports.RuntimeException = core.RuntimeException;
/**
* Returns `true` if the specified value is an `RuntimeException`, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isRuntimeException = exports.isRuntimeException = core.isRuntimeException;
/**
* Represents a checked exception which occurs when a computation doesn't
* finish on schedule.
*
* @since 2.0.0
* @category errors
*/
const TimeoutException = exports.TimeoutException = core.TimeoutException;
/**
* Represents a checked exception which occurs when an unknown error is thrown, such as
* from a rejected promise.
*
* @since 2.0.0
* @category errors
*/
const UnknownException = exports.UnknownException = core.UnknownException;
/**
* Returns `true` if the specified value is an `UnknownException`, `false`
* otherwise.
*
* @since 2.0.0
* @category refinements
*/
const isUnknownException = exports.isUnknownException = core.isUnknownException;
/**
* Returns the specified `Cause` as a pretty-printed string.
*
* @since 2.0.0
* @category rendering
*/
const pretty = exports.pretty = internal.pretty;
/**
* Returns the original, unproxied, instance of a thrown error
*
* @since 2.0.0
* @category errors
*/
const originalError = exports.originalError = core.originalInstance;
//# sourceMappingURL=Cause.js.map