MCPcopy Create free account
hub / github.com/NobyDa/Script / nobyda

Function nobyda

Debug/Real-time-debug.js:29–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 }
28
29 function nobyda() {
30 const isSurge = typeof $httpClient != "undefined";
31 const isQuanX = typeof $task != "undefined";
32 const adapterStatus = (response) => {
33 if (response) {
34 if (response.status) {
35 response["statusCode"] = response.status
36 } else if (response.statusCode) {
37 response["status"] = response.statusCode
38 }
39 }
40 return response
41 };
42 this.write = (value, key) => {
43 if (isQuanX) return $prefs.setValueForKey(value, key);
44 if (isSurge) return $persistentStore.write(value, key);
45 };
46 this.read = (key) => {
47 if (isQuanX) return $prefs.valueForKey(key);
48 if (isSurge) return $persistentStore.read(key);
49 };
50 this.get = (options, callback) => {
51 if (isQuanX) {
52 $task.fetch(options).then(response => {
53 callback(null, adapterStatus(response), response.body)
54 }, reason => callback(reason.error, null, null))
55 }
56 if (isSurge) {
57 $httpClient.get(options, (error, response, body) => {
58 callback(error, adapterStatus(response), body)
59 })
60 }
61 };
62 this.done = (value = {}) => $done(value)
63 }
64}();

Callers

nothing calls this directly

Calls 4

adapterStatusFunction · 0.70
writeMethod · 0.45
readMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected