New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

formatte

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formatte

Formatte is a value formater for JavaScript.

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

FORMATTE

Formatte logo

NPM Version NPM Downloads

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

Contributing Guide

Creators

The original creator of Formatte is Morgan Brown;

License

MIT

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'

Keywords

formatting

FAQs

Package last updated on 22 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts