MCPcopy
hub / github.com/CodeboxIDE/codebox / str

Function str

client/vendors/socket.io.js:714–835  ·  view source on GitHub ↗
(key, holder)

Source from the content-addressed store, hash-verified

712
713
714 function str(key, holder) {
715
716// Produce a string from holder[key].
717
718 var i, // The loop counter.
719 k, // The member key.
720 v, // The member value.
721 length,
722 mind = gap,
723 partial,
724 value = holder[key];
725
726// If the value has a toJSON method, call it to obtain a replacement value.
727
728 if (value instanceof Date) {
729 value = date(key);
730 }
731
732// If we were called with a replacer function, then call the replacer to
733// obtain a replacement value.
734
735 if (typeof rep === 'function') {
736 value = rep.call(holder, key, value);
737 }
738
739// What happens next depends on the value's type.
740
741 switch (typeof value) {
742 case 'string':
743 return quote(value);
744
745 case 'number':
746
747// JSON numbers must be finite. Encode non-finite numbers as null.
748
749 return isFinite(value) ? String(value) : 'null';
750
751 case 'boolean':
752 case 'null':
753
754// If the value is a boolean or null, convert it to a string. Note:
755// typeof null does not produce 'null'. The case is included here in
756// the remote chance that this gets fixed someday.
757
758 return String(value);
759
760// If the type is 'object', we might be dealing with an object or an array or
761// null.
762
763 case 'object':
764
765// Due to a specification blunder in ECMAScript, typeof null is 'object',
766// so watch out for that case.
767
768 if (!value) {
769 return 'null';
770 }
771

Callers 1

socket.io.jsFile · 0.85

Calls 2

dateFunction · 0.85
quoteFunction · 0.85

Tested by

no test coverage detected