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 🙏

© 2024 – Pkg Stats / Ryan Hefner

format-styles

v1.0.3-beta.1

Published

The Format Styles is a powerful npm package designed to provide time formatting capabilities for Discord bots and applications.

Downloads

15

Readme

Format Styles

Format Styles es un potente paquete de NPM diseñado para brindar capacidades de formato de tiempo a bots y aplicaciones de Discord. Con este paquete, podrás convertir sin esfuerzo un valor de tiempo en milisegundos en una cadena de tiempo formateada, personalizable según diversas opciones.

Características Principales:

  1. Formato de Tiempo Flexible: Convierte valores de milisegundos en representaciones de tiempo fáciles de entender.

  2. Opciones Personalizables: Ajusta el formato de salida según tus preferencias. Elige entre una variedad de opciones, como unidades de tiempo (horas, minutos, segundos), estilos de formato (reloj de 12 horas o 24 horas) y más.

  3. Integración con Bots de Discord: Integra el paquete Format Styles sin problemas en tus bots o aplicaciones de Discord para contar con una funcionalidad eficiente de formato de tiempo.

Ejemplo de Uso:

const { createFormatDuration } = require("format-styles");
const formatDuration = createFormatDuration();

// Ejemplo: Convertir hasta el segundo con decimal para la unidad más pequeña
console.log(formatDuration(8000)); // Salida: '8 seconds'
console.log(formatDuration(9250)); // Salida: '9.25 seconds'

// Opción: "language" (Idioma)
console.log(formatDuration(3000, { language: "es" })); // Salida: '3 segundos'
console.log(formatDuration(5000, { language: "en" })); // Salida: '5 seconds'

// Opción: "delimiter" (Delimitador)
console.log(formatDuration(22140000, { delimiter: " y " })); // Salida: '6 hours y 9 minutes'
console.log(formatDuration(22140000, { delimiter: "--" })); // Salida: '6 hours--9 minutes'

// Opción: "spacer" (Espaciador)
console.log(formatDuration(260040000, { spacer: " hi " })); // Salida: '3 hi days, 14 hi minutes'
console.log(formatDuration(260040000, { spacer: "" })); // Salida: '3days, 14minutes'

// Opción: "largest" (Máximo de unidades mostradas)
console.log(formatDuration(1000000000000)); // Salida: '31 years, 8 months, 1 week, 19 hours, 46 minutes, 40 seconds'
console.log(formatDuration(1000000000000, { largest: 2 })); // Salida: '31 years, 8 months'

// Opción: "units" (Unidades de tiempo)
console.log(formatDuration(3600000, { units: ["h"] })); // Salida: '1 hour'
console.log(formatDuration(3600000, { units: ["m"] })); // Salida: '60 minutes'
console.log(formatDuration(3600000, { units: ["d", "h"] })); // Salida: '1 hour'

// Opción: "round" (Redondeo)
console.log(formatDuration(1200)); // Salida: '1.2 seconds'
console.log(formatDuration(2300, { round: true })); // Salida: '2 seconds'
console.log(formatDuration(2700, { round: true })); // Salida: '3 seconds'

// Opción: "conjunction" & "serialComma" (Conjunción y coma serial)
console.log(formatDuration(22140000, { conjunction: " y " })); // Salida: '6 hours, y 9 minutes'
console.log(formatDuration(22141000, { conjunction: "y" })); // Salida: '6 hours, 9 minutes,y1 second'
console.log(
  formatDuration(22140000, { conjunction: " and ", serialComma: false })
); // Salida: '6 hours and 9 minutes'
console.log(
  formatDuration(22141000, { conjunction: " and ", serialComma: false })
); // Salida: '6 hours, 9 minutes and 1 second'

// Ejemplo combinando múltiples opciones
console.log(
  formatDuration(22141000, {
    language: "en",
    delimiter: " | ",
    spacer: " - ",
    largest: 3,
    units: ["h", "m", "s"],
    round: true,
    conjunction: " and ",
    serialComma: false,
  })
);
// Salida: '6 - hours | 9 - minutes and 1 - second'

En el último ejemplo, se combinan múltiples opciones para personalizar la visualización de la duración. Se establece el idioma en inglés, el delimitador como "|", el espaciador como "-", se muestra un máximo de 3 unidades de tiempo (largest), se utilizan las unidades de horas, minutos y segundos, se redondea la unidad más pequeña (round), se establece la conjunción como "and" y se desactiva la coma serial (serialComma). La salida será "6 hours | 9 minutes and 1 second".

Espero que estos ejemplos te ayuden a comprender mejor las opciones disponibles en Format Styles. Si tienes más preguntas, ¡no dudes en hacerlas!

Instalación:

Para comenzar a utilizar el paquete Format Styles, instálalo a través de npm:

npm install format-styles

Para obtener más información sobre cómo utilizar el paquete y explorar todas sus funciones, háblame a mi Discord jainagam3r45.