MCPcopy Create free account
hub / github.com/IceClusters/icmysql / ParseArgs

Function ParseArgs

src/utils/Parser.js:4–47  ·  view source on GitHub ↗
(dbId, query, values, callback, cache)

Source from the content-addressed store, hash-verified

2const { ParseError } = require('../errors/Parser.js');
3
4async function ParseArgs(dbId, query, values, callback, cache) {
5 while (IsConnecting()) {
6 await new Promise(resolve => requestAnimationFrame(resolve));
7 }
8 if (dbId == null) {
9 return ParseError("Invalid params for query function.");
10 }
11
12 if (typeof dbId === "string") {
13 cache = callback != null ? callback : false;
14 callback = values;
15 values = query != null ? query : [];
16 query = dbId;
17 dbId = Config.DefaultDB;
18 }
19
20 if (typeof values === "function") {
21 callback = values;
22 values = [];
23 if (typeof callback === "boolean")
24 cache = callback;
25 else
26 cache = false;
27 } else if (typeof values === "boolean") {
28 cache = values;
29 values = [];
30 } else if (typeof values === "object") {
31 if (typeof callback === "boolean")
32 cache = callback;
33 else
34 cache = false;
35 } else {
36 values = [];
37 }
38 if(values.length > 0) {
39 if(values[0] instanceof Array) {
40 values = values[0];
41 }
42 }
43 if (cache === undefined) cache = false;
44 if (typeof dbId !== "number" || typeof query !== "string" || typeof values !== "object" || typeof cache !== "boolean") return ParseError("Invalid params for query function.");
45 if (pools[dbId] == null) return ParseError(`The database ${dbId} is not registered.`);
46 return { dbId: dbId, query: query, values: values, callback: callback, cache: cache };
47}
48
49function ParseNilArgs(query, values) {
50 const match = query.match(/\?(?!\?)/g);

Callers 2

methodFunction · 0.85
awaitMethodFunction · 0.85

Calls 2

IsConnectingFunction · 0.85
ParseErrorFunction · 0.85

Tested by

no test coverage detected