https://github.com/ozgurg/pad-center
pad-center fills between the start and end characters with character you want while maintaining the length.
https://github.com/ozgurg/pad-center
acikkaynak barcode generator masking pad pad-center pad-middle
Last synced: 5 months ago
JSON representation
pad-center fills between the start and end characters with character you want while maintaining the length.
- Host: GitHub
- URL: https://github.com/ozgurg/pad-center
- Owner: ozgurg
- License: mit
- Created: 2022-06-30T00:10:05.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T16:39:12.000Z (over 3 years ago)
- Last Synced: 2025-08-23T14:59:55.878Z (10 months ago)
- Topics: acikkaynak, barcode, generator, masking, pad, pad-center, pad-middle
- Language: JavaScript
- Homepage: https://npmjs.com/package/pad-center
- Size: 278 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


# pad-center
`pad-center` fills between the start and end characters with character you want while maintaining the length.
Like [padStart](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
and [padEnd](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd) but from
center, padCenter!
## Use cases
- Barcode generation
- It's not goal of the package, but you can use it for masking strings
- _Tell me what you are using it for 🙂_
## Install
```shell
npm install pad-center
```
_This package is a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)._
## Usage
```javascript
import padCenter from "pad-center";
padCenter({
startWith: "053",
endWith: "0",
fillWith: "*",
length: 11
});
// "053*******0"
padCenter({
startWith: "GH1",
endWith: "9",
fillWith: "0",
length: 10
});
// "GH10000009"
padCenter({
startWith: "O",
endWith: "G",
fillWith: "_",
length: 8
});
// "O______G"
```
## API
### padCenter(params) : string
#### params
Default: {}\
Type: object\
Required: Yes
#### params.startWith
Type: string | number\
Required: Yes
#### params.endWith
Type: string | number\
Required: Yes
#### params.fillWith
Type: string | number\
Required: Yes
#### params.length
Type: number\
Required: Yes
## License
[](https://github.com/ozgurg/pad-center/blob/main/LICENSE)