/** * @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 */ import {ɵglobal as global} from '@angular/core'; 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()); } /** * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if * `name` is `'probe'`. * @param name Name under which it will be exported. Keep in mind this will be a property of the * global `ng` object. * @param value The value to export. */ export function exportNgVar(name: string, value: any): void { if (!ng) { global['ng'] = ng = (global['ng'] as{[key: string]: any} | undefined) || {}; } ng[name] = value; } let ng: {[key: string]: any}|undefined;