summaryrefslogtreecommitdiff
path: root/ext/mixed/js/audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-14 21:25:25 -0500
committerGitHub <noreply@github.com>2020-02-14 21:25:25 -0500
commit853faaf48c63b6efba09d3de0c0c508f7c24ff50 (patch)
tree4411d78032b2a7e595a2d573ab0e3fd264788a51 /ext/mixed/js/audio.js
parent548c67ef1ce2a0aa8859dc458e003a98ad5b9ed6 (diff)
parent4dd4926672b4db39721c10a3941246ab1225f988 (diff)
Merge pull request #358 from toasted-nutbread/general-refactoring
General refactoring
Diffstat (limited to 'ext/mixed/js/audio.js')
-rw-r--r--ext/mixed/js/audio.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js
index 76a3e7da..47db5c75 100644
--- a/ext/mixed/js/audio.js
+++ b/ext/mixed/js/audio.js
@@ -114,8 +114,11 @@ function audioGetFromUrl(url, willDownload) {
async function audioGetFromSources(expression, sources, optionsContext, willDownload, cache=null) {
const key = `${expression.expression}:${expression.reading}`;
- if (cache !== null && hasOwn(cache, expression)) {
- return cache[key];
+ if (cache !== null) {
+ const cacheValue = cache.get(expression);
+ if (typeof cacheValue !== 'undefined') {
+ return cacheValue;
+ }
}
for (let i = 0, ii = sources.length; i < ii; ++i) {
@@ -133,7 +136,7 @@ async function audioGetFromSources(expression, sources, optionsContext, willDown
}
const result = {audio, url, source};
if (cache !== null) {
- cache[key] = result;
+ cache.set(key, result);
}
return result;
} catch (e) {