MCPcopy Create free account
hub / github.com/brillout/json-serializer / getPathString

Function getPathString

src/stringify.ts:212–225  ·  view source on GitHub ↗
(path: Path, canBeFirstKey: boolean)

Source from the content-addressed store, hash-verified

210}
211
212function getPathString(path: Path, canBeFirstKey: boolean): string {
213 const pathString = path
214 .map((key, i) => {
215 if (typeof key === 'number') {
216 return `[${key}]`
217 }
218 if (i === 0 && canBeFirstKey && isKeyDotNotationCompatible(key)) {
219 return key
220 }
221 return getPropAccessNotation(key)
222 })
223 .join('')
224 return pathString
225}
226function getPropAccessNotation(key: unknown): `.${string}` | `[${string}]` {
227 return typeof key === 'string' && isKeyDotNotationCompatible(key) ? `.${key}` : `[${JSON.stringify(key)}]`
228}

Callers 2

genErrFunction · 0.85
getSubjectNameFunction · 0.85

Calls 2

getPropAccessNotationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…