| 5115 | }) |
| 5116 | |
| 5117 | class StreamRechunker<out A, in out E> { |
| 5118 | private builder: Array<A> = [] |
| 5119 | private pos = 0 |
| 5120 | |
| 5121 | constructor(readonly n: number) { |
| 5122 | } |
| 5123 | |
| 5124 | isEmpty(): boolean { |
| 5125 | return this.pos === 0 |
| 5126 | } |
| 5127 | |
| 5128 | write(elem: A): Chunk.Chunk<A> | undefined { |
| 5129 | this.builder.push(elem) |
| 5130 | this.pos += 1 |
| 5131 | |
| 5132 | if (this.pos === this.n) { |
| 5133 | const result = Chunk.unsafeFromArray(this.builder) |
| 5134 | this.builder = [] |
| 5135 | this.pos = 0 |
| 5136 | return result |
| 5137 | } |
| 5138 | |
| 5139 | return undefined |
| 5140 | } |
| 5141 | |
| 5142 | emitIfNotEmpty(): Channel.Channel<Chunk.Chunk<A>, unknown, E, E, void, unknown> { |
| 5143 | if (this.pos !== 0) { |
| 5144 | return core.write(Chunk.unsafeFromArray(this.builder)) |
| 5145 | } |
| 5146 | return core.void |
| 5147 | } |
| 5148 | } |
| 5149 | |
| 5150 | /** @internal */ |
| 5151 | export const refineOrDie = dual< |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…