Skip to content

ryuapp/js-semver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-semver

License crates github repo codecov

A parser and evaluator for semantic versioning in JavaScript, including Node.js and Deno.

This crate is designed for the JavaScript ecosystem. It maintains high compatibility with the behavior of node-semver (the one npm uses) and has zero dependencies by default.

Example

use js_semver::{BuildMetadata, PreRelease, Range, Version};

fn main() {
    let range = Range::parse(">=1.2.3 <1.8.0").unwrap();

    // Pre-release versions are not included in the range unless explicitly specified.
    let version = Version {
        major: 1,
        minor: 2,
        patch: 3,
        pre_release: PreRelease::parse("alpha.1").unwrap(),
        build: BuildMetadata::default(),
    };
    assert!(!range.satisfies(&version));

    let version = Version::parse("1.3.0").unwrap();
    assert!(range.satisfies(&version));
}

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

About

A parser and evaluator for semantic versioning in JavaScript, including Node.js and Deno

Resources

License

Stars

Watchers

Forks

Contributors

Languages