-
Notifications
You must be signed in to change notification settings - Fork 11
/
fuzzy.js
39 lines (24 loc) · 1019 Bytes
/
fuzzy.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
const fuzzysort = require('fuzzysort');
const lists = require('./lists.js');
let itemdict = require('./itemdict.json');
let extras = ["mvp card", "mini card", "mvp★ card", "mini★ card", "mvp/mini card", "mvp/mini★ card", "undead card", "dead card", "revenant card", "boss card"];
itemdict = itemdict.concat(extras);
let fuzzy = {};
// RETURNS undefined IF NOT FOUND A MATCH
fuzzy.enchant = function(query) {
let result = fuzzysort.go(query, lists.enchant, { limit: 1 })[0];
return result === undefined ? undefined : result.target;
};
fuzzy.parameter = function(query) {
let result = fuzzysort.go(query, lists.parameter, { limit: 1 })[0];
return result === undefined ? undefined : result.target;
};
fuzzy.name = function(query) {
let result = fuzzysort.go(query, itemdict, { limit: 1 })[0];
return result === undefined ? undefined : result.target;
}
fuzzy.autocomplete = function(query, list) {
let result = fuzzysort.go(query, list, { limit: 25 });
return result;
}
module.exports = fuzzy;