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

util-stunks

v1.3.2

Published

Enhance your productivity with number abbreviation, relative time calculation, and value conversion

Readme

util-stunks

Utilitários pequenos para abreviar números, expandir abreviações, formatar durações e selecionar itens aleatórios. O pacote é escrito em TypeScript e inclui declarações de tipos.

npm CI licença

Instalação

npm install util-stunks

Uso

import {
  abbreviate,
  msToTime,
  randomArray,
  relativeTime,
  unabbreviate,
} from "util-stunks";

abbreviate(1_500); // "1.5K"
unabbreviate("1.5K"); // 1500
msToTime(61_000, { display: 2, removeMs: true });
// "1 minuto e 1 segundo"

const items = ["a", "b", "c"];
randomArray(items, { quantity: 2, removeSelectItem: false });

Tempo relativo e rótulos

relativeTime recebe um timestamp, opções de exibição e, opcionalmente, rótulos personalizados:

relativeTime(
  Date.now() - 3_660_000,
  { display: 2, removeMs: true },
  {
    hours: { unique: "hour", plural: "hours" },
    minutes: { unique: "minute", plural: "minutes" },
    separator: "and",
  },
);
// "1 hour and 1 minute"

Rótulos omitidos usam os valores padrão em português. Quando compact é true, os sufixos compactos originais (h, m, s) são mantidos.

API

| Função | Finalidade | | --- | --- | | abbreviate(number, options?) | Converte números para formatos como 1.5K | | unabbreviate(string) | Converte formatos como 1.5K para 1500 | | msToTime(milliseconds, options?) | Formata uma duração em texto | | relativeTime(timestamp, options?, labels?) | Calcula e formata a distância até um timestamp | | randomArray(array, options?) | Seleciona itens aleatórios, opcionalmente removendo-os |

Os tipos públicos de opções e rótulos também podem ser importados do pacote.

Desenvolvimento

Requer Node.js 24 e npm:

npm ci
npm run typecheck
npm test
npm run build
npm run test:dist
npm pack --dry-run

O build é gravado em dist; test:dist valida a mesma entrada JavaScript usada pelos consumidores do pacote. Consulte CONTRIBUTING.md antes de enviar mudanças e SECURITY.md para relatar vulnerabilidades.

Licença

MIT