Helper library for formatting integer numbers
let str = new IntFormat("# # #").format("123");
//1 2 3
npm install int-format
IntFormat({
format,
padWith,
sigil,
anchor
})
or
IntFormat(format)
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
setFormat
setSigil
setAnchor
setPad
format
- takes string or number as argument
let str = new IntFormat({ padWith: '?', format: "\\## \\\\# #" }).format(12);
//#1 \\2 ?
let str = new IntFormat('+# (###) ###-##-##').format('78037764302');
//+7 (803) 776-43-02
npm run test
npm run cover
IntFormat
is a simple state machine