Socket
Socket
Sign inDemoInstall

left-pad

Package Overview
Dependencies
0
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

left-pad

String left pad


Version published
Maintainers
3
Weekly downloads
1,456,010
decreased by-11.51%

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

Time complexity: O(log(n))

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.

Keywords

FAQs

Last updated on 01 Oct 2016

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