You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

left-pad

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

left-pad

String left pad


Version published
Weekly downloads
1.6M
decreased by-0.79%
Maintainers
3
Install size
10.4 kB
Created
Weekly downloads
 

Package description

What is left-pad?

The left-pad npm package is a simple utility that allows you to pad a string with characters to ensure it reaches a certain length. It is primarily used to add padding to the left side of a string.

What are left-pad's main functionalities?

String Padding

This feature allows you to pad a string with spaces or any other character to a certain length. It is useful for aligning text or ensuring that strings fit into a fixed-width layout.

"hello".padStart(10, ' '); // results in '     hello'

Other packages similar to left-pad

Readme

Source

left-pad

String left pad

Build Status

Install

$ npm install left-pad

Usage

const leftPad = require('left-pad')

leftPad('foo', 5)
// => "  foo"

leftPad('foobar', 6)
// => "foobar"

leftPad(1, 2, '0')
// => "01"

leftPad(17, 5, 0)
// => "00017"

NOTE: The third argument should be a single char. However the module doesn't throw an error if you supply more than one chars. See #28.

NOTE: Characters having code points outside of BMP plan are considered a two distinct characters. See #58.

Keywords

FAQs

Package last updated on 09 Apr 2018

Did you know?

Socket

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc