From 42e96692156ce11db34159d2ebf3d6984f5881c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me>
Date: Wed, 9 Aug 2023 12:29:54 +0200
Subject: [PATCH] Toolbox => Add snakeToCamel and getKeysWithPrefix

---
 helpers/Toolbox.ts | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/helpers/Toolbox.ts b/helpers/Toolbox.ts
index 55fde4d..f1b3974 100644
--- a/helpers/Toolbox.ts
+++ b/helpers/Toolbox.ts
@@ -42,6 +42,14 @@ class Toolbox {
             getTotalSize: this.getTotalSize.bind(this)
         };
     }
+
+    public snakeToCamel(str: string): string {
+        return str.toLowerCase().replace(/([-_][a-z])/g, (group: string) => group.toUpperCase().replace('-', '').replace('_', ''));
+    }
+
+    public getKeysWithPrefix(obj: object, prefix: string): Array<string> {
+        return Object.keys(obj).filter(key => key.startsWith(prefix));
+    }
 }
 
 
-- 
GitLab