Packages

effect

4.1.4 · 11 Nov 2026MIT67.1M / weekRepositoryHomepagenpmAtom feed

Your version

3.13.0

14 Feb 2025Where it was published

3.22.5 is the newest release of 3.x.

In short

16 new1 fixed

Security

2 advisories affect 3.13.0; 3.22.1 fixes them

Release note

Minor Changes

  • Add Promise based apis to Fiber{Handle,Set,Map} modules

  • Add Effect.transposeOption, closes #3142.

    Converts an Option of an Effect into an Effect of an Option.

    Details

    This function transforms an Option<Effect<A, E, R>> into an
    Effect<Option<A>, E, R>. If the Option is None, the resulting Effect
    will immediately succeed with a None value. If the Option is Some, the
    inner Effect will be executed, and its result wrapped in a Some.

    Example

    import { Effect, Option } from "effect"
    
    //      ┌─── Option<Effect<number, never, never>>
    //      ▼
    const maybe = Option.some(Effect.succeed(42))
    
    //      ┌─── Effect<Option<number>, never, never>
    //      ▼
    const result = Effect.transposeOption(maybe)
    
    console.log(Effect.runSync(result))
    // Output: { _id: 'Option', _tag: 'Some', value: 42 }
  • Add Effect.whenLogLevel, which conditionally executes an effect if the specified log level is enabled

  • Add RcMap.touch, for reseting the idle timeout for an item

  • Add HashMap.some

  • Allow accessing args in Effect.fn pipe

  • Add RcMap.invalidate api, for removing a resource from an RcMap

  • Add Layer.updateService mirroring Effect.updateService

  • Differ implements Pipeable

  • Make it easy to convert a DateTime.Zoned to a DateTime.Utc

  • Add missing Either.void constructor.

  • Add HashMap.toValues and HashSet.toValues getters

  • Add {FiberHandle,FiberSet,FiberMap}.awaitEmpty apis

  • Schema: Add standardSchemaV1 API to Generate a Standard Schema v1.

    Example

    import { Schema } from "effect"
    
    const schema = Schema.Struct({
      name: Schema.String
    })
    
    //      ┌─── StandardSchemaV1<{ readonly name: string; }>
    //      ▼
    const standardSchema = Schema.standardSchemaV1(schema)
  • Added Duration.formatIso and Duration.fromIso for formatting and parsing ISO8601 durations.

  • Add Effect.filterEffect* apis

Effect.filterEffectOrElse

Filters an effect with an effectful predicate, falling back to an alternative  
effect if the predicate fails.

```ts
import { Effect, pipe } from "effect"

// Define a user interface
interface User {
  readonly name: string
}

// Simulate an asynchronous authentication function
declare const auth: () => Promise<User | null>

const program = pipe(
  Effect.promise(() => auth()),
  // Use filterEffectOrElse with an effectful predicate
  Effect.filterEffectOrElse({
    predicate: (user) => Effect.succeed(user !== null),
    orElse: (user) => Effect.fail(new Error(`Unauthorized user: ${user}`))
  })
)
```

Effect.filterEffectOrFail

Filters an effect with an effectful predicate, failing with a custom error if the predicate fails.

```ts
import { Effect, pipe } from "effect"

// Define a user interface
interface User {
  readonly name: string
}

// Simulate an asynchronous authentication function
declare const auth: () => Promise<User | null>

const program = pipe(
  Effect.promise(() => auth()),
  // Use filterEffectOrFail with an effectful predicate
  Effect.filterEffectOrFail({
    predicate: (user) => Effect.succeed(user !== null),
    orFailWith: (user) => Effect.fail(new Error(`Unauthorized user: ${user}`))
  })
)
```

Patch Changes

  • Trie<out A> type annotations have been aligned. The type parameter was made covariant because the structure is immutable.

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.