20 lines
580 B
TypeScript
20 lines
580 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
const CAMEL_CASE_REGEXP = /([A-Z])/g;
|
|
const DASH_CASE_REGEXP = /-([a-z])/g;
|
|
|
|
|
|
export function camelCaseToDashCase(input: string): string {
|
|
return input.replace(CAMEL_CASE_REGEXP, (...m: string[]) => '-' + m[1].toLowerCase());
|
|
}
|
|
|
|
export function dashCaseToCamelCase(input: string): string {
|
|
return input.replace(DASH_CASE_REGEXP, (...m: string[]) => m[1].toUpperCase());
|
|
}
|