Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (14 sloc) 0.472 kB

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

Jump to Line
Something went wrong with that request. Please try again.