( path, prop, ...[opts] )
| 28 | ) => string |
| 29 | |
| 30 | export 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 | |
| 64 | export const stringifyPath: StringifyPathFn = (path, ...opts) => |
| 65 | path.reduce<string>( |
no test coverage detected
searching dependent graphs…