Skip to content
This repository has been archived by the owner. It is now read-only.
⬅️ String left pad -- deprecated, use String​.prototype​.pad​Start()
JavaScript
Branch: master
Clone or download
Latest commit 2fca615 Mar 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
perf Removed unnecessary if check at the end of the es6Repeat implmentation Sep 26, 2016
.gitignore initial Mar 14, 2014
.travis.yml metadata May 1, 2016
LICENSE Create LICENSE Nov 14, 2018
README.md Fixes typo in readme Mar 13, 2019
index.d.ts remove unnecessary comments Apr 9, 2018
index.js Update index.js Nov 14, 2018
package.json License Update Jan 6, 2019
test.js Update test.js Nov 14, 2018

README.md

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 plane are considered two distinct characters. See #58.

You can’t perform that action at this time.