Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://easyscript.js.org/images/cover.png">
<img src="https://images.easyscript.dev/cover.png">
</p>

<h1 align="center">Easy Script</h1>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easyscriptjs",
"version": "1.0.5",
"version": "1.1.0",
"description": "Easy Script is a npm package which makes coding in JavaScript easy!",
"main": "src/index.js",
"scripts": {},
Expand All @@ -15,10 +15,10 @@
"js",
"script"
],
"author": "William Harrison",
"author": "Easy Script <packages@easyscript.dev>",
"license": "MIT",
"bugs": {
"url": "https://github.com/EasyScriptJS/EasyScript/issues"
},
"homepage": "https://github.com/EasyScriptJS/EasyScript#readme"
"homepage": "https://easyscript.dev"
}
4 changes: 3 additions & 1 deletion src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ module.exports = {
"flip": require("./modules/flip"),
"log": require("./modules/log"),
"print": require("./modules/print"),
"random": require("./modules/random")
"random": require("./modules/random"),
"util": require("./modules/util"),
"uuid": require("./modules/uuid")
}
7 changes: 7 additions & 0 deletions src/modules/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
"boolToNum": require("./util/boolToNum"),
"boolToStr": require("./util/boolToStr"),
"numToStr": require("./util/numToStr"),
"strToBool": require("./util/strToBool"),
"strToNum": require("./util/strToNum")
}
10 changes: 10 additions & 0 deletions src/modules/util/boolToNum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = function boolToNum(boolean) {
if(typeof boolean !== "boolean") throw new Error("No boolean provided");

let res;

if(boolean) res = + true;
if(!boolean) res = + false;

return res;
}
5 changes: 5 additions & 0 deletions src/modules/util/boolToStr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function boolToStr(boolean) {
if(typeof boolean !== "boolean") throw new Error("No boolean provided");

return boolean.toString();
}
5 changes: 5 additions & 0 deletions src/modules/util/numToStr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function numToStr(number) {
if(!number || (typeof number !== "number")) throw new Error("No number provided");

return number.toString();
}
12 changes: 12 additions & 0 deletions src/modules/util/strToBool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function strToBool(string) {
if(!string || (typeof string !== "string")) throw new Error("No string provided");

if(string !== "true" && string !== "false") throw new Error("No valid string provided");

let res;

if(string === "true") res = Boolean(true);
if(string === "false") res = Boolean(false);

return res;
}
7 changes: 7 additions & 0 deletions src/modules/util/strToNum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function strToNum(string) {
if(!string || (typeof string !== "string")) throw new Error("No string provided");

if(!isFinite(string)) throw new Error("No valid string provided");

return Number(string);
}
15 changes: 15 additions & 0 deletions src/modules/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = function uuid() {
var d = new Date().getTime();

return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function (c) {
var r = Math.random() * 16;

r = (d + r) % 16 | 0;
d = Math.floor(d / 16);

return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
}
)
}