@universis/number-format
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

universis-number-format

Universis library for converting numbers to text

Usage

npm i @universis/number-format

Use NumberFormatter class to convert a number to cardinal:

import {NumberFormatter} from '@universis/number-format';
const text = new NumberFormatter().format(54.5, 'en');
// => fifty-four and five tenths

or define fractional digits

import {NumberFormatter} from '@universis/number-format';
const text = new NumberFormatter().format(9.75, 'en', 3);
// => nine and seven hundred fifty thousandths

A new locale may be register by using NumberFormatter.registerLocale(locale,data);

import {NumberFormatter} from '@universis/number-format';
NumberFormatter.registerLocale('fr', {
    ...
    ["21", "vignt et un"],
    ...
    ["3", "trois"],
    ["2", "deux"],
    ["1", "un"],
    ["0", "zero"],
    ...
})

Package Sidebar

Install

npm i @universis/number-format

Weekly Downloads

49

Version

1.0.4

License

BSD-3-Clause

Unpacked Size

41.1 kB

Total Files

27

Last publish

Collaborators

  • universis