readable-id

1.0.0 • Public • Published

readable-id

Generate (mostly) human readable, Heroku-style ids.

Usage

rid = require('readable-id')
rid()
// red-voice-ekDJ84G-We

Here is, literally, the entire source code:

nanoid = require('nanoid')
adjectives = require('./adjectives')
nouns = require('./nouns')
 
// adjectives and nouns from https://gist.github.com/afriggeri/1266756
 
module.exports = function() {
  id = nanoid(7)
  adjectiveIndex = Math.round(Math.random() * adjectives.length)
  nounIndex = Math.round(Math.random() * nouns.length)
  return adjectives[adjectiveIndex] + "-" + nouns[nounIndex] + "-" + id
}

The nanoid package lends uniqueness and collision resistance, and the adjectives and nouns the human readability.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    79
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    79
  • 0.0.3
    12
  • 0.0.2
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i readable-id

Weekly Downloads

93

Version

1.0.0

License

MIT

Last publish

Collaborators

  • davewasmer