effect
4.1.4 · 11 Nov 2026MIT66.6M / weekRepositoryHomepagenpmAtom feed
3.22.5 is the newest release of 3.x.
In short
11 new
Security
2 advisories affect 3.6.0; 3.22.1 fixes them
- HighEffect: ReDoS in Schema.TemplateLiteral compiled regexGHSA-7589-6fvf-x4pw · 19 Nov 2026Fixed in 3.22.1
- HighEffect `AsyncLocalStorage` context lost/contaminated inside Effect fibers under concurrent load with RPCGHSA-38f7-945m-qr2g · 20 Mar 2026Fixed in 3.20.0
Release note
Minor Changes
Make List.Cons extend NonEmptyIterable
Add DateTime module
The
DateTimemodule provides functionality for working with time, including
support for time zones and daylight saving time.It has two main data types:
DateTime.UtcandDateTime.Zoned.A
DateTime.Utcrepresents a time in Coordinated Universal Time (UTC), and
aDateTime.Zonedcontains both a UTC timestamp and a time zone.There is also a
CurrentTimeZoneservice, for setting a time zone contextually.import { DateTime, Effect } from "effect"; Effect.gen(function* () { // Get the current time in the current time zone const now = yield* DateTime.nowInCurrentZone; // Math functions are included const tomorrow = DateTime.add(now, 1, "day"); // Convert to a different time zone // The UTC portion of the `DateTime` is preserved and only the time zone is // changed const sydneyTime = tomorrow.pipe( DateTime.unsafeSetZoneNamed("Australia/Sydney"), ); }).pipe(DateTime.withCurrentZoneNamed("America/New_York"));Add Stream.asyncPush api
This api creates a stream from an external push-based resource.
You can use the
emithelper to emit values to the stream. You can also use
theemithelper to signal the end of the stream by using apis such asemit.endoremit.fail.By default it uses an "unbounded" buffer size.
You can customize the buffer size and strategy by passing an object as the
second argument with thebufferSizeandstrategyfields.import { Effect, Stream } from "effect"; Stream.asyncPush<string>( (emit) => Effect.acquireRelease( Effect.gen(function* () { yield* Effect.log("subscribing"); return setInterval(() => emit.single("tick"), 1000); }), (handle) => Effect.gen(function* () { yield* Effect.log("unsubscribing"); clearInterval(handle); }), ), { bufferSize: 16, strategy: "dropping" }, );Implement Struct.keys as a typed alternative to Object.keys
import { Struct } from "effect"; const symbol: unique symbol = Symbol(); const value = { a: 1, b: 2, [symbol]: 3, }; const keys: Array<"a" | "b"> = Struct.keys(value);Add
Random.choice.import { Random } from "effect"; Effect.gen(function* () { const randomItem = yield* Random.choice([1, 2, 3]); console.log(randomItem); });Add onlyEffect option to Effect.tap
Support
RefinementinPredicate.tupleandPredicate.structImplement
Stream.onEndthat adds an effect to be executed at the end of the stream.import { Console, Effect, Stream } from "effect"; const stream = Stream.make(1, 2, 3).pipe( Stream.map((n) => n * 2), Stream.tap((n) => Console.log(`after mapping: ${n}`)), Stream.onEnd(Console.log("Stream ended")), ); Effect.runPromise(Stream.runCollect(stream)).then(console.log); // after mapping: 2 // after mapping: 4 // after mapping: 6 // Stream ended // { _id: 'Chunk', values: [ 2, 4, 6 ] }Implement
Stream.onStartthat adds an effect to be executed at the start of the stream.import { Console, Effect, Stream } from "effect"; const stream = Stream.make(1, 2, 3).pipe( Stream.onStart(Console.log("Stream started")), Stream.map((n) => n * 2), Stream.tap((n) => Console.log(`after mapping: ${n}`)), ); Effect.runPromise(Stream.runCollect(stream)).then(console.log); // Stream started // after mapping: 2 // after mapping: 4 // after mapping: 6 // { _id: 'Chunk', values: [ 2, 4, 6 ] }Add
bufferSizeoption to Stream.fromEventListenerChanged various function signatures to return
Arrayinstead ofReadonlyArray
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.