Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

GroupBy

8 exports Since v2.0.0 Source

Constructors

Since v2.0.0

Constructs a GroupBy from a Stream.

Signature

declare const make: <K, V, E, R>(grouped: Stream.Stream<readonly [K, Queue.Dequeue<Take.Take<V, E>>], E, R>) => GroupBy<K, V, E, R>

Destructors

Since v2.0.0

Run the function across all groups, collecting the results in an arbitrary order.

Signature

declare const evaluate: {
<K, V, E, A, E2, R2>(f: (key: K, stream: Stream<V, E, never>) => Stream<A, E2, R2>, options?: {
readonly bufferSize?: number;
}): <R>(self: GroupBy<K, V, E, R>) => Stream<A, E | E2, R2 | R>;
<K, V, E, R, A, E2, R2>(self: GroupBy<K, V, E, R>, f: (key: K, stream: Stream<V, E, never>) => Stream<A, E2, R2>, options?: {
readonly bufferSize?: number;
}): Stream<A, E | E2, R | R2>;
}

Models

GroupBy

interface
Since v2.0.0

Representation of a grouped stream. This allows to filter which groups will be processed. Once this is applied all groups will be processed in parallel and the results will be merged in arbitrary order.

Signature

interface GroupBy<out K, out V, out E = never, out R = never> extends Variance<K, V, E, R>, Pipeable {
readonly grouped: Stream<readonly [K, Dequeue<Take<V, E>>], E, R>;
}

Other

Since v2.0.0

Symbols

Signature

declare const GroupByTypeId: unique symbol
Since v2.0.0

Signature

type GroupByTypeId = typeof GroupByTypeId

Utils

Since v2.0.0

Filter the groups to be processed.

Signature

declare const filter: {
<K>(predicate: Predicate<NoInfer<K>>): <V, E, R>(self: GroupBy<K, V, E, R>) => GroupBy<K, V, E, R>;
<K, V, E, R>(self: GroupBy<K, V, E, R>, predicate: Predicate<K>): GroupBy<K, V, E, R>;
}
Since v2.0.0

Only consider the first n groups found in the Stream.

Signature

declare const first: {
(n: number): <K, V, E, R>(self: GroupBy<K, V, E, R>) => GroupBy<K, V, E, R>;
<K, V, E, R>(self: GroupBy<K, V, E, R>, n: number): GroupBy<K, V, E, R>;
}