/**
* Partition a stream using a predicate. The first stream will contain all
* element evaluated to true and the second one will contain all element
* evaluated to false. The faster stream may advance by up to buffer elements
* further than the slower one.
*
* @tsplus static effect/core/stream/Stream.Aspects partition
* @tsplus pipeable effect/core/stream/Stream partition
*/
export function partition(
p: Predicate,
buffer = 16
) {
return (
self: Stream
): Effect, Stream]> =>
self.partitionEither(
(a) => p(a) ? Effect.succeed(Either.left(a)) : Effect.succeed(Either.right(a)),
buffer
)
}