JSPM

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

Compare two software versions, with any number of points (<1KB)

Package Exports

  • tiny-version-compare

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 (tiny-version-compare) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tiny-version-compare Build Status

Compare two software versions, with any number of points (<1KB)

Supports most version types, from r12.3 to 1.03.4.234567-RC4. Development versions are sorted as: dev, alpha, beta, rc

Install

$ npm install tiny-version-compare

Usage

const versionCompare = require('tiny-version-compare');

switch (versionCompare('1.2.3', '2.3.4')) {
    case -1: console.log('Second one is greater'); break
    case 1:  console.log('Second one is lower'); break
    case 0:  console.log('Versions are equal'); break
}

['v2.0-beta', '1.0', 'v2.0', '1.0.1'].sort(versionCompare);
// ['1.0', '1.0.1', 'v2.0-beta', 'v2.0']

API

versionCompare(versionA, versionB)

Returns -1 if versionA is greater, 1 if versionB is greater, 0 if the versions are equivalent.

versionA, versionB

Type: string

The versions to compare.

License

MIT © Federico Brigante