Skip to content

ssypachev/int-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codecov Coverage

int-format

Helper library for formatting integer numbers

let str = new IntFormat("# # #").format("123");
//1 2 3

Installation

npm install int-format

Constructor

IntFormat({
	format,
	padWith,
	sigil,
	anchor
})

or

IntFormat(format)

Options

format - the format

padWith - which symbol to use to pad empty placeholders, default empty string

sigil - symbol to substitute, default #

anchor - symbol to escape sigil, default is backslash

Methods

setFormat

setSigil

setAnchor

setPad

format - takes string or number as argument

Examples

let str = new IntFormat({ padWith: '?', format: "\\## \\\\# #" }).format(12);
//#1 \\2 ?
let str = new IntFormat('+# (###) ###-##-##').format('78037764302');
//+7 (803) 776-43-02

Testing

npm run test npm run cover

Architecture

IntFormat is a simple state machine

About

node library for integer number formatting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published