-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaceset.js
113 lines (97 loc) · 2.79 KB
/
interfaceset.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright 2024 Joseph P Medley
'use strict';
class InterfaceSet {
constructor() {
this._interfaces = [];
}
[Symbol.iterator]() { return this._interfaces.values() }
add(interfaceMetaObject) {
this._interfaces.push(interfaceMetaObject);
}
findExact(searchValOrArray, includeFlags=false, includeOriginTrials=false) {
const matches = new Map();
const isArray = Array.isArray(searchValOrArray);
for (let i of this._interfaces) {
try {
if ((includeFlags == false) && (i.flagged == true)) { continue; }
if ((includeOriginTrials == false) && (i.originTrial == true)) { continue; }
if (isArray) {
let found = searchValOrArray.some(elem => {
let key = elem.split(".")[0];
return (key === i.name)
});
if (found) {
matches.set(i.name, i);
}
} else {
if (searchValOrArray === "*") {
// matches.push(i);
matches.set(i.name, i);
}
}
} catch (error) {
switch (error.name) {
case 'TypeError':
const msg = `Problem processing ${i.sourcePath}\n${i.sourceContents}`;
global.__logger.info(msg);
break;
default:
global.__logger.error(error);
throw error;
}
}
}
return matches;
}
findMatching(searchValue, includeFlags=false, includeOriginTrials=false) {
const matches = [];
const lcSearchName = searchValue.toLowerCase();
for (let i of this._interfaces) {
try {
if ((includeFlags == false) && (i.flagged == true)) { continue; }
if ((includeOriginTrials == false) && (i.originTrial == true)) { continue; }
let lcKey = i.key.toLowerCase();
if (searchValue == "*") {
matches.push(i);
continue;
}
if (!lcKey.includes(lcSearchName)) { continue; }
matches.push(i);
} catch (error) {
switch (error.name) {
case 'TypeError':
const msg = `Problem processing ${i.sourcePath}\n${i.sourceContents}`;
global.__logger.info(msg);
break;
default:
global.__logger.error(msg);
throw error;
}
}
}
return matches;
}
getSubset(searchAray, includeFlags=false, includeOriginTrials=false) {
}
get count() {
return this._interfaces.length;
}
get interfaces() {
return this._interfaces;
}
get interfaceNames() {
const names = [];
const ifs = this.interfaces;
for (let i of ifs) {
names.push(i.name);
}
return names;
}
}
class InterfaceSearchSet extends InterfaceSet {
constructor() {
super();
}
}
module.exports.InterfaceSearchSet = InterfaceSearchSet;
module.exports.InterfaceSet = InterfaceSet;