Skip to content

A small library to convert number to words (like 10 to ten)

License

Notifications You must be signed in to change notification settings

AliBasicCoder/convert-to-words

Repository files navigation

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/[email protected]/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

About

A small library to convert number to words (like 10 to ten)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published