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

Function Record

packages/effect/src/Config.ts:1270–1292  ·  view source on GitHub ↗
(
  key: K,
  value: V,
  pathOrOptions?: string | Path | RecordOptions,
  options?: RecordOptions
)

Source from the content-addressed store, hash-verified

1268 options?: RecordOptions
1269): Config<Schema.Record.Type<K, V>>
1270export function Record<
1271 K extends Schema.Record.Key & Schema.ConstraintCodec<unknown, unknown>,
1272 V extends Schema.ConstraintCodec<unknown, unknown>
1273>(
1274 key: K,
1275 value: V,
1276 pathOrOptions?: string | Path | RecordOptions,
1277 options?: RecordOptions
1278) {
1279 const hasPath = isPath(pathOrOptions)
1280 const record = Schema.Record(key, value)
1281 const split = SchemaTransformation.splitKeyValue(hasPath ? options : pathOrOptions)
1282 const recordString = Schema.String.pipe(
1283 Schema.decodeTo(Schema.toCodecStringTree(record), {
1284 decode: split.decode,
1285 encode: SchemaGetter.compose(
1286 SchemaGetter.passthrough<Record<string, string>, Schema.StringTree>({ strict: false }),
1287 split.encode
1288 )
1289 })
1290 )
1291 return schema(Schema.Union([record, recordString]), hasPath ? pathOrOptions : undefined)
1292}
1293
1294/**
1295 * Creates a config for a boolean value parsed from common string

Callers

nothing calls this directly

Calls 5

isPathFunction · 0.85
schemaFunction · 0.70
pipeMethod · 0.65
toCodecStringTreeMethod · 0.65
composeMethod · 0.65

Tested by

no test coverage detected