MCPcopy Create free account
hub / github.com/chavyleung/scripts / init

Function init

nio/nio.cookie.js:15–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

nio.cookie.jsFile · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected