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

@statewalker/uris

v0.2.6

Published

URI management utilities

Readme

@statewalker/uris: URIs Management Utilities

A small library (~2.5K compressed/minimized) to manage URIs - parsing, serialization, path resolving, relative paths generation, concatenation and URIs rewriting.

For working examples see this Observable Notebook: https://observablehq.com/@kotelnikov/statewalker-uris.

concatPath(...uris)

Concatenates URI paths and returns the result. The given uris can be objects or strings. The resulting object is a string.

Example:

import { concatPath } from '@statewalker/uris';
console.log(concatPath('http://foo.bar/a/b/', '/my/path.txt'))
// 'http://foo.bar/a/b/my/path.txt'

resolveUrl(...uris)

Resolves URLs one after another starting from the first one and returns the string-serialized resulting URI.

Example:

import { resolveUrl } from '@statewalker/uris';
console.log(resolveUrl('http://foo.bar/a/b/', '../doc/', './my/path.txt'))
// 'http://foo.bar/a/doc/my/path.txt'

makeRelative(first, second)

Returns the relative paths from the first URI to the second one.

Example:

import { makeRelative } from '@statewalker/uris';
console.log(makeRelative('http://foo.bar/a/b/index.md', 'http://foo.bar/a/c/d/readme.md'))
// '../c/d/readme.md'

newPathMapping

This method returns a function rewriting URIs. The parameter of this method defines source base URIs with the corresponding target paths. The returned function transforms URIs to the corresponding expanded paths.

Example:

import { newPathMapping } from '@statewalker/uris';

// Rewriting rules:
const transform = newPathMapping([
    { source: './sources/', target: '/' },
    { source: 'file:///tmp/data/', target: '/toto/' },
    { source: 'http://www.foo.bar/tech/', target: '/docs/' },
    { source: 'http://www.foo.bar/assets/img/', target: '/images/' }
]);

console.log(transform('./sources/index.md')); 
// '/index.md'

console.log(transform('http://www.foo.bar/tech/readme.md'));
// '/docs/readme.md'

console.log(transform('http://www.foo.bar/assets/img/MyImage.jpg'));
// '/images/MyImage.jpg'

console.log(transform('file:///tmp/data/products/prices.md'));
// '/toto/products/prices.md'

parseUri(uri)

Parses the given string and returns the corresponding object with the following fields:

  • schema: ex: "https", "ftp", "mailto"
  • domain: "foobar.com"
  • path: "/path/to/my/file.txt"
  • query: { "a" : "B" }
  • fragment: "hello"

Example:

import { parseUri } from '@statewalker/uris';

console.log(parseUri('http://foo.bar/a/b/?a=b&c=d#foobar'))
/*
{
    schema: "http",
    domain: "foo.bar",
    path: "/a/b/",
    query: { a: "b", c: "d" },
    fragment: "#foobar"
}
*/

serializeUri(uri)

Serializes the given URI and returns the corresponding string representation.

parseQuery(query)

Parses the URI query and returns the corresponding object representation with key/value pairs.

serializeQuery(query)

Serializes the URI query and returns the corresponding string.

newUri(...list)

Creates a new URI from the list of the given URI objects. The returned result contains paths and fragments of the latest URI in the list. If the specified list contains only one URI then this method returns its copy.

resolveUri(from, to)

Resolves the second URI and returns

makeRelativeUri(from, to)

Creates and returns a relative links from the initial URI to the target

joinUri(...uris)

Joins URIs objects and returns resulting object with paths concatanated

License

MIT