| 84 | } |
| 85 | |
| 86 | export function stringify(token: any): string { |
| 87 | if (typeof token === 'string') { |
| 88 | return token; |
| 89 | } |
| 90 | |
| 91 | if (Array.isArray(token)) { |
| 92 | return `[${token.map(stringify).join(', ')}]`; |
| 93 | } |
| 94 | |
| 95 | if (token == null) { |
| 96 | return '' + token; |
| 97 | } |
| 98 | |
| 99 | const name = token.overriddenName || token.name; |
| 100 | if (name) { |
| 101 | return `${name}`; |
| 102 | } |
| 103 | |
| 104 | if (!token.toString) { |
| 105 | return 'object'; |
| 106 | } |
| 107 | |
| 108 | // WARNING: do not try to `JSON.stringify(token)` here |
| 109 | // see https://github.com/angular/angular/issues/23440 |
| 110 | const result = token.toString(); |
| 111 | |
| 112 | if (result == null) { |
| 113 | return '' + result; |
| 114 | } |
| 115 | |
| 116 | const newLineIndex = result.indexOf('\n'); |
| 117 | return newLineIndex >= 0 ? result.slice(0, newLineIndex) : result; |
| 118 | } |
| 119 | |
| 120 | export class Version { |
| 121 | public readonly major: string; |