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