Nutella Peanut-Butter Marshmallow
Wondering what’s next for npm?Check out our public roadmap! »

spanish-number

1.0.0 • Public • Published

Convert Numbers into Spanish

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

Installation

npm install spanish-number

Usage

const SpanishNumber = require('spanish-number');

Pass any decimal representation of a number:

SpanishNumber.nameOf(1521.12); // => "Mil Quinientos Veintiuno más Doce Centésimos"
SpanishNumber.nameOf("40001.7"); // => "Cuarenta Mil Uno más Siete Décimos"

Count off with order()

SpanishNumber.orderOf(208); // => "Ducentésimo Octavo"

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

SpanishNumber.nameOfRatio(7, 2); // "Siete Mitades"
SpanishNumber.nameOfRatio(10, 3); // "Diez Tercios"

Tests

More than 150 Jasmine specs that handle the many irregularities of the Spanish 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.

Install

npm i spanish-number

DownloadsWeekly Downloads

0

Version

1.0.0

License

BSD-3-Clause

Unpacked Size

31.9 kB

Total Files

14

Last publish

Collaborators

  • avatar