MCPcopy Create free account
hub / github.com/Moli-X/Resources / init

Function init

Script/Elem/elemGetCookies.js:85–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83 }
84}
85function init() {
86 isSurge = () => {
87 return undefined === this.$httpClient ? false : true
88 }
89 isQuanX = () => {
90 return undefined === this.$task ? false : true
91 }
92 getdata = (key) => {
93 if (isSurge()) return $persistentStore.read(key)
94 if (isQuanX()) return $prefs.valueForKey(key)
95 }
96 setdata = (key, val) => {
97 if (isSurge()) return $persistentStore.write(key, val)
98 if (isQuanX()) return $prefs.setValueForKey(key, val)
99 }
100 msg = (title, subtitle, body) => {
101 if (isSurge()) $notification.post(title, subtitle, body)
102 if (isQuanX()) $notify(title, subtitle, body)
103 }
104 log = (message) => console.log(message)
105 get = (url, cb) => {
106 if (isSurge()) {
107 $httpClient.get(url, cb)
108 }
109 if (isQuanX()) {
110 url.method = 'GET'
111 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
112 }
113 }
114 post = (url, cb) => {
115 if (isSurge()) {
116 $httpClient.post(url, cb)
117 }
118 if (isQuanX()) {
119 url.method = 'POST'
120 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
121 }
122 }
123 done = (value = {}) => {
124 $done(value)
125 }
126 return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
127}
128sy.done()

Callers 1

elemGetCookies.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