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

Function Array

packages/effect/src/Config.ts:1190–1209  ·  view source on GitHub ↗
(
  value: V,
  pathOrOptions?: string | Path | ArrayOptions,
  options?: ArrayOptions
)

Source from the content-addressed store, hash-verified

1188 options?: ArrayOptions
1189): Config<ReadonlyArray<V["Type"]>>
1190export function Array<V extends Schema.ConstraintCodec<unknown, unknown>>(
1191 value: V,
1192 pathOrOptions?: string | Path | ArrayOptions,
1193 options?: ArrayOptions
1194) {
1195 const hasPath = isPath(pathOrOptions)
1196 const resolvedOptions = hasPath ? options : pathOrOptions
1197 const array = Schema.Array(value)
1198 const separator = resolvedOptions?.separator ?? ","
1199 const arrayString = Schema.String.pipe(
1200 Schema.decodeTo(Schema.toCodecStringTree(array), {
1201 decode: SchemaGetter.split(resolvedOptions),
1202 encode: SchemaGetter.compose(
1203 SchemaGetter.passthrough<ReadonlyArray<string>, Schema.StringTree>({ strict: false }),
1204 SchemaGetter.transform((input) => input.join(separator))
1205 )
1206 })
1207 )
1208 return schema(Schema.Union([arrayString, array]), hasPath ? pathOrOptions : undefined)
1209}
1210
1211/**
1212 * Creates a config for record values that may also be read from a separated key-value string.

Callers 8

patternsFunction · 0.85
Binary.test.tsFile · 0.85
Pool.test.tsFile · 0.85
HttpClient.test.tsFile · 0.85
Arbitrary.test.tsFile · 0.85
mergeSortedFunction · 0.85
parseIpv6SegmentsFunction · 0.85

Calls 8

isPathFunction · 0.85
schemaFunction · 0.70
pipeMethod · 0.65
toCodecStringTreeMethod · 0.65
composeMethod · 0.65
transformMethod · 0.65
splitMethod · 0.45
joinMethod · 0.45

Tested by 1

patternsFunction · 0.68