Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

english-number

1.0.1 • Public • Published

Convert Numbers into English

Using a well-crafted stack structure that abstracts generically across languages.

Installation

npm install english-number

Usage

const EnglishNumber = require('english-number');

Pass any decimal representation of a number:

EnglishNumber.nameOf(1521.12); // => "One Thousand Five Hundred and Twenty-One plus Twelve Hundredths"
EnglishNumber.nameOf("40001.7"); // => "Forty Thousand One plus Seven Tenths"

Count off with order()

EnglishNumber.orderOf(208); // => "Two Hundredth and Eighth"

Or, if you're working with ratios and want to avoid repeating decimals:

EnglishNumber.nameOfRatio(7, 2); // "Seven Halves"
EnglishNumber.nameOfRatio(10, 3); // "Ten Thirds"

Tests

More than 200 Jasmine specs that handle the many irregularities of the English language

npm test

Limitations

Support is limited to numbers not greater in magnitude than one vigintillion (+/- 10^63) and with resolution limited to the vigintillionth (10^-63).

Motivation & Related Work

Number Reference is an online encyclopedia of calculations that relies heavily on this and related packages.

This is an iteration over an inferior package.

Install

npm i english-number

DownloadsWeekly Downloads

4

Version

1.0.1

License

BSD-3-Clause

Unpacked Size

22.4 kB

Total Files

10

Last publish

Collaborators

  • avatar