1.0.0 • Published 4 years ago
spanish-number v1.0.0
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.
1.0.0
4 years ago