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

Commit a56a378

Browse files
authored
feat: fix modules listing + specify error type + add ability to generate multiple uuids
1 parent 96ceb2d commit a56a378

14 files changed

Lines changed: 57 additions & 41 deletions

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "easyscriptjs",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Easy Script is a npm package which makes coding in JavaScript easy!",
55
"main": "src/index.js",
66
"scripts": {},

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ const modules = {
77
util: {
88
boolToNum: require("./modules/util/boolToNum"),
99
boolToStr: require("./modules/util/boolToStr"),
10+
numToBool: require("./modules/util/numToBool"),
1011
numToStr: require("./modules/util/numToStr"),
12+
removeDuplicates: require("./modules/util/removeDuplicates"),
1113
strToBool: require("./modules/util/strToBool"),
12-
strToNum: require("./modules/util/strToNum"),
13-
removeDuplicates: require("./modules/util/removeDuplicates")
14+
strToNum: require("./modules/util/strToNum")
1415
},
1516
uuid: require("./modules/uuid")
1617
}

src/modules/id.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const { customAlphabet } = require("nanoid");
77
*/
88

99
function id(length) {
10-
if (!length) throw new Error("No length specified");
11-
if (typeof length !== "number") throw new Error("Invalid type specified");
10+
if (!length) throw new SyntaxError("No length specified");
11+
if (typeof length !== "number") throw new TypeError("Invalid type specified");
1212

1313
const nanoid = customAlphabet(
1414
"1234567890abcdefghijklmnopqrstuvwxyz",

src/modules/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
function log(input) {
8-
if (!input) throw new Error("No input specified");
8+
if (!input) throw new SyntaxError("No input specified");
99

1010
return console.log(input);
1111
}

src/modules/print.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
function print(input) {
8-
if (!input) throw new Error("No input specified");
8+
if (!input) throw new SyntaxError("No input specified");
99

1010
return console.log(input);
1111
}

src/modules/random.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
function random(max) {
88
let highest = 100;
99

10-
if (max && !isFinite(max)) throw new Error("Max number must be a number");
11-
if ((max && max <= 1) || (max && max >= 2147483647))
12-
throw new Error(
13-
"Max number must be higher than 1 and lower than 2,147,483,647"
14-
);
10+
if (max && !isFinite(max)) throw new TypeError("Max number must be a number");
11+
if ((max && max <= 1) || (max && max >= 2147483647)) throw new RangeError("Max number must be higher than 1 and lower than 2,147,483,647");
1512

1613
if (max) highest = max;
1714

src/modules/util/boolToNum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
function boolToNum(boolean) {
8-
if (typeof boolean !== "boolean") throw new Error("No boolean provided");
8+
if (typeof boolean !== "boolean") throw new TypeError("No boolean provided");
99

1010
let res;
1111

src/modules/util/boolToStr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
function boolToStr(boolean) {
8-
if (typeof boolean !== "boolean") throw new Error("No boolean provided");
8+
if (typeof boolean !== "boolean") throw new TypeError("No boolean provided");
99

1010
return boolean.toString();
1111
}

src/modules/util/numToBool.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
*/
66

77
function numToBool(number) {
8-
if (typeof number !== "number") throw new Error("No number provided");
9-
if (number !== 1 && number !== 0)
10-
throw new Error("Number must be either 0 or 1");
8+
if (typeof number !== "number") throw new TypeError("No number provided");
9+
if (number !== 1 && number !== 0) throw new SyntaxError("Number must be either 0 or 1");
1110

1211
let res;
1312

0 commit comments

Comments
 (0)