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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@royaltics/utils

v1.1.2

Published

🚀 Una librería de utilidades y componentes UI reutilizables para proyectos JavaScript y TypeScript. Compatible con utilsJS y ESM.

Readme

📦 Royaltics Utils & UI

🚀 Una librería de utilidades y componentes UI reutilizables para proyectos JavaScript y TypeScript. Compatible con utilsJS y ESM.


📦 Índice de Componentes


Fechas src/dates

  • parseDate(date, timezone?): Convierte un string a objeto Date.
  • convertTimeZone(date): Ajusta una fecha a la zona horaria local.
  • formatDate(date, timezone?, format?): Formatea una fecha a string (YYYY-MM-DD o DD/MM/YYYY).
  • formatDateTime(date, timezone?, format?): Formatea fecha y hora.
  • formatDateLocal(date, timezone?): Formatea fecha a formato local.
  • formatTimeString(date): Extrae la hora en formato HH:mm.
  • nowTime(): Fecha y hora actual en formato string.
  • nowDate(): Fecha actual en formato string.
  • dateToStringEs(date, format?): Fecha en español, ej: "Lunes, 30 de Marzo del 2023".
  • monthsToStringEs(month): Nombre del mes en español.
  • monthsGenerate(count?, letters?): Array de nombres de meses.
  • addDaysDate(days, date?): Suma dĂ­as a una fecha.
  • diffDate(date_start, date_end, type?): Diferencia entre fechas en dĂ­as, meses o semanas.
  • formatTimeSince(date): Tiempo transcurrido desde una fecha (ej: "Hace 2 horas").

NĂşmeros src/numbers

  • sumFloat(...values): Suma valores como flotantes.
  • calculateEqPercent(total, value): Calcula el porcentaje de un valor respecto a un total.
  • defaultFloat(data, default_value?): Convierte a float, valor por defecto si no es válido.
  • roundFloat(number, decimals?): Redondea un nĂşmero flotante.
  • calculateDiscount(price_a, price_b): Calcula el descuento entre dos precios.
  • addTaxPorcent(price, tax_value, methodInverse?): Suma o resta porcentaje de impuesto.
  • getUtility(pvp, price, methodInverse?): Calcula utilidad aplicada.
  • getPercent(a, b): Calcula el porcentaje de a respecto a b.

Imágenes src/images

  • getDataUriFromImage(url, width?, height?): Convierte una imagen a Data URI (base64) con tamaño personalizado.

Cadenas src/string

  • fillSpaces(text, limit?, character?): Rellena un texto con caracteres hasta un lĂ­mite.
  • randomString(length?): Genera un string aleatorio.
  • truncateText(message, length?, index?): Trunca un texto a una longitud máxima.

Descargas src/download

  • downloadBlob(data, fileName): Fuerza la descarga de un archivo Blob en el navegador.

Plataforma src/platform

  • getDeviceOS(): Detecta el sistema operativo del dispositivo.
  • getDeviceName(): Devuelve el nombre del navegador y sistema operativo.
  • isMobileDevice(): Indica si el dispositivo es mĂłvil (por ancho de pantalla).

Formularios src/forms

src/forms/format.ts

  • parseNumberDoc(number): Formatea un nĂşmero de documento a 001-001-xxxxxx.
  • setSequence(number, limit?, serie?): Formatea una secuencia numĂ©rica con ceros a la izquierda.
  • toString(object, options?): Convierte cualquier valor a string, con opciones de formato.

src/forms/validator.ts

  • isEmpty(data, minLength?): Verifica si un campo está vacĂ­o.
  • isInteger(value): Verifica si es un entero.
  • isFloat(value): Verifica si es un flotante.
  • isUUID(value): Verifica si es un UUID válido.
  • isNumberDocument(doc_number): Verifica formato de nĂşmero de documento.
  • isEmail(value): Verifica si es un email válido.
  • isURL(value): Verifica si es una URL válida.
  • isValidForm(inputs, rulesObject, toast?): Valida un objeto de formulario segĂşn reglas.

Ejemplo de Uso

import {
  formatDate,
  sumFloat,
  getDataUriFromImage,
  fillSpaces,
  downloadBlob,
  getDeviceOS,
  isValidForm
} from "royaltics/utils";

console.log(formatDate(new Date())); // "2023-03-30"
console.log(sumFloat("5,599", 2)); // 7.599
getDataUriFromImage("https://ejemplo.com/img.jpg").then(console.log);
console.log(fillSpaces("123", 6)); // "000123"
downloadBlob("Hola mundo", "saludo.txt");
console.log(getDeviceOS()); // "Windows", "Android", etc.

const formRules = {
  email: { rules: ["req", "email"], name: "Correo" }
};
console.log(isValidForm({ email: "[email protected]" }, formRules)); // true

⚙️ Compilación y Desarrollo

Para compilar la librerĂ­a:

pnpm build

Para ejecutar en modo desarrollo:

pnpm dev

📜 Licencia

MIT License © 2025 - Royaltics Solutions