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

conversor-numero-a-letras-es-ar

v1.0.3

Published

Clase para convertir un numero a su representación en letras en español, por ejemplo: 15 se convierte a 'quince'

Downloads

580

Readme

Conversor de numeros a letras en español

Clase con métodos que pueden llamarse para convertir un número entero a su equivalente en letras en español.

Descripción

En este paquete hay una clase Conversor, la cual posee los métodos necesarios para convertir números enteros a su representación en letras. Basado en la [escala numérica larga] (https://es.wikipedia.org/wiki/Escalas_num%C3%A9ricas_larga_y_corta) Limitaciones: Llega hasta el orden de los billones.

Instalación

La instalación se realiza vía [npm] (https://www.npmjs.com/). mediante el comando

npm install --save conversor-numero-a-letras-es-ar

Features

  • Convertir números enteros (number o string) a su representación en letras (string).
  • Convertir números del 1 al 12 (number o string) a su representación en letras del mes correspondiente (string).

Ejemplos

const conversor = require('conversor-numero-a-letras-es-ar');

let ClaseConversor = conversor.conversorNumerosALetras;
let miConversor = new ClaseConversor();

var a = miConversor.convertToText(27);
var b = miConversor.convertToText('27');

console.log(a); // imprime "veintisiete"
console.log(b); // imprime "veintisiete"


var c = miConversor.convertToText(2019);

console.log(c); // imprime "dos mil diecinueve"


function getFechaActualEnTexto() {
    var today = new Date();

    var dd = String(today.getDate()).padStart(2, '0');
    var mm = String(today.getMonth() + 1).padStart(2, '0'); //Enero es 0!
    var yyyy = today.getFullYear();
    
    dd = miConversor.convertToText(String(dd));
    mm = miConversor.convertirNroMesAtexto(String(mm));
    yyyy = miConversor.convertToText(String(yyyy));

    return `${dd} de ${mm} de ${yyyy}`;
}
console.log(getFechaActualEnTexto()) //Siendo 10/11/2019(dd/mm/aaaa) imprime "diez de Noviembre de dos mil diecinueve"

Guia

Luego de instalar el paquete como dependencia, para utilizarlo debe importar el módulo dentro del archivo .js donde lo quiera utilizar con nodejs.

const <conversor> = require('conversor-numero-a-letras-es-ar');

Donde es el objeto que posee el módulo. Para acceder a la clase del conversor debe referenciarlo a una variable.

const <ClaseConversor> = <Conversor>.conversorNumerosALetras;

Luego puede crear una instancia de la clase.

const <miConversor> = new <ClaseConversor>();

Ahora puede utilizar los métodos de la clase, los cuales son:

  • convertToText(number) Convierte un número a su nombre en texto, el argumento puede ser de tipo number o string. Devuelve un string.
  • convertirNroMesAtexto(number) Convierte un número de mes a su nombre en texto, el argumento puede ser de tipo number o string. Devuelve un string.
  • deleteZerosLeft(number) Elimina los ceros a la izquierda en un número, acepta sólo strings como argumento.
  • validateNumber(number) Valida que el argumento sea un número y si es una cadena que no esté vacía`, que no tenga punto decimal y que no sea negativo.