MCPcopy Create free account
hub / github.com/Semporia/Scripts / Env

Function Env

jd_api_test.js:113–385  ·  view source on GitHub ↗
(t, e)

Source from the content-addressed store, hash-verified

111
112// prettier-ignore
113function Env(t, e) {
114 "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0);
115
116 class s {
117 constructor(t) {
118 this.env = t
119 }
120
121 send(t, e = "GET") {
122 t = "string" == typeof t ? {url: t} : t;
123 let s = this.get;
124 return "POST" === e && (s = this.post), new Promise((e, i) => {
125 s.call(this, t, (t, s, r) => {
126 t ? i(t) : e(s)
127 })
128 })
129 }
130
131 get(t) {
132 return this.send.call(this.env, t)
133 }
134
135 post(t) {
136 return this.send.call(this.env, t, "POST")
137 }
138 }
139
140 return new class {
141 constructor(t, e) {
142 this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`)
143 }
144
145 isNode() {
146 return "undefined" != typeof module && !!module.exports
147 }
148
149 isQuanX() {
150 return "undefined" != typeof $task
151 }
152
153 isSurge() {
154 return "undefined" != typeof $httpClient && "undefined" == typeof $loon
155 }
156
157 isLoon() {
158 return "undefined" != typeof $loon
159 }
160
161 toObj(t, e = null) {
162 try {
163 return JSON.parse(t)
164 } catch {
165 return e
166 }
167 }
168
169 toStr(t, e = null) {
170 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected