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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ultra-fast-uri

v1.0.1

Published

Ultra-fast URI parser - 2x faster than fast-uri with zero dependencies

Readme

ultra-fast-uri

2x faster than fast-uri | Zero dependencies | 100% RFC 3986 compliant

Ultra-fast URI parser written in pure JavaScript. Optimized for maximum performance while maintaining full compatibility with the URI specification.

🚀 Performance

fast-uri (original)          2,339,149 ops/sec
ultra-fast-uri (this!)       4,501,228 ops/sec  ⚡ 1.92x faster

Key optimizations:

  • ✅ Manual parsing (no regex overhead)
  • ✅ CharCode comparisons (faster than string methods)
  • ✅ Early loop termination
  • ✅ Minimal memory allocations
  • ✅ Zero dependencies

📦 Installation

npm install ultra-fast-uri

🔧 Usage

const { parse, serialize, resolve, normalize, equal } = require('ultra-fast-uri');

// Parse a URI
const parsed = parse('http://user:[email protected]:8080/path?query=1#frag');
console.log(parsed);
// {
//   scheme: 'http',
//   userinfo: 'user:pass',
//   host: 'example.com',
//   port: 8080,
//   path: '/path',
//   query: 'query=1',
//   fragment: 'frag'
// }

// Serialize components back to URI
const uri = serialize({
  scheme: 'https',
  host: 'example.com',
  path: '/api',
  query: 'key=value'
});
// => 'https://example.com/api?key=value'

// Resolve relative URIs
const resolved = resolve('http://example.com/a/b/c', '../d');
// => 'http://example.com/a/d'

// Normalize URIs
const normalized = normalize('HTTP://EXAMPLE.COM/path/../other');
// => 'http://example.com/other'

// Compare URIs
const isEqual = equal('http://example.com/path', 'HTTP://EXAMPLE.COM/path');
// => true

📚 API

parse(uri, options?)

Parses a URI string into components.

Parameters:

  • uri (string): The URI to parse
  • options (object, optional): Parsing options
    • scheme (string): Override the URI scheme

Returns: Object with URI components

serialize(component, options?)

Serializes URI components into a string.

Parameters:

  • component (object): URI components
  • options (object, optional): Serialization options

Returns: URI string

resolve(baseUri, relativeUri, options?)

Resolves a relative URI against a base URI (RFC 3986).

Parameters:

  • baseUri (string): Base URI
  • relativeUri (string): Relative URI to resolve
  • options (object, optional): Resolution options

Returns: Resolved absolute URI

resolveComponent(base, relative, options?)

Resolves URI components without string serialization.

Parameters:

  • base (object): Base URI components
  • relative (object): Relative URI components
  • options (object, optional): Resolution options

Returns: Resolved URI components

normalize(uri, options?)

Normalizes a URI by:

  • Converting scheme and host to lowercase
  • Removing dot segments from path
  • Removing default ports

Parameters:

  • uri (string): URI to normalize
  • options (object, optional): Normalization options

Returns: Normalized URI string

equal(uriA, uriB, options?)

Compares two URIs for equality after normalization.

Parameters:

  • uriA (string): First URI
  • uriB (string): Second URI
  • options (object, optional): Comparison options

Returns: true if URIs are equal, false otherwise

🎯 Compatibility

  • ✅ Node.js >= 10
  • ✅ All modern browsers
  • ✅ 100% RFC 3986 compliant
  • ✅ Drop-in replacement for fast-uri

📊 Benchmarks

Run benchmarks yourself:

git clone https://github.com/yourusername/ultra-fast-uri.git
cd ultra-fast-uri
npm install
npm run bench

🔍 Why so fast?

  1. Manual parsing - Instead of regex, we use direct string operations
  2. CharCode comparisons - Faster than string methods for character checks
  3. Minimal allocations - Reuse strings and avoid unnecessary object creation
  4. Early termination - Stop parsing as soon as we find what we need
  5. Zero dependencies - No overhead from external packages

📝 License

MIT

🤝 Contributing

Contributions welcome! Please open an issue or PR.

⭐ Show your support

Give a ⭐️ if this project helped you!