MCPcopy Create free account
hub / github.com/angular/angular / stringify

Function stringify

packages/compiler/src/util.ts:84–116  ·  view source on GitHub ↗
(token: any)

Source from the content-addressed store, hash-verified

82}
83
84export 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
118export class Version {
119 public readonly major: string;

Callers 2

util_spec.tsFile · 0.90
identifierNameFunction · 0.90

Calls 6

isArrayMethod · 0.80
mapMethod · 0.80
indexOfMethod · 0.80
joinMethod · 0.65
toStringMethod · 0.65
sliceMethod · 0.65

Tested by

no test coverage detected