MCPcopy Index your code
hub / github.com/vercel/hyper / parse

Method parse

bin/yarn-standalone.js:34630–34744  ·  view source on GitHub ↗
(indent = 0)

Source from the content-addressed store, hash-verified

34628 }
34629
34630 parse(indent = 0) {
34631 const obj = (0, (_map || _load_map()).default)();
34632
34633 while (true) {
34634 const propToken = this.token;
34635
34636 if (propToken.type === TOKEN_TYPES.newline) {
34637 const nextToken = this.next();
34638 if (!indent) {
34639 // if we have 0 indentation then the next token doesn't matter
34640 continue;
34641 }
34642
34643 if (nextToken.type !== TOKEN_TYPES.indent) {
34644 // if we have no indentation after a newline then we've gone down a level
34645 break;
34646 }
34647
34648 if (nextToken.value === indent) {
34649 // all is good, the indent is on our level
34650 this.next();
34651 } else {
34652 // the indentation is less than our level
34653 break;
34654 }
34655 } else if (propToken.type === TOKEN_TYPES.indent) {
34656 if (propToken.value === indent) {
34657 this.next();
34658 } else {
34659 break;
34660 }
34661 } else if (propToken.type === TOKEN_TYPES.eof) {
34662 break;
34663 } else if (propToken.type === TOKEN_TYPES.string) {
34664 // property key
34665 const key = propToken.value;
34666 (0, (_invariant || _load_invariant()).default)(key, 'Expected a key');
34667
34668 const keys = [key];
34669 this.next();
34670
34671 // support multiple keys
34672 while (this.token.type === TOKEN_TYPES.comma) {
34673 this.next(); // skip comma
34674
34675 const keyToken = this.token;
34676 if (keyToken.type !== TOKEN_TYPES.string) {
34677 this.unexpected('Expected string');
34678 }
34679
34680 const key = keyToken.value;
34681 (0, (_invariant || _load_invariant()).default)(key, 'Expected a key');
34682 keys.push(key);
34683 this.next();
34684 }
34685
34686 const wasColon = this.token.type === TOKEN_TYPES.colon;
34687 if (wasColon) {

Callers 15

parseFunction · 0.95
getPathFunction · 0.80
lsRemoteFunction · 0.80
mainFunction · 0.80
api.tsFile · 0.80
getDeprecatedConfigFunction · 0.80
_importConfFunction · 0.80
yarn-standalone.jsFile · 0.80
explodeEntryFunction · 0.80
ComparatorFunction · 0.80
urlPartsFunction · 0.80
loadConfigMethod · 0.80

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

no test coverage detected