MCPcopy
hub / github.com/amark/gun / i

Function i

test/expect.js:578–766  ·  view source on GitHub ↗

* Inspects an object. * * @see taken from node.js `util` module (copyright Joyent, MIT license) * @api private

(obj, showHidden, depth)

Source from the content-addressed store, hash-verified

576 */
577
578 function i (obj, showHidden, depth) {
579 var seen = [];
580
581 function stylize (str) {
582 return str;
583 }
584
585 function format (value, recurseTimes) {
586 // Provide a hook for user-specified inspect functions.
587 // Check that value is an object with an inspect function on it
588 if (value && typeof value.inspect === 'function' &&
589 // Filter out the util module, it's inspect function is special
590 value !== exports &&
591 // Also filter out any prototype objects using the circular check.
592 !(value.constructor && value.constructor.prototype === value)) {
593 return value.inspect(recurseTimes);
594 }
595
596 // Primitive types cannot have properties
597 switch (typeof value) {
598 case 'undefined':
599 return stylize('undefined', 'undefined');
600
601 case 'string':
602 var simple = '\'' + json.stringify(value).replace(/^"|"$/g, '')
603 .replace(/'/g, "\\'")
604 .replace(/\\"/g, '"') + '\'';
605 return stylize(simple, 'string');
606
607 case 'number':
608 return stylize('' + value, 'number');
609
610 case 'boolean':
611 return stylize('' + value, 'boolean');
612 }
613 // For some reason typeof null is "object", so special case here.
614 if (value === null) {
615 return stylize('null', 'null');
616 }
617
618 if (isDOMElement(value)) {
619 return getOuterHTML(value);
620 }
621
622 // Look up the keys of the object.
623 var visible_keys = keys(value);
624 var $keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
625
626 // Functions without properties can be shortcutted.
627 if (typeof value === 'function' && $keys.length === 0) {
628 if (isRegExp(value)) {
629 return stylize('' + value, 'regexp');
630 } else {
631 var name = value.name ? ': ' + value.name : '';
632 return stylize('[Function' + name + ']', 'special');
633 }
634 }
635

Callers 2

sFunction · 0.70
expect.jsFile · 0.70

Calls 1

formatFunction · 0.85

Tested by

no test coverage detected