Skip to content

Commit

Permalink
Lib refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Dec 27, 2021
1 parent fd9cbda commit 889b0c7
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 128 deletions.
6 changes: 3 additions & 3 deletions lib/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {

/**
* Generate key from password and salt
* @param {String} password
* @param {string} password
* @param {Buffer} salt
* @return {Buffer} key
*/
Expand All @@ -39,7 +39,7 @@ module.exports = {

/**
* Encrypt a string
* @param {String} text
* @param {string} text
* @param {Buffer} key
* @return {Buffer} encrypted text
*/
Expand All @@ -55,7 +55,7 @@ module.exports = {

/**
* Decrypt a string
* @param {String} text
* @param {string} text
* @param {Buffer} key
* @returns {Buffer} decrypted text
*/
Expand Down
8 changes: 4 additions & 4 deletions lib/convert.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
/**
* Convert codes from plain text to arrays
* @param {String} text
* @param {Number} sortNumber
* @param {string} text
* @param {number} sortNumber
* @return {LibImportFile} Import file structure
*/
fromText: (text, sortNumber) => {
Expand Down Expand Up @@ -116,8 +116,8 @@ module.exports = {

/**
* Convert JSON to text
* @param {Object} object
* @return {String} stringify
* @param {object} object
* @return {string} stringify
*/
fromJSON: (object) => {
return JSON.stringify(object, null, "\t")
Expand Down
50 changes: 25 additions & 25 deletions lib/logger/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ module.exports = logger = {

/**
* Writes a log to the console
* @param {String} message
* @param {String} log
* @return {String} log
* @param {string} message
* @param {string|object} log
* @return {string} log
*/
log: (message, log) => {
if (typeof log == "object") {
Expand All @@ -53,10 +53,10 @@ module.exports = logger = {

/**
* Writes a log to the console
* @param {String} id
* @param {String} message
* @param {String} log
* @return {String} log
* @param {string} id
* @param {string} message
* @param {string|object} log
* @return {string} log
*/
rendererLog: (id, message, log) => {
if (typeof log == "object") {
Expand All @@ -82,9 +82,9 @@ module.exports = logger = {

/**
* Writes a warn to the console
* @param {String} message
* @param {String} warn
* @return {String} warn
* @param {string} message
* @param {string|object} warn
* @return {string} warn
*/
warn: (message, warn) => {
if (typeof warn == "object") {
Expand All @@ -110,10 +110,10 @@ module.exports = logger = {

/**
* Writes a warn to the console
* * @param {String} id
* @param {String} message
* @param {String} warn
* @return {String} warn
* @param {string} id
* @param {string} message
* @param {string|object} warn
* @return {string} warn
*/
rendererWarn: (id, message, warn) => {
if (typeof warn == "object") {
Expand All @@ -139,9 +139,9 @@ module.exports = logger = {

/**
* Writes an error to the console
* @param {String} message
* @param {String} error
* @return {String} error
* @param {string} message
* @param {string|object} error
* @return {string} error
*/
error: (message, error) => {
if (typeof error == "object") {
Expand All @@ -167,10 +167,10 @@ module.exports = logger = {

/**
* Writes an error to the console
* @param {String} id
* @param {String} message
* @param {String} error
* @return {String} error
* @param {string} id
* @param {string} message
* @param {string|object} error
* @return {string} error
*/
rendererError: (id, message, error) => {
if (typeof error == "object") {
Expand All @@ -196,8 +196,8 @@ module.exports = logger = {

/**
* Creates a log file
* @param {String} file
* @param {String} name
* @param {string} file
* @param {string} name
*/
createFile: (file, name) => {
const time = new Date().toISOString().replace("T", "-").replaceAll(":", "-").substring(0, 19)
Expand All @@ -220,7 +220,7 @@ module.exports = logger = {

/**
* Writes to a log file
* @param {String} message
* @param {string} message
*/
writeFile: (message) => {
fs.appendFileSync(path.join(file_path, file_name), message, (err) => {
Expand All @@ -234,7 +234,7 @@ module.exports = logger = {

/**
* Returns current file name
* @return {String} file_name
* @return {string} file_name
*/
fileName: () => {
return file_name
Expand Down
22 changes: 11 additions & 11 deletions lib/logger/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let window = ""
module.exports = {
/**
* Writes a log to the console
* @param {String} message
* @param {String} log
* @return {String} log
* @param {string} message
* @param {string|object} log
* @return {string} log
*/
log: (message, log) => {
console.log(message)
Expand All @@ -17,9 +17,9 @@ module.exports = {

/**
* Writes a warn to the console
* @param {String} message
* @param {String} warn
* @return {String} warn
* @param {string} message
* @param {string|object} warn
* @return {string} warn
*/
warn: (message, warn) => {
console.warn(message)
Expand All @@ -29,9 +29,9 @@ module.exports = {

/**
* Writes a error to the console
* @param {String} message
* @param {String} error
* @return {String} error
* @param {string} message
* @param {string|object} error
* @return {string} error
*/
error: (message, error) => {
console.error(message)
Expand All @@ -41,8 +41,8 @@ module.exports = {

/**
* Get window name
* @param {String} name
* @return {String} window name
* @param {string} name
* @return {string} window name
*/
getWindow: (name) => {
window = name
Expand Down
4 changes: 2 additions & 2 deletions lib/markdown.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
/**
* Convert Markdown to text
* @param {String} text
* @return {String} body
* @param {string} text
* @return {string} body
*/
convert: (text) => {
const body = text
Expand Down
2 changes: 0 additions & 2 deletions lib/password/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ module.exports = {
let match = false

for (let i = 0; i < passwords.length; i++) {
console.log(i)

if (passwords[i] === input) {
return (match = true)
}
Expand Down
14 changes: 7 additions & 7 deletions lib/rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const crypto = require("crypto")
module.exports = {
/**
* Generate a public and private key
* @return {String} public and private key
* @return {string} public and private key
*/
generateKeys: () => {
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
Expand All @@ -25,9 +25,9 @@ module.exports = {

/**
* Encrypt message with public key
* @param {String} publicKey
* @param {String} data
* @return {String} encrypted data
* @param {string} publicKey
* @param {string} data
* @return {string} encrypted data
*/
encrypt: (publicKey, data) => {
const encrypted_data = crypto.publicEncrypt(
Expand All @@ -44,9 +44,9 @@ module.exports = {

/**
* Decrypt message with private key
* @param {String} privateKey
* @param {String} data
* @return {String} decrypted data
* @param {string} privateKey
* @param {string} data
* @return {string} decrypted data
*/
decrypt: (privateKey, data) => {
const decrypted_data = crypto.privateDecrypt(
Expand Down
6 changes: 3 additions & 3 deletions lib/sha.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const crypto = require("crypto")

module.exports = {
/**
* Create SHA3-512 hash
* @param {String} data
* @return {String} hashed string
* Create SHA-512 hash
* @param {string} data
* @return {string} hashed string
*/
generateHash: (data) => {
const hashed = crypto.createHash("sha512").update(data).digest("base64")
Expand Down
2 changes: 1 addition & 1 deletion lib/time.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
/**
* Returns the current timestamp
* @return {String} Timestamp
* @return {string} Timestamp
*/
timestamp: () => {
return new Date().toISOString().replace("T", "-").replaceAll(":", "-").substring(0, 19)
Expand Down
Loading

0 comments on commit 889b0c7

Please sign in to comment.