| 243 | return "undefined" != typeof $loon; |
| 244 | } |
| 245 | loaddata() { |
| 246 | if (!this.isNode()) return {}; |
| 247 | { |
| 248 | this.fs = this.fs ? this.fs : require("fs"); |
| 249 | this.path = this.path ? this.path : require("path"); |
| 250 | const t = this.path.resolve(this.dataFile), |
| 251 | s = this.path.resolve(process.cwd(), this.dataFile), |
| 252 | e = this.fs.existsSync(t), |
| 253 | i = !e && this.fs.existsSync(s); |
| 254 | if (!e && !i) return {}; |
| 255 | { |
| 256 | const i = e ? t : s; |
| 257 | try { |
| 258 | return JSON.parse(this.fs.readFileSync(i)); |
| 259 | } catch (t) { |
| 260 | return {}; |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | writedata() { |
| 266 | if (this.isNode()) { |
| 267 | this.fs = this.fs ? this.fs : require("fs"); |