Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #156

Merged
merged 5 commits into from
Mar 3, 2024
Merged

Dev #156

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source
tsconfig.json
tslint.json
.eslintrc.json
.eslintrc.yml
.github
library
dist
Expand All @@ -13,3 +13,7 @@ node_modules
.deepsource.toml
.gitpod.yml
docker-compose.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LEARN.md
SECURITY.md
16 changes: 3 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "outers",
"version": "8.1.4",
"version": "8.1.5",
"description": "outers - a all in one package for your day to day use",
"main": "./lib/Config/outer.js",
"types": "./lib/Config/outer.d.ts",
Expand Down Expand Up @@ -45,7 +45,6 @@
"crypto-js": "^4.2.0",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"mongosuper": "^4.4.3",
"uniquegen": "^8.5.0"
"mongosuper": "^4.4.3"
}
}
28 changes: 15 additions & 13 deletions source/UniqueGen/Base.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {
randomMixed,
randomNumber,
randomSymbol,
randomWord,
randomBoolean,
} from "uniquegen"; // Import the module
// Import Functions
import GenerateBooleanID from "./Function/BooleanFunction"; // Import the Boolean Function
import GenerateMixedID from "./Function/MixedFunction"; // Import the Mixed Function
import GenerateNumberID from "./Function/NumFunction"; // Import the Number Function
import GenerateSymbolID from "./Function/SymbolFunction"; // Import the Symbol Function
import GenerateWordID from "./Function/WordFunction"; // Import the Word Function

export class UniqueGen {
#_length?: number;
Expand All @@ -26,8 +25,11 @@ export class UniqueGen {
* parameter, the function will generate a random number
* @returns a random number.
*/
public RandomNumber(withzero = true, CustomNumbers?: number[]): number {
return randomNumber(this.#_length, withzero, CustomNumbers); // Returns a random number
public RandomNumber(
withzero: boolean = true,
CustomNumbers?: number[],
): number {
return GenerateNumberID(this.#_length, withzero, CustomNumbers); // Returns a random number
}

// Random Word
Expand All @@ -46,7 +48,7 @@ export class UniqueGen {
isCAPITAL: boolean = false,
CustomWords?: string[],
): string {
return randomWord(this.#_length, isCAPITAL, CustomWords); // Returns a random word
return GenerateWordID(this.#_length, isCAPITAL, CustomWords); // Returns a random word
}

// Mixed
Expand All @@ -67,7 +69,7 @@ export class UniqueGen {
isCAPITAL: boolean = false,
CustomMixeds?: string[],
): string {
return randomMixed(this.#_length, isCAPITAL, CustomMixeds); // Returns a random mixed string
return GenerateMixedID(this.#_length, isCAPITAL, CustomMixeds); // Returns a random mixed string
}

// Symbol
Expand All @@ -82,7 +84,7 @@ export class UniqueGen {
* `CustomSymbols` array as arguments.
*/
public RandomSymbol(CustomSymbols?: string[]): string {
return randomSymbol(this.#_length, CustomSymbols); // Returns a random symbol
return GenerateSymbolID(this.#_length, CustomSymbols); // Returns a random symbol
}

// Boolean
Expand All @@ -91,7 +93,7 @@ export class UniqueGen {
* @returns {boolean} A random boolean value.
*/
public RandomBoolean(): boolean {
return randomBoolean(); // Returns a random boolean value
return GenerateBooleanID(); // Returns a random boolean value
}

/**
Expand Down
16 changes: 16 additions & 0 deletions source/UniqueGen/Function/BooleanFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// global typescript types
type bool = boolean; // Type for boolean

// import Gen functions
import GenerateBoolean from "../gen/BooleanGen";

// Main Function to Generate Random Boolean
/**
* Generates a random boolean value.
* @returns The generated boolean value.
*/
export default function GenerateBooleanID(): bool {
const ArrayOFboolean: bool[] = [true, false]; // All Possible Booleans to generate
const GenerationResult: bool = GenerateBoolean(ArrayOFboolean); // Generate the Random Boolean
return GenerationResult; // Return the Result
}
92 changes: 92 additions & 0 deletions source/UniqueGen/Function/MixedFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// global typescript types
type num = number; // Type for number
type str = string; // Type for string
type bool = boolean; // Type for boolean

import GenerateMixed from "../gen/MixedGen"; // function for generating a random word

// function for generating a random mixed ID

/**
* This TypeScript function generates a random mixed ID of a specified length, with the option to
* include custom characters and make the ID all capital letters.
* @param {num} [length=1] - The length parameter is a number that determines the length of the
* generated mixed ID.
* @param {bool} [isCAPITAL=false] - A boolean parameter that determines whether the generated mixed ID
* should be in all capital letters or not. If set to true, the function will return the generated ID
* in all capital letters. If set to false or not provided, the function will return the generated ID
* in lowercase letters.
* @param {str[]} [CustomMixeds] - CustomMixeds is an optional parameter that allows the user to
* provide their own array of characters to be used in generating the mixed ID. If this parameter is
* not provided, the function will use the default array of characters defined in the code.
* @returns a Promise that resolves to a string. The string is a randomly generated mixed ID of the
* specified length, with the option to include custom characters and to make the ID all uppercase.
*/
export default function GenerateMixedID(
length: num = 1,
isCAPITAL: bool = false,
CustomMixeds?: str[],
): str {
/* This line of code is creating an array of all possible letters from 'a' to 'z' that will be used to*/
const Mixed: str[] = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"0",
"!",
"@",
"#",
"$",
"%",
"^",
"&",
"*",
"(",
")",
"-",
"_",
"=",
"+",
"[",
"]",
"{",
"}",
";",
":",
"<",
".",
">",
"/",
"?",
"|",
"\\",
"~",
]; // All Possible Words to generate

let Result: str = GenerateMixed(
length,
CustomMixeds !== undefined ? CustomMixeds : Mixed,
); // Generate the Random Number

// Checking if the Word should be Capital
if (isCAPITAL === true) {
return (Result = Result.toUpperCase()); // Return the Result in Capital
} else {
return Result; // Return the Result
}
}
45 changes: 45 additions & 0 deletions source/UniqueGen/Function/NumFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// global typescript types
type num = number; // Type for number
type bool = boolean; // Type for boolean

// import Gen functions
import GenerateNumber from "../gen/NumGen"; // function for generating a random word

// function for generating a random number

/**
* This TypeScript function generates a random number ID of a specified length, with the option to
* exclude zero and use a custom set of numbers.
* @param {num} [length=1] - The length parameter is a number that specifies the length of the
* generated number ID.
* @param {bool} [WithZero=true] - A boolean value that determines whether or not the generated number
* can include the digit 0. If set to true, the digit 0 will be included in the possible numbers to
* generate. If set to false, the digit 0 will be removed from the possible numbers to generate.
* @param {num[] | undefined} CustomNumbers - An optional parameter that allows the user to provide a
* custom array of numbers to generate the random number ID from. If not provided, the function will
* use the default array of numbers from 0 to 9.
* @returns a Promise that resolves to a number (num).
*/
export default function GenerateNumberID(
length: num = 1,
WithZero: bool = true,
CustomNumbers?: num[],
): num {
/* Creating an array of numbers from 0 to 9 that will be used to generate the random 10-digit number
ID. */
const NumbersArray: num[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; // All Possible Numbers to generate

// Filtered Array
const FilteredArray: num[] =
CustomNumbers !== undefined ? CustomNumbers : NumbersArray;

if (WithZero === false) {
const ZeroIndexNum: num = FilteredArray.indexOf(0); // Get the index of Zero
FilteredArray.splice(ZeroIndexNum, 1); // Remove Zero from the Array
const GenerationResult: num = GenerateNumber(length, FilteredArray); // Generate the Random Number
return GenerationResult; // Return the Result
} else {
const GenerationResult: num = GenerateNumber(length, FilteredArray); // Generate the Random Number
return GenerationResult; // Return the Result
}
}
65 changes: 65 additions & 0 deletions source/UniqueGen/Function/SymbolFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// global typescript types
type num = number; // Type for number
type str = string; // Type for string

// import Gen functions
import GenerateSymbol from "../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.
*/
export default function GenerateSymbolID(
length: num = 1,
CustomSymbols?: str[],
): str {
/* 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: str[] = [
"!",
"@",
"#",
"$",
"%",
"^",
"&",
"*",
"(",
")",
"-",
"_",
"=",
"+",
"[",
"]",
"{",
"}",
";",
":",
"<",
".",
">",
"/",
"?",
"|",
"\\",
"~",
"`",
]; // Symbol Array
const Result: str = GenerateSymbol(
length,
CustomSymbols !== undefined ? CustomSymbols : Symbols,
); // Generate the Random Number
return Result; // Return the Result
}
Loading
Loading