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

Function splitKeyValue

packages/effect/src/SchemaGetter.ts:1136–1151  ·  view source on GitHub ↗
(options?: {
  readonly separator?: string | undefined
  readonly keyValueSeparator?: string | undefined
})

Source from the content-addressed store, hash-verified

1134 * @since 4.0.0
1135 */
1136export function splitKeyValue<E extends string>(options?: {
1137 readonly separator?: string | undefined
1138 readonly keyValueSeparator?: string | undefined
1139}): Getter<Record<string, string>, E> {
1140 const separator = options?.separator ?? ","
1141 const keyValueSeparator = options?.keyValueSeparator ?? "="
1142 return transform((input) =>
1143 input.split(separator).reduce((acc, pair) => {
1144 const [key, value] = pair.split(keyValueSeparator)
1145 if (key && value) {
1146 InternalRecord.assignProperty(acc, key, value)
1147 }
1148 return acc
1149 }, {} as Record<string, string>)
1150 )
1151}
1152
1153/**
1154 * Joins a record of key-value pairs into a delimited string.

Callers

nothing calls this directly

Calls 2

transformFunction · 0.70
splitMethod · 0.45

Tested by

no test coverage detected