MCPcopy
hub / github.com/Leaflet/Leaflet.markercluster / format

Function format

spec/expect.js:567–741  ·  view source on GitHub ↗
(value, recurseTimes)

Source from the content-addressed store, hash-verified

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

Callers 1

iFunction · 0.85

Calls 10

stylizeFunction · 0.85
isDOMElementFunction · 0.85
getOuterHTMLFunction · 0.85
isRegExpFunction · 0.85
isDateFunction · 0.85
isArrayFunction · 0.85
mapFunction · 0.85
indexOfFunction · 0.85
reduceFunction · 0.85
keysFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…