@philiprehberger/semver-ts
v0.1.4
Published
Lightweight semver parsing, comparison, and range matching
Readme
@philiprehberger/semver-ts
Lightweight semver parsing, comparison, and range matching
Installation
npm install @philiprehberger/semver-tsUsage
import { parse, satisfies, sort, increment } from '@philiprehberger/semver-ts';
parse('2.1.0-rc.1');
// { major: 2, minor: 1, patch: 0, prerelease: ['rc', 1] }
satisfies('1.5.0', '^1.0.0'); // true
sort(['2.0.0', '1.0.0', '1.5.0']); // ['1.0.0', '1.5.0', '2.0.0']
increment('1.2.3', 'minor'); // '1.3.0'API
| Function | Description |
|----------|-------------|
| parse(version) | Parse to SemVer object |
| coerce(input) | Loose parse (e.g. "v1.2") |
| compare(a, b) | Compare two versions |
| gt / lt / gte / lte / eq | Boolean comparisons |
| satisfies(version, range) | Check range match |
| maxSatisfying(versions, range) | Highest matching version |
| minSatisfying(versions, range) | Lowest matching version |
| increment(version, type) | Bump version |
| sort(versions) / rsort(versions) | Sort versions |
Development
npm install
npm run build
npm testSupport
If you find this project useful:
