From 2bd23ac785e0febfec3ba792f495ae8048f78f8e Mon Sep 17 00:00:00 2001 From: evlist Date: Mon, 5 Jun 2023 11:17:01 +0200 Subject: [PATCH] One timer helper to change the structure ofoverlay definitions --- helper.ts | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/helper.ts b/helper.ts index 5d5a5aa..fd6fc11 100644 --- a/helper.ts +++ b/helper.ts @@ -11,4 +11,36 @@ Object.keys(overlayDefinitions).forEach((key) => { filters = [...filters, filter]; }); -console.log({ overlayDefinitions, filters, json: JSON.stringify(filters) }); +// One timer + +const categories = ['hiking', 'cycling', 'vanlife']; + +let overlays = {}; + +for (const category of categories) { + console.log({ caller: 'onetimer / category', category }); + overlays[category] = {}; + for (const tag of Object.keys(overlayDefinitions)) { + overlays[category][tag] = {}; + for (const tagValue of Object.keys(overlayDefinitions[tag] || {})) { + const def = overlayDefinitions[tag][tagValue]; + if (!!def[category]) { + overlays[category][tag][tagValue] = def[category]; + } + } + } +} + +console.log({ + caller: 'onetimer / result', + overlays: JSON.stringify(overlays), +}); + +// End of one timer + +console.log({ + overlayDefinitions, + filters, + json: JSON.stringify(filters), + overlays: JSON.stringify(overlays), +});