@yash580o/full-pad
v1.0.3
Published
Adding give element to string (start)test(middle)string(end).
Readme
full-pad
@yash580o/full-pad is a lightweight npm package for padding strings with a given character.
It replaces spaces with padded characters and also adds padding to both ends of the string.
Installation
npm install @yash580o/full-padUsage
const fullPad = require('@yash580o/full-pad');
// Example 1: Pad with '*', 3 times
console.log(fullPad("hello world", "*", 3));
// Output: ***hello***world***
// Example 2: Pad with '-', 2 times
console.log(fullPad("foo bar", "-", 2));
// Output: --foo--bar--
// Example 3: No padding
console.log(fullPad("test", "", 0));
// Output: testAPI
fullPad(str, chr, nochar)
- str:
string— The input string to pad. - chr:
string— The character to use for padding. - nochar:
number— Number of times the character should be added at each space and at both ends.
License
ISC
