MCPcopy Index your code
hub / github.com/nodejs/node / jsToYaml

Function jsToYaml

lib/internal/test_runner/reporter/tap.js:140–287  ·  view source on GitHub ↗
(indent, name, value, seen)

Source from the content-addressed store, hash-verified

138}
139
140function jsToYaml(indent, name, value, seen) {
141 if (value === undefined) {
142 return '';
143 }
144
145 const prefix = `${indent} ${name}:`;
146
147 if (value === null) {
148 return `${prefix} ~\n`;
149 }
150
151 if (typeof value !== 'object') {
152 if (typeof value !== 'string') {
153 return `${prefix} ${inspectWithNoCustomRetry(value, inspectOptions)}\n`;
154 }
155
156 const lines = RegExpPrototypeSymbolSplit(kLineBreakRegExp, value);
157
158 if (lines.length === 1) {
159 return `${prefix} ${inspectWithNoCustomRetry(value, inspectOptions)}\n`;
160 }
161
162 let str = `${prefix} |-\n`;
163
164 for (let i = 0; i < lines.length; i++) {
165 str += `${indent} ${lines[i]}\n`;
166 }
167
168 return str;
169 }
170
171 seen.add(value);
172 const entries = ObjectEntries(value);
173 const isErrorObj = isError(value);
174 let propsIndent = indent;
175 let result = '';
176
177 if (name != null) {
178 result += prefix;
179 if (internalBinding('types').isDate(value)) {
180 // YAML uses the ISO-8601 standard to express dates.
181 result += ' ' + DatePrototypeToISOString(value);
182 }
183 result += '\n';
184 propsIndent += ' ';
185 }
186
187 for (let i = 0; i < entries.length; i++) {
188 const { 0: key, 1: value } = entries[i];
189
190 if (isErrorObj && (key === 'cause' || key === 'code')) {
191 continue;
192 }
193 if (seen.has(value)) {
194 result += `${propsIndent} ${key}: <Circular>\n`;
195 continue;
196 }
197

Callers 1

reportDetailsFunction · 0.85

Calls 6

inspectWithNoCustomRetryFunction · 0.85
lazyLoadTestFunction · 0.85
isAssertionLikeFunction · 0.85
addMethod · 0.65
hasMethod · 0.65
isErrorFunction · 0.50

Tested by

no test coverage detected