« get me outta code hell

wiki-data: combineWikiDataArrays - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-14 19:48:37 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-15 20:40:13 -0400
commit5a7500688040fc19940adf0e2d0d96a0f75d014b (patch)
treef40f937756b6aeb03f84e323249d4a8efb474ff0 /src
parent9d91023e7c7827e640e8edcda3743cb0109f2170 (diff)
wiki-data: combineWikiDataArrays
Diffstat (limited to 'src')
-rw-r--r--src/util/wiki-data.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 4855a7a2..f97ecd63 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -460,3 +460,16 @@ export class TupleMapForBabies {
     }
   }
 }
+
+const combinedWikiDataTupleMap = new TupleMapForBabies();
+
+export function combineWikiDataArrays(arrays) {
+  const map = combinedWikiDataTupleMap;
+  if (map.has(...arrays)) {
+    return map.get(...arrays);
+  } else {
+    const combined = arrays.flat();
+    map.set(...arrays, combined);
+    return combined;
+  }
+}