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

Function str

deps/v8/test/webkit/resources/json2-es5-compat.js:222–351  ·  view source on GitHub ↗
(key, holder)

Source from the content-addressed store, hash-verified

220
221
222 function str(key, holder) {
223
224// Produce a string from holder[key].
225
226 var i, // The loop counter.
227 k, // The member key.
228 v, // The member value.
229 length,
230 mind = gap,
231 partial,
232 value = holder[key];
233
234// If the value has a toJSON method, call it to obtain a replacement value.
235
236 if (value && typeof value === 'object' &&
237 typeof value.toJSON === 'function') {
238 value = value.toJSON(key);
239 }
240
241// If we were called with a replacer function, then call the replacer to
242// obtain a replacement value.
243
244 if (typeof rep === 'function') {
245 value = rep.call(holder, key, value);
246 }
247
248// What happens next depends on the value's type.
249
250 if (value && ((typeof value) === "object")) {
251 if (value.constructor === String || value.constructor === Number || value.constructor === Boolean)
252 value = value.valueOf();
253 }
254
255 switch (typeof value) {
256 case 'string':
257 return quote(value);
258
259 case 'number':
260
261// JSON numbers must be finite. Encode non-finite numbers as null.
262
263 return isFinite(value) ? String(value) : 'null';
264
265 case 'boolean':
266 case 'null':
267
268// If the value is a boolean or null, convert it to a string. Note:
269// typeof null does not produce 'null'. The case is included here in
270// the remote chance that this gets fixed someday.
271
272 return String(value);
273
274// If the type is 'object', we might be dealing with an object or an array or
275// null.
276
277 case 'object':
278
279// Due to a specification blunder in ECMAScript, typeof null is 'object',

Callers 15

configure.pyFile · 0.85
configure_intlFunction · 0.85
configure_section_fileFunction · 0.85
make_bin_overrideFunction · 0.85
HasRunTestMethod · 0.85
MainFunction · 0.85
CheckedUnlinkFunction · 0.85
MainFunction · 0.85
repl_atFunction · 0.85
mainFunction · 0.85
FormatJUnitXMLMethod · 0.85
search_files.pyFile · 0.85

Calls 7

StringClass · 0.85
quoteFunction · 0.70
toJSONMethod · 0.45
callMethod · 0.45
applyMethod · 0.45
joinMethod · 0.45
pushMethod · 0.45

Tested by 15

CheckedUnlinkFunction · 0.68
MainFunction · 0.68
__init__Method · 0.68
CallMethod · 0.68
sort_keyFunction · 0.68
test_suffixesMethod · 0.68
testFunction · 0.68
genMethod · 0.68
get_git_file_statusMethod · 0.68