MCPcopy Create free account
hub / github.com/denoland/std / readBlockSequence

Method readBlockSequence

yaml/_loader_state.ts:383–440  ·  view source on GitHub ↗
(
    tag: string | null,
    anchor: string | null,
    nodeIndent: number,
  )

Source from the content-addressed store, hash-verified

381 }
382 }
383 readBlockSequence(
384 tag: string | null,
385 anchor: string | null,
386 nodeIndent: number,
387 ): State | void {
388 let detected = false;
389
390 const result: unknown[] = [];
391
392 if (anchor !== null) this.anchorMap.set(anchor, result);
393
394 let ch = this.#scanner.peek();
395
396 while (ch !== 0) {
397 if (ch !== MINUS) {
398 break;
399 }
400
401 const following = this.#scanner.peek(1);
402
403 if (!isWhiteSpaceOrEOL(following)) {
404 break;
405 }
406
407 detected = true;
408 this.#scanner.next();
409
410 if (this.skipSeparationSpace(true, -1)) {
411 if (this.lineIndent <= nodeIndent) {
412 result.push(null);
413 ch = this.#scanner.peek();
414 continue;
415 }
416 }
417
418 const line = this.line;
419 const newState = this.composeNode({
420 parentIndent: nodeIndent,
421 nodeContext: CONTEXT_BLOCK_IN,
422 allowToSeek: false,
423 allowCompact: true,
424 });
425 if (newState) result.push(newState.result);
426 this.skipSeparationSpace(true, -1);
427
428 ch = this.#scanner.peek();
429
430 if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
431 throw this.#createError(
432 "Cannot read block sequence: bad indentation of a sequence entry",
433 );
434 } else if (this.lineIndent < nodeIndent) {
435 break;
436 }
437 }
438
439 if (detected) return { tag, anchor, kind: "sequence", result };
440 }

Callers 1

composeNodeMethod · 0.95

Calls 8

skipSeparationSpaceMethod · 0.95
composeNodeMethod · 0.95
#createErrorMethod · 0.95
isWhiteSpaceOrEOLFunction · 0.90
setMethod · 0.65
peekMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected