npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ver-sion

v0.1.1

Published

light-weighted semantic version implementation

Downloads

15

Readme

ver.sion

light-weighted semantic version implementation and enhancement

total downloads of ver.sion ver.sion's License latest version of ver.sion

Table of contents

Links

Get Started

ver.sion is not only a Node.js module, but also a CLI tool. When installed, command version and command alias v2 will be created. Run the commands without any options for help info.

npm install -g ver.sion --prod

Of course, the main business is to be required as a module.

const ver = require('ver.sion');

// Compare two versions.
ver.lt('1.2.3', '1.3.0');  // true
ver.gt('1.2.3', '1.2.0');  // true
ver.eq('1.2.3', '1.2'  );  // true

const range = new ver.Range('^1.2.3');
range.covers('1.2.0');    // false
range.covers('1.2.3');    // true
range.covers('1.3.0');    // true
range.covers('2.0.0');    // false

API

Suppose ver is the name of required package:

const ver = require('ver.sion');
// OR require package named "ver-sion" if you prefer and have installed with such name.
const ver = require('ver-sion');

ver.sion accepts dot-number notation according to Semantic Versioning 2.0.0 (hereinafter referred as SemVer). However, versions having less or more than three numbers, which are understood as Major, Minor and Patch, are also accepted. For SemVer, 1.2.3 is valid, but 1.2.3.4 and 1.2 are invalid (1.2 is accepted as version range in NPM package semver). For ver.sion, all of them are valid versions.

Class ver.Range

const range = new ver.Range(version_range_code);

The syntax of version_range_code is compatible with which used in semver.

Comparators Methods

ver.sion has following static methods to compare two versions:

  • boolean eq(string v1, string v2)
  • boolean neq(string v1, string v2)
  • boolean lt(string v1, string v2)
  • boolean gt(string v1, string v2)
  • boolean lte(string v1, string v2)
  • boolean gte(string v1, string v2)
  • boolean equal(string v1, string v2)
  • boolean notEqual(string v1, string v2)
  • boolean lessThan(string v1, string v2)
  • boolean greaterThan(string v1, string v2)
  • boolean lessThanOrEqual(string v1, string v2)
  • boolean greaterThanOrEqual(string v1, string v2)

Range Methods

  • boolean ver.covers(string rangeCode, string version)
  • boolean ver.statisfy(string version, string rangeCode)

Examples

Read the unit tests for examples of ver.sion:

Why ver.sion

In general, SemVer is enough. However, there are still version notations smiliar to SemVer but have more or less than three numbers. E.g., run the following command and observe components' versions in Node.js.

node -e 'console.log(process.versions)'

The output looks like,

{ http_parser: '2.7.0',
  node: '6.11.1',
  v8: '5.1.281.103',
  uv: '1.11.0',
  zlib: '1.2.11',
  ares: '1.10.1-DEV',
  icu: '58.2',
  modules: '48',
  openssl: '1.0.2k' }

With ver.sion, we can deal with versions made up of dots and numbers, exceeding the restriction of Major.Minor.Patch as SemVer requires.

Honorable Dependents

Welcome to be honorable dependents of ver.sion!

References