MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / skipWhitespace

Method skipWhitespace

src/common/json5.ts:262–297  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260 }
261
262 skipWhitespace(): void {
263 while (!this.isAtEnd()) {
264 const ch = this.currentChar();
265 if (/\s/.test(ch)) {
266 this.index++;
267 continue;
268 }
269 if (ch === '/') {
270 // Support for comments: either // or /* ... */
271 const next = this.peekChar(1);
272 if (next === '/') {
273 // Single-line comment
274 this.index += 2;
275 while (!this.isAtEnd() && this.currentChar() !== '\n') {
276 this.index++;
277 }
278 continue;
279 } else if (next === '*') {
280 // Multi-line comment
281 this.index += 2;
282 while (
283 !this.isAtEnd() &&
284 !(this.currentChar() === '*' && this.peekChar(1) === '/')
285 ) {
286 this.index++;
287 }
288 if (this.isAtEnd()) {
289 throw this.error('Unterminated multi-line comment');
290 }
291 this.index += 2; // consume closing */
292 continue;
293 }
294 }
295 break;
296 }
297 }
298
299 private expectChar(expected: string): void {
300 if (this.currentChar() !== expected) {

Callers 4

parseMethod · 0.95
parseValueMethod · 0.95
parseObjectMethod · 0.95
parseArrayMethod · 0.95

Calls 4

isAtEndMethod · 0.95
currentCharMethod · 0.95
peekCharMethod · 0.95
errorMethod · 0.95

Tested by

no test coverage detected