2.0.0 • Published 6 years ago

aligns v2.0.0

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

npm package

build status Coverage Status Dependency Status NPM download NPM quality

Aligns

A tool to align array or table

Table of Contents

Installation

$ npm install aligns

Usage

Align an array

const align = require('aligns');

const xs = ['Ludwig van Beethoven', 'Beyond', 'Michael Jackson', 'Wolfgang Amadeus Mozart'];
const aligned = align.alignLeft(0, xs);

/*
[ 'Ludwig van Beethoven   ',
  'Beyond                 ',
  'Taylor Swift           ',
  'Wolfgang Amadeus Mozart' ]
*/

Align a table

const align = require('aligns');

const xss = [
  ['Ludwig van Beethoven', 'Wolfgang Amadeus Mozart'],
  ['Symphony No.9 in D minor op.125', 'Le nozze di Figaro K.492'],
  ['Symphony No.5 in C minor op.67', 'Serenade No.13 K.525']
];
const aligned = align.alignTableL(xss);

/*
[ [ 'Ludwig van Beethoven           ','Wolfgang Amadeus Mozart ' ],
  [ 'Symphony No.9 in D minor op.125','Le nozze di Figaro K.492' ],
  [ 'Symphony No.5 in C minor op.67 ','Serenade No.13 K.525    ' ] ]
*/

API

Align.left(indent, xs)

Align an array of String to left.

Align.right(indent, xs)

Align an array of String to right.

Align.center(indent, xs)

Align an array of String to center.

Align.tableL(xss)

Align each column to left.

Align.tableR(xs)

Align.table(xs)