Installations
npm install version-range
Developer Guide
Typescript
Yes
Module System
ESM, UMD
Min. Node Version
>=4
Node Version
20.10.0
NPM Version
10.2.3
Score
99.6
Supply Chain
100
Quality
76.2
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
bevry
Download Statistics
Total Downloads
8,350,970
Last Day
18,228
Last Week
85,772
Last Month
350,218
Last Year
1,834,745
GitHub Statistics
2 Stars
36 Commits
1 Forks
3 Watching
1 Branches
2 Contributors
Bundle Size
1.55 kB
Minified
711.00 B
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
4.14.0
Package Id
version-range@4.14.0
Unpacked Size
81.15 kB
Size
15.26 kB
File Count
16
NPM Version
10.2.3
Node Version
20.10.0
Publised On
07 Jan 2024
Total Downloads
Cumulative downloads
Total Downloads
8,350,970
Last day
24.4%
18,228
Compared to previous day
Last week
-4.8%
85,772
Compared to previous week
Last month
29.1%
350,218
Compared to previous month
Last year
548.7%
1,834,745
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
version-range
Check version ranges like >=N
and X || Y || Z
with support for Node.js, Web Browsers, Deno, and TypeScript.
Usage
Range comparison of versions for the most common use cases. Fast with broad ecosystem support.
1import satisfies from 'version-range' 2console.log(satisfies('1.0', '>=1.0')) // true 3console.log(satisfies('1.0', '1')) // true 4console.log(satisfies('1.0', '1 || 2')) // true 5console.log(satisfies('1.1.0', '^1.1')) // true 6console.log(satisfies('1.1.0', '~1.1')) // true 7console.log(satisfies('1.0.0', '5 || <=2')) // true 8 9console.log(satisfies('1', '<=2')) // true 10console.log(satisfies('1.0', '<=2')) // true 11console.log(satisfies('1.0.0', '<=2')) // true 12 13console.log(satisfies('2', '>1')) // true 14console.log(satisfies('2', '>=1')) // true 15console.log(satisfies('1', '>=1')) // true 16console.log(satisfies('1.0', '>=1')) // true 17console.log(satisfies('1.0.0', '>=1')) // true 18console.log(satisfies('1', '>=1.0.0')) // true 19console.log(satisfies('1.0', '>=1.0.0')) // true 20console.log(satisfies('1.0.0', '>=1.0.0')) // true 21 22console.log(satisfies('1', '^1')) // true 23console.log(satisfies('1', '~1')) // false, not all 1.x versions (1.1, 1.2, etc) match 1.0.x 24console.log(satisfies('1', '^1.1')) // false, not all 1.x versions (1.0) match >=1.1<2 25console.log(satisfies('1', '~1.1')) // false, not all 1.x versions (1.0) match 1.1.x 26console.log(satisfies('1.0.0', '^1')) // true 27console.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.
Related
This package comprises this suite of related packages:
And if you are specifically interested in Node.js and ECMAScript versions:
Install
npm
- Install:
npm install --save version-range
- Import:
import pkg from ('version-range')
- Require:
const pkg = require('version-range').default
Deno
1import pkg from 'https://unpkg.com/version-range@^4.14.0/edition-deno/index.ts'
Skypack
1<script type="module"> 2 import pkg from '//cdn.skypack.dev/version-range@^4.14.0' 3</script>
unpkg
1<script type="module"> 2 import pkg from '//unpkg.com/version-range@^4.14.0' 3</script>
jspm
1<script type="module"> 2 import pkg from '//dev.jspm.io/version-range@4.14.0' 3</script>
Editions
This package is published with the following editions:
version-range/source/index.ts
is TypeScript source code with Import for modulesversion-range/edition-browsers/index.js
is TypeScript compiled against ES2022 for web browsers with Import for modulesversion-range
aliasesversion-range/edition-es5/index.js
version-range/edition-es5/index.js
is TypeScript compiled against ES5 for Node.js 4 || 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modulesversion-range/edition-es2022-esm/index.js
is TypeScript compiled against ES2022 for Node.js 12 || 14 || 16 || 18 || 20 || 21 with Import for modulesversion-range/edition-types/index.d.ts
is TypeScript compiled Types with Import for modulesversion-range/edition-deno/index.ts
is TypeScript source code made to be compatible with Deno
History
Discover the release history by heading on over to the HISTORY.md
file.
Backers
Code
Discover how to contribute via the CONTRIBUTING.md
file.
Authors
- Benjamin Lupton — Accelerating collaborative wisdom.
Maintainers
- Benjamin Lupton — Accelerating collaborative wisdom.
Contributors
Finances
Sponsors
- Andrew Nesbitt — Software engineer and researcher
- Balsa — We're Balsa, and we're building tools for builders.
- Codecov — Empower developers with tools to improve code quality and testing.
- Frontend Masters — The training platform for web app engineering skills – from front-end to full-stack! 🚀
- Mr. Henry
- Poonacha Medappa
- Rob Morris
- Sentry — Real-time crash reporting for your web apps, mobile apps, and games.
- Syntax — Syntax Podcast
Donors
- Andrew Nesbitt
- Armen Mkrtchian
- Balsa
- Chad
- Codecov
- dr.dimitru
- Elliott Ditman
- entroniq
- Frontend Masters
- GitHub
- Hunter Beast
- Jean-Luc Geering
- Michael Duane Mooring
- Michael Harry Scepaniak
- Mohammed Shah
- Mr. Henry
- Nermal
- Pleo
- Poonacha Medappa
- Rob Morris
- Robert de Forest
- Sentry
- ServieJS
- Skunk Team
- Syntax
- WriterJohnBuck
License
Unless stated otherwise all works are:
- Copyright © Benjamin Lupton
and licensed under:
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
SAST tool is run on all commits
Details
- Info: all commits (6) are checked with a SAST tool
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/bevry.yml:79
- Warn: no topLevel permission defined: .github/workflows/bevry.yml:1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bevry.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bevry.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bevry.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bevry.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bevry.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/bevry/version-range/bevry.yml/master?enable=pin
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
4.5
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to version-range
@changesets/get-version-range-type
Common get-version-range-type shared between changeset packages
bin-version-check
Check whether a binary version satisfies a semver range
@lerna/has-npm-version
Test if the current version of npm satisfies a given semver range
@resdir/version-range
VersionRange class used by Resdir