Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

smart-line

felipep18ISC1.0.2

a smart line with formatting features

fixed, string, formatting

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 ');

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  ');