-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
35 lines (25 loc) · 819 Bytes
/
utils.js
File metadata and controls
35 lines (25 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function formatResultQuery(dataBuffer) {
const extractResults = dataBuffer.filter((el) => el !== '>');
const result = extractResults.map((el) => el.replace(/\r\n/g, ''));
const columnNames = result[0].split(',');
let values = result.slice(1);
values = values.map((element) => {
return element.replace(/,\b/g, '|');
}).map((element) => {
return element.replace(/,\|/g, '||');
}).map((element) => {
return element.replace(/,\(/g, '|(')
})
const arrObje = [];
values.forEach(el => {
const obj = {};
for (let i = 0; i < columnNames.length; i++) {
obj[columnNames[i]] = el.split('|')[i]
}
arrObje.push(obj)
})
return arrObje;
}
module.exports = {
formatResultQuery
}