Comparing version 2.0.0 to 2.0.1
32
index.js
const fs = require ('fs') | ||
let addmsg; | ||
class MrSmart { | ||
@@ -39,5 +38,14 @@ constructor() { | ||
} | ||
has(key){ | ||
if (!key) throw Error("Cant find the key in the data!"); | ||
return Boolean(this.data[key])} | ||
check(data){ | ||
if(!fs.existsSync(`data.json`)) { | ||
fs.writeFileSync(`data.json`, "{}"); | ||
if(!data)throw new TypeError("The data is not defined!") | ||
const file = JSON.parse(fs.readFileSync("data.json","utf8")) | ||
return file[data] ? true : false | ||
}else{ | ||
if(!data)throw new TypeError("The data is not defined!") | ||
const file = JSON.parse(fs.readFileSync("data.json","utf8")) | ||
return file[data] ? true : false | ||
} | ||
} | ||
delete(data){ | ||
@@ -71,10 +79,10 @@ if(!fs.existsSync(`data.json`)) { | ||
} | ||
add(key, count){ | ||
if (!count) throw Error("The data must defined!"); | ||
if (!key) throw Error("The data must defined!"); | ||
if(!this.data[key]) this.data[key] = 0; | ||
this.data[key] += count; | ||
this.saveDataToFile(); | ||
if(addmsg) { | ||
console.log(addmsg)}} | ||
add(data , value){ | ||
if(!fs.existsSync(`data.json`)) { | ||
fs.writeFileSync(`data.json`, "{}"); | ||
if(!data)throw new TypeError("The data is not defined!") | ||
if(isNaN(value))throw new TypeError("The value must be a number!") | ||
if(!this.check(data)){ | ||
this.set(data , 0) | ||
} | ||
@@ -81,0 +89,0 @@ if(typeof this.fetch(data) !== "number")throw new TypeError("cant add number value to text value!") |
{ | ||
"name": "pro.db", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "a simple and easy database package make your life easy.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32224
243