From 5a7500688040fc19940adf0e2d0d96a0f75d014b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 14 Nov 2024 19:48:37 -0400 Subject: wiki-data: combineWikiDataArrays --- src/util/wiki-data.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/util') 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; + } +} -- cgit 1.3.0-6-gf8a5