| 196 | * @since 4.0.0 |
| 197 | */ |
| 198 | export const decodeSchema = < |
| 199 | S extends EventCodec, |
| 200 | IE, |
| 201 | Done |
| 202 | >( |
| 203 | schema: S, |
| 204 | options?: DecodeOptions, |
| 205 | parseOptions?: SchemaAST.ParseOptions |
| 206 | ): Channel.Channel< |
| 207 | NonEmptyReadonlyArray<S["Type"]>, |
| 208 | IE | Retry | SseError | Schema.SchemaError, |
| 209 | Done, |
| 210 | NonEmptyReadonlyArray<string>, |
| 211 | IE, |
| 212 | Done, |
| 213 | S["DecodingServices"] |
| 214 | > => |
| 215 | Channel.pipeTo( |
| 216 | decode<IE, Done>(options), |
| 217 | ChannelSchema.decode( |
| 218 | Event.pipe( |
| 219 | Schema.decodeTo(schema, transformEvent) |
| 220 | ), |
| 221 | parseOptions |
| 222 | )() |
| 223 | ) |
| 224 | |
| 225 | /** |
| 226 | * Creates an SSE decoder channel that JSON-decodes each event `data` field with a schema. |