Run prettier

This commit is contained in:
Mouse Reeve 2022-01-10 16:55:30 -08:00
parent 4202498442
commit 60761b19ba

View file

@ -1,5 +1,5 @@
(function() { (function () {
'use strict'; "use strict";
/** /**
* Suggest a completion as a user types * Suggest a completion as a user types
@ -30,7 +30,7 @@
suggestionsBox.innerHTML = ""; suggestionsBox.innerHTML = "";
// Populate suggestions box // Populate suggestions box
suggestions.forEach(suggestion => { suggestions.forEach((suggestion) => {
const suggestionItem = document.createElement("option"); const suggestionItem = document.createElement("option");
suggestionItem.textContent = suggestion; suggestionItem.textContent = suggestion;
@ -40,7 +40,7 @@
function getSuggestions(input, trie) { function getSuggestions(input, trie) {
// Follow the trie through the provided input // Follow the trie through the provided input
input.split("").forEach(letter => { input.split("").forEach((letter) => {
trie = trie[letter]; trie = trie[letter];
if (!trie) { if (!trie) {
@ -58,55 +58,54 @@
function searchTrie(trie) { function searchTrie(trie) {
const options = Object.values(trie); const options = Object.values(trie);
if (typeof trie == 'string') { if (typeof trie == "string") {
return [trie]; return [trie];
} }
return options.map(option => { return options
const newTrie = option; .map((option) => {
const newTrie = option;
if (typeof newTrie == 'string') { if (typeof newTrie == "string") {
return [newTrie]; return [newTrie];
} }
return searchTrie(newTrie); return searchTrie(newTrie);
}).reduce((prev, next) => prev.concat(next)); })
.reduce((prev, next) => prev.concat(next));
} }
document document.querySelectorAll("[data-autocomplete]").forEach((input) => {
.querySelectorAll('[data-autocomplete]') input.addEventListener("input", autocomplete);
.forEach(input => { });
input.addEventListener('input', autocomplete);
});
})(); })();
const mimetypeTrie = { const mimetypeTrie = {
"a": { a: {
"a": { a: {
"c": "AAC", c: "AAC",
},
z: {
w: "AZW",
}, },
"z": {
"w": "AZW",
}
}, },
"d": "Daisy", d: "Daisy",
"e": "ePub", e: "ePub",
"f": "FLAC", f: "FLAC",
"h": "HTML", h: "HTML",
"m": { m: {
"4": { 4: {
"a": "M4A", a: "M4A",
"b": "M4B", b: "M4B",
}, },
"o": "MOBI", o: "MOBI",
"p": "MP3", p: "MP3",
}, },
"o": "OGG", o: "OGG",
"p": { p: {
"d": { d: {
"f": "PDF", f: "PDF",
}, },
"l": "Plaintext", l: "Plaintext",
}, },
}; };