1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.Arguments = exports.Raw = exports.Status = exports.Parsed = void 0;
|
19 | const getValue = (arg) => {
|
20 | for (const key in arg) {
|
21 | if (key === 'name' || key === 'textValue' || key === 'status') {
|
22 | continue;
|
23 | }
|
24 | return arg[key];
|
25 | }
|
26 |
|
27 | if (arg.name === 'PERMISSION') {
|
28 | return !!arg.boolValue;
|
29 | }
|
30 | return arg.textValue;
|
31 | };
|
32 | class Parsed {
|
33 |
|
34 | constructor(raw) {
|
35 |
|
36 | this.input = {};
|
37 | this.list = raw.map((arg, i) => {
|
38 | const value = getValue(arg);
|
39 | const name = arg.name;
|
40 | this.input[name] = value;
|
41 | return value;
|
42 | });
|
43 | }
|
44 | get(name) {
|
45 | return this.input[name];
|
46 | }
|
47 | }
|
48 | exports.Parsed = Parsed;
|
49 | class Status {
|
50 |
|
51 | constructor(raw) {
|
52 |
|
53 | this.input = {};
|
54 | this.list = raw.map((arg, i) => {
|
55 | const name = arg.name;
|
56 | const status = arg.status;
|
57 | this.input[name] = status;
|
58 | return status;
|
59 | });
|
60 | }
|
61 |
|
62 | get(name) {
|
63 | return this.input[name];
|
64 | }
|
65 | }
|
66 | exports.Status = Status;
|
67 | class Raw {
|
68 |
|
69 | constructor(list) {
|
70 | this.list = list;
|
71 | this.input = list.reduce((o, arg) => {
|
72 | o[arg.name] = arg;
|
73 | return o;
|
74 | }, {});
|
75 | }
|
76 |
|
77 | get(name) {
|
78 | return this.input[name];
|
79 | }
|
80 | }
|
81 | exports.Raw = Raw;
|
82 | class Arguments {
|
83 |
|
84 | constructor(raw = []) {
|
85 | this.parsed = new Parsed(raw);
|
86 | this.status = new Status(raw);
|
87 | this.raw = new Raw(raw);
|
88 | }
|
89 | get(name) {
|
90 | return this.parsed.get(name);
|
91 | }
|
92 |
|
93 | [Symbol.iterator]() {
|
94 | return this.raw.list[Symbol.iterator]();
|
95 |
|
96 |
|
97 | }
|
98 | }
|
99 | exports.Arguments = Arguments;
|
100 |
|
\ | No newline at end of file |