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

Function init

everphoto/everphoto.js:56–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54}
55
56function init() {
57 isSurge = () => {
58 return undefined === this.$httpClient ? false : true
59 }
60 isQuanX = () => {
61 return undefined === this.$task ? false : true
62 }
63 getdata = (key) => {
64 if (isSurge()) return $persistentStore.read(key)
65 if (isQuanX()) return $prefs.valueForKey(key)
66 }
67 setdata = (key, val) => {
68 if (isSurge()) return $persistentStore.write(key, val)
69 if (isQuanX()) return $prefs.setValueForKey(key, val)
70 }
71 msg = (title, subtitle, body) => {
72 if (isSurge()) $notification.post(title, subtitle, body)
73 if (isQuanX()) $notify(title, subtitle, body)
74 }
75 log = (message) => console.log(message)
76 get = (url, cb) => {
77 if (isSurge()) {
78 $httpClient.get(url, cb)
79 }
80 if (isQuanX()) {
81 url.method = 'GET'
82 $task.fetch(url).then((resp) => cb(null, resp, resp.body))
83 }
84 }
85 post = (url, cb) => {
86 if (isSurge()) {
87 $httpClient.post(url, cb)
88 }
89 if (isQuanX()) {
90 url.method = 'POST'
91 $task.fetch(url).then((resp) => cb(null, resp, resp.body))
92 }
93 }
94 done = (value = {}) => {
95 $done(value)
96 }
97 return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
98}

Callers 1

everphoto.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…