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
48 lines (47 loc) • 3.03 kB
TypeScript
/**
* Internal Effect abstraction
* This file abstracts away the Effect library so users don't need to install it directly
*/
import * as EffectMod from 'effect/Effect';
import * as Exit from 'effect/Exit';
import * as Cause from 'effect/Cause';
import * as Option from 'effect/Option';
import * as Either from 'effect/Either';
import { pipe } from 'effect/Function';
export { pipe };
export type Effect<A, E = never> = EffectMod.Effect<A, E>;
export type ExitType = Exit.Exit<any, any>;
export type EitherType<E, A> = Either.Either<E, A>;
export declare const succeed: <A>(value: A) => EffectMod.Effect<A>;
export declare const fail: <E>(error: E) => EffectMod.Effect<never, E>;
export declare const flatMap: {
<A, B, E1, R1>(f: (a: A) => EffectMod.Effect<B, E1, R1>): <E, R>(self: EffectMod.Effect<A, E, R>) => EffectMod.Effect<B, E1 | E, R1 | R>;
<A, E, R, B, E1, R1>(self: EffectMod.Effect<A, E, R>, f: (a: A) => EffectMod.Effect<B, E1, R1>): EffectMod.Effect<B, E | E1, R | R1>;
};
export declare const map: {
<A, B>(f: (a: A) => B): <E, R>(self: EffectMod.Effect<A, E, R>) => EffectMod.Effect<B, E, R>;
<A, E, R, B>(self: EffectMod.Effect<A, E, R>, f: (a: A) => B): EffectMod.Effect<B, E, R>;
};
export declare const orDie: <A, E, R>(self: EffectMod.Effect<A, E, R>) => EffectMod.Effect<A, never, R>;
export declare const all: <const Arg extends Iterable<EffectMod.Effect<any, any, any>> | Record<string, EffectMod.Effect<any, any, any>>, O extends {
readonly concurrency?: import("effect/Types").Concurrency | undefined;
readonly batching?: boolean | "inherit" | undefined;
readonly discard?: boolean | undefined;
readonly mode?: "default" | "validate" | "either" | undefined;
}>(arg: Arg, options?: O) => EffectMod.All.Return<Arg, O>;
export declare const forEach: <A, B, E>(items: readonly A[], f: (a: A, i: number) => EffectMod.Effect<B, E>) => EffectMod.Effect<B[], E>;
export declare const runSync: <A, E>(effect: EffectMod.Effect<A, E>) => A;
export declare const runSyncExit: <A, E>(effect: EffectMod.Effect<A, E>) => Exit.Exit<A, E>;
export declare const runPromise: <A, E>(effect: EffectMod.Effect<A, E, never>, options?: {
readonly signal?: AbortSignal;
} | undefined) => Promise<A>;
export declare const either: <A, E, R>(self: EffectMod.Effect<A, E, R>) => EffectMod.Effect<Either.Either<A, E>, never, R>;
export declare const isSuccess: <A, E>(self: Exit.Exit<A, E>) => self is Exit.Success<A, E>;
export declare const failureOption: <E>(self: Cause.Cause<E>) => Option.Option<E>;
export declare const getOrElse: {
<B>(onNone: import("effect/Function").LazyArg<B>): <A>(self: Option.Option<A>) => B | A;
<A, B>(self: Option.Option<A>, onNone: import("effect/Function").LazyArg<B>): A | B;
};
export declare const isRight: <R, L>(self: Either.Either<R, L>) => self is Either.Right<L, R>;
export declare const isLeft: <R, L>(self: Either.Either<R, L>) => self is Either.Left<L, R>;
export declare const unwrapEither: <E, A>(either: Either.Either<E, A>) => A | E;