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

hsh

v1.2.6

Published

Lightweight log-level mapper — because sometimes you just need a little hsh.

Readme

hsh

Lightweight log-level mapper — because sometimes you just need a little hsh.

This package provides a tiny function that maps string input to log levels. It supports:

  • A single default log level (e.g., debug, info, ...)
  • A comma-separated map like serviceA=debug,serviceB=error,default=warn

It returns a small helper with a get(key) method so you can ask for the log level of a component/service and fall back to a default.

Installation

npm install hsh

Usage

Use a single level for all components:

import hsh from "hsh";

const levels = hsh("debug");
levels.get("anything"); // "debug"

Or provide a map string to configure per-key levels with a default:

import hsh from "hsh";

const levels = hsh("serviceA=debug,serviceB=error,default=warn");
levels.get("serviceA"); // "debug"
levels.get("serviceB"); // "error"
levels.get("other"); // "warn" (default)

Accepted log levels are exactly: trace, debug, info, warn, error, fatal, silent.

Invalid levels are coerced to warn by the validator.

Notes:

  • Keys in the map must be alphanumeric (as defined by the regex in source).
  • Level strings are case-insensitive; they will be lowercased during parsing.

API

  • Default export: hsh(input: string): { get(key: string): LogLevel }
    • input can be a single level or a map string as shown above.
    • get(key) returns the configured level for key or the default level. If no default is provided, it falls back to warn.

Environment variables

The library itself does not read environment variables. A common pattern is to pass a string from an env var into hsh().

You can use the environment variable HSH and wire it in your application like this:

import hsh from "hsh";

// Read from process.env.HSH with a sensible fallback
const levels = hsh(process.env.HSH ?? "warn");

// Later in your code
levels.get("my-service"); // resolves based on HSH or falls back to "warn"

Examples:

  • Single level for everything:
    • HSH=debug node app.js
  • Map with per-key levels and a default:
    • HSH="serviceA=debug,serviceB=error,default=info" node app.js

Notes:

  • If HSH is unset or empty, choose a default (e.g., "warn") as shown above.
  • Invalid values are coerced to "warn" by the validator, and missing default in maps also falls back to "warn".
  • Keys must be alphanumeric and levels are case-insensitive.

License

MIT