MCPcopy
hub / github.com/BloombergGraphics/whatiscode / parseObjectProperty

Function parseObjectProperty

scripts/libs/esprima.js:2495–2522  ·  view source on GitHub ↗
(hasProto)

Source from the content-addressed store, hash-verified

2493 }
2494
2495 function parseObjectProperty(hasProto) {
2496 var token = lookahead, node = new Node(), computed, key, maybeMethod, value;
2497
2498 computed = match('[');
2499 key = parseObjectPropertyKey();
2500 maybeMethod = tryParseMethodDefinition(token, key, computed, node);
2501
2502 if (maybeMethod) {
2503 checkProto(maybeMethod.key, maybeMethod.computed, hasProto);
2504 // finished
2505 return maybeMethod;
2506 }
2507
2508 // init property or short hand property.
2509 checkProto(key, computed, hasProto);
2510
2511 if (match(':')) {
2512 lex();
2513 value = parseAssignmentExpression();
2514 return node.finishProperty('init', key, computed, value, false, false);
2515 }
2516
2517 if (token.type === Token.Identifier) {
2518 return node.finishProperty('init', key, computed, key, false, true);
2519 }
2520
2521 throwUnexpectedToken(lookahead);
2522 }
2523
2524 function parseObjectInitialiser() {
2525 var properties = [], hasProto = {value: false}, node = new Node();

Callers 1

parseObjectInitialiserFunction · 0.85

Calls 7

matchFunction · 0.85
parseObjectPropertyKeyFunction · 0.85
tryParseMethodDefinitionFunction · 0.85
checkProtoFunction · 0.85
lexFunction · 0.85
throwUnexpectedTokenFunction · 0.85

Tested by

no test coverage detected