test-version

Test if a version matches the given versions

Usage no npm install needed!

<script type="module">
  import testVersion from 'https://cdn.skypack.dev/test-version';
</script>

README

test-version

NPM version build status

Test if a given version matches a version pattern

Install

$ npm install test-version

Usage

const test = require('test-version');

if (test('v1.0.0', '>=1.0.0')) {
    console.log('matched!');
}
else {
    console.log('not matched');
}

Patterns

version can be like:

1.0.0 => 1.0.0
1-0-0 => 1.0.0
v1.0  => 1.0

version pattern can be like:

1.0.0
1.0.x
1.0.*
!1.0.0
~1.0.0
^1.0.0
>1.0.0
<1.0.0
1.0.0...1.9.9
1.0.0~1.9.9