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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nejs/semver

v1.0.1

Published

A pure JavaScript wrapper for semantic versions

Readme

SemVer

A flexible single class, zero dependency, class for managing semantic versions.

Features

  • Allows programmatic management of semantic version strings.
  • Fully compliant with semantic versions conforming to the 2.0 spec
  • Testing and separation of strings purported to be in semver format can be statically tested without creating a SemVer instance.
  • Version adjustments for each of the parts of a semantic version can be performed on each instance.

Future Features

  • SemVer.compare(SemVer) and SemVer.compare(string)

Installation

NodeJS

In a nodejs or compatible engine project, perform the following npm install

npm install @nejs/semver

Browser

In a browser, a script tag pointed here can get you a CDN served version of the latest build

<script type="module">
  const { SemVer } = await import('https://cdn.jsdelivr.net/gh/nyteshade/ne-semver@main/dist/semver.mjs')

  // ... use SemVer here
</script>

Or if you want it to automatically be injected into the window, you can use the iffy variant.

<script src="'https://cdn.jsdelivr.net/gh/nyteshade/ne-semver@main/dist/semver.js'"></script>

Usage

Statically

Extracting a semantic version into its parts can be done in the following manner. It will also allow you to determine if it fails to be parsed through the return of a null value.

// This is an invalid version, and will result in a null
let bad = SemVer.test('1.2')

// This is a simple semantic version
let ver = SemVer.test('1.2.0')

console.log(ver.major)       // 1
console.log(ver.minor)       // 2
console.log(ver.patch)       // 0
console.log(ver.prerelease)  // undefined
console.log(ver.build)       // undefined
console.log(ver.toString())  // "1.2.0"
console.log(String(ver))     // "1.2.0"

// This is a more complex variant
let ver = SemVer.test('1.2.32-prod.124+arm64')

console.log(ver.major)       // 1
console.log(ver.minor)       // 2
console.log(ver.patch)       // 32
console.log(ver.prerelease)  // "prod.124"
console.log(ver.build)       // "arm64"
console.log(ver.toString())  // "1.2.32-prod.124+arm64"
console.log(String(ver))     // "1.2.32-prod.124+arm64"

Instance variants

More functionally, an instance of SemVer will allow you to manipulate the versions.

// This is an invalid version with instances. These will throw a TypeError
let bad = new SemVer("1.2")

// Similar to the static test() output, the five parts of a semantic version
// can be accessed directly. 
//   `.major`
//   `.minor`
//   `.patch`
//   `.prerelease`
//   `.build`
let ver = new SemVer('1.2.32-prod.124+arm64')

// Additionally, however we can manipulate the parts. The numeric portions
// can be mathematically adjusted
ver.adjustBy('major', 2, '*')
conosle.log(ver.major)         // 2
ver.adjustBy('major', 2, '/')  // 1
ver.adjustBy('major', 2, '-')  // -1; note this is actually an invalid semver now
ver.adjustBy('major', 1, '+')  // 1; addition is the default, so '+' can be omitted

// If addition is the only option needed, a shorter variant is 'bump'
ver.bump('major')              // now 2

// Numeric and non-numeric parts can be directly set with 'adjustTo'
ver.adjustTo('major', 1)
ver.adjustTo('build', 'x86_64')

// Conversion to string can be achieved in several ways
ver.toString()    // "2.2.32-prod.124+x86_64"
String(ver)       // "2.2.32-prod.124+x86_64"
`Version ${ver}`  // "Version 2.2.32-prod.124+x86_64"

License

MIT

Contributing

Contributors are welcome! Please submit a Pull Request.