| 853 | } |
| 854 | |
| 855 | loaddata() { |
| 856 | if (!this.isNode()) return {}; |
| 857 | { |
| 858 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); |
| 859 | const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); |
| 860 | if (!s && !i) return {}; |
| 861 | { |
| 862 | const i = s ? t : e; |
| 863 | try { |
| 864 | return JSON.parse(this.fs.readFileSync(i)) |
| 865 | } catch (t) { |
| 866 | return {} |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | writedata() { |
| 873 | if (this.isNode()) { |