Naughty Push Message

    number-speller
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    number-speller

    Small (3Kb) ESM and (4Kb) commonJs NPM package to spell numbers in plain English. I.e:

    • spellNumber(1000) > one thousand
    • spellNumber(7598025) > seven million five hundred ninety eight thousand twenty five
    • spellNumber(900000000) > nine hundred million

    Can be used in a browser as well and nodeJs applications. Witten in TypeScript and covered with unit tests.

    Online Demo

    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:

    • spellNumber function accepts a single argument - number to be spelled and returns a string.
    • maxSupportedNumber constant 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 21 and 99: 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!

    Install

    npm i number-speller

    DownloadsWeekly Downloads

    21

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • amalitsky