Skip to main content

Module path

Module path 

Source
Expand description

The single path grammar used by every traversal operation.

A dot separates segments. \. embeds a dot in a key and \\ embeds a backslash. Every other escape is rejected so a path is reversible.

A segment may be empty, because "" is a legal key in JSON and YAML — npm writes one into every package-lock.json as the root package. Rejecting it did not make it unreachable, only unspeakable: join_path still rendered ["packages", ""] as packages., so paths emitted addresses that value and set then refused, and the reversibility this grammar exists to guarantee did not hold.

The one sequence with no spelling is [""] on its own: it renders as the empty string, which names no path at all. A "" key at the document root is therefore unaddressable, and that is the only hole left.

Functions§

join_path
parse_path