All Projects → estools → Esdispatch

estools / Esdispatch

Licence: bsd-3-clause
trigger events based on esquery selectors during a traversal of a SpiderMonkey format AST

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects
ecmascript
72 projects

Labels

Projects that are alternatives of or similar to Esdispatch

Tenko
An 100% spec compliant ES2021 JavaScript parser written in JS
Stars: ✭ 490 (+5344.44%)
Mutual labels:  ast
Postcss
Transforming styles with JS plugins
Stars: ✭ 25,612 (+284477.78%)
Mutual labels:  ast
Micromark
the smallest commonmark compliant markdown parser that exists; new basis for @unifiedjs (hundreds of projects w/ billions of downloads for dealing w/ content)
Stars: ✭ 793 (+8711.11%)
Mutual labels:  ast
Escope
Escope: ECMAScript scope analyzer
Stars: ✭ 497 (+5422.22%)
Mutual labels:  ast
Tiny Compiler
A tiny evaluator and compiler of arithmetic expressions.
Stars: ✭ 680 (+7455.56%)
Mutual labels:  ast
Js Code To Svg Flowchart
js2flowchart - a visualization library to convert any JavaScript code into beautiful SVG flowchart. Learn other’s code. Design your code. Refactor code. Document code. Explain code.
Stars: ✭ 6,290 (+69788.89%)
Mutual labels:  ast
Qone
Next-generation web query language, extend .NET LINQ for javascript.
Stars: ✭ 463 (+5044.44%)
Mutual labels:  ast
Modiscript
Acche din aa gaye
Stars: ✭ 888 (+9766.67%)
Mutual labels:  ast
Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (+7566.67%)
Mutual labels:  ast
Php Parser
PHP parser written in Go
Stars: ✭ 787 (+8644.44%)
Mutual labels:  ast
Esquery
ECMAScript AST query library.
Stars: ✭ 513 (+5600%)
Mutual labels:  ast
Rehype
HTML processor powered by plugins part of the @unifiedjs collective
Stars: ✭ 634 (+6944.44%)
Mutual labels:  ast
Esprima
ECMAScript parsing infrastructure for multipurpose analysis
Stars: ✭ 6,391 (+70911.11%)
Mutual labels:  ast
Mdast
Markdown Abstract Syntax Tree format
Stars: ✭ 493 (+5377.78%)
Mutual labels:  ast
Estraverse
ECMAScript JS AST traversal functions
Stars: ✭ 795 (+8733.33%)
Mutual labels:  ast
Fantomas
FSharp source code formatter
Stars: ✭ 475 (+5177.78%)
Mutual labels:  ast
Tolerant Php Parser
An early-stage PHP parser designed for IDE usage scenarios.
Stars: ✭ 717 (+7866.67%)
Mutual labels:  ast
Metric Parser
📜 AST-based advanced mathematical parser written by Typescript.
Stars: ✭ 26 (+188.89%)
Mutual labels:  ast
Proposal Binary Ast
Binary AST proposal for ECMAScript
Stars: ✭ 831 (+9133.33%)
Mutual labels:  ast
Astring
🌳 Tiny and fast JavaScript code generator from an ESTree-compliant AST.
Stars: ✭ 757 (+8311.11%)
Mutual labels:  ast

esdispatch

Trigger events based on esquery selectors during a traversal of a SpiderMonkey format AST.

Install

npm install --save esdispatch

Examples

var counter = 0, dispatcher = new ESDispatcher;
dispatcher.on(
  'UpdateExpression[operator="++"] > Identifier[name=i]',
  function(node, ancestors) { ++counter; }
);
dispatcher.observe(spidermonkeyAST, function() {
  counter; // 4
});

API

new ESDispatcher → ESDispatcher instance

The ESDispatcher constructor takes no arguments.

ESDispatcher::addListener(selector, listener) → void

Invoke listener whenever esdispatch walks over a node that matches selector. listener is given two arguments: the node that matched the selector, and a list containing the ancestors of that node. listener may also be an object containing an enter and, optionally, a leave function. In that case, the enter function will be called in pre-order, and the leave function will be called in post-order. Aliased as ESDispatcher::on.

ESDispatcher::once(selector, listener) → void

Adds a listener that is invoked only the first time selector matches.

ESDispatcher::observe(ast, onFinished) → void

Begin a traversal using the given SpiderMonkey AST, triggering any listeners associated with matching queries. onFinished, if given, is called with no arguments once the traversal is completed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].