JSPM

@brunorb/semverjs

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q39857F
  • License MIT

Semantic Versioning 2.0.0 utility library

Package Exports

  • @brunorb/semverjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@brunorb/semverjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

semverjs

Semantic Versioning 2.0.0 utility library:

  • Comparison
  • Validation
  • Split

Installing / Running

yarn add @brunorb/semverjs

||

npm install @brunorb/semverjs

Node.JS:

const SemverJS = require('@brunorb/semverjs');

Browser:

<script src="@brunorb/semverjs/src/main.js"><script>`
<script>
SemverJS...
</script>

API

isValid(semver)

let v1 = '1.2.0-alpha+001';
let v2 = '1.2.1';
SemverJS.isValid(v1); // true
SemverJS.isValid(v2); // true
SemverJS.isValid('1.1'); // false

split(semver, asArray = false)

let v1 = '1.2.0-alpha+001';
let v2 = '1.2.1+001';

SemverJS.split(v1); // {major: '1', minor: '2', patch: '0', preRelease: 'alpha', 'buildMetadata': '001'}
SemverJS.split(v2); // {major: '1', minor: '2', patch: '1', preRelease: null, buildMetadata: '001'}

SemverJS.split(v1, true); // ['1', '2', '0', 'alpha', '001']
SemverJS.split(v2, true); // ['1', '2', '1', null, '001']

compare(semver1, semver2)

let v1 = '1.2.0-alpha+001';
let v2 = '1.2.1';

SemverJS.compare(v1, v2); // -1
SemverJS.compare(v2, v1); // 1
SemverJS.compare(v1, v1); // 0

pattern -> regex

SemverJS.pattern.test("semver");
SemverJS.pattern.match("semver");
... other regex methods

Tests

test/BasicTest.js

yarn run test

yarn run lint

License

The MIT License