| 702 | > => Channel.pipeTo(decode(options), ChannelSchema.decodeUnknown(schema)()) |
| 703 | |
| 704 | const stringify = (value: unknown): string => { |
| 705 | let output: string | undefined |
| 706 | try { |
| 707 | output = JSON.stringify(value) |
| 708 | } catch (cause) { |
| 709 | throw new JsonArrayError({ kind: "Encode", message: cause instanceof Error ? cause.message : String(cause), cause }) |
| 710 | } |
| 711 | if (output === undefined) { |
| 712 | throw new JsonArrayError({ kind: "Encode", message: `Value of type ${typeof value} cannot be represented as JSON` }) |
| 713 | } |
| 714 | return output |
| 715 | } |
| 716 | |
| 717 | /** |
| 718 | * Creates a channel that writes a stream of values as the text of one JSON |