MCPcopy
hub / github.com/chavyleung/scripts / init

Function init

csdn/csdn.js:165–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163}
164
165function init() {
166 isSurge = () => {
167 return undefined === this.$httpClient ? false : true
168 }
169 isQuanX = () => {
170 return undefined === this.$task ? false : true
171 }
172 getdata = (key) => {
173 if (isSurge()) return $persistentStore.read(key)
174 if (isQuanX()) return $prefs.valueForKey(key)
175 }
176 setdata = (key, val) => {
177 if (isSurge()) return $persistentStore.write(key, val)
178 if (isQuanX()) return $prefs.setValueForKey(key, val)
179 }
180 msg = (title, subtitle, body) => {
181 if (isSurge()) $notification.post(title, subtitle, body)
182 if (isQuanX()) $notify(title, subtitle, body)
183 }
184 log = (message) => console.log(message)
185 get = (url, cb) => {
186 if (isSurge()) {
187 $httpClient.get(url, cb)
188 }
189 if (isQuanX()) {
190 url.method = 'GET'
191 $task.fetch(url).then((resp) => cb(null, resp, resp.body))
192 }
193 }
194 post = (url, cb) => {
195 if (isSurge()) {
196 $httpClient.post(url, cb)
197 }
198 if (isQuanX()) {
199 url.method = 'POST'
200 $task.fetch(url).then((resp) => cb(null, resp, resp.body))
201 }
202 }
203 done = (value = {}) => {
204 $done(value)
205 }
206 return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
207}

Callers 1

csdn.jsFile · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…