| 300 | const { isQX, isLoon, isSurge, isNode, isJSBox, isScriptable } = ENV(); |
| 301 | return new (class { |
| 302 | constructor(name, debug) { |
| 303 | this.name = name; |
| 304 | this.debug = debug; |
| 305 | |
| 306 | this.http = HTTP(); |
| 307 | this.env = ENV(); |
| 308 | |
| 309 | this.node = (() => { |
| 310 | if (isNode) { |
| 311 | const fs = require("fs"); |
| 312 | |
| 313 | return { |
| 314 | fs, |
| 315 | }; |
| 316 | } else { |
| 317 | return null; |
| 318 | } |
| 319 | })(); |
| 320 | this.initCache(); |
| 321 | |
| 322 | const delay = (t, v) => |
| 323 | new Promise(function (resolve) { |
| 324 | setTimeout(resolve.bind(null, v), t); |
| 325 | }); |
| 326 | |
| 327 | Promise.prototype.delay = function (t) { |
| 328 | return this.then(function (v) { |
| 329 | return delay(t, v); |
| 330 | }); |
| 331 | }; |
| 332 | } |
| 333 | |
| 334 | // persistence |
| 335 | // initialize cache |