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