github Effect-TS/effect effect@3.4.0

latest releases: @effect/typeclass@0.24.40, @effect/printer@0.33.40, @effect/printer-ansi@0.33.40...
14 days ago

Minor Changes

  • #2938 c0ce180 Thanks @LaureRC! - Make Option.liftPredicate dual

  • #2938 61707b6 Thanks @LaureRC! - Add Effect.liftPredicate

    Effect.liftPredicate transforms a Predicate function into an Effect returning the input value if the predicate returns true or failing with specified error if the predicate fails.

    import { Effect } from "effect";
    
    const isPositive = (n: number): boolean => n > 0;
    
    // succeeds with `1`
    Effect.liftPredicate(1, isPositive, (n) => `${n} is not positive`);
    
    // fails with `"0 is not positive"`
    Effect.liftPredicate(0, isPositive, (n) => `${n} is not positive`);
  • #2938 9c1b5b3 Thanks @tim-smart! - add EventListener type to Stream to avoid use of dom lib

  • #2938 a35faf8 Thanks @gcanti! - Add lastNonEmpty function to Chunk module, closes #2946

  • #2938 ff73c0c Thanks @dilame! - feat(Stream): implement Success, Error, Context type accessors

  • #2938 984d516 Thanks @tim-smart! - add Micro module

    A lightweight alternative to Effect, for when bundle size really matters.

    At a minimum, Micro adds 5kb gzipped to your bundle, and scales with the amount
    of features you use.

  • #2938 8c3b8a2 Thanks @gcanti! - add ManagedRuntime type utils (Context, and Error)

  • #2938 017e2f9 Thanks @LaureRC! - Add Either.liftPredicate

  • #2938 91bf8a2 Thanks @msensys! - Add Tuple.at api, to retrieve an element at a specified index from a tuple.

    import { Tuple } from "effect";
    
    assert.deepStrictEqual(Tuple.at([1, "hello", true], 1), "hello");
  • #2938 c6a4a26 Thanks @datner! - add ensure util for Array, used to normalize A | ReadonlyArray<A>

    import { ensure } from "effect/Array";
    
    // lets say you are not 100% sure if it's a member or a collection
    declare const someValue: { foo: string } | Array<{ foo: string }>;
    
    // $ExpectType ({ foo: string })[]
    const normalized = ensure(someValue);

Don't miss a new effect release

NewReleases is sending notifications on new releases.