output-formatter

1.0.2 • Public • Published

output-formatter

NPM version build status Test coverage

format helper for output

const fmt = require('output-formatter');

fmt.left(str, len)

fmt.left('hello', 10).should.equal('hello     ');
fmt.left('hello', 5).should.equal('hello');
fmt.left('hello', 2).should.equal('hello');
fmt.left(234, 5).should.equal('234  ');
fmt.left(null, 5).should.equal('null ');

fmt.center(str, len)

fmt.center('hi', 10).should.be.equal('    hi    ');
fmt.center('hi', 9).should.be.equal('   hi    ');
fmt.center('hi', 2).should.be.equal('hi');
fmt.center('hi', 1).should.be.equal('hi');
fmt.center(0, 5).should.equal('  0  ');
fmt.center(undefined, 5).should.equal('undefined');

fmt.right(str, len)

fmt.right('world', 10).should.be.equal('     world');
fmt.right('world', 5).should.be.equal('world');
fmt.right('world', 1).should.be.equal('world');
fmt.right(true, 1).should.equal('true');

fmt.line(ch, num)

fmt.line('-', 5).should.be.equal('-----');
fmt.line('+', 0).should.be.equal('');

fmt.red(msg)

console.log(fmt.red('hello world'));
 

fmt.yellow(msg)

console.log(fmt.yellow('warning'));

Readme

Keywords

none

Package Sidebar

Install

npm i output-formatter

Weekly Downloads

2

Version

1.0.2

License

ISC

Last publish

Collaborators

  • bencode