Clear timer variable

This commit is contained in:
toasted-nutbread 2020-02-23 11:44:24 -05:00
parent 897f2360be
commit 0f9f2e446d

View File

@ -109,7 +109,8 @@ function countKanjiWithCharacter(kanji, character) {
function clearDatabase(timeout) { function clearDatabase(timeout) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timer = setTimeout(() => { let timer = setTimeout(() => {
timer = null;
reject(new Error(`clearDatabase failed to resolve after ${timeout}ms`)); reject(new Error(`clearDatabase failed to resolve after ${timeout}ms`));
}, timeout); }, timeout);
@ -122,7 +123,9 @@ function clearDatabase(timeout) {
request.onsuccess = () => resolve2(); request.onsuccess = () => resolve2();
}); });
} }
if (timer !== null) {
clearTimeout(timer); clearTimeout(timer);
}
resolve(); resolve();
})(); })();
}); });