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

@onzipper/nb-common-libs

v1.0.1

Published

> A tiny, dependency-free set of TypeScript utilities, split into subpath modules so you only import what you use.

Readme

@onzipper/nb-common-libs npm license

A tiny, dependency-free set of TypeScript utilities, split into subpath modules so you only import what you use.

  • Zero dependencies — nothing is pulled into your tree
  • Typed — declarations are bundled, no @types/… needed
  • Subpath exports…/datetime is imported separately from the root
  • ESM + CommonJS — works with import, require(), and every major bundler

Install

npm install @onzipper/nb-common-libs

Usage

import { sum, capitalize } from "@onzipper/nb-common-libs";
import { getDate } from "@onzipper/nb-common-libs/datetime";

// Numbers
sum(2, 3);
//=> 5

sum(-1, 1);
//=> 0

// Strings — only the first character is touched
capitalize("hello");
//=> "Hello"

capitalize("hello world");
//=> "Hello world"

// Dates — a fresh Date on every call
getDate();
//=> 2026-08-11T03:24:11.482Z

CommonJS works identically:

const { sum, capitalize } = require("@onzipper/nb-common-libs");
const { getDate } = require("@onzipper/nb-common-libs/datetime");

API

sum(a, b)

Returns: number

Adds two numbers together.

a

Type: number

b

Type: number

sum(2, 3);
//=> 5

sum(-1, 1);
//=> 0

// Ordinary IEEE-754 float behaviour applies — this is not rounded for you
sum(0.1, 0.2);
//=> 0.30000000000000004

Extra arguments are ignored, so sum can be handed straight to reduce:

[1, 2, 3, 4].reduce(sum);
//=> 10

// Pass an initial value to stay safe on a possibly-empty array
[].reduce(sum, 0);
//=> 0

capitalize(str)

Returns: string

Upper-cases the first character of a string. The rest of the string is left exactly as-is, so existing casing is preserved rather than lower-cased.

str

Type: string

capitalize("hello");
//=> "Hello"

// Only the first character changes — not every word
capitalize("hello world");
//=> "Hello world"

// The tail is preserved, not lower-cased
capitalize("hELLO");
//=> "HELLO"

// Accented characters are handled
capitalize("ñandu");
//=> "Ñandu"

Values with no leading letter come back unchanged, so it is safe to call on arbitrary input:

capitalize("");
//=> ""

capitalize("123abc");
//=> "123abc"

capitalize("😀 hi");
//=> "😀 hi"

One caveat worth knowing: leading whitespace counts as the first character, so trim first if the input may be padded.

capitalize("  hi");
//=> "  hi"

capitalize("  hi".trim());
//=> "Hi"

getDate()

Returns: Date

Returns a new Date for the current date and time. Each call produces a distinct object, so a returned value can be mutated without affecting anything else.

const now = getDate();

now instanceof Date;
//=> true

now.toISOString();
//=> "2026-08-11T03:24:11.482Z"

getDate() === getDate();
//=> false — a fresh instance every time

Examples

Normalising user input before display:

import { capitalize } from "@onzipper/nb-common-libs";

const name = capitalize(form.firstName.trim());
//   "  somchai " -> "Somchai"

Totalling a cart, then stamping the order:

import { capitalize, sum } from "@onzipper/nb-common-libs";
import { getDate } from "@onzipper/nb-common-libs/datetime";

const items = [
  { label: "coffee", price: 120 },
  { label: "pastry", price: 85 },
  { label: "juice", price: 65 },
];

const order = {
  total: items.map((item) => item.price).reduce(sum, 0),
  //=> 270
  placedAt: getDate(),
  labels: items.map((item) => capitalize(item.label)),
  //=> ["Coffee", "Pastry", "Juice"]
};

Routing getDate through one place means tests can stub the clock in a single spot instead of every new Date() call site:

jest.mock("@onzipper/nb-common-libs/datetime", () => ({
  getDate: () => new Date("2026-01-01T00:00:00Z"),
}));

Subpath exports

Each module has its own specifier, so importing dates never pulls in the rest:

| Import specifier | Exports | | ----------------------------------- | ------------------- | | @onzipper/nb-common-libs | sum, capitalize | | @onzipper/nb-common-libs/datetime | getDate |

TypeScript

Type declarations ship with the package — there is no separate @types/… to install, and types resolve for every subpath automatically.

The code is compiled to CommonJS targeting ES2020, and the exports map declares types, require, and default conditions. That means it resolves from ESM import, CommonJS require(), and bundlers including webpack, Turbopack, Vite, and Rollup.

If your tsconfig.json uses "moduleResolution" of "node16", "nodenext", or "bundler", subpath types work with no extra configuration.

Requirements

  • Node.js 12 or newer — required by the exports field

License

ISC