esquery
A query library for ECMAScript AST using a CSS selector like query language.
Last updated 4 years ago by michaelficarra .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install esquery 
SYNC missed versions from official npm registry.

ESQuery is a library for querying the AST output by Esprima for patterns of syntax using a CSS style selector system. Check out the demo:

demo

The following selectors are supported:

  • AST node type: ForStatement
  • wildcard: *
  • attribute existence: [attr]
  • attribute value: [attr="foo"] or [attr=123]
  • attribute regex: [attr=/foo.*/] or (with flags) [attr=/foo.*/is]
  • attribute conditions: [attr!="foo"], [attr>2], [attr<3], [attr>=2], or [attr<=3]
  • nested attribute: [attr.level2="foo"]
  • field: FunctionDeclaration > Identifier.id
  • First or last child: :first-child or :last-child
  • nth-child (no ax+b support): :nth-child(2)
  • nth-last-child (no ax+b support): :nth-last-child(1)
  • descendant: ancestor descendant
  • child: parent > child
  • following sibling: node ~ sibling
  • adjacent sibling: node + adjacent
  • negation: :not(ForStatement)
  • has: :has(ForStatement)
  • matches-any: :matches([attr] > :first-child, :last-child)
  • subject indicator: !IfStatement > [name="foo"]
  • class of AST node: :statement, :expression, :declaration, :function, or :pattern

Build Status

Current Tags

  • 1.6.0                                ...           latest (4 months ago)

17 Versions

  • 1.6.0                                ...           4 months ago
  • 1.5.0                                ...           2 years ago
  • 1.4.2                                ...           2 years ago
  • 1.4.1                                ...           2 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           8 years ago
  • 0.4.0                                ...           10 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
  • 0.0.1                                ...           11 years ago
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (16)

© 2010 - cnpmjs.org x YWFE | Home | YWFE