js-semver
A parser and evaluator for npm's flavor of Semantic Versioning, compliant with node-semver.
This crate is designed for the JavaScript ecosystem and follows node-semver (the one npm uses) parsing and range semantics. It maintains high compatibility and performance, and has zero dependencies by default.
Example
use ;
Features
serde
Enable serde to serialize and deserialize versions and ranges:
[]
= { = "0.3", = ["serde"] }
= "1"
For example, read a dependency range from package.json:
use Range;
let package: Value =
from_str.unwrap;
let react: Range = from_value.unwrap;
assert!;
Range is serialized in its normalized form. Invalid strings produce a deserialization error.
no-std
std feature is enabled by default. To use js-semver in a no_std environment, disable the default features:
[]
= { = "0.3", = false }
Comparison with other crates
node-semver
node-semver crate has numerous issues, including unnecessary dependencies like miette, incompatibilities with npm's node-semver, and the fact that it is no longer actively maintained.
semver
semver crate is designed for Cargo. Therefore, it is not well-suited for the Node.js ecosystem, such as parsing versions in package.json.
License
MIT-0
This project's tests incorporate material from third parties, but they are not part of the library. For attribution and additional notice information, see NOTICE.md.