This package has been deprecated

Author message:

No longer maintained.

tab-align

0.0.2 • Public • Published

tab-align

Align text with whitespaces + position


Build Status Version Downloads MIT License Dependency Status NSP Status

Code of Conduct

This package helps aligning rows of texts with ease. Texts can be aligned according to your preferences such as the position of the text, how many whitespaces between columns, replacing whitespaces with other symbols, et al.

Pre-requisite

How to use

Install

# Install package with NPM 
$ npm install --save tab-align

How to use

The following is a simple code snippet:

/** Import the package */
const tabAlign = require('tab-align');
 
/** Setting up with the position and whitespaces for alignment */
const pos = 'end';
const whitespaces = 4;
const allPossibleTitles = [
  'really really long title',
  'random title',
  'short title',
  'how\'s your day',
];
const fillWith = '.';
const alignText = tabAlign(allPossibleTitles, pos, whitespaces, fillWith);
 
console.log(alignText('Today\'s title'));
// This logs `........................Today's title`

tabAlign(stringArrays, [alignTo, whitespaces, fillWith])

  • stringArrays <string[]> An array of strings to determine the length of the longest title.
  • alignTo <string> Position to align text to. Possible values: start, center, or end.
  • whitespaces <number> Number of whitespaces to fill in.
  • fillWith <string> Symbol to replace whitespaces during the filling in.
  • returns <Function>
    • text <string> Text for alignment.

License

MIT License © Rong Sen Ng

Package Sidebar

Install

npm i tab-align

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • motss