numab
v0.0.14
Published
A package that allows the conversion between string abbreviations of numbers to actual numbers.
Downloads
9
Readme
Numab
Number abbreviation or for short Numab is a simple module for parsing string numbers.
Installation
With npm do
$ npm install numab
Usage
Basic usage
var numab = require('numab');
numab.parse("2.5"); // => 2.5
numab.parse("2.5k"); // => 2500
numab.parse("2.5M"); // => 2500000
Dehumanizing
Accepts a string of a number that is formatted in a "humanized" manner and converts it to a proper number.
numab.dehumanize("10,010"); // => 10010
numab.dehumanize("10,010.50"); // => 10010.50
Instancing
The module can create instances for different local configurations.
var numab = require("numab");
var numabInstance = numab.createInstace();
numab.parse // => [Function: parse]
numabInstance.parse // => [Function: parse]
Configuration
var numab = require('numab');
numab.parse("2.5k"); // => 2500
numab.parse("2,5k"); // => NaN
numab.config({separator: ","});
numab.parse("2,5k"); // => 2500
numab.config({separator: "," , deliminer: "."});
numab.dehumanize("1,100.52")
Configuring instances
var configObj = {separator: ","};
var numabInstance = numab.createInstace();
numabIntance.config(configObj);
// or
var numabInstance = numab.createInstace(configObj);