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

fast-semver-lite-ts

v1.0.0

Published

Ultra-fast (<1 KB), zero-dependency Semantic Versioning (SemVer) parser, validator, and comparator for TypeScript.

Readme

🏷️ fast-semver-lite-ts

Ultra-fast (< 1 KB), zero-dependency Semantic Versioning (SemVer) parser, comparator, and sorter supporting pre-releases and build metadata.

npm version License: MIT Sponsor TypeScript Size


💡 Why fast-semver-lite-ts?

Checking minimum client version requirements, sorting release tags, or comparing compatibility versions often leads developers to install semver (a 60 KB+ package with multiple internal regex engines).

fast-semver-lite-ts provides:

  • ⚡ Zero Dependencies — Minified to less than 1 KB, pure native TypeScript.
  • 🎯 Full SemVer 2.0.0 Compliance — Parses major, minor, patch, dot-separated pre-releases (alpha.1), and build metadata (+build.2026).
  • ⚖️ Fast Comparison Operators — Clean boolean helpers: gt(), gte(), lt(), lte(), and eq().
  • 🗂️ Array Sorting — Sort lists of version strings in ascending or descending order with sortSemver().
  • 📦 Dual ESM & CommonJS — Native compatibility across Node.js, Next.js, Vite, React Native, and edge workers.

📥 Installation

# npm
npm install fast-semver-lite-ts

# pnpm
pnpm add fast-semver-lite-ts

# yarn
yarn add fast-semver-lite-ts

# bun
bun add fast-semver-lite-ts

🚀 Usage & Real-World Examples

1. Comparing Versions

import { gt, lt, gte, eq } from 'fast-semver-lite-ts';

console.log(gt('2.0.0', '1.9.9'));       // true
console.log(lt('1.0.0-alpha', '1.0.0')); // true (pre-release is lower)
console.log(eq('v1.0.0', '1.0.0'));      // true ('v' prefix tolerated)
console.log(gte('1.2.3', '1.2.3'));      // true

2. Parsing Structured SemVer Components

import { parseSemver } from 'fast-semver-lite-ts';

const parts = parseSemver('v2.1.4-beta.2+exp.sha.5114f85');

console.log(parts);
// Output:
// {
//   major: 2,
//   minor: 1,
//   patch: 4,
//   prerelease: ['beta', '2'],
//   build: ['exp', 'sha', '5114f85'],
//   raw: 'v2.1.4-beta.2+exp.sha.5114f85'
// }

3. Sorting Releases & API Compatibility Checks

import { sortSemver, gte } from 'fast-semver-lite-ts';

// 1. Sort tags in chronological / release order:
const releases = ['1.0.0', '2.0.1', '0.9.0', '1.0.0-rc.1', '2.0.0'];
const sortedAsc = sortSemver(releases, 'asc');
console.log(sortedAsc);
// ['0.9.0', '1.0.0-rc.1', '1.0.0', '2.0.0', '2.0.1']

// 2. Client Compatibility Guard:
function isSupportedClient(clientVersion: string, minRequired = '1.4.0'): boolean {
  return gte(clientVersion, minRequired);
}

if (!isSupportedClient('1.3.9')) {
  console.warn('Please update your app to access this endpoint.');
}

📖 API Reference

compareSemver(v1, v2)

Compares two SemVer strings.

  • Returns: 1 if v1 > v2, -1 if v1 < v2, 0 if v1 === v2.

Boolean Helper Operators:

  • gt(v1, v2): Returns true if v1 > v2.
  • gte(v1, v2): Returns true if v1 >= v2.
  • lt(v1, v2): Returns true if v1 < v2.
  • lte(v1, v2): Returns true if v1 <= v2.
  • eq(v1, v2): Returns true if v1 === v2.

parseSemver(version)

  • Parameters:
    • version (string): The version string to parse.
  • Returns: SemverParts | null:
    interface SemverParts {
      major: number;
      minor: number;
      patch: number;
      prerelease: string[];
      build: string[];
      raw: string;
    }

sortSemver(versions, direction?)

  • Parameters:
    • versions (string[]): Array of version strings.
    • direction ('asc' | 'desc', default: 'asc').
  • Returns: string[] (new sorted array).

diffSemver(v1, v2)

Determines the difference level between two versions.

  • Parameters: v1 (string), v2 (string)
  • Returns: 'major' | 'minor' | 'patch' | 'prerelease' | 'equal' | null

validSemver(version)

Validates whether a string adheres to semantic versioning format.

  • Parameters: version (string)
  • Returns: boolean

🧪 Testing

Verified with 100% test coverage using Vitest:

npm test

💖 Support the Project

If fast-semver-lite-ts streamlined version comparison in your codebase, please consider sponsoring:

👉 Sponsor @Piratha97 on GitHub Sponsors


📄 License

MIT © 2026 Pirapaakaran Pirathapan