-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
47 lines (40 loc) · 1.38 KB
/
utils.ts
File metadata and controls
47 lines (40 loc) · 1.38 KB
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
import { coreConfig } from '.';
import { FALLBACK_KEYWORDS } from './consts';
import { Keyword } from './types';
// Get a list of all the keywords
export const getKeywordNames = (): string[] => {
const keywords = coreConfig.get<any>('keywords') ?? FALLBACK_KEYWORDS;
return Object.keys(keywords);
};
// Get the properties of all the keywords
export const getKeyword = (key: string): Keyword => {
return getKeywordsProperty()[key];
};
// Get the keywords property object
export const getKeywordsProperty = (): any => {
return coreConfig.get<any>('keywords') ?? FALLBACK_KEYWORDS;
};
// Get the keyword names by group
export const getKeywordNamesByGroup = (group: string): string[] => {
const keywords = coreConfig.get<any>('keywords') ?? FALLBACK_KEYWORDS;
const result = [];
for (const keyword in keywords) {
if (keywords[keyword]?.group === group) result.push(keyword);
}
return result;
};
export const getGroups = (): string[] => {
const keywords = coreConfig.get<any>('keywords') ?? FALLBACK_KEYWORDS;
const result: string[] = [];
for (const keyword in keywords) {
if (keywords[keyword]?.group?.length && !result.includes(keywords[keyword]?.group)) result.push(keywords[keyword]?.group);
}
return result;
};
export default {
getKeywordNames,
getKeyword,
getKeywordsProperty,
getKeywordNamesByGroup,
getGroups,
};