UNPKG

@autonomousorganization/ao-cli

Version:

An interactive command-line interface (CLI) tool to help you install, use, and administer an AO instance.

21 lines (16 loc) 662 B
// General helper functions // Returns a random int between min and max (inclusive) export function randomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } // Returns a random item from the given array export function selectRandom(arrayToChooseFrom) { return arrayToChooseFrom[randomInt(0, arrayToChooseFrom.length - 1)] } // Waits for the given number of milliseconds (or a brief pause by default) export function sleep(ms = 550) { return new Promise((r) => setTimeout(r, ms)) } export const isObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]'