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

Function ArrayEnsure

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

Source from the content-addressed store, hash-verified

4723 * @since 3.10.0
4724 */
4725export function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S> {
4726 return Union([schema, ArraySchema(schema)]).pipe(decodeTo(
4727 ArraySchema(toType(schema)),
4728 SchemaTransformation.transform({
4729 decode: Arr.ensure,
4730 encode: (array) => array.length === 1 ? array[0] : array
4731 })
4732 ))
4733}
4734
4735/**
4736 * Type-level representation returned by {@link UniqueArray}.

Callers

nothing calls this directly

Calls 5

toTypeInterface · 0.85
UnionFunction · 0.70
decodeToFunction · 0.70
pipeMethod · 0.65
transformMethod · 0.65

Tested by

no test coverage detected