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

@stencitecnologia/utils

v0.1.0

Published

Pure utility functions: validators, formatters, and date helpers. Framework-agnostic.

Readme

@stencitecnologia/utils

Funções utilitárias puras: formatação de datas, strings, documentos brasileiros (CPF, CNPJ), telefone, endereço, e validadores. JavaScript framework-agnostic. Única dependência: dayjs.

Instalação

npm install @stencitecnologia/utils

dayjs é instalado automaticamente como dependência.

Uso

import {
  formatDate,
  formatPhone,
  onlyNumber,
  isValidCPF,
  addMonths,
  today,
} from '@stencitecnologia/utils';

// Exibição
formatDate(record.createdAt);                    // '14/05/2026'
formatPhone(onlyNumber('+55 (11) 99999-9999'));  // '(11) 99999-9999'

// Validação (sempre passe o valor já limpo)
const digits = onlyNumber(rawInput);
if (isValidCPF(digits)) {
  // CPF válido
}

// Aritmética de datas
const proximoMes = addMonths(today(), 1);

Referência — datas

Internamente usa dayjs configurado com locale pt-BR e os plugins customParseFormat, localizedFormat, utc, timezone.

Tipos aceitos: Date | string | number | dayjs. Formatos string aceitos: YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss, DD/MM/YYYY, DD/MM/YYYY HH:mm, DD/MM/YYYY HH:mm:ss.

| Função | Assinatura | Descrição | |---|---|---| | formatDate | (date, format?) => string | Default 'DD/MM/YYYY'. | | formatDateTime | (date, format?) => string | Default 'DD/MM/YYYY HH:mm'. | | formatTime | (date, format?) => string | Default 'HH:mm'. | | formatWeekday | (date, format?) => string | Default 'ddd' em caixa alta ('SEG'). | | formatFullDate | (date, format?) => string | Default 'dddd, DD[ de ]MMMM[ de ]YYYY'. | | formatDateToApi | (date, format?) => string | Default 'YYYY-MM-DD'. | | formatDateTimeToApi | (date, format?) => string | Default 'YYYY-MM-DD HH:mm:ss'. | | toDate | (value) => Date \| null | Converte para Date nativo ou retorna null. | | startOfDay | (date) => Date | Meia-noite da data informada. | | today | () => Date | Hoje à meia-noite. | | add | (date, amount, unit?) => Date | Unit default: 'day'. | | addDays | (date, days) => Date | | | addMonths | (date, months) => Date | | | addYears | (date, years) => Date | | | addMinutes | (date, minutes) => Date | |

Referência — strings

| Função | Assinatura | Descrição | |---|---|---| | getInitials | (name: string) => string | Primeira letra das duas primeiras palavras, em caixa alta. 'John Doe Smith' → 'JD'. | | toCamelCaseWords | (value: string) => string | Title-case por palavra. 'hello world' → 'Hello World'. | | onlyNumber | (value: string) => string | Remove tudo que não for dígito. | | formatDocument | (value: string \| null) => string | Formata como CPF (11 dígitos) ou CNPJ (14 dígitos). Retorna '-' para vazio. | | formatNumber | (value: number, decimals?) => string | Locale pt-BR. Default 2 casas. 1234.5 → '1.234,50'. | | shortCode | (objectId: string) => string | Últimos 8 caracteres em caixa alta. |

Referência — formatadores

| Função | Assinatura | Descrição | |---|---|---| | formatPhone | (value: string) => string | Aceita dígitos crus (com ou sem 55). 11 dígitos → (XX) XXXXX-XXXX, 10 → (XX) XXXX-XXXX. | | formatAddress | (address) => string | Recebe { postalCode, state, city, neighborhood, addressLine1, addressLine2? }. CEP renderizado como XXXXX-XXX. | | formatCouncil | (council) => string | Recebe { name, state, record }. Retorna 'name state record'. |

Referência — validadores

Predicados puros (value) => boolean. Recebem o valor já limpo (use onlyNumber() antes para documentos/telefones).

| Função | Assinatura | Descrição | |---|---|---| | isValidCPF | (value: string) => boolean | 11 dígitos, valida dígitos verificadores. | | isValidCNPJ | (value: string) => boolean | 14 dígitos, valida com pesos. | | isValidCellphone | (value: string) => boolean | Vazio OU exatamente 11 dígitos. | | isValidPhone | (value: string) => boolean | Vazio OU exatamente 10 dígitos. | | isValidPostalCode | (value: string) => boolean | Exatamente 8 dígitos. | | isValidDate | (value: Date \| string) => boolean | | | isFutureDate | (value: Date, baseDate?: Date) => boolean | baseDate default: hoje. | | isValidDateRange | (value: [Date \| null, Date \| null]) => boolean | end >= start. | | isOnlyNumbers | (value: string) => boolean | | | isValidFullName | (value: string) => boolean | ≥2 tokens, sem caracteres especiais (exceto ' e -), ≥2 chars por token. |

Restrições

  • Nunca importe dayjs diretamente — use as funções deste pacote para garantir locale e plugins corretos.
  • Validadores não fazem stripping. Chame onlyNumber() antes de isValidCPF, isValidCellphone etc.
  • Nada de imports de vue, vue-router, pinia, primevue, @vuelidate/* ou axios.