uniquegen
Version:
uniquegen is an package for Node.js projects, enabling the generation of random numbers and words. It offers flexibility and ease of use, making it a valuable tool for developers.
68 lines (67 loc) • 2.66 kB
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../gen/SymbolGen"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// import Gen functions
const SymbolGen_1 = require("../gen/SymbolGen"); // function for generating a random word
// function for generating a random number
/**
* This is a TypeScript function that generates a random string of symbols with a specified length and
* custom symbols if provided.
* @param {num} [length=1] - The length parameter is a number that specifies the length of the
* generated symbol ID. By default, it is set to 1 if no value is provided.
* @param {str[] | undefined} CustomSymbols - CustomSymbols is an optional parameter that allows the
* user to provide their own array of symbols to be used in generating the random string. If this
* parameter is not provided, the function will use the default array of symbols defined in the code.
* @returns The function `GenerateSymbolIDsync` is returning a promise that resolves to a string
* (`Promise<str>`). The string is a randomly generated sequence of symbols of length `length`, using
* either the default symbol array or a custom symbol array if provided.
*/
function GenerateSymbolIDsync(length = 1, CustomSymbols) {
/* Defining an array of symbols that will be used to generate a random string of symbols in the
`GenerateSymbol` function. The array contains various symbols such as exclamation mark, at sign,
hash, dollar sign, etc. */
// Symbol Array
const Symbols = [
'!',
'@',
'#',
'$',
'%',
'^',
'&',
'*',
'(',
')',
'-',
'_',
'=',
'+',
'[',
']',
'{',
'}',
';',
':',
'<',
'.',
'>',
'/',
'?',
'|',
'\\',
'~',
'`',
]; // Symbol Array
const Result = (0, SymbolGen_1.default)(length, CustomSymbols !== undefined ? CustomSymbols : Symbols); // Generate the Random Number
return Result; // Return the Result
}
exports.default = GenerateSymbolIDsync;
});