aster-equery
Replace nodes with pattern-matching selectors in aster.
Allows to use pattern-matching (JavaScript code examples with wildcards and some other special syntax) for finding nodes and replacing them with results of corresponding handlers.
Uses grasp-equery behind the scenes, so check out official documentation for syntax details.
Usage
First, install aster-equery
as a development dependency:
npm install --save-dev aster-equery
Then, add it to your build script:
var aster = ;var equery = ; aster;
can be also written as:
var aster = ;var equery = ; aster;
API
equery(mappings)
mappings
Type: {pattern: handler}
Replacement mappings.
pattern
Type: String
handler (option 1: callback)
Type: Function(node, named)
Callback to be called on each found match. It will get two arguments - matched node object and hashmap of named subpatterns.
handler (option 2: template)
Type: String
estemplate string to be used for generating AST.