https://github.com/souvikinator/pad-even
pad strings evenly
https://github.com/souvikinator/pad-even
padding spacing string
Last synced: 10 months ago
JSON representation
pad strings evenly
- Host: GitHub
- URL: https://github.com/souvikinator/pad-even
- Owner: souvikinator
- License: mit
- Created: 2021-04-14T05:32:26.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T06:37:49.000Z (almost 5 years ago)
- Last Synced: 2025-03-20T00:44:40.769Z (10 months ago)
- Topics: padding, spacing, string
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/pad-even
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pad-even
simple package to pad strings evenly
## Install
`npm install pad-even`
## example:
- without padeven
```js
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
```js
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 " "