(value: Value)
| 9494 | * @since 3.10.0 |
| 9495 | */ |
| 9496 | export function ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value> { |
| 9497 | const schema = declareConstructor< |
| 9498 | globalThis.ReadonlySet<Value["Type"]>, |
| 9499 | globalThis.ReadonlySet<Value["Encoded"]>, |
| 9500 | ReadonlySetIso<Value> |
| 9501 | >()( |
| 9502 | [value], |
| 9503 | ([value]) => { |
| 9504 | const array = ArraySchema(value) |
| 9505 | return (input, ast, options) => { |
| 9506 | if (input instanceof globalThis.Set) { |
| 9507 | return Effect.mapBothEager( |
| 9508 | SchemaParser.decodeUnknownEffect(array)([...input], options), |
| 9509 | { |
| 9510 | onSuccess: (array: ReadonlyArray<Value["Type"]>) => new globalThis.Set(array), |
| 9511 | onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "values", issue, input, options) |
| 9512 | } |
| 9513 | ) |
| 9514 | } |
| 9515 | return Effect.fail(new SchemaIssue.InvalidType(ast, input, options)) |
| 9516 | } |
| 9517 | }, |
| 9518 | { |
| 9519 | representation: { |
| 9520 | id: "effect/schema/ReadonlySet", |
| 9521 | payload: null |
| 9522 | }, |
| 9523 | expected: "ReadonlySet", |
| 9524 | toCodec: ([value]) => |
| 9525 | link<globalThis.Set<Value["Encoded"]>>()( |
| 9526 | ArraySchema(value), |
| 9527 | SchemaTransformation.transform({ |
| 9528 | decode: (values) => new globalThis.Set(values), |
| 9529 | encode: (set) => [...set.values()] |
| 9530 | }) |
| 9531 | ) |
| 9532 | } |
| 9533 | ) |
| 9534 | return make(schema.ast, { value }) |
| 9535 | } |
| 9536 | /** |
| 9537 | * Type-level representation of {@link RegExp}. |
| 9538 | * |
nothing calls this directly
no test coverage detected