FORMATTE
Lightweight Value Formatter
const formatter = new Formatter('dollar');
const value = formatter.validate('1000000.50');
// value = '$1,000,000.50'
Intro
Formatte is a value formater for JavaScript. It uses rule sets built from utility functions like removeLeadingZeros
to produce formated data.
Instaliation
This is a JavaScript module available through the npm registry.
Before installing, download and install Node.JS.
Installation is done using the npm install
command:
npm install formatte
Contributing
Creators
The original creator of Formatte is Morgan Brown;
License
Some of the format types supported are...
- Dollars
- Floats
- Integer
- Percentage
- Year
- Long Percentage
Example
Input
const formated = new Formater('dollar').validate('001234.1234);
Output
'$1,234.12'
Formatte can be used with both NodeJS and Javascript. Formatte Utilizes the ES6 Class Syntax.
Currently Supported Formats
Year
Input
const formated = new Formater('year').validate('00a2014.1');
Output
'2014'
Dollar
Input
const formated = new Formater('dollar').validate('001234.1234');
Output
'$1,234.12'
Percent
Input
const formated = new Formater('percent').validate('001234.1234');
Output
'1,234.12%'
Long Percent
Input
const formated = new Formater('longPercent').validate('001234.1234');
Output
'1,234.1234%'
Integer
Input
const formated = new Formater('integer').validate('hello123402');
Output
'123402'