semver-range-intersect
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

semver-range-intersect

npm package GitHub License Type Definitions: TypeScript Build Status Maintainability Status

Get the intersection of multiple semver ranges.

Install

npm install semver-range-intersect

Usage

const { intersect } = require('semver-range-intersect');
 
// equals to: '^4.1.0'
intersect('^4.0.0', '^4.1.0') === '>=4.1.0 <5.0.0'
 
// equals to: 1.1.0 - 1.4.0
intersect('1.1.0 - 1.2.3 || 1.2.0 - 1.4.0') === '>=1.1.0 <=1.4.0'
 
intersect('8.2.6 - 8.x.x', '<=8.6.9') === '>=8.2.6 <=8.6.9'
 
intersect('^6.0.0', '6.7.9') === '6.7.9'
 
// equals to: ^8.15.0 || ^10.13.0 || >=11.10.1
intersect('^8.15.0 || >=10.0.0', '^8.10.0 || ^10.13.0 || >=11.10.1') === '>=8.15.0 <9.0.0 || >=10.13.0 <11.0.0 || >=11.10.1'
 
intersect('x.x.x') === '*'
 
// null for invalid version
intersect('a.b.c') === null
 
// null for version range not crossing
intersect('^2.0.0', '^5.0.0') === null
intersect('8.2.6 - 8.x.x', '>=9.0.1') === null

Tests

To run the test suite, first install the dependencies, then run npm test:

npm install
npm test

Contributing

see CONTRIBUTING.md

Related

Package Sidebar

Install

npm i semver-range-intersect

Weekly Downloads

3,890

Version

0.3.1

License

MIT

Unpacked Size

60.2 kB

Total Files

20

Last publish

Collaborators

  • sounisi5011