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

Method parseArrayPattern

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

Source from the content-addressed store, hash-verified

1906 }
1907
1908 parseArrayPattern(params, kind?: string): Node.ArrayPattern {
1909 const node = this.createNode();
1910
1911 this.expect('[');
1912 const elements: Node.ArrayPatternElement[] = [];
1913 while (!this.match(']')) {
1914 if (this.match(',')) {
1915 this.nextToken();
1916 elements.push(null);
1917 } else {
1918 if (this.match('...')) {
1919 elements.push(this.parseBindingRestElement(params, kind));
1920 break;
1921 } else {
1922 elements.push(this.parsePatternWithDefault(params, kind));
1923 }
1924 if (!this.match(']')) {
1925 this.expect(',');
1926 }
1927 }
1928
1929 }
1930 this.expect(']');
1931
1932 return this.finalize(node, new Node.ArrayPattern(elements));
1933 }
1934
1935 parsePropertyPattern(params, kind?: string): Node.Property {
1936 const node = this.createNode();

Callers 1

parsePatternMethod · 0.95

Calls 8

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

Tested by

no test coverage detected