<A, L, A2, E2, R2, L2 = never>(
f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>
): <In, E, R>(
self: Sink<A, In, L, E, R>
) => Sink<A2, In, L2, E2 | E, R2 | R>
<A, In, L, E, R, A2, E2, R2, L2 = never>(
self: Sink<A, In, L, E, R>,
f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>
): Sink<A2, In, L2, E | E2, R | R2>Transforms the full End produced by this sink effectfully.
Details
This can change both the result value and the optional leftovers, and the transformation can fail or require services.
export const const mapEffectEnd: {
<A, L, A2, E2, R2, L2 = never>(
f: (
end: End<A, L>
) => Effect.Effect<End<A2, L2>, E2, R2>
): <In, E, R>(
self: Sink<A, In, L, E, R>
) => Sink<A2, In, L2, E2 | E, R2 | R>
<A, In, L, E, R, A2, E2, R2, L2 = never>(
self: Sink<A, In, L, E, R>,
f: (
end: End<A, L>
) => Effect.Effect<End<A2, L2>, E2, R2>
): Sink<A2, In, L2, E | E2, R | R2>
}
Transforms the full End produced by this sink effectfully.
Details
This can change both the result value and the optional leftovers, and the
transformation can fail or require services.
mapEffectEnd: {
<function (type parameter) A in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>A, function (type parameter) L in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>L, function (type parameter) A2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>A2, function (type parameter) E2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>E2, function (type parameter) R2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>R2, function (type parameter) L2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>L2 = never>(
f: (
end: End<A, L>
) => Effect.Effect<End<A2, L2>, E2, R2>
f: (end: End<A, L>(parameter) end: {
0: A;
1: readonly [L, ...L[]] | undefined;
length: 2 | 1;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<A | readonly [L, ...L[]] | undefined>>): Array<A | readonly [L, ...L[]] | undefined>; (...items: Array<A | readonly [L, ...L[]] | ConcatArray<A | readonly [L, ...L[]] | undefined> | undefined>): Array<A | rea…;
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<A | readonly [L, ...L[]] | undefined>;
indexOf: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => number;
every: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: A | readonly [L, ...L[]] | unde…;
some: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | readonly [L, ...L[]] | undefined, index…;
reduce: { (callbackfn: (previousValue: A | readonly [L, ...L[]] | undefined, currentValue: A | readonly [L, ...L[]] | undefined, currentIndex: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => A | readonly [L, ...L[]] | undefi…;
reduceRight: { (callbackfn: (previousValue: A | readonly [L, ...L[]] | undefined, currentValue: A | readonly [L, ...L[]] | undefined, currentIndex: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => A | readonly [L, ...L[]] | undefi…;
find: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, obj: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | readonly [L, ...L[]] | undefined, in…;
findIndex: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, obj: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, A | readonly [L, ...L[]] | undefined]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | readonly [L, ...L[]] | undefined>;
includes: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | readonly [L, ...L[]] | undefined, index: number, array: Array<A | readonly [L, ...L[]] | undefined>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | readonly [L, ...L[]] | undefined;
findLast: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | readonly [L, ...L[]] | undefined, …;
findLastIndex: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | readonly [L, ...L[]] | undefined>;
toSorted: (compareFn?: ((a: A | readonly [L, ...L[]] | undefined, b: A | readonly [L, ...L[]] | undefined) => number) | undefined) => Array<A | readonly [L, ...L[]] | undefined>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | readonly [L, ...L[]] | undefined>): Array<A | readonly [L, ...L[]] | undefined>; (start: number, deleteCount?: number): Array<A | readonly [L, ...L[]] | undefined> };
with: (index: number, value: A | readonly [L, ...L[]] | undefined) => Array<A | readonly [L, ...L[]] | undefined>;
}
end: type End<A, L = never> = readonly [
value: A,
leftover?: any
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>A, function (type parameter) L in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>L>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<type End<A, L = never> = readonly [
value: A,
leftover?: any
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>A2, function (type parameter) L2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>L2>, function (type parameter) E2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>E2, function (type parameter) R2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>R2>
): <function (type parameter) In in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>In, function (type parameter) E in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>E, function (type parameter) R in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | 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, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>A, function (type parameter) In in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>In, function (type parameter) L in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>L, function (type parameter) E in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>E, function (type parameter) R in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | 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) A2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>A2, function (type parameter) In in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>In, function (type parameter) L2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>L2, function (type parameter) E2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>E2 | function (type parameter) E in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>E, function (type parameter) R2 in <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>R2 | function (type parameter) R in <In, E, R>(self: Sink<A, In, L, E, R>): Sink<A2, In, L2, E2 | E, R2 | R>R>
<function (type parameter) A in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A, function (type parameter) In in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>In, function (type parameter) L in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L, function (type parameter) E in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E, function (type parameter) R in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R, function (type parameter) A2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A2, function (type parameter) E2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E2, function (type parameter) R2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R2, function (type parameter) L2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L2 = never>(
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, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A, function (type parameter) In in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>In, function (type parameter) L in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L, function (type parameter) E in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E, function (type parameter) R in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R>,
f: (
end: End<A, L>
) => Effect.Effect<End<A2, L2>, E2, R2>
f: (end: End<A, L>(parameter) end: {
0: A;
1: readonly [L, ...L[]] | undefined;
length: 2 | 1;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<A | readonly [L, ...L[]] | undefined>>): Array<A | readonly [L, ...L[]] | undefined>; (...items: Array<A | readonly [L, ...L[]] | ConcatArray<A | readonly [L, ...L[]] | undefined> | undefined>): Array<A | rea…;
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<A | readonly [L, ...L[]] | undefined>;
indexOf: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => number;
every: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: A | readonly [L, ...L[]] | unde…;
some: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | readonly [L, ...L[]] | undefined, index…;
reduce: { (callbackfn: (previousValue: A | readonly [L, ...L[]] | undefined, currentValue: A | readonly [L, ...L[]] | undefined, currentIndex: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => A | readonly [L, ...L[]] | undefi…;
reduceRight: { (callbackfn: (previousValue: A | readonly [L, ...L[]] | undefined, currentValue: A | readonly [L, ...L[]] | undefined, currentIndex: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => A | readonly [L, ...L[]] | undefi…;
find: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, obj: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | readonly [L, ...L[]] | undefined, in…;
findIndex: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, obj: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, A | readonly [L, ...L[]] | undefined]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | readonly [L, ...L[]] | undefined>;
includes: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | readonly [L, ...L[]] | undefined, index: number, array: Array<A | readonly [L, ...L[]] | undefined>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | readonly [L, ...L[]] | undefined;
findLast: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | readonly [L, ...L[]] | undefined, …;
findLastIndex: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | readonly [L, ...L[]] | undefined>;
toSorted: (compareFn?: ((a: A | readonly [L, ...L[]] | undefined, b: A | readonly [L, ...L[]] | undefined) => number) | undefined) => Array<A | readonly [L, ...L[]] | undefined>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | readonly [L, ...L[]] | undefined>): Array<A | readonly [L, ...L[]] | undefined>; (start: number, deleteCount?: number): Array<A | readonly [L, ...L[]] | undefined> };
with: (index: number, value: A | readonly [L, ...L[]] | undefined) => Array<A | readonly [L, ...L[]] | undefined>;
}
end: type End<A, L = never> = readonly [
value: A,
leftover?: any
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A, function (type parameter) L in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<type End<A, L = never> = readonly [
value: A,
leftover?: any
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A2, function (type parameter) L2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L2>, function (type parameter) E2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E2, function (type parameter) R2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R2>
): 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) A2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A2, function (type parameter) In in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>In, function (type parameter) L2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L2, function (type parameter) E in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E | function (type parameter) E2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E2, function (type parameter) R in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R | function (type parameter) R2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R2>
} = import dualdual(2, <function (type parameter) A in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A, function (type parameter) In in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>In, function (type parameter) L in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L, function (type parameter) E in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E, function (type parameter) R in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R, function (type parameter) A2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A2, function (type parameter) E2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E2, function (type parameter) R2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R2, function (type parameter) L2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L2 = never>(
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, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A, function (type parameter) In in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>In, function (type parameter) L in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L, function (type parameter) E in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E, function (type parameter) R in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R>,
f: (
end: End<A, L>
) => Effect.Effect<End<A2, L2>, E2, R2>
f: (end: End<A, L>(parameter) end: {
0: A;
1: readonly [L, ...L[]] | undefined;
length: 2 | 1;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<A | readonly [L, ...L[]] | undefined>>): Array<A | readonly [L, ...L[]] | undefined>; (...items: Array<A | readonly [L, ...L[]] | ConcatArray<A | readonly [L, ...L[]] | undefined> | undefined>): Array<A | rea…;
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<A | readonly [L, ...L[]] | undefined>;
indexOf: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => number;
lastIndexOf: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => number;
every: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: A | readonly [L, ...L[]] | unde…;
some: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => void, thisArg?: any) => void;
map: (callbackfn: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): Array<S>; (predicate: (value: A | readonly [L, ...L[]] | undefined, index…;
reduce: { (callbackfn: (previousValue: A | readonly [L, ...L[]] | undefined, currentValue: A | readonly [L, ...L[]] | undefined, currentIndex: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => A | readonly [L, ...L[]] | undefi…;
reduceRight: { (callbackfn: (previousValue: A | readonly [L, ...L[]] | undefined, currentValue: A | readonly [L, ...L[]] | undefined, currentIndex: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => A | readonly [L, ...L[]] | undefi…;
find: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, obj: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | readonly [L, ...L[]] | undefined, in…;
findIndex: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, obj: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, A | readonly [L, ...L[]] | undefined]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<A | readonly [L, ...L[]] | undefined>;
includes: (searchElement: A | readonly [L, ...L[]] | undefined, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: A | readonly [L, ...L[]] | undefined, index: number, array: Array<A | readonly [L, ...L[]] | undefined>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => A | readonly [L, ...L[]] | undefined;
findLast: { (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => value is S, thisArg?: any): S | undefined; (predicate: (value: A | readonly [L, ...L[]] | undefined, …;
findLastIndex: (predicate: (value: A | readonly [L, ...L[]] | undefined, index: number, array: ReadonlyArray<A | readonly [L, ...L[]] | undefined>) => unknown, thisArg?: any) => number;
toReversed: () => Array<A | readonly [L, ...L[]] | undefined>;
toSorted: (compareFn?: ((a: A | readonly [L, ...L[]] | undefined, b: A | readonly [L, ...L[]] | undefined) => number) | undefined) => Array<A | readonly [L, ...L[]] | undefined>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<A | readonly [L, ...L[]] | undefined>): Array<A | readonly [L, ...L[]] | undefined>; (start: number, deleteCount?: number): Array<A | readonly [L, ...L[]] | undefined> };
with: (index: number, value: A | readonly [L, ...L[]] | undefined) => Array<A | readonly [L, ...L[]] | undefined>;
}
end: type End<A, L = never> = readonly [
value: A,
leftover?: any
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A, function (type parameter) L in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<type End<A, L = never> = readonly [
value: A,
leftover?: any
]
Tuple returned when a Sink finishes.
Details
The first element is the sink result. The optional second element contains a
non-empty array of leftover input that was pulled but not consumed.
End<function (type parameter) A2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A2, function (type parameter) L2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L2>, function (type parameter) E2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E2, function (type parameter) R2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R2>
): 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) A2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>A2, function (type parameter) In in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>In, function (type parameter) L2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>L2, function (type parameter) E in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E | function (type parameter) E2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>E2, function (type parameter) R in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R | function (type parameter) R2 in <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>R2> => const transformEffect: <
A,
In,
L,
E,
R,
A2,
E2,
R2,
L2 = never
>(
self: Sink<A, In, L, E, R>,
f: (
effect: Effect.Effect<End<A, L>, E, R>
) => Effect.Effect<End<A2, L2>, E2, R2>
) => Sink<A2, In, L2, E2, R2>
transformEffect(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 EffectEffect.flatMap(f: (
end: End<A, L>
) => Effect.Effect<End<A2, L2>, E2, R2>
f)))