MCPcopy Create free account
hub / github.com/Lobos/react-ui / friendlyStringify

Function friendlyStringify

docs/lib/react.js:6411–6433  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

6409}
6410
6411function friendlyStringify(obj) {
6412 if (typeof obj === 'object') {
6413 if (Array.isArray(obj)) {
6414 return '[' + obj.map(friendlyStringify).join(', ') + ']';
6415 } else {
6416 var pairs = [];
6417 for (var key in obj) {
6418 if (Object.prototype.hasOwnProperty.call(obj, key)) {
6419 var keyEscaped = /^[a-z$_][\w$_]*$/i.test(key) ? key : JSON.stringify(key);
6420 pairs.push(keyEscaped + ': ' + friendlyStringify(obj[key]));
6421 }
6422 }
6423 return '{' + pairs.join(', ') + '}';
6424 }
6425 } else if (typeof obj === 'string') {
6426 return JSON.stringify(obj);
6427 } else if (typeof obj === 'function') {
6428 return '[function object]';
6429 }
6430 // Differs from JSON.stringify in that undefined because undefined and that
6431 // inf and nan don't become null
6432 return String(obj);
6433}
6434
6435var styleMutationWarning = {};
6436

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…