MCPcopy
hub / github.com/Exrick/xpay / writeNode

Function writeNode

xpay-code/src/main/resources/static/swagger/swagger-ui.js:10887–10959  ·  view source on GitHub ↗
(state, level, object, block, compact, iskey)

Source from the content-addressed store, hash-verified

10885// Returns true on success, or false on invalid object.
10886//
10887function writeNode(state, level, object, block, compact, iskey) {
10888 state.tag = null;
10889 state.dump = object;
10890
10891 if (!detectType(state, object, false)) {
10892 detectType(state, object, true);
10893 }
10894
10895 var type = _toString.call(state.dump);
10896
10897 if (block) {
10898 block = (state.flowLevel < 0 || state.flowLevel > level);
10899 }
10900
10901 var objectOrArray = type === '[object Object]' || type === '[object Array]',
10902 duplicateIndex,
10903 duplicate;
10904
10905 if (objectOrArray) {
10906 duplicateIndex = state.duplicates.indexOf(object);
10907 duplicate = duplicateIndex !== -1;
10908 }
10909
10910 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
10911 compact = false;
10912 }
10913
10914 if (duplicate && state.usedDuplicates[duplicateIndex]) {
10915 state.dump = '*ref_' + duplicateIndex;
10916 } else {
10917 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
10918 state.usedDuplicates[duplicateIndex] = true;
10919 }
10920 if (type === '[object Object]') {
10921 if (block && (Object.keys(state.dump).length !== 0)) {
10922 writeBlockMapping(state, level, state.dump, compact);
10923 if (duplicate) {
10924 state.dump = '&ref_' + duplicateIndex + state.dump;
10925 }
10926 } else {
10927 writeFlowMapping(state, level, state.dump);
10928 if (duplicate) {
10929 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
10930 }
10931 }
10932 } else if (type === '[object Array]') {
10933 if (block && (state.dump.length !== 0)) {
10934 writeBlockSequence(state, level, state.dump, compact);
10935 if (duplicate) {
10936 state.dump = '&ref_' + duplicateIndex + state.dump;
10937 }
10938 } else {
10939 writeFlowSequence(state, level, state.dump);
10940 if (duplicate) {
10941 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
10942 }
10943 }
10944 } else if (type === '[object String]') {

Callers 5

writeFlowSequenceFunction · 0.85
writeBlockSequenceFunction · 0.85
writeFlowMappingFunction · 0.85
writeBlockMappingFunction · 0.85
dumpFunction · 0.85

Calls 6

detectTypeFunction · 0.85
writeBlockMappingFunction · 0.85
writeFlowMappingFunction · 0.85
writeBlockSequenceFunction · 0.85
writeFlowSequenceFunction · 0.85
writeScalarFunction · 0.85

Tested by

no test coverage detected