Skip to content

Instantly share code, notes, and snippets.

@daaniam
Created November 13, 2023 20:55
Show Gist options
  • Save daaniam/8b00c9741e98ca6eea60b8428a2a6d0f to your computer and use it in GitHub Desktop.
Save daaniam/8b00c9741e98ca6eea60b8428a2a6d0f to your computer and use it in GitHub Desktop.
bruno scripts

Randoms

const _ = require('lodash');

// Function to generate random string
function randStr(length) {
    return _.join(_.times(length, () => _.random(35).toString(36)), '');
}

// Function to generate a random integer with a specified number of digits
function randInt(digits) {
    const min = Math.pow(10, digits - 1);
    const max = Math.pow(10, digits) - 1;
    return _.random(min, max);
}

// Set vars
bru.setVar("randStr8", randStr(8))
bru.setVar("randInt4", randInt(4))
bru.setVar("randEmail", randStr(8) + "@example.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment