import { concreteStream, StreamInternal } from "@effect/core/stream/Stream/operations/_internal/StreamInternal" /** * Drops the specified number of elements from this stream. * * @tsplus static effect/core/stream/Stream.Aspects drop * @tsplus pipeable effect/core/stream/Stream drop */ export function drop(n: number) { return (self: Stream): Stream => { concreteStream(self) return new StreamInternal(self.channel >> loop(n)) } } function loop( r: number ): Channel, unknown, E, Chunk, unknown> { return Channel.readWith( (chunk: Chunk) => { const dropped = chunk.drop(r) const leftover = Math.max(0, r - chunk.length) const more = chunk.isEmpty || leftover > 0 return more ? loop(leftover) : Channel.write(dropped).flatMap(() => Channel.identity, unknown>()) }, (err) => Channel.fail(err), () => Channel.unit ) }