MCPcopy Create free account
hub / github.com/denodrivers/postgres / parse

Method parse

query/array_parser.ts:83–118  ·  view source on GitHub ↗
(nested = false)

Source from the content-addressed store, hash-verified

81 }
82
83 parse(nested = false): ArrayResult<T> {
84 let character, parser, quote;
85 this.consumeDimensions();
86 while (!this.isEof()) {
87 character = this.nextCharacter();
88 if (character.value === "{" && !quote) {
89 this.dimension++;
90 if (this.dimension > 1) {
91 parser = new ArrayParser(
92 this.source.substring(this.position - 1),
93 this.transform,
94 this.separator,
95 );
96 this.entries.push(parser.parse(true));
97 this.position += parser.position - 2;
98 }
99 } else if (character.value === "}" && !quote) {
100 this.dimension--;
101 if (!this.dimension) {
102 this.newEntry();
103 if (nested) return this.entries;
104 }
105 } else if (character.value === '"' && !character.escaped) {
106 if (quote) this.newEntry(true);
107 quote = !quote;
108 } else if (character.value === this.separator && !quote) {
109 this.newEntry();
110 } else {
111 this.record(character.value);
112 }
113 }
114 if (this.dimension !== 0) {
115 throw new Error("array dimension not balanced");
116 }
117 return this.entries;
118 }
119}

Callers 3

parseArrayFunction · 0.80
decodeJsonFunction · 0.80

Calls 6

consumeDimensionsMethod · 0.95
isEofMethod · 0.95
nextCharacterMethod · 0.95
newEntryMethod · 0.95
recordMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected