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

u-node

v0.0.8

Published

A library to compactly encode data which can be used in URL.

Readme

μ

Without μ: http://app.com/url#%7B%22lookingFor%22:%22bride%22,%22age%22:%5B25,30%5D,%22religion%22:%22Hindu%22,%22motherTongue%22:%22Bengali%22,%22onlyProfileWithPhoto%22:true%7D

With μ: http://app.com/url#bHhc9I-aqa

μ is a JavaScript library for encoding/decoding state (JavaScript object) in URL. Define a spec for the state, based on which the encoding is done. Manage the state with versioning.

Example

Import the library

import { fromJson, encode, decode } from "u-node";

Define the spec.

const spec = {
  lookingFor: ["oneOf", "bride", "groom"],
  age: ["tuple", ["integer"] /* min */, ["integer"] /* max */],
  religion: ["oneOf", "Hindu", "Muslim", "Christian", "Sikh", "Parsi", "Jain", "Buddhist", "Jewish", "No Religion", "Spiritual", "Other" ],
  motherTongue: ["oneOf", "Assamese", "Bengali", "English", "Gujarati", "Hindi", "Kannada", "Konkani", "Malayalam", "Marathi", "Marwari", "Odia", "Punjabi", "Sindhi", "Tamil", "Telugu", "Urdu"],
  onlyProfileWithPhoto: ["boolean"],
};

const v1 = fromJson(1, spec);

Encode the object/state.

const encodedv1 = encode(v1, {
  lookingFor: "bride",
  age: [25, 30],
  religion: "Hindu",
  motherTongue: "Bengali",
  onlyProfileWithPhoto: true,
});
// => 'bHhc9I-aqa'

decode([v1], encodedv1);
// => { lookingFor: 'bride', age: [25, 30], religion: 'Hindu', motherTongue: 'Bengali', onlyProfileWithPhoto: true }

Update your spec as your application state space grows. Use versioning to encode/decode state.

const newSpec = {
  ...spec,
  maritialStatus: ["oneOf", "Doesn't Matter", "Never Married", "Divorced", "Widowed", "Awaiting Divorce", "Annulled"],
};

const v2 = fromJson(2, newSpec, (old) => {
  old.maritialStatus = "Doesn't Matter";
  return old;
});

decode([v1, v2], encodedv1);
// => { lookingFor: 'bride', age: [25, 30], religion: 'Hindu', motherTongue: 'Bengali', onlyProfileWithPhoto: true, maritialStatus: "Doesn't Matter" }

const encodedv2 = encode(v2, {
  lookingFor: "bride",
  age: [25, 30],
  religion: "Hindu",
  motherTongue: "Bengali",
  onlyProfileWithPhoto: true,
  maritialStatus: "Never Married",
});
// => 'cHlc9I-aHaa'

decode([v1, v2], encodedv2);
// => { lookingFor: 'bride', age: [25, 30], religion: 'Hindu', motherTongue: 'Bengali', onlyProfileWithPhoto: true, maritialStatus: 'Never Married' }

Recursive structure

const node = {
  name: ["varchar"],
  children: ["array", ["ref", "node"]],
};

const v1 = fromJson(1, node, (a) => a, { node });

API

fromJson(version, spec, [migrate], [definitions])

  • version - spec version number

  • spec - used to define the structure and domain of the data.

    • structure

      • object is defined using { key: specForValue, ... }
      • array is defined using ["array", specForValue]
      • tuple is defined using ["tuple", specForValueAtIndexZero, specForValueAtIndexOne, ...]
    • domain domain is defined using [domainName, arg1, arg2, ...]

      | Domain | Args | Description | | --------- | ------------------ | --------------------------------------- | | oneOf | allowed values | similar to enum; encodes index position | | integer | | any integer | | float | | any float | | boolean | | true or false | | fixedchar | size of the string | fixed length string | | varchar | | variable length string |

  • migrate (optional) - called when decoding older versions. Each subsequent version’s migrate runs in sequence.

  • definitions (optional) - object mapping names to specs for recursive structures. Reference via ["ref", name].

encode(coder, object)

  • coder - coder created using fromJson
  • object - object to encode

decode(coders, blob)

  • coders - array of coders
  • blob - encoded string returned by encode