| 8254 | } |
| 8255 | } |
| 8256 | const zip = ( |
| 8257 | leftChunk: Chunk.Chunk<A>, |
| 8258 | rightChunk: Chunk.Chunk<A2>, |
| 8259 | f: (a: A, a2: A2) => A3 |
| 8260 | ): readonly [Chunk.Chunk<A3>, ZipAllState.ZipAllState<A, A2>] => { |
| 8261 | const [output, either] = zipChunks(leftChunk, rightChunk, f) |
| 8262 | switch (either._tag) { |
| 8263 | case "Left": { |
| 8264 | if (Chunk.isEmpty(either.left)) { |
| 8265 | return [output, ZipAllState.PullBoth] as const |
| 8266 | } |
| 8267 | return [output, ZipAllState.PullRight(either.left)] as const |
| 8268 | } |
| 8269 | case "Right": { |
| 8270 | if (Chunk.isEmpty(either.right)) { |
| 8271 | return [output, ZipAllState.PullBoth] as const |
| 8272 | } |
| 8273 | return [output, ZipAllState.PullLeft(either.right)] as const |
| 8274 | } |
| 8275 | } |
| 8276 | } |
| 8277 | return combineChunks(self, options.other, ZipAllState.PullBoth, pull) |
| 8278 | } |
| 8279 | ) |