<T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<
[T[number]] extends [never]
? never
: {
[K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R>
? A
: never
},
[T[number]] extends [never]
? never
: T[number] extends Stream<infer _A, infer _E, infer _R>
? _E
: never,
[T[number]] extends [never]
? never
: T[number] extends Stream<infer _A, infer _E, infer _R>
? _R
: never
>Zips multiple streams so that when a value is emitted by any stream, it is combined with the latest values from the other streams to produce a result.
When to use
Use when each stream should contribute its latest value after all streams have emitted at least once.
Gotchas
Note: tracking the latest value is done on a per-array basis. That means that emitted elements that are not the last value in arrays will never be used for zipping.
Example (Zipping latest values from many streams)
import { Console, Effect, Stream } from "effect"
const stream = Stream.zipLatestAll(
Stream.make(1, 2, 3).pipe(Stream.rechunk(1)),
Stream.make("a", "b", "c").pipe(Stream.rechunk(1)),
Stream.make(true, false, true).pipe(Stream.rechunk(1))
)
const program = Effect.gen(function*() {
const result = yield* Stream.runCollect(stream)
yield* Console.log(result)
})
Effect.runPromise(program)
// Output: [ [ 1, "a", true ], [ 2, "a", true ], [ 3, "a", true ], [ 3, "b", true ], [ 3, "c", true ], [ 3, "c", false ], [ 3, "c", true ] ]export const const zipLatestAll: <
T extends ReadonlyArray<Stream<any, any, any>>
>(
...streams: T
) => Stream<
[T[number]] extends [never]
? never
: {
[K in keyof T]: T[K] extends Stream<
infer A,
infer _E,
infer _R
>
? A
: never
},
[T[number]] extends [never]
? never
: T[number] extends Stream<
infer _A,
infer _E,
infer _R
>
? _E
: never,
[T[number]] extends [never]
? never
: T[number] extends Stream<
infer _A,
infer _E,
infer _R
>
? _R
: never
>
Zips multiple streams so that when a value is emitted by any stream, it is
combined with the latest values from the other streams to produce a result.
When to use
Use when each stream should contribute its latest value after all streams have
emitted at least once.
Gotchas
Note: tracking the latest value is done on a per-array basis. That means
that emitted elements that are not the last value in arrays will never be
used for zipping.
Example (Zipping latest values from many streams)
import { Console, Effect, Stream } from "effect"
const stream = Stream.zipLatestAll(
Stream.make(1, 2, 3).pipe(Stream.rechunk(1)),
Stream.make("a", "b", "c").pipe(Stream.rechunk(1)),
Stream.make(true, false, true).pipe(Stream.rechunk(1))
)
const program = Effect.gen(function*() {
const result = yield* Stream.runCollect(stream)
yield* Console.log(result)
})
Effect.runPromise(program)
// Output: [ [ 1, "a", true ], [ 2, "a", true ], [ 3, "a", true ], [ 3, "b", true ], [ 3, "c", true ], [ 3, "c", false ], [ 3, "c", true ] ]
zipLatestAll = <function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T extends interface ReadonlyArray<T>ReadonlyArray<interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<any, any, any>>>(
...streams: T extends ReadonlyArray<Stream<any, any, any>>streams: function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T
): interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<
[function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T[number]] extends [never] ? never
: { [function (type parameter) KK in keyof function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T]: function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T[function (type parameter) KK] extends interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<infer function (type parameter) AA, infer function (type parameter) _E_E, infer function (type parameter) _R_R> ? function (type parameter) AA : never },
[function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T[number]] extends [never] ? never : function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T[number] extends interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<infer function (type parameter) _A_A, infer function (type parameter) _E_E, infer function (type parameter) _R_R> ? function (type parameter) _E_E : never,
[function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T[number]] extends [never] ? never : function (type parameter) T in <T extends ReadonlyArray<Stream<any, any, any>>>(...streams: T): Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream<infer A, infer _E, infer _R> ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _E : never, [T[number]] extends [never] ? never : T[number] extends Stream<infer _A, infer _E, infer _R> ? _R : never>T[number] extends interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<infer function (type parameter) _A_A, infer function (type parameter) _E_E, infer function (type parameter) _R_R> ? function (type parameter) _R_R : never
> =>
const fromChannel: <
Arr extends Arr.NonEmptyReadonlyArray<any>,
E,
R
>(
channel: Channel.Channel<
Arr,
E,
void,
unknown,
unknown,
unknown,
R
>
) => Stream<
Arr extends Arr.NonEmptyReadonlyArray<infer A>
? A
: never,
E,
R
>
Creates a stream from a array-emitting Channel.
Example (Creating a stream from an array-emitting channel)
import { Channel, Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
const channel = Channel.succeed([1, 2, 3] as const)
const stream = Stream.fromChannel(channel)
const result = yield* Stream.runCollect(stream)
yield* Console.log(result)
})
// Output: [ 1, 2, 3 ]
fromChannel(import ChannelChannel.const suspend: <
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
evaluate: LazyArg<
Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
>
) => Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
Creates a Channel that lazily evaluates to another channel.
Example (Suspending channel creation)
import { Channel } from "effect"
const channel = Channel.suspend(() => Channel.succeed(42))
// The inner channel is not created until the suspended channel is run
suspend(() => {
const const latest: any[]latest: interface Array<T>Array<any> = []
const const emitted: Set<number>emitted = new var Set: SetConstructor
new <number>(iterable?: Iterable<number> | null | undefined) => Set<number> (+1 overload)
Set<number>()
const const readyLatch: Latch.Latchconst readyLatch: {
open: Effect.Effect<boolean>;
openUnsafe: (this: Latch) => boolean;
release: Effect.Effect<boolean>;
await: Effect.Effect<void>;
close: Effect.Effect<boolean>;
closeUnsafe: (this: Latch) => boolean;
whenOpen: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
isOpen: (this: Latch) => boolean;
}
readyLatch = import LatchLatch.const makeUnsafe: (
open?: boolean | undefined
) => Latch
Creates a Latch synchronously, outside of Effect.
When to use
Use when you need to allocate a Latch synchronously outside an Effect
workflow.
Details
The latch starts closed by default; pass true to create it open.
Example (Creating a latch unsafely)
import { Effect, Latch } from "effect"
const latch = Latch.makeUnsafe(false)
const waiter = Effect.gen(function*() {
yield* Effect.log("Waiting for latch to open...")
yield* latch.await
yield* Effect.log("Latch opened! Continuing...")
})
const opener = Effect.gen(function*() {
yield* Effect.sleep("2 seconds")
yield* Effect.log("Opening latch...")
yield* latch.open
})
const program = Effect.all([waiter, opener])
makeUnsafe()
return import ChannelChannel.const mergeAll: {
(options: {
readonly concurrency: number | "unbounded"
readonly bufferSize?: number | undefined
readonly switch?: boolean | undefined
}): <
OutElem,
OutErr1,
OutDone1,
InElem1,
InErr1,
InDone1,
Env1,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
channels: Channel<
Channel<
OutElem,
OutErr1,
OutDone1,
InElem1,
InErr1,
InDone1,
Env1
>,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
) => Channel<
OutElem,
OutErr1 | OutErr,
OutDone,
InElem & InElem1,
InErr & InErr1,
InDone & InDone1,
Env1 | Env
>
<
OutElem,
OutErr1,
OutDone1,
InElem1,
InErr1,
InDone1,
Env1,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
channels: Channel<
Channel<
OutElem,
OutErr1,
OutDone1,
InElem1,
InErr1,
InDone1,
Env1
>,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>,
options: {
readonly concurrency: number | "unbounded"
readonly bufferSize?: number | undefined
readonly switch?: boolean | undefined
}
): Channel<
OutElem,
OutErr1 | OutErr,
OutDone,
InElem & InElem1,
InErr & InErr1,
InDone & InDone1,
Env1 | Env
>
}
mergeAll(
import ChannelChannel.const fromArray: <A>(
array: ReadonlyArray<A>
) => Channel<A>
Creates a Channel that emits all elements from an array.
Example (Creating channels from arrays)
import { Channel } from "effect"
const channel = Channel.fromArray([1, 2, 3, 4, 5])
// Emits: 1, 2, 3, 4, 5
fromArray(
streams: T extends ReadonlyArray<Stream<any, any, any>>streams.ReadonlyArray<Stream<any, any, any>>.map<Channel.Channel<[any[], ...any[][]], any, void, unknown, unknown, unknown, any>>(callbackfn: (value: Stream<any, any, any>, index: number, array: readonly Stream<any, any, any>[]) => Channel.Channel<[any[], ...any[][]], any, void, unknown, unknown, unknown, any>, thisArg?: any): Channel.Channel<[any[], ...any[][]], any, void, unknown, unknown, unknown, any>[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((s: Stream<any, any, any>(parameter) s: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
s, i: numberi) =>
s: Stream<any, any, any>(parameter) s: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
s.Stream<any, any, any>.channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>(property) Stream<any, any, any>.channel: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
channel.Pipeable.pipe<Channel.Channel<readonly [any, ...any[]], any, void, unknown, unknown, unknown, any>, Channel.Channel<any, any, void, unknown, unknown, unknown, any>, Channel.Channel<[any[], ...any[][]] | undefined, any, void, unknown, unknown, unknown, any>, Channel.Channel<[any[], ...any[][]], any, void, unknown, unknown, unknown, any>>(this: Channel.Channel<...>, ab: (_: Channel.Channel<readonly [any, ...any[]], any, void, unknown, unknown, unknown, any>) => Channel.Channel<any, any, void, unknown, unknown, unknown, any>, bc: (_: Channel.Channel<any, any, void, unknown, unknown, unknown, any>) => Channel.Channel<[any[], ...any[][]] | undefined, any, void, unknown, unknown, unknown, any>, cd: (_: Channel.Channel<[...] | undefined, ... 5 more ..., any>) => Channel.Channel<...>): Channel.Channel<...> (+21 overloads)pipe(
import ChannelChannel.const flattenArray: <
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
self: Channel<
ReadonlyArray<OutElem>,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
) => Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
Flattens a channel that outputs arrays into a channel that outputs individual elements.
Example (Flattening arrays of channel output)
import { Channel, Data } from "effect"
class FlattenError extends Data.TaggedError("FlattenError")<{
readonly message: string
}> {}
// Create a channel that outputs arrays
const arrayChannel = Channel.fromIterable([
[1, 2, 3],
[4, 5],
[6, 7, 8, 9]
])
// Flatten the arrays into individual elements
const flattenedChannel = Channel.flattenArray(arrayChannel)
// Outputs: 1, 2, 3, 4, 5, 6, 7, 8, 9
flattenArray,
import ChannelChannel.const mapEffect: {
<OutElem, OutElem1, OutErr1, Env1>(
f: (
d: OutElem,
i: number
) => Effect.Effect<OutElem1, OutErr1, Env1>,
options?: {
readonly concurrency?:
| number
| "unbounded"
| undefined
readonly unordered?: boolean | undefined
}
): <
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
self: Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
) => Channel<
OutElem1,
OutErr1 | OutErr,
OutDone,
InElem,
InErr,
InDone,
Env1 | Env
>
<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env,
OutElem1,
OutErr1,
Env1
>(
self: Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>,
f: (
d: OutElem,
i: number
) => Effect.Effect<OutElem1, OutErr1, Env1>,
options?: {
readonly concurrency?:
| number
| "unbounded"
| undefined
readonly unordered?: boolean | undefined
}
): Channel<
OutElem1,
OutErr | OutErr1,
OutDone,
InElem,
InErr,
InDone,
Env | Env1
>
}
mapEffect((a: anya) => {
const latest: any[]latest[i: numberi] = a: anya
if (!const emitted: Set<number>emitted.Set<number>.has(value: number): booleanhas(i: numberi)) {
const emitted: Set<number>emitted.Set<number>.add(value: number): Set<number>Appends a new element with a specified value to the end of the Set.
add(i: numberi)
if (const emitted: Set<number>emitted.Set<number>.size: numbersize < streams: T extends ReadonlyArray<Stream<any, any, any>>streams.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length) {
return const readyLatch: Latch.Latchconst readyLatch: {
open: Effect.Effect<boolean>;
openUnsafe: (this: Latch) => boolean;
release: Effect.Effect<boolean>;
await: Effect.Effect<void>;
close: Effect.Effect<boolean>;
closeUnsafe: (this: Latch) => boolean;
whenOpen: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
isOpen: (this: Latch) => boolean;
}
readyLatch.Latch.await: Effect.Effect<void>(property) Latch.await: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Waits for the latch to be opened or released.
When to use
Use to suspend until the latch allows the current fiber to continue.
await as import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<undefined>
}
return import EffectEffect.const as: {
<B>(value: B): <A, E, R>(
self: Effect<A, E, R>
) => Effect<B, E, R>
<A, E, R, B>(
self: Effect<A, E, R>,
value: B
): Effect<B, E, R>
}
as(const readyLatch: Latch.Latchconst readyLatch: {
open: Effect.Effect<boolean>;
openUnsafe: (this: Latch) => boolean;
release: Effect.Effect<boolean>;
await: Effect.Effect<void>;
close: Effect.Effect<boolean>;
closeUnsafe: (this: Latch) => boolean;
whenOpen: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
isOpen: (this: Latch) => boolean;
}
readyLatch.Latch.open: Effect.Effect<boolean>(property) Latch.open: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Opens the latch, releasing all fibers waiting on it.
When to use
Use to let current and future waiters continue.
open, import ArrArr.const of: <A>(a: A) => NonEmptyArray<A>Wraps a single value in a NonEmptyArray.
Example (Creating a single-element array)
import { Array } from "effect"
console.log(Array.of(1)) // [1]
of(const latest: any[]latest.Array<any>.slice(start?: number, end?: number): any[]Returns a copy of a section of an array.
For both start and end, a negative index can be used to indicate an offset from the end of the array.
For example, -2 refers to the second to last element of the array.
slice()))
}
return import EffectEffect.const succeed: <A>(value: A) => Effect<A>Creates an Effect that always succeeds with a given value.
When to use
Use when an effect should complete successfully with a specific value without any errors
or external dependencies.
Example (Creating a successful effect)
import { Effect } from "effect"
// Creating an effect that represents a successful scenario
//
// ┌─── Effect<number, never, never>
// ▼
const success = Effect.succeed(42)
succeed(import ArrArr.const of: <A>(a: A) => NonEmptyArray<A>Wraps a single value in a NonEmptyArray.
Example (Creating a single-element array)
import { Array } from "effect"
console.log(Array.of(1)) // [1]
of(const latest: any[]latest.Array<any>.slice(start?: number, end?: number): any[]Returns a copy of a section of an array.
For both start and end, a negative index can be used to indicate an offset from the end of the array.
For example, -2 refers to the second to last element of the array.
slice()))
}),
import ChannelChannel.const filter: {
<OutElem, B extends OutElem>(
refinement: Predicate.Refinement<OutElem, B>
): <
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
self: Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
) => Channel<
B,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
<OutElem>(
predicate: Predicate.Predicate<OutElem>
): <
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
self: Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
) => Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env,
B extends OutElem
>(
self: Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>,
refinement: Predicate.Refinement<OutElem, B>
): Channel<
B,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>(
self: Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>,
predicate: Predicate.Predicate<OutElem>
): Channel<
OutElem,
OutErr,
OutDone,
InElem,
InErr,
InDone,
Env
>
}
filter(function isNotUndefined<A>(input: A): input is Exclude<A, undefined>Checks whether a value is not undefined.
When to use
Use when you need a Predicate refinement that filters out undefined
while preserving other falsy values.
Details
Returns a refinement that excludes undefined.
Example (Filtering undefined values)
import { Predicate } from "effect"
const values = [1, undefined, 2]
const defined = values.filter(Predicate.isNotUndefined)
console.log(defined)
isNotUndefined)
)
)
),
{
concurrency: number | "unbounded"concurrency: "unbounded",
bufferSize?: number | undefinedbufferSize: 0
}
)
})) as any