MCPcopy Index your code
hub / github.com/angular/angular / stringify

Function stringify

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

Source from the content-addressed store, hash-verified

84}
85
86export 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
120export class Version {
121 public readonly major: string;

Callers 2

util_spec.tsFile · 0.90
identifierNameFunction · 0.90

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…