expresso
  • Get Started
    • 👋Welcome!
    • ⚡Quick Start
  • Expresso Library
    • 📖Introduction
    • ⚛️expresso-core
      • Currency
      • Random String
      • Formatter
      • File
      • Phone
    • ⚓expresso-hooks
      • Multer
      • Token
      • OTP
    • 🚀expresso-provider
      • FCM
      • SMTP
      • Redis
      • Storage
    • 🔗expresso-query
      • TypeORM
      • Sequelize
Powered by GitBook
On this page
  • Random String generate by default length 32
  • Generate with length 10
  • Generate with type Numeric
  1. Expresso Library
  2. expresso-core

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'
PreviousCurrencyNextFormatter

Last updated 1 year ago

⚛️