2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
|
|
|
|
|
2016-11-12 14:08:58 +01:00
|
|
|
const CAMEL_CASE_REGEXP = /([A-Z])/g;
|
|
|
|
|
const DASH_CASE_REGEXP = /-([a-z])/g;
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-06-24 13:46:39 -07:00
|
|
|
|
2015-06-26 11:10:52 -07:00
|
|
|
export function camelCaseToDashCase(input: string): string {
|
2016-10-06 15:10:27 -07:00
|
|
|
return input.replace(CAMEL_CASE_REGEXP, (...m: string[]) => '-' + m[1].toLowerCase());
|
2015-03-23 14:10:55 -07:00
|
|
|
}
|
|
|
|
|
|
2015-06-26 11:10:52 -07:00
|
|
|
export function dashCaseToCamelCase(input: string): string {
|
2016-10-06 15:10:27 -07:00
|
|
|
return input.replace(DASH_CASE_REGEXP, (...m: string[]) => m[1].toUpperCase());
|
2015-05-18 11:57:20 -07:00
|
|
|
}
|