MCPcopy
hub / github.com/Kong/insomnia / parse

Method parse

packages/insomnia/bin/yarn-standalone.js:34208–34322  ·  view source on GitHub ↗
(indent = 0)

Source from the content-addressed store, hash-verified

34206 }
34207
34208 parse(indent = 0) {
34209 const obj = (0, (_map || _load_map()).default)();
34210
34211 while (true) {
34212 const propToken = this.token;
34213
34214 if (propToken.type === TOKEN_TYPES.newline) {
34215 const nextToken = this.next();
34216 if (!indent) {
34217 // if we have 0 indentation then the next token doesn't matter
34218 continue;
34219 }
34220
34221 if (nextToken.type !== TOKEN_TYPES.indent) {
34222 // if we have no indentation after a newline then we've gone down a level
34223 break;
34224 }
34225
34226 if (nextToken.value === indent) {
34227 // all is good, the indent is on our level
34228 this.next();
34229 } else {
34230 // the indentation is less than our level
34231 break;
34232 }
34233 } else if (propToken.type === TOKEN_TYPES.indent) {
34234 if (propToken.value === indent) {
34235 this.next();
34236 } else {
34237 break;
34238 }
34239 } else if (propToken.type === TOKEN_TYPES.eof) {
34240 break;
34241 } else if (propToken.type === TOKEN_TYPES.string) {
34242 // property key
34243 const key = propToken.value;
34244 (0, (_invariant || _load_invariant()).default)(key, 'Expected a key');
34245
34246 const keys = [key];
34247 this.next();
34248
34249 // support multiple keys
34250 while (this.token.type === TOKEN_TYPES.comma) {
34251 this.next(); // skip comma
34252
34253 const keyToken = this.token;
34254 if (keyToken.type !== TOKEN_TYPES.string) {
34255 this.unexpected('Expected string');
34256 }
34257
34258 const key = keyToken.value;
34259 (0, (_invariant || _load_invariant()).default)(key, 'Expected a key');
34260 keys.push(key);
34261 this.next();
34262 }
34263
34264 const valToken = this.token;
34265

Callers 15

parseFunction · 0.95
exportSpecificationFunction · 0.45
readAndInsertDocFunction · 0.45
insomniaAdapterFunction · 0.45
cleanCyclesFunction · 0.45
generate.test.tsFile · 0.45
yarn-standalone.jsFile · 0.45
explodeEntryFunction · 0.45
ComparatorFunction · 0.45
urlPartsFunction · 0.45
loadConfigMethod · 0.45

Calls 8

nextMethod · 0.95
unexpectedMethod · 0.95
_load_mapFunction · 0.85
_load_invariantFunction · 0.85
isValidPropValueTokenFunction · 0.85
_load_utilFunction · 0.85
pushMethod · 0.45
inspectMethod · 0.45

Tested by 2

getSpecResultFunction · 0.36
getSpecResultFunction · 0.36