{"id":16473199,"url":"https://github.com/saintedlama/estools","last_synced_at":"2025-03-23T11:32:49.511Z","repository":{"id":19727080,"uuid":"22983112","full_name":"saintedlama/estools","owner":"saintedlama","description":"Provides a set of utility function to traverse, filter and map esprima ASTs","archived":false,"fork":false,"pushed_at":"2017-05-31T21:36:43.000Z","size":19,"stargazers_count":6,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T20:07:11.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saintedlama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-15T08:12:57.000Z","updated_at":"2017-02-08T17:40:17.000Z","dependencies_parsed_at":"2022-08-24T11:40:08.521Z","dependency_job_id":null,"html_url":"https://github.com/saintedlama/estools","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Festools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Festools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Festools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saintedlama%2Festools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saintedlama","download_url":"https://codeload.github.com/saintedlama/estools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097158,"owners_count":20560311,"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":[],"created_at":"2024-10-11T12:25:45.391Z","updated_at":"2025-03-23T11:32:49.181Z","avatar_url":"https://github.com/saintedlama.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# estools [![Build Status](https://travis-ci.org/saintedlama/estools.svg?branch=master)](https://travis-ci.org/saintedlama/estools) [![Coverage Status](https://coveralls.io/repos/saintedlama/estools/badge.png?branch=master)](https://coveralls.io/r/saintedlama/estools?branch=master)\n\nEstools provides a set of utility functions to traverse, filter and map esprima ASTs.\n\n    npm install estools --save\n\n    var estools = require('estools')\n\n# API\n\n## traverse(ast, visitor)\nTraverses all tree nodes of an AST and calls visitor functions passing the AST node.\n\nast is the result of esprima.parse, visitor may be a function or a visitor object.\n\nThe visitor object may define the following functions\n\n### enter(node, parent)\n\nCalled when entering a node. The current node and parent node are passed as parameter\n\nExample\n\n    traverse(ast, {\n      enter : function(node, parent) {\n        console.log(node.type);  // Print the node type to std out\n      }\n    });\n\n\n### leave(node, parent)\n\nCalled when leaving a node. The current node and parent node are passed as parameter\n\nExample\n\n    traverse(ast, {\n      leave : function(node, parent) {\n        console.log(node.type);  // Print the node type to std out\n      }\n    });\n\n### visit(node, parent, next)\n\nCalled after `enter` and before `leave`. The current node and a parent node are passed as parameter. Additionally\na function `next` is passed. The `visit` function is responsible to call `next` to visit child nodes. To skip\nchild nodes just omit the call to `visit`.\n\nExample\n\n    traverse(ast, {\n      visit : function(node, parent, next) {\n        next();\n      }\n    });\n\nExample skipping nodes\n    traverse(ast, {\n      visit : function(node, parent, next) {\n        if (node.type != 'FunctionExpression') { // Skip child nodes of function expressions\n          next();\n        }\n      }\n    });\n\n## filter(ast, filterObj)\n\nFilters AST nodes and returns matching AST nodes as a flat list.\n\n## map(ast, mappingFunction)\n\nMaps ASTs and nodes to a normalized tree with node having child nodes stored in a nodes field array.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaintedlama%2Festools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaintedlama%2Festools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaintedlama%2Festools/lists"}