MCPcopy Index your code
hub / github.com/Moli-X/Resources / init

Function init

Script/Elem/elemSign.js:293–337  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

291
292
293function init() {
294 isSurge = () => {
295 return undefined === this.$httpClient ? false : true
296 }
297 isQuanX = () => {
298 return undefined === this.$task ? false : true
299 }
300 getdata = (key) => {
301 if (isSurge()) return $persistentStore.read(key)
302 if (isQuanX()) return $prefs.valueForKey(key)
303 }
304 setdata = (key, val) => {
305 if (isSurge()) return $persistentStore.write(key, val)
306 if (isQuanX()) return $prefs.setValueForKey(key, val)
307 }
308 msg = (title, subtitle, body) => {
309 if (isSurge()) $notification.post(title, subtitle, body)
310 if (isQuanX()) $notify(title, subtitle, body)
311 }
312 log = (message) => console.log(message)
313 get = (url, cb) => {
314 if (isSurge()) {
315 $httpClient.get(url, cb)
316 }
317 if (isQuanX()) {
318 url.method = 'GET'
319 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
320 }
321 }
322 post = (options, callback) => {
323 if (isQuanX()) {
324 if (typeof options == "string") options = { url: options }
325 options["method"] = "POST"
326 $task.fetch(options).then(response => {
327 response["status"] = response.statusCode
328 callback(null, response, response.body)
329 }, reason => callback(reason.error, null, null))
330 }
331 if (isSurge()) $httpClient.post(options, callback)
332 }
333 done = (value = {}) => {
334 $done(value)
335 }
336 return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
337}
338
339
340

Callers 1

elemSign.jsFile · 0.70

Calls 9

isSurgeFunction · 0.85
isQuanXFunction · 0.85
$notifyFunction · 0.50
readMethod · 0.45
writeMethod · 0.45
postMethod · 0.45
logMethod · 0.45
getMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…