MCPcopy
hub / github.com/jquery/esprima / parsePropertyPattern

Method parsePropertyPattern

src/parser.ts:1935–1971  ·  view source on GitHub ↗
(params, kind?: string)

Source from the content-addressed store, hash-verified

1933 }
1934
1935 parsePropertyPattern(params, kind?: string): Node.Property {
1936 const node = this.createNode();
1937
1938 let computed = false;
1939 let shorthand = false;
1940 const method = false;
1941
1942 let key: Node.PropertyKey | null;
1943 let value: Node.PropertyValue;
1944
1945 if (this.lookahead.type === Token.Identifier) {
1946 const keyToken = this.lookahead;
1947 key = this.parseVariableIdentifier();
1948 const init = this.finalize(node, new Node.Identifier(keyToken.value));
1949 if (this.match('=')) {
1950 params.push(keyToken);
1951 shorthand = true;
1952 this.nextToken();
1953 const expr = this.parseAssignmentExpression();
1954 value = this.finalize(this.startNode(keyToken), new Node.AssignmentPattern(init, expr));
1955 } else if (!this.match(':')) {
1956 params.push(keyToken);
1957 shorthand = true;
1958 value = init;
1959 } else {
1960 this.expect(':');
1961 value = this.parsePatternWithDefault(params, kind);
1962 }
1963 } else {
1964 computed = this.match('[');
1965 key = this.parseObjectPropertyKey();
1966 this.expect(':');
1967 value = this.parsePatternWithDefault(params, kind);
1968 }
1969
1970 return this.finalize(node, new Node.Property('init', key, computed, value, method, shorthand));
1971 }
1972
1973 parseObjectPattern(params, kind?: string): Node.ObjectPattern {
1974 const node = this.createNode();

Callers 1

parseObjectPatternMethod · 0.95

Calls 11

createNodeMethod · 0.95
finalizeMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
startNodeMethod · 0.95
expectMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected