Skip to content
/ bpad Public

↔️ Leftpad and rightpad at the same time, aka balancedpad

Notifications You must be signed in to change notification settings

Jamesford/bpad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bpad Drone build status

↔️ Leftpad and rightpad at the same time, aka balancedpad

Install

$ npm install bpad
$ yarn add bpad

Usage

API
/**
 * Pads a string on left & right sides
 * evenly if possible
 *
 * @param {string}  str   - The string to be padded.
 * @param {int}     width - The total length of the padded string.
 * @param {string}  ch    - The character to use when padding.
 * @param {boolean} left  - If true asymmetric padding will occur on the left.
 */
function bpad (str, width, ch, left) {...}
Examples
const bpad = require('bpad')

bpad('foobar', 8)
// -> ' foobar '

bpad('foobar', 6)
// -> 'foobar'

bpad('foobar', 8, '*')
// -> '*foobar*'

bpad('foobar', 9, '*')
// -> '*foobar**'

bpad('foobar', 9, '*', true)
// -> '**foobar*'

About

↔️ Leftpad and rightpad at the same time, aka balancedpad

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published