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

Function init

everphoto/everphoto.cookie.js:26–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26function init() {
27 isSurge = () => {
28 return undefined === this.$httpClient ? false : true
29 }
30 isQuanX = () => {
31 return undefined === this.$task ? false : true
32 }
33 getdata = (key) => {
34 if (isSurge()) return $persistentStore.read(key)
35 if (isQuanX()) return $prefs.valueForKey(key)
36 }
37 setdata = (key, val) => {
38 if (isSurge()) return $persistentStore.write(key, val)
39 if (isQuanX()) return $prefs.setValueForKey(key, val)
40 }
41 msg = (title, subtitle, body) => {
42 if (isSurge()) $notification.post(title, subtitle, body)
43 if (isQuanX()) $notify(title, subtitle, body)
44 }
45 log = (message) => console.log(message)
46 get = (url, cb) => {
47 if (isSurge()) {
48 $httpClient.get(url, cb)
49 }
50 if (isQuanX()) {
51 url.method = 'GET'
52 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
53 }
54 }
55 post = (url, cb) => {
56 if (isSurge()) {
57 $httpClient.post(url, cb)
58 }
59 if (isQuanX()) {
60 url.method = 'POST'
61 $task.fetch(url).then((resp) => cb(null, {}, resp.body))
62 }
63 }
64 done = (value = {}) => {
65 $done(value)
66 }
67 return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
68}
69chavy.done()

Callers 1

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…