Repository URL to install this package:
Version:
2.0.11-7 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs-extra");
const electron = require("electron");
const path = require("path");
const logger = require("electron-log");
class JsonStore {
constructor(name) {
const userDataPath = electron.app.getPath("userData");
this.filePath = path.join(userDataPath, name + ".json");
this.loadSync();
}
get() {
return this.data;
}
async set(value) {
this.data = value;
await this.save();
}
setSync(value) {
this.data = value;
this.saveSync();
}
async load() {
try {
this.data = await fs.readJSON(this.filePath);
}
catch (error) {
logger.info("Error reading " + this.filePath, error);
}
}
loadSync() {
try {
this.data = fs.readJSONSync(this.filePath);
}
catch (error) {
logger.info("Error reading " + this.filePath, error);
}
}
async save() {
try {
await fs.writeJSON(this.filePath, this.data);
}
catch (error) {
logger.info("Error writing " + this.filePath, error);
}
}
saveSync() {
try {
fs.writeJSONSync(this.filePath, this.data);
}
catch (error) {
logger.info("Error writing " + this.filePath, error);
}
}
}
exports.JsonStore = JsonStore;
//# sourceMappingURL=JsonStore.js.map
//notion-enhancer
require('notion-enhancer/pkg/loader.js')(__filename, exports);