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

iri

v1.3.1

Published

IRI parsing and IRI-URI conversion utilities

Downloads

6,174

Readme

IRI: A utility for converting and parsing URIs and IRIs

Utilities for using RFC 3987 and RFC 3986

IRIs are unicode URIs, URIs by definition being 7-bit characters.

Construction of the URI

From RFC 3986:

     foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment
      |   _____________________|__
     / \ /                        \
     urn:example:animal:ferret:nose

The authority exists in a URI/IRI and is marked by a leading //. It can be broken down into a number of other components:

     root:hunter2@[::1]:8080
     \__________/ \___/ \__/
           |        |    |
       userinfo   host  port

Usage of IRI

The constructor takes a single argument, a URI or IRI string:

var iri = require('iri');
var path = new iri.IRI(str).resolveReference('/');

toString()

Returns UTF-16 IRI

defrag()

Returns the IRI without the fragment component. Useful for dereferencing URLs on a network.

new IRI().defrag() === 'http://example.com/resource'

isAbsolute()

IRIs with a fragment are not absolute.

toAbsolute()

Resolves the IRI against itself, having the effect of stripping the fragment and checking that the supplied IRI is valid (absolute).

authority()

Returns the authority component of the IRI, such as "user:[email protected]:8080"

fragment()

Returns the fragment component of the IRI.

hierpart()

Returns the hier-part of the IRI, the hierarchial component: Everything between the scheme and query, including leading // for the host, if it exists.

host()

Returns the host component of the URI, either a domain name or string-formatted IP address. Excludes port number and username/password.

path()

Returns the path component of the hier-part. Does not include the authority/host, query, or fragment.

port()

Returns the port component of the authority as a string, or null if there is no port.

query()

Returns the query component of the IRI including leading "?", or null if there is no query component.

resolveReference(ref)

Resolve the provided URI/IRI reference against this IRI.

scheme()

Returns the scheme of the IRI, e.g. "https", "file", or "urn".

userinfo()

Returns the username/password component of the IRI.

toURIString()

Returns a URI formatted string with only 7-bit characters.

toIRIString()

Decodes URI-encoded UTF-8 characters and returns a unicode string (Strings in ECMAScript/JavaScript are UTF-16).

toIRI()

Returns a new IRI object with URI-encoded UTF-8 characters decoded.

Function Usage

iri.fromURI(uri)

Returns an iri.IRI object with UTF-8 escaped characterd decoded.

iri.toIRIString(uri)

Returns an IRI string decoded from the given URI.

Tests

Tests are available as a Vows test suite. Run vows in the package directory to execute.