1.0.3 • Published 7 years ago
int-format v1.0.3
int-format
Helper library for formatting integer numbers
let str = new IntFormat("# # #").format("123");
//1 2 3Installation
npm install int-formatConstructor
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-02Testing
npm run test
npm run cover
Architecture
IntFormat is a simple state machine