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

smolxxh

v1.1.0

Published

Tiny xxHash JS implementation

Readme

Smol xxHash

Tiny xxHash JS implementation.

Smol xxHash is a modern, faster, and smaller alternative to the xxhashjs package. It is 3.8x faster than it, and xxh32 and xxh64 are just 366B and 475B, respectively.

It is only 1.8x slower than the xxhash-wasm package that is 3 KB and requires WebAssembly support.

The package features dual CJS/ESM support and built-in TypeScript definitions.

Implementation is a port of a reference C implementation (xxhash32-ref.c and xxhash64-ref.c).

Installation

The package is available on npm:

npm install smolxxh

Usage

Basics

Pass Buffer or Uint8Array to the xxh32/xxh64 function to get the hash of the content:

import { xxh32, xxh64 } from "smolxxh";

xxh32(Buffer.from("hello world", "utf8")).toString(16);
// => "cebb6622"

xxh64(Buffer.from("hello world", "utf8")).toString(16);
// => "45ab6734b21e6968"

Helpers

Smol xxHash comes with a set of helper functions helping to reduce boilerplate when hashing strings and JS values.

String Hashing

To quickly hash string values, you can use the xxh32Str and xxh64Str helpers:

import { xxh32Str, xxh64Str } from "smolxxh/str";

xxh32Str("hello world");
// => "cebb6622"

xxh64Str("hello world");
// => "45ab6734b21e6968"

It supports any string as well as objects implementing toString and [Symbol.toPrimitive](hint: "string") methods.

You also can pass encoding as the second argument, which defaults to utf8:

xxh32Str("cafebabe", "hex");
// => "408e9853"

xxh32Str("cafebabe");
// => "f6a25a07"

Both xxh32Str and xxh64Str infer the return type, so you can use it with branded strings without explicitly casting the result:

type UserHash = string & { [userHashBrand]: true };
declare const userHashBrand: unique symbol;

// No type error!
const userHash: UserHash = xxh32Str(user);

// Can pass the generic type parameter too:
callback(xxh32Str<UserHash>(user));

Any JS Value Hashing

To consistently hash any JS value, including objects, they must be canonized first.

Smol xxHash comes with xxh32Any and xxh64Any helpers that utilize the Smol Canon package to canonize the value before hashing it:

import { xxh32Any, xxh64Any } from "smolxxh/any";

// Objects get canonized, so order doesn't matter:
xxh32Any({ foo: "bar", baz: "qux" });
//=> "ed4e5029"
xxh32Any({ baz: "qux", foo: "bar" });
//=> "ed4e5029"

// Any JS value can be hashed
xxh64Any([1, 2, 3]);
//=> "bba91612761944c5"
xxh64Any(undefined);
//=> "6aeed7835f4984a3"
xxh64Any(null);
//=> "3ec9e10063179f3a"
xxh64Any(NaN);
//=> "bada388f33705db6"

Both xxh32Any and xxh64Any infer the return type, so you can use it with branded strings without explicitly casting the result:

type UserHash = string & { [userHashBrand]: true };
declare const userHashBrand: unique symbol;

// No type error!
const userHash: UserHash = xxh32Any(user);

// Can pass the generic type parameter too:
callback(xxh64Any<UserHash>(user));

To use the xxh32Any and xxh64Any helpers, you need to have the smolcanon package installed in your project, as they depend on it for canonization:

npm install smolcanon

Changelog

See the changelog.

License

MIT © Sasha Koss