Socket
Socket
Sign inDemoInstall

bpad

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bpad

Leftpad and rightpad at the same time, aka balancedpad


Version published
Weekly downloads
221
decreased by-22.18%
Maintainers
1
Install size
112 kB
Created
Weekly downloads
 

Readme

Source

bpad

↔️ 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*'

Keywords

FAQs

Last updated on 01 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc