(value: Value)
| 15949 | * @since 3.10.0 |
| 15950 | */ |
| 15951 | export function HashSet<Value extends Constraint>(value: Value): HashSet<Value> { |
| 15952 | const schema = declareConstructor< |
| 15953 | HashSet_.HashSet<Value["Type"]>, |
| 15954 | HashSet_.HashSet<Value["Encoded"]>, |
| 15955 | HashSetIso<Value> |
| 15956 | >()( |
| 15957 | [value], |
| 15958 | ([value]) => { |
| 15959 | const values = ArraySchema(value) |
| 15960 | return (input, ast, options) => { |
| 15961 | if (HashSet_.isHashSet(input)) { |
| 15962 | return Effect.mapBothEager( |
| 15963 | SchemaParser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), |
| 15964 | { |
| 15965 | onSuccess: HashSet_.fromIterable, |
| 15966 | onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "values", issue, input, options) |
| 15967 | } |
| 15968 | ) |
| 15969 | } |
| 15970 | return Effect.fail(new SchemaIssue.InvalidType(ast, input, options)) |
| 15971 | } |
| 15972 | }, |
| 15973 | { |
| 15974 | representation: { |
| 15975 | id: "effect/schema/HashSet", |
| 15976 | payload: null |
| 15977 | }, |
| 15978 | expected: "HashSet", |
| 15979 | toCodec: ([value]) => hashSetLink(ArraySchema(value)), |
| 15980 | toCodecArbitrary: ({ constraint, typeParameters: [value] }) => |
| 15981 | hashSetLink( |
| 15982 | withArrayLengthConstraints( |
| 15983 | ArraySchema(value).check(isUnique()), |
| 15984 | constraint?.minSize, |
| 15985 | constraint?.maxSize |
| 15986 | ) |
| 15987 | ), |
| 15988 | toEquivalence: ([value]) => Equal.makeCompareSet(value) |
| 15989 | } |
| 15990 | ) |
| 15991 | return make(schema.ast, { value }) |
| 15992 | } |
| 15993 | |
| 15994 | // ----------------------------------------------------------------------------- |
| 15995 | // Option schemas |
nothing calls this directly
no test coverage detected