(t, e)
| 1 | function Env(t, e) { |
| 2 | class s { |
| 3 | constructor(t) { |
| 4 | this.env = t |
| 5 | } |
| 6 | send(t, e = 'GET') { |
| 7 | t = 'string' == typeof t ? { url: t } : t |
| 8 | let s = this.get |
| 9 | return ( |
| 10 | 'POST' === e && (s = this.post), |
| 11 | new Promise((e, a) => { |
| 12 | s.call(this, t, (t, s, r) => { |
| 13 | t ? a(t) : e(s) |
| 14 | }) |
| 15 | }) |
| 16 | ) |
| 17 | } |
| 18 | get(t) { |
| 19 | return this.send.call(this.env, t) |
| 20 | } |
| 21 | post(t) { |
| 22 | return this.send.call(this.env, t, 'POST') |
| 23 | } |
| 24 | } |
| 25 | return new (class { |
| 26 | constructor(t, e) { |
| 27 | ;(this.name = t), |
| 28 | (this.http = new s(this)), |
| 29 | (this.data = null), |
| 30 | (this.dataFile = 'box.dat'), |
| 31 | (this.logs = []), |
| 32 | (this.isMute = !1), |
| 33 | (this.isNeedRewrite = !1), |
| 34 | (this.logSeparator = '\n'), |
| 35 | (this.encoding = 'utf-8'), |
| 36 | // (this.startTime = new Date().getTime()), |
| 37 | Object.assign(this, e) |
| 38 | // this.log('', `🔔${this.name}, 开始!`) |
| 39 | } |
| 40 | getEnv() { |
| 41 | return 'undefined' != typeof $environment && $environment['surge-version'] |
| 42 | ? 'Surge' |
| 43 | : 'undefined' != typeof $environment && $environment['stash-version'] |
| 44 | ? 'Stash' |
| 45 | : 'undefined' != typeof module && module.exports |
| 46 | ? 'Node.js' |
| 47 | : 'undefined' != typeof $task |
| 48 | ? 'Quantumult X' |
| 49 | : 'undefined' != typeof $loon |
| 50 | ? 'Loon' |
| 51 | : 'undefined' != typeof $rocket |
| 52 | ? 'Shadowrocket' |
| 53 | : void 0 |
| 54 | } |
| 55 | isNode() { |
| 56 | return 'Node.js' === this.getEnv() |
| 57 | } |
| 58 | isQuanX() { |
| 59 | return 'Quantumult X' === this.getEnv() |
| 60 | } |
nothing calls this directly
no outgoing calls
no test coverage detected