( predicate: (input: In) => Effect.Effect<boolean, E, R>, done: Chunk.Chunk<In> )
| 235 | |
| 236 | /** @internal */ |
| 237 | const collectAllWhileEffectReader = <In, R, E>( |
| 238 | predicate: (input: In) => Effect.Effect<boolean, E, R>, |
| 239 | done: Chunk.Chunk<In> |
| 240 | ): Channel.Channel<Chunk.Chunk<In>, Chunk.Chunk<In>, E, never, Chunk.Chunk<In>, unknown, R> => |
| 241 | core.readWith({ |
| 242 | onInput: (input: Chunk.Chunk<In>) => |
| 243 | pipe( |
| 244 | core.fromEffect(pipe(input, Effect.takeWhile(predicate), Effect.map(Chunk.unsafeFromArray))), |
| 245 | core.flatMap((collected) => { |
| 246 | const leftovers = pipe(input, Chunk.drop(collected.length)) |
| 247 | if (Chunk.isEmpty(leftovers)) { |
| 248 | return collectAllWhileEffectReader(predicate, pipe(done, Chunk.appendAll(collected))) |
| 249 | } |
| 250 | return pipe(core.write(leftovers), channel.zipRight(core.succeed(pipe(done, Chunk.appendAll(collected))))) |
| 251 | }) |
| 252 | ), |
| 253 | onFailure: core.fail, |
| 254 | onDone: () => core.succeed(done) |
| 255 | }) |
| 256 | |
| 257 | /** @internal */ |
| 258 | export const collectAllWhileWith: { |
no test coverage detected