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!
- 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 🙂
npm install pad-center
This package is a pure ESM package.
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"
Default: {}
Type: object
Required: Yes
Type: string | number
Required: Yes
Type: string | number
Required: Yes
Type: string | number
Required: Yes
Type: number
Required: Yes