Skip to content

A repository for npm module Pad inspired by Azar's Leftpad, with performance improvement and padding for left + center option too.

License

Notifications You must be signed in to change notification settings

Sayanc93/stringpad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stringpad

run:
npm install stringpad

A repository for npm module stringpad inspired by Azar's Leftpad (which recently broke the internet), with performance improvements and Rightpad and Centerpad option too.

Implemented algorithm used for Javascript's repeat. Probably the fastest implementation of Azar's Leftpad, with added options.

Run tests using: node test

Usage:
stringpad.left('foo', 5)
' foo'
stringpad.left('foobar', 6)
'foobar'
stringpad.left(1, 2, 0)
'01'
stringpad.left(1, 2, '-')
'-1'
stringpad.right('foo', 5)
'foo '
stringpad.right('foobar', 6)
'foobar'
stringpad.right(1, 2, 0)
'10'
stringpad.right(1, 2, '-')
'1-'
stringpad.center('foo', 5)
' foo '
stringpad.center('foo', 6, '-')
'---foo---'

About

A repository for npm module Pad inspired by Azar's Leftpad, with performance improvement and padding for left + center option too.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published