Share your code. Components are building blocks, you are the architect.

string/left-pad
v1.0.0
1.0.0
0.0.1
MIT
PUBLIC
49
0     DEPENDENCIES
Build: pass
BuildPass
Build Status: pass
pad a string to the left.
bit
Contributors
Gravatar for undefinedGravatar for undefined
0

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use string/left-pad in your project
npm i @bit/bit.utils.string.left-pad
Copied

leftPad (str:string, len:number, ch:string) : string

pad a string to the left.

Example

leftPad('foo', 5) // => "  foo"
 leftPad('foobar', 6) // => "foobar"
 leftPad(1, 2, '0') // => "01"

Arguments

str: string

string to pad

len: number

total

ch: string

char to use for padding

Returns

string

modified string

Test Summary


#leftPad() should pad string `foo` to a total char size of 5Pass
#leftPad() should not pad string `foobar` any char as 6 is the original str lengthPass
#leftPad() should pad string `1` with one 0Pass