| 181 | return "undefined" != typeof $loon; |
| 182 | } |
| 183 | loaddata() { |
| 184 | if (!this.isNode()) return {}; |
| 185 | { |
| 186 | this.fs = this.fs ? this.fs : require("fs"); |
| 187 | this.path = this.path ? this.path : require("path"); |
| 188 | const t = this.path.resolve(this.dataFile), |
| 189 | s = this.path.resolve(process.cwd(), this.dataFile), |
| 190 | e = this.fs.existsSync(t), |
| 191 | i = !e && this.fs.existsSync(s); |
| 192 | if (!e && !i) return {}; |
| 193 | { |
| 194 | const i = e ? t : s; |
| 195 | try { |
| 196 | return JSON.parse(this.fs.readFileSync(i)); |
| 197 | } catch (t) { |
| 198 | return {}; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | writedata() { |
| 204 | if (this.isNode()) { |
| 205 | this.fs = this.fs ? this.fs : require("fs"); |