<A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<
[A, Duration.Duration],
In,
L,
E,
R
>Returns the sink that executes this one and times its execution.
export const const withDuration: <A, In, L, E, R>(
self: Sink<A, In, L, E, R>
) => Sink<[A, Duration.Duration], In, L, E, R>
Returns the sink that executes this one and times its execution.
withDuration = <function (type parameter) A in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>A, function (type parameter) In in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>In, function (type parameter) L in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>L, function (type parameter) E in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>E, function (type parameter) R in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>R>(
self: Sink<A, In, L, E, R>(parameter) self: {
transform: (upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>, scope: Scope.Scope) => Effect.Effect<End<A, L>, E, 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; <…;
}
self: interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A Sink<A, In, L, E, R> is used to consume elements produced by a Stream.
You can think of a sink as a function that will consume a variable amount of
In elements (could be 0, 1, or many), might fail with an error of type E,
and will eventually yield a value of type A together with a remainder of
type L (i.e. any leftovers).
Example (Running a sink with a stream)
import { Effect, Sink, Stream } from "effect"
// Create a simple sink that always succeeds with a value
const sink: Sink.Sink<number> = Sink.succeed(42)
// Use the sink to consume a stream
const stream = Stream.make(1, 2, 3)
const program = Stream.run(stream, sink)
Effect.runPromise(program).then(console.log)
// Output: 42
Namespace containing types and interfaces for Sink variance and type relationships.
Sink<function (type parameter) A in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>A, function (type parameter) In in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>In, function (type parameter) L in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>L, function (type parameter) E in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>E, function (type parameter) R in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>R>
): interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A Sink<A, In, L, E, R> is used to consume elements produced by a Stream.
You can think of a sink as a function that will consume a variable amount of
In elements (could be 0, 1, or many), might fail with an error of type E,
and will eventually yield a value of type A together with a remainder of
type L (i.e. any leftovers).
Example (Running a sink with a stream)
import { Effect, Sink, Stream } from "effect"
// Create a simple sink that always succeeds with a value
const sink: Sink.Sink<number> = Sink.succeed(42)
// Use the sink to consume a stream
const stream = Stream.make(1, 2, 3)
const program = Stream.run(stream, sink)
Effect.runPromise(program).then(console.log)
// Output: 42
Namespace containing types and interfaces for Sink variance and type relationships.
Sink<[function (type parameter) A in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>A, import DurationDuration.type Duration.Duration = /*unresolved*/ anyDuration], function (type parameter) In in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>In, function (type parameter) L in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>L, function (type parameter) E in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>E, function (type parameter) R in <A, In, L, E, R>(self: Sink<A, In, L, E, R>): Sink<[A, Duration.Duration], In, L, E, R>R> =>
const summarized: {
<A2, E2, R2, A3>(
summary: Effect.Effect<A2, E2, R2>,
f: (start: A2, end: A2) => A3
): <A, In, L, E, R>(
self: Sink<A, In, L, E, R>
) => Sink<[A, A3], In, L, E2 | E, R2 | R>
<A, In, L, E, R, A2, E2, R2, A3>(
self: Sink<A, In, L, E, R>,
summary: Effect.Effect<A2, E2, R2>,
f: (start: A2, end: A2) => A3
): Sink<[A, A3], In, L, E | E2, R | R2>
}
summarized(self: Sink<A, In, L, E, R>(parameter) self: {
transform: (upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>, scope: Scope.Scope) => Effect.Effect<End<A, L>, E, 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; <…;
}
self, import ClockClock.currentTimeNanos, (start: unknownstart, end: unknownend) => import DurationDuration.nanos(end: unknownend - start: unknownstart))