anoverse
v1.0.0
Published
A versatile random data generation library for JavaScript
Maintainers
Readme
Anoverse
A versatile random data generation library for JavaScript applications.
Installation
Using npm:
npm install anoverseUsing yarn:
yarn add anoverseUsing pnpm:
pnpm add anoverseUsing Bun:
bun add anoverseUsage
First, import and initialize the library:
import anoverse from "anoverse";
const ano = anoverse();API Reference
Basic Random Number Generation
generateRandomNumber(max)
Generates a random integer from 0 to max (inclusive).
console.log(ano.generateRandomNumber(88)); // Example output: 42getRange(max)
Returns an array of integers from 0 to max-1.
console.log(ano.getRange(8)); // Output: [0, 1, 2, 3, 4, 5, 6, 7]String Generation
generateRandomAlpha(length)
Generates a random string of alphabetic characters of the specified length.
console.log(ano.generateRandomAlpha(6)); // Example output: "XwBrTq"generateRandomAlphaNumeric(length)
Generates a random string of alphanumeric characters of the specified length.
console.log(ano.generateRandomAlphaNumeric(10)); // Example output: "a7Bf9X2p0Z"generateRandomSymbol(length)
Generates a random string of symbols of the specified length.
console.log(ano.generateRandomSymbol(3)); // Example output: "#@!"Utility Functions
generateOTP(length)
Generates a one-time password (numeric) of the specified length.
console.log(ano.generateOTP(4)); // Example output: "5382"generateUUID()
Generates a UUID (Universally Unique Identifier).
console.log(ano.generateUUID()); // Example output: "f47ac10b-58cc-4372-a567-0e02b2c3d479"getRandomBoolean()
Returns a random boolean value (true or false).
console.log(ano.getRandomBoolean()); // Example output: trueArray Operations
getRandomItem(array)
Returns a random item from the provided array.
console.log(ano.getRandomItem(['red', 'blue', 'green'])); // Example output: "blue"shuffleArray(array)
Returns a new array with the elements of the provided array in a random order.
console.log(ano.shuffleArray([1, 2, 3, 4, 5])); // Example output: [3, 1, 5, 2, 4]Date Generation
getRandomDate()
Generates a random date.
console.log(ano.getRandomDate()); // Example output: 2023-05-17T14:32:17.123ZLicense
MIT
