Core
Framework v2.x
2

generateRandomName #

Available since 2.19.0

Generates a random formatted name that consists of an optional prefix, a random adjective, a random name and an optional random number separated by separator (default: '-').

Format: [prefix<separator>]<adjective><separator><name>[<separator>random number]

Format example: something-dashing-euler-1164

Usage #

let name = NameGenerator.generateRandomName({
  prefix: 'my',
  separator: '_',
  postfixRandRange: { min: 1, max: 10 }
}); // 'my_abandoned_yogi_5'

name = NameGenerator.generateRandomName({
  separator: ' ',
  postfixRandRange: false
}); // 'amused vampire'
static generateRandomName(opts?: GenerateRandomNameOpts): string

ArgumentTypeDescription
opts
object
(optional) Name format options

opts #

PropertyTypeDefaultDescription
prefix
string
nonePrefix put before the adjective
separator
string
-Separator put between the parts of the name
postfixRandRange
{ min?: number, max: number } | false
{ min: 0, max: 100000 }Range of the random number put at the end of the name: min is inclusive (default 0), max is exclusive. false puts no number

The GenerateRandomNameOpts type of this argument is not exported by kuzzle.

Returns #

Returns a random formatted name