UNPKG

outers

Version:

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

123 lines 7.66 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _UniqueGen__length; Object.defineProperty(exports, "__esModule", { value: true }); exports.UniqueGen = void 0; // Import Functions const BooleanFunction_1 = __importDefault(require("./Function/BooleanFunction")); // Import the Boolean Function const MixedFunction_1 = __importDefault(require("./Function/MixedFunction")); // Import the Mixed Function const NumFunction_1 = __importDefault(require("./Function/NumFunction")); // Import the Number Function const SymbolFunction_1 = __importDefault(require("./Function/SymbolFunction")); // Import the Symbol Function const WordFunction_1 = __importDefault(require("./Function/WordFunction")); // Import the Word Function class UniqueGen { constructor(length) { _UniqueGen__length.set(this, void 0); __classPrivateFieldSet(this, _UniqueGen__length, length, "f"); } // Methods for generating random values /** * The function "RandomNumber" generates a random number with the option to include zero and the * ability to provide a custom set of numbers. * @param {boolean} [withzero=true] - The "withzero" parameter is a boolean value that determines * whether or not the generated random number can include zero. If set to true, zero can be included * in the range of possible random numbers. If set to false, zero will not be included in the range. * @param {number[]} [CustomNumbers] - The `CustomNumbers` parameter is an optional array of numbers * that you can pass to the `RandomNumber` function. If you provide this parameter, the function * will generate a random number from the `CustomNumbers` array. If you don't provide this * parameter, the function will generate a random number * @returns a random number. */ RandomNumber(withzero = true, CustomNumbers) { return (0, NumFunction_1.default)(__classPrivateFieldGet(this, _UniqueGen__length, "f"), withzero, CustomNumbers); // Returns a random number } // Random Word /** * The RandomWord function generates a random word with an optional parameter to make it all capital * letters and an optional array of custom words to choose from. * @param {boolean} [isCAPITAL=false] - The `isCAPITAL` parameter is a boolean value that determines * whether the generated random word should be in all capital letters or not. If `isCAPITAL` is set to * `true`, the generated word will be in all capital letters. If `isCAPITAL` is set to `false * @param {string[]} [CustomWords] - The `CustomWords` parameter is an optional array of strings that * allows you to provide your own set of words from which the random word will be selected. If you * don't provide any custom words, the function will use a default set of words. * @returns a random word. */ RandomWord(isCAPITAL = false, CustomWords) { return (0, WordFunction_1.default)(__classPrivateFieldGet(this, _UniqueGen__length, "f"), isCAPITAL, CustomWords); // Returns a random word } // Mixed /** * The function "RandomMixed" generates a random mixed string with optional capitalization and custom * character options. * @param {boolean} [isCAPITAL=false] - The `isCAPITAL` parameter is a boolean value that determines * whether the generated random mixed string should include capital letters or not. If `isCAPITAL` is * set to `true`, capital letters will be included in the generated string. If it is set to `false` or * not provided, * @param {string[]} [CustomMixeds] - CustomMixeds is an optional parameter of type string array. It * allows you to provide a custom set of characters that will be used for generating the random mixed * string. If you don't provide any custom set, the function will use a default set of characters. * @returns The function `RandomMixed` returns the result of calling the `randomMixed` function with * the `_length` property, `isCAPITAL` argument, and `CustomMixeds` argument. */ RandomMixed(isCAPITAL = false, CustomMixeds) { return (0, MixedFunction_1.default)(__classPrivateFieldGet(this, _UniqueGen__length, "f"), isCAPITAL, CustomMixeds); // Returns a random mixed string } // Symbol /** * The function "RandomSymbol" generates a random symbol based on a specified length and optional * custom symbols. * @param {string[]} [CustomSymbols] - CustomSymbols is an optional parameter of type string array. It * allows you to pass an array of custom symbols that you want to include in the random symbol * generation. If you don't provide any custom symbols, the function will generate a random symbol from * a default set of symbols. * @returns the result of calling the `randomSymbol` function with the `_length` parameter and the * `CustomSymbols` array as arguments. */ RandomSymbol(CustomSymbols) { return (0, SymbolFunction_1.default)(__classPrivateFieldGet(this, _UniqueGen__length, "f"), CustomSymbols); // Returns a random symbol } // Boolean /** * Generates a random boolean value. * @returns {boolean} A random boolean value. */ RandomBoolean() { return (0, BooleanFunction_1.default)(); // Returns a random boolean value } /** * Sets the length property of the instance. * This method updates the instance's length with the provided numeric value, ensuring that it is a positive number. * * @param {number} length - The new length value to be set. Must be a positive number. * @throws {Error} Throws an error if `length` is not provided, is not a number, or is less than or equal to zero. */ setLength(length) { if (!length) { throw new Error("Length cannot be empty"); // Throw an error if the length is empty } if (typeof length !== "number") { throw new Error("Length must be a number"); // Throw an error if the length is not a number } if (length <= 0) { throw new Error("Length must be greater than zero"); // Throw an error if the length is less than or equal to zero } // Set the length property __classPrivateFieldSet(this, _UniqueGen__length, length, "f"); // Set the length property to the number } } exports.UniqueGen = UniqueGen; _UniqueGen__length = new WeakMap(); //# sourceMappingURL=Base.js.map