MCPcopy Create free account
hub / github.com/codemix/graph / describeExpected

Method describeExpected

packages/graph/src/grammar.js:119–146  ·  view source on GitHub ↗
(expected)

Source from the content-addressed store, hash-verified

117 }
118
119 function describeExpected(expected) {
120 const descriptions = expected.map(describeExpectation);
121 descriptions.sort();
122
123 if (descriptions.length > 0) {
124 let j = 1;
125 for (let i = 1; i < descriptions.length; i++) {
126 if (descriptions[i - 1] !== descriptions[i]) {
127 descriptions[j] = descriptions[i];
128 j++;
129 }
130 }
131 descriptions.length = j;
132 }
133
134 switch (descriptions.length) {
135 case 1:
136 return descriptions[0];
137
138 case 2:
139 return descriptions[0] + " or " + descriptions[1];
140
141 default:
142 return descriptions.slice(0, -1).join(", ")
143 + ", or "
144 + descriptions[descriptions.length - 1];
145 }
146 }
147
148 function describeFound(found) {
149 return found ? "\"" + literalEscape(found) + "\"" : "end of input";

Callers

nothing calls this directly

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected