()
| 54 | } |
| 55 | |
| 56 | function 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 | } |
no test coverage detected
searching dependent graphs…