(key, def = null)
| 25 | } |
| 26 | } |
| 27 | async get(key, def = null) { |
| 28 | if (!this.isNode()) return def; |
| 29 | try { |
| 30 | const data = await this.fs.promises.readFile(this.bucket, "utf-8"); |
| 31 | const json = JSON.parse(data); |
| 32 | return json.hasOwnProperty(key) ? json[key] : def; |
| 33 | } catch (e) { |
| 34 | this.log("❌ 读取bucket失败: " + e.message); |
| 35 | return def; |
| 36 | } |
| 37 | } |
| 38 | async set(key, value) { |
| 39 | if (!this.isNode()) return; |
| 40 | try { |
no test coverage detected