pad-even

1.0.1 • Public • Published

pad-even

simple package to pad strings evenly

Install

npm install pad-even

example:

  • without padeven
const obj = {
    'abcd': 1234,
    'def': 123,
    'verylongword': 'evenly padded'
};

for (let key in obj) {
    console.log(`${key}= ${obj[key]}`);
}

/*
output:

abcd= 1234
def= 123
verylongword= evenly padded

*/
  • with pad-even
const padeven=require('pad-even');
const obj = {
    'abcd': 1234,
    'def': 123,
    'verylongword': 'evenly padded'
};

for (let key in obj) {
    console.log(`${padeven(key,20)}= ${obj[key]}`);
}

/*
output:

abcd                = 1234
def                 = 123
verylongword        = evenly paddedd
*/

API

padeven(str,n,c)

  • str: string that needs to be padded
  • n: padding value. Use positive value for padding to the right of the string, negative value for padding to the left of the string
  • c: padding string, default is " "

Dependents (1)

Package Sidebar

Install

npm i pad-even

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

3.54 kB

Total Files

5

Last publish

Collaborators

  • darthcucumber