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-05-31 22:22:59 +00:00
|
|
|
import {StringWrapper} from '../facade/lang';
|
2015-07-30 00:41:09 +00:00
|
|
|
|
2015-06-23 10:46:38 +00:00
|
|
|
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
|
|
|
|
var 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-06-08 23:38:52 +00:00
|
|
|
return StringWrapper.replaceAllMapped(
|
|
|
|
|
input, CAMEL_CASE_REGEXP, (m: any /** TODO #9100 */) => { return '-' + 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-06-08 23:38:52 +00:00
|
|
|
return StringWrapper.replaceAllMapped(
|
|
|
|
|
input, DASH_CASE_REGEXP, (m: any /** TODO #9100 */) => { return m[1].toUpperCase(); });
|
2015-05-18 18:57:20 +00:00
|
|
|
}
|