
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A simple JavaScript library which provides the pronunciation of long numbers. Read long number up to 303 digits (10^303)
A simple JavaScript library which provides the pronunciation of long numbers. Read long number up to 303 digits (10^303).
// based on use case
npm install spelljs
bower install spelljs
Or you can just include spell.js file if you want.
There are 3 ways to use it:
1. Using function call:
spell(124); //"one hundred twenty four"
spell("123"); //"one hundred twenty three"
2. Using String Object method
"12312312321321313123123123123123".spell(); //"twelve nonillion , three hundred twelve octillion , three hundred twelve septillion , three hundred twenty one sextillion , three hundred twenty one quintillion , three hundred thirteen quadrillion , one hundred twenty three trillion , one hundred twenty three billion , one hundred twenty three million , one hundred twenty three thousand , one hundred twenty three"
3. Using Number Object method
123..spell(); //"one hundred twenty three"
Be careful while working with numbers in JavaScript:
1.Numbers don't won't allow direct operation like:
12.toString(); //wrong syntax
12.spell(); // wrong syntax
This is because JavScript is ambiguous if it is a decimal number or a property (like 12.5 or 13.7 ) So way around numbers is as follow:
12..toString();
12..spell();
12.0.spell();
(12).spell();
2.Be careful while using function call and Number Object method. By default JavaScript can only safely represent numbers between:
-(2^53 - 1) and 2^53 - 1
The Number.MAX_SAFE_INTEGER constant represents the maximum safe integer in JavaScript (2^53 - 1).
Number.MAX_SAFE_INTEGER // 9007199254740991
Math.pow(2, 53) - 1 // 9007199254740991
So using the spell method on very long numbers will cause trouble. A loss of precision occurs. i.e.
console.log(21321312312321321312313123123) //2.1321312312321322e+28
// So a loss of precision occurs here
21321312312321321312313123123..spell(); //"two hundred thirteen Tredecillion , two hundred thirteen duodecillion , one hundred twenty three undecillion , one hundred twenty three decillion , two hundred thirteen nonillion , two hundred twenty octillion "
spell(21321312312321321312313123123); //"two hundred thirteen Tredecillion , two hundred thirteen duodecillion , one hundred twenty three undecillion , one hundred twenty three decillion , two hundred thirteen nonillion , two hundred twenty octillion "
So best approach is to prefer string equivalents of them :
"21321312312321321312313123123".spell();
spell("21321312312321321312313123123");
document.querySelector("#input").value.trim().spell();
$("#input").val().trim().spell()
//Because it returns String value not Number value of input
spell(070) // outputs "fifty six"
spell(080) // outputs "eighty"
//because if it were octadecimal 8 should not be there. Hence treated as default i.e. binary
Likewise numbers preceding with 0x are hexadecimal. Hence safest approach as discussed earlier is to use string equivalent!!!
spell("070") // outputs "seventy"
spell("080") // outputs "eighty"
As there is limit on maximum integer size that we can use in JavaScript, spellJS uses Strings to manipulate the numbers. A huge number is broken down into chunks of strings and then recursively spelled out. The current max limit is 303 digits long number. And that too is is not because of memory issues. By increasing the map provided to SpellJS, the range can be further increased.
We welcome contributions and improvements!
FAQs
A simple JavaScript library which provides the pronunciation of long numbers. Read long number up to 303 digits (10^303)
We found that spelljs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.