From 4c4e347e47788ff883446785624b79d732bdc930 Mon Sep 17 00:00:00 2001 From: Aroop Roelofs Date: Sun, 20 Aug 2023 23:39:26 +0200 Subject: [PATCH] Allow turning strings into camelCase --- utility/inflector.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utility/inflector.ts b/utility/inflector.ts index 4bf088ba..b5c272df 100644 --- a/utility/inflector.ts +++ b/utility/inflector.ts @@ -32,6 +32,16 @@ export class Inflector { .replaceAll(' ', ''); } + /** + * Turn a string into camelCase + * + * @param input + * @param delimiter Optional delimiter by which to split the string + */ + public static camelize(input: string, delimiter: string = '_'): string { + return this.lcfirst(this.pascalize(input, delimiter)); + } + /** * Return the input lower_case_delimited_string as "A Human Readable String". * (Underscores are replaced by spaces and capitalized following words.)