mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Update the license headers throughout the repository to reference Google LLC rather than Google Inc, for the required license headers. PR Close #37205
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC 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
|
|
*/
|
|
|
|
export function stringify(token: any): string {
|
|
if (typeof token === 'string') {
|
|
return token;
|
|
}
|
|
|
|
if (Array.isArray(token)) {
|
|
return '[' + token.map(stringify).join(', ') + ']';
|
|
}
|
|
|
|
if (token == null) {
|
|
return '' + token;
|
|
}
|
|
|
|
if (token.overriddenName) {
|
|
return `${token.overriddenName}`;
|
|
}
|
|
|
|
if (token.name) {
|
|
return `${token.name}`;
|
|
}
|
|
|
|
const res = token.toString();
|
|
|
|
if (res == null) {
|
|
return '' + res;
|
|
}
|
|
|
|
const newLineIndex = res.indexOf('\n');
|
|
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
|
}
|
|
|
|
/**
|
|
* Concatenates two strings with separator, allocating new strings only when necessary.
|
|
*
|
|
* @param before before string.
|
|
* @param separator separator string.
|
|
* @param after after string.
|
|
* @returns concatenated string.
|
|
*/
|
|
export function concatStringsWithSpace(before: string|null, after: string|null): string {
|
|
return (before == null || before === '') ?
|
|
(after === null ? '' : after) :
|
|
((after == null || after === '') ? before : before + ' ' + after);
|
|
}
|