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

Method readFlowCollection

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

Source from the content-addressed store, hash-verified

883 );
884 }
885 readFlowCollection(
886 tag: string | null,
887 anchor: string | null,
888 nodeIndent: number,
889 ): State | void {
890 let ch = this.#scanner.peek();
891 let terminator: number;
892 let isMapping = true;
893 let result = {};
894 if (ch === LEFT_SQUARE_BRACKET) {
895 terminator = RIGHT_SQUARE_BRACKET;
896 isMapping = false;
897 result = [];
898 } else if (ch === LEFT_CURLY_BRACKET) {
899 terminator = RIGHT_CURLY_BRACKET;
900 } else {
901 return;
902 }
903
904 if (anchor !== null) this.anchorMap.set(anchor, result);
905
906 this.#scanner.next();
907 ch = this.#scanner.peek();
908
909 let readNext = true;
910 let valueNode = null;
911 let keyNode = null;
912 let keyTag: string | null = null;
913 let isExplicitPair = false;
914 let isPair = false;
915 let following = 0;
916 let line = 0;
917 const overridableKeys = new Set<string>();
918 while (ch !== 0) {
919 this.skipSeparationSpace(true, nodeIndent);
920
921 ch = this.#scanner.peek();
922
923 if (ch === terminator) {
924 this.#scanner.next();
925 const kind = isMapping ? "mapping" : "sequence";
926 return { tag, anchor, kind, result };
927 }
928 if (!readNext) {
929 throw this.#createError(
930 "Cannot read flow collection: missing comma between flow collection entries",
931 );
932 }
933
934 keyTag = keyNode = valueNode = null;
935 isPair = isExplicitPair = false;
936
937 if (ch === QUESTION) {
938 following = this.#scanner.peek(1);
939
940 if (isWhiteSpaceOrEOL(following)) {
941 isPair = isExplicitPair = true;
942 this.#scanner.next();

Callers 1

composeNodeMethod · 0.95

Calls 9

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

Tested by

no test coverage detected