number-speller
v1.0.3
Published
Spells number in English language
Maintainers
Readme
number-speller
Small (3Kb) ESM and (4Kb) commonJs NPM package to spell numbers in plain English. I.e:
spellNumber(1000)> one thousandspellNumber(7598025)> seven million five hundred ninety eight thousand twenty fivespellNumber(900000000)> nine hundred million
Can be used in a browser as well and nodeJs applications. Witten in TypeScript and covered with unit tests.
Installation & Usage
Install with npm install number-speller and import with
import { spellNumber } from 'number-speller';or
const { spellNumber } = require('number-speller');for commonJs environment.
API
Module exports:
spellNumberfunction accepts a single argument - number to be spelled and returns a string.maxSupportedNumberconstant with the maximum number currently supported by the module.
Limitations
- Works with integers. Number with fractional part gets rounded.
- Supports positive numbers only.
- Doesn't support numbers passed in string form.
I.e.
spellNumber('1000')throws an exception. - Maximum number currently supported is one thousand billion minus one -
999 999 999 999. - Does not use hyphens for numbers between
21and99: twenty one instead of twenty-one.
Feedback and Contributions
Please open an issue if you have a question or ping me on twitter. Thanks for your interest!
