semvergh
v1.0.0
Published
A module to return SemVer versions which are known to satisfy or unsatisfy a basic SemVer range.
Downloads
5
Readme
SemVergh
A module to return SemVer versions which are known to satisfy or unsatisfy a basic SemVer range.
This has only been tested with these SemVer range types:
- Hyphen Ranges (
1.2.3 - 2.3.4
) - X-Ranges (
1.2.x
,1.X
,1.2.*
,*
) - Partial version ranges (
1
,1.2
) - Tilde Ranges (
~1.2.3
,~1.2
,~1
) - Caret Ranges (
^1.2.3
,^0.2.5
,^0.0.4
) - Greater Than (
>3
) - Greater Than or Equal (
>=3
) - Less Than (
<3
) - Less Than or Equal (
<=3
)
Install
npm install --save semvergh
Usage
"use strict";
const { satisfyingVersion, unsatisfyingVersion } = require("./");
satisfyingVersion("1.2.3 - 2.3.4"); // => '1.2.3'
unsatisfyingVersion("1.2.3 - 2.3.4"); // =>'0.2.3'
satisfyingVersion("3.x"); // => '3.0.0'
unsatisfyingVersion("3.x"); // => '3.1.0'
satisfyingVersion("1"); // => '1.0.0'
unsatisfyingVersion("1"); // => '2.0.0'
satisfyingVersion("~1"); // => '1.0.0'
unsatisfyingVersion("~1"); // => '0.0.0'
satisfyingVersion("^1"); // => '1.0.0'
unsatisfyingVersion("^1"); // => '0.0.0'
satisfyingVersion(">3"); // => '4.0.0'
unsatisfyingVersion(">3"); // => '3.0.0'
satisfyingVersion(">=3"); // => '3.0.0'
unsatisfyingVersion(">=3"); // => '2.0.0'
satisfyingVersion("<3"); // => '0.0.0'
unsatisfyingVersion("<3"); // => '4.0.0'
satisfyingVersion("<=3"); // => '3.0.0'
unsatisfyingVersion("<=3"); // => '4.0.0'
satisfyingVersion("*"); // => '0.0.0'
unsatisfyingVersion("*"); // => null
API
satisfyingVersion(range)
-> string
Find a SemVer version that satisfies the supplied SemVer range.
- Parameters:
string
- A SemVer range. E.G. ">=3" or "3.*" (Required) - Returns:
string
- A SemVer version that satisfies the supplied range.
unsatisfyingVersion(range)
-> string
or null
Find a SemVer version that does not satisfy the supplied SemVer range. Will return null
if all versions would satisfy the range.
- Parameters:
string
- A SemVer range. E.G. ">=3" or "3.*" (Required) - Returns:
string
ornull
- A SemVer version that does not satisfy the supplied range. Will returnnull
if all versions would satisfy the range.
License
MIT