smart-line

a smart line with formatting features

Usage no npm install needed!

<script type="module">
  import smartLine from 'https://cdn.skypack.dev/smart-line';
</script>

README

smart-line

A smart fixed line with some formatting abilities

usage

const smartLine = require('smart-line').line;

center

var line = new smartLine(10);
line.center('abc');
assert.equal(line,'   abc    ');

left

var line = new smartLine(10);
line.left('xyz');
assert.equal(line,'xyz       ');
line.left('abc',7);
assert.equal(line,'xyz   abc ');

right

Please note that for legacy reasons the position is the start of the insertion

var line = new smartLine(10);
line.right('testing',5,4);
assert.equal(line,'    ting  ');
line.reset();
line.right('testing');
assert.equal(line,'   testing');

insert

var line = new smartLine(10);
line.insert('abc',6);
assert.equal(line,'     abc  ');