MCPcopy Create free account
hub / github.com/Effect-TS/effect / ArrayEnsure

Function ArrayEnsure

packages/effect/src/Schema.ts:4828–4839  ·  view source on GitHub ↗
(schema: S)

Source from the content-addressed store, hash-verified

4826 * @since 3.10.0
4827 */
4828export function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S> {
4829 const many = ArraySchema(schema)
4830 const to = ArraySchema(toType(schema))
4831 const one = decodeTo(
4832 Tuple([Unknown]),
4833 SchemaTransformation.transform({
4834 decode: (value) => [value] as const,
4835 encode: ([value]) => value
4836 })
4837 )(schema)
4838 return make(Union([one, many]).pipe(decodeTo(to)).ast, { from: Union([schema, many]), to })
4839}
4840/**
4841 * Type-level representation returned by {@link UniqueArray}.
4842 *

Callers

nothing calls this directly

Calls 7

toTypeInterface · 0.70
decodeToFunction · 0.70
TupleFunction · 0.70
makeFunction · 0.70
UnionFunction · 0.70
transformMethod · 0.65
pipeMethod · 0.65

Tested by

no test coverage detected