pad-number

convert a number to a padded string with n leading zeroes

npm install pad-number
4 downloads in the last month

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

npm loves you