lpad-align

Left pad a string to align with the longest string in an array

MIT 9 个版本
安装
npm install lpad-align
yarn add lpad-align
pnpm add lpad-align
bun add lpad-align
README

lpad-align Build Status

Left pad a string to align with the longest string in an array

Install

$ npm install lpad-align

Usage

const lpadAlign = require('lpad-align');

const words = [
	'foo',
	'foobar',
	'foobarcat'
];

for (const x of words) {
	console.log(lpadAlign(x, words, 4));
}

/*
		  foo
	   foobar
	foobarcat
 */

API

lpadAlign(string, array, indent)

string

Type: string

String that will be padded.

array

Type: Array

Array to align against.

indent

Type: number
Default: 4

Indentation to prepend the string with.

CLI

$ npm install --global lpad-align
  Usage
    $ cat <file> | lpad-align

  Example
    $ cat unicorn.txt | lpad-align
          foo
       foobar
    foobarcat
版本列表
3.0.0 2021-07-05
2.0.0 2017-05-22
1.1.2 2017-05-22
1.1.1 2017-05-21
1.1.0 2015-07-18
1.0.3 2015-02-26
1.0.2 2014-10-24
1.0.1 2014-10-23
1.0.0 2014-10-15