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