Convert a number to a string with n leading zeroes.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test add test Jan 7, 2016
Readme.md remove component stuff Nov 24, 2015
index.js avoid changing argument values and clean up Jan 7, 2016
package.json bump Jan 7, 2016

Readme.md

pad-number

Convert a number to a string with n leading zeroes.

Using @Pointy's answer on Stackoverflow.

Installation

$ npm install 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