pad-center
v1.1.4
Published
pad-center fills between the start and end characters with character you want while maintaining the length.
Downloads
5
Maintainers
Readme
pad-center
pad-center
fills between the start and end characters with character you want while maintaining the length.
Like padStart
and 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
npm install pad-center
This package is a pure ESM package.
Usage
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