1.0.5 • Published 8 years ago

format2 v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

format2

Code Climate Test Coverage Travis

What

This lib is for formatting strings for the CLI. For example if you want to create a list shown in the advanced example.

Installation

It's available on npm.

$ npm install --save format2

Basic example

var format2 = require('format2');

format2('should replace {0:3} with "#" and two trailing spaces', '#');

Output:
should replace #   with "#" and two trailing spaces

// Should cut the string and replace with only one hashtag
format2('{1:2}', '##');

Output:
#

Advanced example

var format2 = require('format2');
var formatting = '{0:3} | {0:25} | {0:25} | {0:25}';

console.log(format2(
    formatting,
    '#',
    'Artist',
    'Song',
    'Album'
));
console.log(format2(
    formatting,
    '-'.repeat(3),
    '-'.repeat(24),
    '-'.repeat(24),
    '-'.repeat(24)
));
console.log(format2(
    formatting,
    '1.',
    'Bjarne Oeverli',
    'Let me node you',
    'Best of Node'
));
console.log(format2(
    formatting,
    '2.',
    'Bjarne Oeverli',
    'Node',
    'Best of Node'
));

Output

Contribution

Contributions are appreciated.

License

MIT-licensed. See LICENSE.

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago