| 2203 | } |
| 2204 | |
| 2205 | loaddata() { |
| 2206 | if (!this.isNode()) return {}; |
| 2207 | { |
| 2208 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); |
| 2209 | 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); |
| 2210 | if (!s && !i) return {}; |
| 2211 | { |
| 2212 | const i = s ? t : e; |
| 2213 | try { |
| 2214 | return JSON.parse(this.fs.readFileSync(i)) |
| 2215 | } catch (t) { |
| 2216 | return {} |
| 2217 | } |
| 2218 | } |
| 2219 | } |
| 2220 | } |
| 2221 | |
| 2222 | writedata() { |
| 2223 | if (this.isNode()) { |