Random String

library random string to simplify generate unique string

Using commonjs

const { randomString } = require('expresso-core')

Using ES6

import { randomString } from 'expresso-core'

Random String generate by default length 32

import { randomString } from 'expresso-core'

const result = randomString.generate() // by default length 32

console.log(result)

// output :
'aq52PvnFrtvsX6rtA8MLj27xR2HcEJht'

Generate with length 10

const result = randomString.generate(10)

console.log(result)

// output :
'aq52PvnFrt'

Generate with type Numeric

const result = randomString.generate({
  type: 'numeric',
  length: 5,
})

console.log(result)

// output :
'72810'

Last updated