From c1a090688e2274c0a6a00b4bbec9d7722f6aed58 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 4 Aug 2024 23:08:41 -0500 Subject: [PATCH] refactor: dynamic names --- app/ecs/components/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/ecs/components/index.js b/app/ecs/components/index.js index d077722..f83fb51 100644 --- a/app/ecs/components/index.js +++ b/app/ecs/components/index.js @@ -6,9 +6,13 @@ const Gathered = gather( const Components = {}; for (const componentName in Gathered) { - Components[componentName] = class Named extends Gathered[componentName] { - static componentName = componentName; - }; + Components[componentName] = eval(` + ((Gathered) => ( + class ${componentName} extends Gathered['${componentName}'] { + static componentName = '${componentName}'; + } + )) + `)(Gathered); } export default Components;