Skip to content

Convert a number to a string with n leading zeroes.

Notifications You must be signed in to change notification settings

puckey/pad-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Convert a number to a string with n leading zeroes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published