(schema: S)
| 771 | */ |
| 772 | export const decodeSchemaString = |
| 773 | <S extends Schema.Constraint>(schema: S) => |
| 774 | <IE = never, Done = unknown>(options?: DecodeSchemaOptions, parseOptions?: SchemaAST.ParseOptions): Channel.Channel< |
| 775 | Arr.NonEmptyReadonlyArray<S["Type"]>, |
| 776 | IE | CsvError | Schema.SchemaError, |
| 777 | Done, |
| 778 | Arr.NonEmptyReadonlyArray<string>, |
| 779 | IE, |
| 780 | Done, |
| 781 | S["DecodingServices"] |
| 782 | > => { |
| 783 | const codec = toCodec(schema, options?.disableCodecs) |
| 784 | checkCells(SchemaAST.toEncoded(codec.ast), undefined) |
| 785 | const item = options?.headers === true && options.disableCodecs !== true ? headerCodec(codec) : codec |
| 786 | const decode = Schema.decodeUnknownEffect(toArrayCodec(item), parseOptions) |
| 787 | return Channel.mapEffect(decodeRecords<IE, Done>(options), (records) => |
| 788 | Effect.mapError( |
| 789 | decode(Arr.map(records, (record) => record.value)), |
| 790 | (error) => rebaseIssue(error, (index) => records[index].record) |
| 791 | )) |
| 792 | } |
| 793 | |
| 794 | /** |
| 795 | * Creates a channel that parses UTF-8 CSV and decodes each record with a schema. |
no test coverage detected