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

semvish

v1.1.0

Published

Multiple version scheme parser and comparitor

Downloads

10

Readme

SemVish Build Status Code Climate License

A versioning interpretter that can process multiple versioning schemes such as

  • SemVer
  • <Max>-<Min>
  • <Max>-<Min>-<release>
  • <Max>
  • <Max>-<release>
  • <release>

Passes some 1290 tests (mostly from node-semver)

Install

$ [sudo] npm install semvish

Motivation

jsDelivr needed a multi version comparitor scheme

API

Borrows directly from node-semver's API

  • clean process a SemVer-ish string to a SemVer compliant string
clean("1.2") // => 1.2.0
clean("1.2.0") // => 1.2.0
clean("1.2.0-beta1") // => 1.2.0-beta1
clean("1.2.0beta1") // => 1.2.0-beta1
clean("1.2-alpha1") // => 1.2.0-alpha1
clean("1.2alpha1") // => 1.2.0-alpha1
clean("1") // => 1.0.0
clean("1-rc1") // => 1.0.0-rc1
clean("1rc1") // => 1.0.0-rc1
clean("alpha1") // => 0.0.0-alpha1

// Handes prefixs and trims strings for all inputs (pretty much every stupid scheme I've ever seen)
clean("v-1.2.0     ") // => 1.2.0
clean("   v1.2   ") // => 1.2.0
clean("==v==1.2") // => 1.2.0
clean("_v--1.2.0") // => 1.2.0
clean("V1.2") // => 1.2.0
clean("-VERSION-1.2 ") // => 1.2.0
clean("v.1.2") // => 1.2.0
  • valid is some string semverish?

  • satisfies(version, range, loose): whethere a given (SemVish) version matches a semver range - currently only supports semver ranges so ^2015-20-15 and similar will not work, instead use ^0.0.0-2015-20-15.

  • gt(v1, v2): v1 > v2

  • gte(v1, v2): v1 >= v2

  • lt(v1, v2): v1 < v2

  • lte(v1, v2): v1 <= v2

  • eq(v1, v2): v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.

  • neq(v1, v2): v1 != v2 The opposite of eq.

  • cmp(v1, comparator, v2): Pass in a comparison string, and it'll call the corresponding function above. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.

  • compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().

  • rcompare(v1, v2): The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().

Differences from semver spec

  • Minorly divergent (see #1) in the way pre-releases are handled: prereleases are compared naturally while the semver spec states that

Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows: identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order.

Therefore as defined by Semver: 0.0.0-a100 < 0.0.0-a2. This minor rule limited us in the alternate supported versioning schemes so we forked the handling.