effect-io-ai

Package: effect
Module: Stream

Stream.bindTo

Maps each element into a record keyed by the provided name.

Example (Binding values to a record key)

import { Console, Effect, Stream } from "effect"

const stream = Stream.make(1, 2, 3).pipe(Stream.bindTo("value"))

const program = Stream.runCollect(stream).pipe(Effect.flatMap(Console.log))

Effect.runPromise(program)
// [{ value: 1 }, { value: 2 }, { value: 3 }]

Signature

declare const bindTo: { <N extends string>(name: N): <A, E, R>(self: Stream<A, E, R>) => Stream<{ [K in N]: A; }, E, R>; <A, E, R, N extends string>(self: Stream<A, E, R>, name: N): Stream<{ [K in N]: A; }, E, R>; }

Source

Since v2.0.0