(options: EncodeOptions | undefined)
| 855 | } |
| 856 | |
| 857 | const encodeRecords = <A, IE, Done>(options: EncodeOptions | undefined): Channel.Channel< |
| 858 | Arr.NonEmptyReadonlyArray<string>, |
| 859 | IE, |
| 860 | Done, |
| 861 | Arr.NonEmptyReadonlyArray<A>, |
| 862 | IE, |
| 863 | Done |
| 864 | > => { |
| 865 | const { header, writeRecord } = makeWriter(options) |
| 866 | return Channel.fromTransform((upstream, _scope) => |
| 867 | Effect.sync(() => { |
| 868 | let pending = header |
| 869 | const pull: Pull.Pull<Arr.NonEmptyReadonlyArray<string>, IE, Done> = Effect.suspend(() => { |
| 870 | if (pending !== undefined) { |
| 871 | const text = pending |
| 872 | pending = undefined |
| 873 | return Effect.succeed(Arr.of(text)) |
| 874 | } |
| 875 | return Effect.flatMap(upstream, (records) => Effect.sync(() => Arr.map(records, writeRecord))) |
| 876 | }) |
| 877 | return pull |
| 878 | }) |
| 879 | ) |
| 880 | } |
| 881 | |
| 882 | /** |
| 883 | * Creates a channel that writes CSV records as text, one string per record. |
no test coverage detected