MCPcopy Index your code
hub / github.com/Effect-TS/effect / record

Function record

packages/effect/src/SchemaAST.ts:2363–2404  ·  view source on GitHub ↗
(key: AST, value: AST)

Source from the content-addressed store, hash-verified

2361
2362/** @internal */
2363export const record = (key: AST, value: AST): {
2364 propertySignatures: Array<PropertySignature>
2365 indexSignatures: Array<IndexSignature>
2366} => {
2367 const propertySignatures: Array<PropertySignature> = []
2368 const indexSignatures: Array<IndexSignature> = []
2369 const go = (key: AST): void => {
2370 switch (key._tag) {
2371 case "NeverKeyword":
2372 break
2373 case "StringKeyword":
2374 case "SymbolKeyword":
2375 case "TemplateLiteral":
2376 case "Refinement":
2377 indexSignatures.push(new IndexSignature(key, value, true))
2378 break
2379 case "Literal":
2380 if (Predicate.isString(key.literal) || Predicate.isNumber(key.literal)) {
2381 propertySignatures.push(new PropertySignature(key.literal, value, false, true))
2382 } else {
2383 throw new Error(errors_.getASTUnsupportedLiteralErrorMessage(key.literal))
2384 }
2385 break
2386 case "Enums": {
2387 for (const [_, name] of key.enums) {
2388 propertySignatures.push(new PropertySignature(name, value, false, true))
2389 }
2390 break
2391 }
2392 case "UniqueSymbol":
2393 propertySignatures.push(new PropertySignature(key.symbol, value, false, true))
2394 break
2395 case "Union":
2396 key.types.forEach(go)
2397 break
2398 default:
2399 throw new Error(errors_.getASTUnsupportedKeySchemaErrorMessage(key))
2400 }
2401 }
2402 go(key)
2403 return { propertySignatures, indexSignatures }
2404}
2405
2406/**
2407 * Equivalent at runtime to the built-in TypeScript utility type `Pick`.

Callers

nothing calls this directly

Calls 1

goFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…