| 173 | * @since 4.0.0 |
| 174 | */ |
| 175 | export const decodeSchema = < |
| 176 | S extends EventCodec, |
| 177 | IE, |
| 178 | Done |
| 179 | >( |
| 180 | schema: S, |
| 181 | options?: DecodeOptions |
| 182 | ): Channel.Channel< |
| 183 | NonEmptyReadonlyArray<S["Type"]>, |
| 184 | IE | Retry | SseError | Schema.SchemaError, |
| 185 | Done, |
| 186 | NonEmptyReadonlyArray<string>, |
| 187 | IE, |
| 188 | Done, |
| 189 | S["DecodingServices"] |
| 190 | > => |
| 191 | Channel.pipeTo( |
| 192 | decode<IE, Done>(options), |
| 193 | ChannelSchema.decode(EventEncoded.pipe( |
| 194 | Schema.decodeTo(schema) |
| 195 | ))() |
| 196 | ) |
| 197 | |
| 198 | /** |
| 199 | * Creates an SSE decoder channel that JSON-decodes each event `data` field with a schema. |