Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Component: convert a number to a string with n leading zeroes.
JavaScript
Branch: master
Failed to load latest commit information.
test Add tests + package.json.
.gitignore Initial commit.
History.md Initial commit.
Makefile Initial commit.
Readme.md Update Readme.md
component.json Initial commit.
index.js Lets do that the right way around.
package.json Add tests + package.json.

Readme.md

pad-number

Component: convert a number to a string with n leading zeroes.

Using @Pointy's answer on Stackoverflow.

Installation

$ component install puckey/pad-number

API

var pad = require('pad-number');

console.log(pad(10, 4)); // '0010'

console.log(pad(10, 5)); // '00010'

console.log(pad(10, 1)); // '10'

// Optional padding character:
console.log(pad(10, 5, '-')); // '---10'

License

MIT

Something went wrong with that request. Please try again.