convert-to-words

a small js lib to convert numbers to words


Keywords
numbers, Spanish, English, words
License
MIT
Install
npm install convert-to-words@1.3.5

Documentation

convert-to-words

npm GitHub npm bundle size npm FOSSA Status

convert-to-words is a small javaScript TypeScript lib helps you to convert any number up to 10^300 and also covers decimal numbers and if its in the numbers you want to convert ar in dome txt you don't want to change it will do that for you be default

installation

npm

npm i convert-to-words

cdn

https://cdn.jsdelivr.net/npm/convert-to-words@1.3.5/index.js

options:

option description default
lang changes the lang the supported languages is English:'en' Spanish:'es' en
numbersOnly when it set to true it makes the functions receive numbers only false

Usage:

// this will run on both browser and node
const convertToWords = convertToWords || require('convert-to-words');

convertToWords(999.999, {lang:'es'}); // => novecientos noveta y nueve comma novecientos noveta y nueve

also you can change the default of the function

// changing the default lang
convertToWords.options.lang = 'es';

// making the function receive numbers only (number could be also pass in as string)
// NOTE: it will throw an error if receives any thing except numbers
convertToWords.options.numberOnly = true;

convertToWords('999.99') // => novecientos noveta y nueve comma novecientos noveta y nueve

LICENCE

MIT License

Copyright (c) 2019 AliBasicCoder