FuncType - v0.20.0
    Preparing search index...

    Variable Either

    Either: <L extends unknown, R extends unknown>(
        value: L | R,
        isRight: boolean,
    ) => Either<L, R> & {
        ap: <L extends unknown, R extends unknown, U extends unknown>(
            eitherF: Either<L, (value: R) => U>,
            eitherV: Either<L, R>,
        ) => Either<L, U>;
        fromBinary: <L extends unknown, R extends unknown>(
            binary: string,
        ) => Either<L, R>;
        fromJSON: <L extends unknown, R extends unknown>(
            json: string,
        ) => Either<L, R>;
        fromNullable: <L extends unknown, R extends unknown>(
            value: R | null | undefined,
            leftValue: L,
        ) => Either<L, R>;
        fromPredicate: <L extends unknown, R extends unknown>(
            value: R,
            predicate: (value: R) => boolean,
            leftValue: L,
        ) => Either<L, R>;
        fromPromise: <L, R>(
            promise: Promise<R>,
            onRejected: (reason: unknown) => L,
        ) => Promise<Either<L, R>>;
        fromYAML: <L extends unknown, R extends unknown>(
            yaml: string,
        ) => Either<L, R>;
        isLeft: <L extends unknown, R extends unknown>(
            either: Either<L, R>,
        ) => either is Either<L, R> & { value: L };
        isRight: <L extends unknown, R extends unknown>(
            either: Either<L, R>,
        ) => either is Either<L, R> & { value: R };
        left: <L extends unknown, R extends unknown>(value: L) => Either<L, R>;
        right: <L extends unknown, R extends unknown>(value: R) => Either<L, R>;
        sequence: <L extends unknown, R extends unknown>(
            eithers: Either<L, R>[],
        ) => Either<L, R[]>;
        traverse: <L extends unknown, R extends unknown, U extends unknown>(
            arr: R[],
            f: (value: R) => Either<L, U>,
        ) => Either<L, U[]>;
    }

    Type Declaration

      • <L extends unknown, R extends unknown>(
            value: L | R,
            isRight: boolean,
        ): Either<L, R>
      • Either constructor that creates Left or Right based on the isRight parameter

        Type Parameters

        • L extends unknown
        • R extends unknown

        Parameters

        • value: L | R

          The value to wrap

        • isRight: boolean

          If true, creates Right, otherwise creates Left

        Returns Either<L, R>

        Either instance

    • ap: <L extends unknown, R extends unknown, U extends unknown>(
          eitherF: Either<L, (value: R) => U>,
          eitherV: Either<L, R>,
      ) => Either<L, U>

      Applicative apply - applies a wrapped function to a wrapped value

    • fromBinary: <L extends unknown, R extends unknown>(binary: string) => Either<L, R>

      Creates an Either from binary string

    • fromJSON: <L extends unknown, R extends unknown>(json: string) => Either<L, R>

      Creates an Either from JSON string

    • fromNullable: <L extends unknown, R extends unknown>(
          value: R | null | undefined,
          leftValue: L,
      ) => Either<L, R>

      Creates an Either from a nullable value

    • fromPredicate: <L extends unknown, R extends unknown>(
          value: R,
          predicate: (value: R) => boolean,
          leftValue: L,
      ) => Either<L, R>

      Creates an Either based on a predicate

    • fromPromise: <L, R>(
          promise: Promise<R>,
          onRejected: (reason: unknown) => L,
      ) => Promise<Either<L, R>>

      Creates an Either from a Promise

    • fromYAML: <L extends unknown, R extends unknown>(yaml: string) => Either<L, R>

      Creates an Either from YAML string

    • isLeft: <L extends unknown, R extends unknown>(
          either: Either<L, R>,
      ) => either is Either<L, R> & { value: L }

      Type guard to check if an Either is Left

    • isRight: <L extends unknown, R extends unknown>(
          either: Either<L, R>,
      ) => either is Either<L, R> & { value: R }

      Type guard to check if an Either is Right

    • left: <L extends unknown, R extends unknown>(value: L) => Either<L, R>

      Creates a Left instance

    • right: <L extends unknown, R extends unknown>(value: R) => Either<L, R>

      Creates a Right instance

    • sequence: <L extends unknown, R extends unknown>(
          eithers: Either<L, R>[],
      ) => Either<L, R[]>

      Combines an array of Eithers into a single Either containing an array

    • traverse: <L extends unknown, R extends unknown, U extends unknown>(
          arr: R[],
          f: (value: R) => Either<L, U>,
      ) => Either<L, U[]>

      Maps an array through a function that returns Either, then sequences the results