4.4.0-next.1700712407.b10698a673ef0e599caf75bbac4ab689514fdb32 • Published 2 years ago

version-range v4.4.0-next.1700712407.b10698a673ef0e599caf75bbac4ab689514fdb32

Weekly downloads
15,774
License
Artistic-2.0
Repository
github
Last release
2 years ago

Check version ranges like >=N and X || Y || Z with support for Node.js, Web Browsers, Deno, and TypeScript.

Usage

Complete API Documentation.

Range comparison of versions for the most common use cases. Fast with broad ecosystem support.

import satisfies from 'version-range'
console.log(satisfies('1.0', '>=1.0')) // true
console.log(satisfies('1.0', '1')) // true
console.log(satisfies('1.0', '1 || 2')) // true
console.log(satisfies('1.1.0', '^1.1')) // true
console.log(satisfies('1.1.0', '~1.1')) // true
console.log(satisfies('1.0.0', '5 || <=2')) // true

console.log(satisfies('1', '<=2')) // true
console.log(satisfies('1.0', '<=2')) // true
console.log(satisfies('1.0.0', '<=2')) // true

console.log(satisfies('2', '>1')) // true
console.log(satisfies('2', '>=1')) // true
console.log(satisfies('1', '>=1')) // true
console.log(satisfies('1.0', '>=1')) // true
console.log(satisfies('1.0.0', '>=1')) // true
console.log(satisfies('1', '>=1.0.0')) // true
console.log(satisfies('1.0', '>=1.0.0')) // true
console.log(satisfies('1.0.0', '>=1.0.0')) // true

console.log(satisfies('1', '^1')) // true
console.log(satisfies('1', '~1')) // false, not all 1.x versions (1.1, 1.2, etc) match 1.0.x
console.log(satisfies('1', '^1.1')) // false, not all 1.x versions (1.0) match >=1.1<2
console.log(satisfies('1', '~1.1')) // false, not all 1.x versions (1.0) match 1.1.x
console.log(satisfies('1.0.0', '^1')) // true
console.log(satisfies('1.0.0', '~1')) // true

The above results are expected, but not what the semver package returns. The semver package has two different behaviours based on whether the version is coerced or not, alternating between expected and unexpected results. This package differs to match our actual expectations, as you can see above.

Doesn't do special handling for -releaseTag and 0.x versions.

npm

Deno

import pkg from 'https://unpkg.com/version-range@^4.4.0/edition-deno/index.ts'

Skypack

<script type="module">
    import pkg from '//cdn.skypack.dev/version-range@^4.4.0'
</script>

unpkg

<script type="module">
    import pkg from '//unpkg.com/version-range@^4.4.0'
</script>

jspm

<script type="module">
    import pkg from '//dev.jspm.io/version-range@4.4.0'
</script>

Discover the release history by heading on over to the HISTORY.md file.

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

These amazing people are maintaining this project:

No sponsors yet! Will you be the first?

These amazing people have contributed code to this project:

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Unless stated otherwise all works are:

and licensed under:

4.14.0

2 years ago

4.13.0

2 years ago

4.12.0

2 years ago

4.9.0

2 years ago

4.8.0

2 years ago

1.5.0

2 years ago

2.0.0

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

4.5.0

2 years ago

4.4.0

2 years ago

4.7.0

2 years ago

4.6.0

2 years ago

4.5.1

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago

4.3.0

2 years ago

4.2.0

2 years ago

4.11.0

2 years ago

4.10.0

2 years ago

1.4.0

4 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago