Skip to content
Snippets Groups Projects
Commit 42e96692 authored by michael.minelli's avatar michael.minelli
Browse files

Toolbox => Add snakeToCamel and getKeysWithPrefix

parent 97020c38
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,14 @@ class Toolbox { ...@@ -42,6 +42,14 @@ class Toolbox {
getTotalSize: this.getTotalSize.bind(this) 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));
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment