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

Method readFlowCollection

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

Source from the content-addressed store, hash-verified

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