MCPcopy Index your code
hub / github.com/arktypeio/arktype / appendStringifiedKey

Function appendStringifiedKey

ark/util/path.ts:30–62  ·  view source on GitHub ↗
(
	path,
	prop,
	...[opts]
)

Source from the content-addressed store, hash-verified

28) => string
29
30export const appendStringifiedKey: AppendStringifiedKeyFn = (
31 path,
32 prop,
33 ...[opts]
34) => {
35 const stringifySymbol = opts?.stringifySymbol ?? printable
36 let propAccessChain: string = path
37 switch (typeof prop) {
38 case "string":
39 propAccessChain =
40 isDotAccessible(prop) ?
41 path === "" ?
42 prop
43 : `${path}.${prop}`
44 : `${path}[${JSON.stringify(prop)}]`
45 break
46 case "number":
47 propAccessChain = `${path}[${prop}]`
48 break
49 case "symbol":
50 propAccessChain = `${path}[${stringifySymbol(prop)}]`
51 break
52 default:
53 if (opts?.stringifyNonKey)
54 propAccessChain = `${path}[${opts.stringifyNonKey(prop as never)}]`
55 else {
56 throwParseError(
57 `${printable(prop)} must be a PropertyKey or stringifyNonKey must be passed to options`
58 )
59 }
60 }
61 return propAccessChain
62}
63
64export const stringifyPath: StringifyPathFn = (path, ...opts) =>
65 path.reduce<string>(

Callers 2

stringifyPathFunction · 0.85
stringifyAncestorsMethod · 0.85

Calls 4

isDotAccessibleFunction · 0.90
throwParseErrorFunction · 0.90
printableFunction · 0.90
stringifyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…