| name | path-sequence-to-string |
| description | Builds JavaScript property-access path strings incrementally from typed segments. Use when constructing or tracking object paths for debugging, proxies, or code generation — handles dot notation, bracket notation, numeric indexes, symbols, and verbatim fragments automatically. |
| license | MIT |
| metadata | {"author":"Oleg Galaburda","version":"0.0.7"} |
Path Sequence to String
Incrementally builds a JavaScript property-access path string from a sequence of typed segments, choosing the correct notation for each segment automatically.
When to use
- Building paths for Proxy-based object trackers or recorders
- Generating human-readable paths for debugging or error messages
- Code generation tools that need correct JS accessor syntax
- Any situation where you need to convert a sequence of property accesses into a string like
root.items[0]["display-name"]
Segment notation rules
| Segment | Example | Output |
|---|
| Valid identifier | 'foo', '_bar', '$el' | .foo |
| Integer / integer string | 0, '42' | [0] |
| Non-identifier string | 'foo-bar' | ["foo-bar"] |
| Symbol | Symbol('id') | [Symbol(id)] |
AsIs (verbatim) | new AsIs('[0].name') | [0].name |
Usage
import { createPathSequence, AsIs } from '@actualwave/path-sequence-to-string';
const p = createPathSequence('root');
p.append('items', 0, 'display-name');
const copy = p.clone('length');
p.appendRaw('[Symbol.iterator]');
console.log(`path: ${p}`);