Rework results system

Now uses object properties instead of array indices, much less confusing
This commit is contained in:
Dominik Reh
2023-01-10 14:59:09 +01:00
parent 54641ddbfc
commit 964b4fcff3
2 changed files with 131 additions and 55 deletions

27
javascript/_result.js Normal file
View File

@@ -0,0 +1,27 @@
// Type enum
const ResultType = Object.freeze({
"tag": 1,
"embedding": 2,
"wildcardTag": 3,
"wildcardFile": 4,
"yamlWildcard": 5
});
// Class to hold result data and annotations to make it clearer to use
class AutocompleteResult {
// Main properties
text = "";
type = ResultType.tag;
// Additional info, only used in some cases
category = null;
count = null;
aliases = null;
meta = null;
// Constructor
constructor(text, type) {
this.text = text;
this.type = type;
}
}