Expand description
The npm “package spec” — the dependency-specifier grammar, per https://docs.npmjs.com/cli/v8/using-npm/package-spec.
A package.json dependencies value is one of these forms. Spec::parse classifies
a value by form; Spec::is_registry reports whether it resolves to a fetchable
registry tarball — the only form npm-utils installs (git / remote-tarball / local-path /
alias-to-non-registry are not). Range parsing is deferred to version_req: classifying
never fails, so an npm range we can’t fully parse (spaces, ||) is still a registry spec.
Structs§
- Range
- An npm version range:
||-separated alternatives, each a (possibly space-separated) set of comparators. Rust’sVersionReqhandles only comma-separated comparators and has no||, yet||ranges are pervasive in published packages’ dependencies (e.g.@lit/reactive-element’s^1.6.2 || ^2.1.0). ARangeparses npm’s grammar into a set ofVersionReqs and is satisfied when any alternative is — so transitive resolution works on real-world trees. (version_reqstays for the single-comparator-set case.)
Enums§
- Spec
- A classified npm dependency specifier.
Functions§
- version_
req - npm-faithful version →
VersionReq: a bare full version (1.2.3) is an exact pin (=1.2.3);*, empty,x, andlatestmean any; range syntax (^,~,>=, …) parses as written, within what the Rustsemvercrate accepts (comma-separated comparators; npm’s space-separated and||ranges are not supported).