UNPKG

outers

Version:

outers - a all in one package for your day to day use

69 lines 2.94 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); // import Gen functions const WordGen_1 = __importDefault(require("../gen/WordGen")); // function for generating a random word // function for generating a random number /** * This TypeScript function generates a random string of characters with a specified length and the * option to make it all uppercase, using an array of possible letters. * @param {num} [length=1] - The length parameter is a number that determines the length of the * generated random string of characters. By default, it is set to 1. * @param {bool} [isCAPITAL=false] - A boolean parameter that determines whether the generated word * should be in all capital letters or not. If set to true, the generated word will be returned in all * capital letters. If set to false or not provided, the generated word will be returned in lowercase * letters. * @param {str[] | undefined} CustomWords - CustomWords is an optional parameter that allows the user * to provide their own array of words to be used in generating the random string. If this parameter * is not provided, the function will use the default array of all possible letters from 'a' to 'z'. * @returns a string (type `str`) that is a randomly generated sequence of characters of a specified * length, with the option to make it all uppercase if desired. The string is generated using an array * of possible characters (`Words`) that includes all lowercase letters of the English alphabet by * default, but can be customized by passing in a different array of characters as an argument * (`CustomWords`). The */ function GenerateWordID(length = 1, isCAPITAL = false, CustomWords) { /* This line of code is creating an array of all possible letters from 'a' to 'z' that will be used to generate a random string of characters. The array is stored in the constant variable `Words` and has a type of `str[]`, which means it is an array of strings. */ const Words = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ]; // All Possible Words to generate const Result = (0, WordGen_1.default)(length, CustomWords !== undefined ? CustomWords : Words); // Generate the Random Number // Checking if the Word should be Capital if (isCAPITAL === true) { return Result.toUpperCase(); // Return the Result in Capital } else { return Result; // Return the Result } } exports.default = GenerateWordID; //# sourceMappingURL=WordFunction.js.map