A speedy and lightweight io manipulation tool
const std = require('ciomanip');
Reading from stdin (sync):
// ... require
const input = std.in.read('What\'s your name? ');
console.log('His name is ' + input + '!');
Setting the fill will check if the width is more than 0,
if it is, it will use the width to fill in the text (1 -> 001)
std.setwidth(3);
std.setfill('0');
std.write('1'); // 001
Lists use the width and align each row to fit in the list
std.setwidth(16);
std.fillWith([
['hello', 'world', 5],
['world', 'hello'],
[5, 'world', 'hello'],
]);
std.line(); // console.log(); | process.stdout.write('\n');
std.alignLeft('text'); // has no special functionality
std.setwidth(20);
std.alignRight('Hello world');
Arguments: Array<any> left
, Array<any> right
, Number<> padding
std.setwidth(50);
std.leftRightTable(
['Value1', 'Value2'],
['I\'m on the right!'],
);
std.setwidth(51);
std.writeTable([
['hello, world!', 'hey'],
['hello, world!', 'hey again']
]);
std.setwidth(51);
std.formatTable([
['hello, world!', 'hey'],
['hello, world!', 'hey again']
]);
Hex Mode (displays 0x<hex> rather than <number>)
std.hex();
std.writes(0xA); // 0xA
std.writes(10); // 0xA
std.bin();
std.writes(0xA); // 1010
std.writes(10); // 1010
std.plain();
std.write(0xA); // 10
std.write(10); // 10
Using different modes without a state change
std.dir.hex(0xA); // 0xA
std.dir.hex(10); // 0xA
std.dir.bin(0xA); // 1010
std.dir.bin(10); // 1010
std.dir.plain(10); // 10
std.dir.plain(0xA); // 10
// Title
std.setwidth(16);
std.center('-');
std.write('Notes');
// Table
std.fillWith([
['hello', 'world', 5],
['world', 'hello'],
[5, 'world', 'hello'],
]);
// Align
std.alignRight('Hello');
std.line();
// console.log(std.in.read('Hello, '));
std.reset();
std.hex();
std.writes(0x3A);