@luvio/utils
Advanced tools
Comparing version 3.5.1 to 3.5.2
@@ -9,1 +9,8 @@ export declare function toPascalCase(s: string): string; | ||
export declare const toCamelCase: (name: string) => string; | ||
/** | ||
* Converts the passed string to screaming snake case, i.e. uppercase words separated by underscores. | ||
* | ||
* @param name the param name to convert | ||
* @returns a constant case version of the parameter | ||
*/ | ||
export declare const toScreamingSnakeCase: (name: string) => string; |
@@ -186,2 +186,18 @@ /** | ||
.replace(/^(.)/, (_, m) => m.toLowerCase()); | ||
/** | ||
* Converts the passed string to screaming snake case, i.e. uppercase words separated by underscores. | ||
* | ||
* @param name the param name to convert | ||
* @returns a constant case version of the parameter | ||
*/ | ||
const toScreamingSnakeCase = (name) => name | ||
// -+, _+ | ||
// split on existing hyphens & underscores, "foo-bar_baz" => [foo, bar, baz] | ||
// (?<=[a-z])(?=[A-Z]) | ||
// split at transition from lowercase to uppercase, "fooBar" => [foo, Bar] | ||
// (?<=[A-Z])(?=[A-Z][a-z]) | ||
// split at transition from uppercase to lowercase, "FOOBar" => [FOO, Bar] | ||
.split(/-+|_+|(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/) | ||
.join('_') | ||
.toUpperCase(); | ||
@@ -198,2 +214,2 @@ /** | ||
export { ConsoleFileParserLogger, ConsoleLogger, LogLevelMap, bfs, emptyServices, includes, isPromiseLike, loggerService, satisfies, toCamelCase, toPascalCase }; | ||
export { ConsoleFileParserLogger, ConsoleLogger, LogLevelMap, bfs, emptyServices, includes, isPromiseLike, loggerService, satisfies, toCamelCase, toPascalCase, toScreamingSnakeCase }; |
{ | ||
"name": "@luvio/utils", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "Luvio utils", | ||
@@ -5,0 +5,0 @@ "repository": { |
13928
372