MCPcopy Index your code
hub / github.com/documentcloud/visualsearch / selectStream

Function selectStream

docs/assets/highlight.js:94–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92 var nodeStack = [];
93
94 function selectStream() {
95 if (stream1.length && stream2.length) {
96 if (stream1[0].offset != stream2[0].offset)
97 return (stream1[0].offset < stream2[0].offset) ? stream1 : stream2;
98 else {
99 /*
100 To avoid starting the stream just before it should stop the order is
101 ensured that stream1 always starts first and closes last:
102
103 if (event1 == 'start' && event2 == 'start')
104 return stream1;
105 if (event1 == 'start' && event2 == 'stop')
106 return stream2;
107 if (event1 == 'stop' && event2 == 'start')
108 return stream1;
109 if (event1 == 'stop' && event2 == 'stop')
110 return stream2;
111
112 ... which is collapsed to:
113 */
114 return stream2[0].event == 'start' ? stream1 : stream2;
115 }
116 } else {
117 return stream1.length ? stream1 : stream2;
118 }
119 }
120
121 function open(node) {
122 var result = '<' + node.nodeName.toLowerCase();

Callers 1

mergeStreamsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected