esquery
A query library for ECMAScript AST using a CSS selector like query language.
Last updated 3 months ago by michaelficarra .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm 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.3.1                                ...           latest (3 months ago)

12 Versions

  • 1.3.1                                ...           3 months ago
  • 1.3.0                                ...           3 months ago
  • 1.2.1                                ...           3 months ago
  • 1.2.0                                ...           4 months ago
  • 1.1.0                                ...           5 months ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.0                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Downloads
Today 71
This Week 125,681
This Month 416,168
Last Day 31,197
Last Week 179,043
Last Month 739,521
Dependencies (1)
Dev Dependencies (16)
Dependents (160)

Copyright 2014 - 2016 © taobao.org |