Packages

effect

4.1.4 · 11 Nov 2026MIT66.6M / weekRepositoryHomepagenpmAtom feed

Your version

2.4.2

10 Mar 2024Where it was published

2.4.19 is the newest release of 2.x.

In short

6 new5 fixed

Security

2 advisories affect 2.4.2; 3.22.1 fixes them

Release note

Patch Changes

  • Unmatched function fallthrough in andThen and tap

  • Add Effect.Tag to simplify access to service.

    This change allows to define tags in the following way:

    class DemoTag extends Effect.Tag("DemoTag")<
      DemoTag,
      {
        readonly getNumbers: () => Array<number>;
        readonly strings: Array<string>;
      }
    >() {}

    And use them like:

    DemoTag.getNumbers();
    DemoTag.strings;

    This fuses together serviceFunctions and serviceConstants in the static side of the tag.

    Additionally it allows using the service like:

    DemoTag.use((_) => _.getNumbers());

    This is especially useful when having functions that contain generics in the service given that those can't be reliably transformed at the type level and because of that we can't put them on the tag.

  • Request: Swap Success and Error params

  • Add structured logging apis

    • Logger.json / Logger.jsonLogger

    • Logger.structured / Logger.structuredLogger

    Logger.json logs JSON serialized strings to the console.

    Logger.structured logs structured objects, which is useful in the browser
    where you can inspect objects logged to the console.

  • Make sure Effect.Tag works on primitives.

    This change allows the following to work just fine:

    import { Effect, Layer } from "effect";
    
    class DateTag extends Effect.Tag("DateTag")<DateTag, Date>() {
      static date = new Date(1970, 1, 1);
      static Live = Layer.succeed(this, this.date);
    }
    
    class MapTag extends Effect.Tag("MapTag")<MapTag, Map<string, string>>() {
      static Live = Layer.effect(
        this,
        Effect.sync(() => new Map()),
      );
    }
    
    class NumberTag extends Effect.Tag("NumberTag")<NumberTag, number>() {
      static Live = Layer.succeed(this, 100);
    }
  • Add FiberMap/FiberSet.join api

    This api can be used to propogate failures back to a parent fiber, in case any of the fibers added to the FiberMap/FiberSet fail with an error.

    Example:

    import { Effect, FiberSet } from "effect";
    
    Effect.gen(function* (_) {
      const set = yield* _(FiberSet.make());
      yield* _(FiberSet.add(set, Effect.runFork(Effect.fail("error"))));
    
      // parent fiber will fail with "error"
      yield* _(FiberSet.join(set));
    });
  • Make Effect.request dual

  • Allow duration inputs to be singular

  • Added Either.Either.{Left,Right} and Option.Option.Value type utils

  • Add Logger.batched, for batching logger output

    It takes a duration window and an effectful function that processes the batched output.

    Example:

    import { Console, Effect, Logger } from "effect";
    
    const LoggerLive = Logger.replaceScoped(
      Logger.defaultLogger,
      Logger.logfmtLogger.pipe(
        Logger.batched("500 millis", (messages) =>
          Console.log("BATCH", messages.join("\n")),
        ),
      ),
    );
    
    Effect.gen(function* (_) {
      yield* _(Effect.log("one"));
      yield* _(Effect.log("two"));
      yield* _(Effect.log("three"));
    }).pipe(Effect.provide(LoggerLive), Effect.runFork);
  • Struct: Make pick / omit dual

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.