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

Function ArrayConfig

packages/effect/src/Config.ts:1036–1051  ·  view source on GitHub ↗
(value: V, options?: {
  readonly separator?: string | undefined
})

Source from the content-addressed store, hash-verified

1034}
1035
1036const ArrayConfig = <V extends Schema.Constraint>(value: V, options?: {
1037 readonly separator?: string | undefined
1038}) => {
1039 const array = Schema.Array(value)
1040 const separator = options?.separator ?? ","
1041 const arrayString = Schema.String.pipe(
1042 Schema.decodeTo(Schema.toCodecStringTree(array), {
1043 decode: SchemaGetter.split(options),
1044 encode: SchemaGetter.passthrough<ReadonlyArray<string>, Schema.StringTree>({ strict: false }).compose(
1045 SchemaGetter.transform((input) => input.join(separator))
1046 )
1047 })
1048 )
1049
1050 return Schema.Union([arrayString, array])
1051}
1052
1053export {
1054 /**

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
pipeMethod · 0.65
composeMethod · 0.65
transformMethod · 0.65
toCodecStringTreeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected