mini-effect
    Preparing search index...

    Class WrapEffect<T, C, CE, D, P>

    A specialized Effect subclass that carries error-handling metadata.

    WrapEffect extends Effect and adds a phantom type parameter CE that tracks which error types this wrapper is capable of catching. It is produced by catchSome and catchTags and is consumed by pipe to remove the handled error types from the resulting effect's error channel.

    You should not instantiate WrapEffect directly — use catchSome or catchTags to create instances.

    import { catchSome, succeed, pipe, fn, run } from "mini-effect";

    // catchSome returns a WrapEffect
    const handler = catchSome((cause) =>
    cause instanceof Error ? succeed("recovered") : undefined,
    );

    const result = await run(
    pipe(fn(() => { throw new Error("x"); }), handler),
    );
    // => "recovered"

    Type Parameters

    • T = any

      The success value type of the recovery effect

    • C = any

      The error type of the recovery effect

    • CE = any

      The error type(s) that this wrapper catches (excluded from the upstream error channel)

    • D = any

      Dependencies required by the recovery effect

    • P = any

      Dependencies provided by the recovery effect

    Hierarchy (View Summary)

    Index

    Constructors

    • Type Parameters

      • T = any

        The success value type of the recovery effect

      • C = any

        The error type of the recovery effect

      • CE = any

        The error type(s) that this wrapper catches (excluded from the upstream error channel)

      • D = any

        Dependencies required by the recovery effect

      • P = any

        Dependencies provided by the recovery effect

      Parameters

      • Optionalrun: Thunk<T>
      • OptionalcatchSome: (cause: unknown) => Effect<any, any, any, any> | undefined

      Returns WrapEffect<T, C, CE, D, P>

    Properties

    "[DEPENDENCY_TYPE]": D
    "[ERROR]"?: (cause: unknown) => Effect<any, any, any, any> | undefined
    "[HANDLES_ERROR]": CE
    "[PROVIDES_TYPE]": P
    "[RUN]"?: Thunk<T>

    Methods

    • Composes this effect with one or more Pipeable operations into a single sequential effect.

      Type Parameters

      Parameters

      • ...pipeable: E

        One or more pipeable operations to apply after this effect

      Returns PipeReturn<[Effect<T, C, D, P>, ...E[]]>

      A new Effect representing the composed pipeline

      This is a fluent convenience method equivalent to calling the standalone pipe function with this effect as the first argument. It accepts transform functions, error handlers, and dependency providers.

      import { succeed, catchSome, run } from "mini-effect";

      const result = await run(
      succeed(5).pipe(
      (n: number) => succeed(n * 2),
      (n: number) => succeed(n + 1),
      ),
      );
      // => 11