Left pad a string to align with the longest string in an array
$ npm install --save lpad-align
const lpadAlign = require('lpad-align');
const words = [
'foo',
'foobar',
'foobarcat'
];
for (const x of words) {
console.log(lpadAlign(x, words, 4));
}
/*
foo
foobar
foobarcat
*/
Type: string
String that will be padded.
Type: Array
Array to align against.
Type: number
Default: 4
Indentation to prepend the string with.
$ npm install --global lpad-align
Usage
$ cat <file> | lpad-align
Example
$ cat unicorn.txt | lpad-align
foo
foobar
foobarcat
MIT © Kevin Mårtensson
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.