🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

human-id

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

human-id

Returns from a pool of 10m human-readable IDs

Source
npmnpm
Version
4.0.0
Version published
Weekly downloads
4.6M
5.75%
Maintainers
1
Weekly downloads
 
Created
Source

💃🆔

Human-Readable Identifiers

Downloads License

Using words to identify datasets (instead of numbers) provides various advantages when humans are involved, ie increased distinction and rememberability.

Human-ID generates readable strings by chaining common short words of the english language in a semi-meaningful way. The result is concatenated of adjective + noun + verb resulting in an minimum pool size of 15 000 000 possible combinations.

  • SFW: no bad words; family friendly results
  • No dependencies

Examples

  • FortyGhostsTalk
  • CalmSnailsDream
  • TastyRocksSparkle
  • HealthyCowsSmile
  • AfraidWallsExist
  • StrangeCarsRush
  • TwoLizardsSing
  • HappyLionsJump

Install

Yarn

yarn add human-id

NPM

npm install human-id

Usage

import humanId from 'human-id'

// RareGeckosJam
humanId()

// Rare~Geckos~Jam
// alias for { separator: '~' }
humanId('~')

// rare-geckos-jam
humanId({
  separator: '-',
  capitalize: false,
})

poolSize()  // 15,000,000
minLength() //          8
maxLength() //         19

Extended Pool Size

For most cases, the default pool size should be large enough. However, the options adjectiveCount and addAdverb can be utilized to increase the pool size for the price of the string length.

const options = {
  adjectiveCount: 2,
  addAdverb: true,
  separator: '.'
}

humanId(options)   // Ten.Wet.Files.Cheer.Lazily
poolSize(options)  // 630.000.000
minLength(options) //          20
maxLength(options) //          41

API

humanId(options?: string | Option): string

Generates a human ID. Options can be a string (separator), a boolean (capitalize) or an Options object of:

  • separator string = '' - Separates the words from each other
  • capitalize boolean = true - Whether to transform the first character of each word to upper case
  • adjectiveCount number = 1 - How many adjectives to return
  • addAdverb boolean = false - Adds a fourth part to the id

This function is also available as the default export

poolSize(options?: string | Option): number

Returns the number of possible combinations for a given set of options.

minLength(options?: Option): number

The length of the shortest possible id for a given set of options.

maxLength(options?: Option): number

The length of the longest possible id for a given set of options.

adjectives: string[]

List of possible values for the first part of the human id.

nouns: string[]

List of possible values for the second part of the human id.

verbs: string[]

List of possible values for the third part of the human id.

adverbs: string[]

List of possible values for the optional fourth part of the human id.

💃🆔

Keywords

human

FAQs

Package last updated on 09 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts