{"id":13656442,"url":"https://github.com/estools/esdispatch","last_synced_at":"2025-05-01T14:31:49.125Z","repository":{"id":10899004,"uuid":"13193216","full_name":"estools/esdispatch","owner":"estools","description":"trigger events based on esquery selectors during a traversal of a SpiderMonkey format AST","archived":false,"fork":false,"pushed_at":"2014-09-09T16:39:14.000Z","size":149,"stargazers_count":12,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T14:43:07.781Z","etag":null,"topics":["ast","ecmascript","estree","javascript"],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/estools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-29T13:55:33.000Z","updated_at":"2024-02-02T21:14:08.000Z","dependencies_parsed_at":"2022-08-29T14:11:27.405Z","dependency_job_id":null,"html_url":"https://github.com/estools/esdispatch","commit_stats":null,"previous_names":["michaelficarra/esdispatch"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estools%2Fesdispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estools%2Fesdispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estools%2Fesdispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estools%2Fesdispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/estools","download_url":"https://codeload.github.com/estools/esdispatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251027224,"owners_count":21525096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","ecmascript","estree","javascript"],"created_at":"2024-08-02T05:00:20.543Z","updated_at":"2025-05-01T14:31:48.836Z","avatar_url":"https://github.com/estools.png","language":"CoffeeScript","funding_links":[],"categories":["CoffeeScript"],"sub_categories":[],"readme":"# esdispatch\n\nTrigger events based on [esquery](https://github.com/jrfeenst/esquery) selectors during a traversal of a [SpiderMonkey format AST](https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API).\n\n\n\n## Install\n\n    npm install --save esdispatch\n\n\n\n## Examples\n\n```js\nvar counter = 0, dispatcher = new ESDispatcher;\ndispatcher.on(\n  'UpdateExpression[operator=\"++\"] \u003e Identifier[name=i]',\n  function(node, ancestors) { ++counter; }\n);\ndispatcher.observe(spidermonkeyAST, function() {\n  counter; // 4\n});\n```\n\n\n\n## API\n\n#### `new ESDispatcher` → ESDispatcher instance\nThe ESDispatcher constructor takes no arguments.\n\n#### `ESDispatcher::addListener(selector, listener)` → void\nInvoke `listener` whenever esdispatch walks over a node that matches\n`selector`. `listener` is given two arguments: the node that matched the\nselector, and a list containing the ancestors of that node. `listener` may also\nbe an object containing an `enter` and, optionally, a `leave` function. In that\ncase, the `enter` function will be called in pre-order, and the `leave`\nfunction will be called in post-order. Aliased as `ESDispatcher::on`.\n\n#### `ESDispatcher::once(selector, listener)` → void\nAdds a listener that is invoked only the first time `selector` matches.\n\n#### `ESDispatcher::observe(ast, onFinished)` → void\nBegin a traversal using the given SpiderMonkey AST, triggering any listeners\nassociated with matching queries. `onFinished`, if given, is called with no\narguments once the traversal is completed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festools%2Fesdispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Festools%2Fesdispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festools%2Fesdispatch/lists"}