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

@drawbridge/drawbridge-utils

v0.0.26

Published

Shared helpers and data used across the drawbridge-* repositories.

Readme

@drawbridge/drawbridge-utils

Shared helpers and data used across the drawbridge-* repositories.

Main entry

const utils = require( '@drawbridge/drawbridge-utils' );
// or: import { capitalize } from '@drawbridge/drawbridge-utils';

Exports:

  • bytesToGB( bytes ) / bytesToMB( bytes ) — byte conversion.
  • capitalize( string ) — uppercases the first character.
  • constants — default record shape per Mongo collection name (action, brand, campaign, draw, member, organization, page, prize, range, referrer, template, usage, user).
  • currencies / currency( code ) — list of ISO currencies (key/value/code/digits) and lookup by code.
  • expiredPaymentMethod( card ) — checks if a card record's year/month is in the past.
  • formatCurrency({ code, digits, display, locale, value }) — Intl-based formatter. display: 'standard' (default) returns Intl's standard string; 'parts' splits symbol/number for custom layouts.
  • formatDateString({ date, locale, time, options }) — Intl-based date formatter. time: true adds hour/minute.
  • formatNumber( number, digits ) — Intl-based number formatter with fixed-digit min/max.
  • getPlanFeature( plan, key ){ granted, message } lookup.
  • infinite, isInfinite( value ), megabyte, gigabyte — size constants.
  • nanoid() — 8-char base36 random ID.
  • percentage( value1, value2, decimals )(value1 / value2) * 100, fixed decimals (default 1).
  • reducers.fields — reducer for grouping fields by additional / lead type.
  • regex.url / regex.protocols / regex.domain — shared regex constants.
  • shareUrls({ formUri, organization, page }) — builds share URLs from the configured form base URI. Falls back to process.env.APP_CLIENT_FORM_URI if formUri is not passed (server-only).
  • urlRoot( string )'https://' if input contains 'https', else 'http://'.

Encrypt entry (server-only)

const { encrypt, decrypt } = require( '@drawbridge/drawbridge-utils/encrypt' );

Server-only because it uses Node crypto and reads process.env.ENCRYPT_CONNECTION_SECRET. Exposed as a sub-export so client bundles don't pull Node built-ins.

Axios entry (server-only)

const { safe, axios } = require( '@drawbridge/drawbridge-utils/axios' );
  • safe.get( url, axiosOptions ) — SSRF-protected GET request.
  • axios — raw axios passthrough for advanced usage.

Circuit entry (server-only)

const { circuit } = require( '@drawbridge/drawbridge-utils/circuit' );
  • circuit({ name, threshold, timeout }) — circuit breaker for async operations.

Upload entry

const { allowedUploadTypes, allowedMimes, resolveUploadType, isAllowedMime } = require( '@drawbridge/drawbridge-utils/upload' );
  • allowedUploadTypes / allowedMimes — shared whitelist constants.
  • resolveUploadType( type, extension ) — resolves an upload type from MIME + extension.
  • isAllowedMime( mime ) — predicate for the MIME whitelist.

Nanoid entry (server-only)

const { nanoid, retry } = require( '@drawbridge/drawbridge-utils/nanoid' );
  • nanoid() — 8-char base36 random ID (same as the main export).
  • retry({ field, operation, maxRetries }) — runs an async operation that generates a nanoid, retrying on Mongo duplicate-key errors.

Build & publish

nvm use
npm install
npm run build

build runs tsup (multi-entry, dual CJS + ESM output) and then npm publish. Bump version in package.json first.