MCPcopy Create free account
hub / github.com/arktypeio/arktype / withPrefixedMeta

Function withPrefixedMeta

ark/schema/parseSchema.ts:508–522  ·  view source on GitHub ↗
(input: dict)

Source from the content-addressed store, hash-verified

506
507// meta. prefixed keys are moved to meta, overwriting a nested key of the same name
508const withPrefixedMeta = (input: dict): dict => {
509 let meta: dict | undefined
510 let rest: dict | undefined
511 for (const k in input) {
512 if (!k.startsWith("meta.")) continue
513 rest ??= { ...input }
514 meta ??=
515 typeof input.meta === "string" ? { description: input.meta }
516 : input.meta ? { ...(input.meta as dict) }
517 : {}
518 meta[k.slice(5)] = input[k]
519 delete rest[k]
520 }
521 return rest ? { ...rest, meta } : input
522}

Callers 1

parseNodeSchemaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected