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