(value: ValueSchema)
| 289 | * An annotated `S.Array` of unique items that decodes to a `ReadonlySet`. |
| 290 | */ |
| 291 | export const ReadonlySetFromArray = <ValueSchema extends S.Top>(value: ValueSchema) => { |
| 292 | const from = S |
| 293 | .Array(value) |
| 294 | .annotate({ ...concurrencyUnbounded, expected: "an array of unique items that will be decoded as a ReadonlySet" }) |
| 295 | const to = S.instanceOf(Set) as S.instanceOf<ReadonlySet<ValueSchema["Type"]>> |
| 296 | const schema = from.pipe( |
| 297 | S.decodeTo( |
| 298 | to, |
| 299 | SchemaTransformation.transform({ |
| 300 | decode: (arr) => new Set(arr) as ReadonlySet<ValueSchema["Type"]>, |
| 301 | encode: (set) => [...set] |
| 302 | }) |
| 303 | ) |
| 304 | ) |
| 305 | return schema |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * An annotated `S.Array` of key-value tuples that decodes to a `ReadonlyMap`. |
no test coverage detected
searching dependent graphs…