Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 6ee75bc

Browse files
wdhdevnorisurgit
andauthored
v1.1.5
This release adds self-documenting to all modules. Co-authored-by: Abdennour Boudjema <nourik27@gmail.com>
1 parent aa1be93 commit 6ee75bc

9 files changed

Lines changed: 47 additions & 16 deletions

File tree

package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modules.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ module.exports = {
1414
"util": {
1515
"removeDuplicates": require("./modules/util/removeDuplicates")
1616
},
17+
"removeDuplicates": require("./modules/removeDuplicates"),
1718
"uuid": require("./modules/uuid")
1819
}

src/modules/flip.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
/**
2+
*
3+
* @function `flip` - Quickly execute a heads or tails decision randomly
4+
* @returns {string} Returns "heads" or "tails" (*as string*)
5+
*/
6+
17
function flip() {
28
return Math.random() >= 0.5 ? "heads" : "tails";
39
}
410

5-
module.exports = flip;
11+
module.exports = flip;

src/modules/id.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
const { customAlphabet } = require("nanoid");
22

3+
/**
4+
* @function `id` - Randomly generate a unique ID composed of random characters and numbers
5+
* @param {Number} length - (*Required*) The length of the ID. Condition: *`1 <= length <= 64`*
6+
* @returns {String} A unique ID string of a specified length (e.g. *abthvmyt3h1j3it*)
7+
*/
8+
39
function id(length) {
410
if(!length) throw new Error("No length specified");
511
if(typeof length !== "number") throw new Error("Invalid type specified");
@@ -12,4 +18,4 @@ function id(length) {
1218
return id;
1319
}
1420

15-
module.exports = id;
21+
module.exports = id;

src/modules/log.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
/**
2+
* @function `log` - Quickly log any data to the console.
3+
* @param {any} input - *Required* The data that will be passed on to the console. Will throw an error if the input is undefined
4+
* @returns {Function} an Instance of console.log() that is executed instantly using `input`
5+
*/
6+
17
function log(input) {
2-
if(!input) {
3-
throw new Error("No input specified");
4-
}
8+
if(!input) throw new Error("No input specified");
59

610
return console.log(input);
711
}
812

9-
module.exports = log;
13+
module.exports = log;

src/modules/print.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
/**
2+
* @function `print` - Quickly log any data to the console.
3+
* @param {any} input - *Required* The data that will be passed on to the console. Will throw an error if the input is undefined
4+
* @returns {Function} An instance of console.log() that is executed instantly using `input`
5+
*/
6+
17
function print(input) {
2-
if(!input) {
3-
throw new Error("No input specified");
4-
}
8+
if(!input) throw new Error("No input specified");
59

610
return console.log(input);
711
}
812

9-
module.exports = print;
13+
module.exports = print;

src/modules/random.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* @function `random` - Used to generate a random number between 1 and a max value
3+
* @param {Number} [max] - The max value used. Condition: **`1 < max < 2_147_483_647`**
4+
* @returns {Number} A random number between 1 and max (*parameter*). If max is *undefined*, will return a random number between 1 and 100
5+
*/
6+
17
function random(max) {
28
let highest = 100;
39

@@ -11,4 +17,4 @@ function random(max) {
1117
return result;
1218
}
1319

14-
module.exports = random;
20+
module.exports = random;

src/modules/util/removeDuplicates.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const removeDuplicates = (
6565
});
6666
} else if (typeof truthy_only !== "boolean")
6767
throw new MethodException(
68-
`Illegal use of parameter multi_dim - Expected true or false - Found: ${truthy_only}`
68+
`Illegal use of parameter truthy_only - Expected true or false - Found: ${truthy_only}`
6969
);
7070

7171
// Sort
@@ -122,7 +122,7 @@ const removeDuplicates = (
122122
} else if (e === "lengthwise") {
123123
newArray.sort((a, b) =>
124124
(typeof a === "string" && typeof b == "string") ||
125-
(Array.isArray(a) && Array.isArray(b))
125+
(Array.isArray(a) && Array.isArray(b))
126126
? a.length - b.length
127127
: -1
128128
);

src/modules/uuid.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @function `uuid` - Randomly generate a unique UUID composed of random characters and numbers
3+
* @returns {String} A unique UUID string that follows this rule: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
4+
*/
5+
16
function uuid() {
27
var d = new Date().getTime();
38

0 commit comments

Comments
 (0)