Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including left-pad with all npm packages installed. Try it out:

const leftPad = require('left-pad') leftPad('foo', 4)

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

left-pad v1.2.0

String left pad

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.

Typings

Typings copied from @types/left-pad for convenience.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free