0.0.1 • Published 6 years ago

post-id v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

post-id

Given a number, this package generates stackoverflow-like post ids.

You've probably noticed them in urls: https://stackoverflow.com/questions/7474354/include-jquery-in-the-javascript-console

  • normalize () => 0000001
  • normalize (5) => 0000005
  • normalize (5325) => 0005325

The number of digits a number is normalized to can be set as follows: normalize({ max: 1e7 }).

normalize (start, options)

  • start: initial value to increment from (default = 1)
  • options: used to normalized the length of the post id (default = { max = 1e7 })

Example

const normalize = require('post-id')

normalize() 
// => 0000001
normalize() 
// => 0000002


normalize(5, { max: 100 })
// => 05
normalize({ max: 100 })
// => 06