-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDSSArray.js
32 lines (32 loc) · 839 Bytes
/
DSSArray.js
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
export class DSSArray {
s;
strVal;
objVal;
arrVal;
constructor(s) {
this.s = s;
}
async parse() {
const { parse } = await import('./dss/parse.js');
const split = this.s.split(' ').map(s => s.trim()).filter(s => !!s);
const specifiers = [];
let lastDSS;
let inAsMode = false;
for (const dss of split) {
if (dss === 'and')
continue;
if (dss === 'as') {
inAsMode = true;
continue;
}
if (lastDSS !== undefined && inAsMode) {
lastDSS.as = dss;
inAsMode = false;
continue;
}
lastDSS = await parse(dss);
specifiers.push(lastDSS);
}
this.arrVal = specifiers;
}
}