( self: Channel<ReadonlyArray<OutElem>, OutErr, OutDone, InElem, InErr, InDone, Env> )
| 3064 | * @since 4.0.0 |
| 3065 | */ |
| 3066 | export const flattenArray = < |
| 3067 | OutElem, |
| 3068 | OutErr, |
| 3069 | OutDone, |
| 3070 | InElem, |
| 3071 | InErr, |
| 3072 | InDone, |
| 3073 | Env |
| 3074 | >( |
| 3075 | self: Channel<ReadonlyArray<OutElem>, OutErr, OutDone, InElem, InErr, InDone, Env> |
| 3076 | ): Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env> => |
| 3077 | transformPull(self, (pull) => { |
| 3078 | let array: ReadonlyArray<OutElem> | undefined |
| 3079 | let index = 0 |
| 3080 | const pump = Effect.suspend(function loop(): Pull.Pull<OutElem, OutErr, OutDone> { |
| 3081 | if (array === undefined) { |
| 3082 | return Effect.flatMap(pull, (array_) => { |
| 3083 | switch (array_.length) { |
| 3084 | case 0: |
| 3085 | return loop() |
| 3086 | case 1: |
| 3087 | return Effect.succeed(array_[0]) |
| 3088 | default: { |
| 3089 | array = array_ |
| 3090 | return Effect.succeed(array_[index++]) |
| 3091 | } |
| 3092 | } |
| 3093 | }) |
| 3094 | } |
| 3095 | const next = array[index++] |
| 3096 | if (index >= array.length) { |
| 3097 | array = undefined |
| 3098 | index = 0 |
| 3099 | } |
| 3100 | return Effect.succeed(next) |
| 3101 | }) |
| 3102 | return Effect.succeed(pump) |
| 3103 | }) |
| 3104 | |
| 3105 | /** |
| 3106 | * Flattens a channel that emits `Take` values into a channel that emits the |
nothing calls this directly
no test coverage detected