SkyNX/SkyNX-Streamer/Devlord_modules/DB.js
2020-04-15 18:15:44 -06:00

21 lines
No EOL
532 B
JavaScript

//Authour: Dustin Harris
//GitHub: https://github.com/DevL0rd
var fs = require('fs');
var getDirName = require('path').dirname;
function load(path) {
var contents = fs.readFileSync(path).toString('utf-8');
return JSON.parse(contents)
}
function save(path, obj) {
var contents = JSON.stringify(obj, null, "\t")
fs.mkdir(getDirName(path), { recursive: true }, function (err) {
if (err) throw err;
fs.writeFileSync(path, contents, function (err) {
if (err) throw err;
});
});
}
exports.load = load;
exports.save = save;