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