{"id":17069602,"url":"https://github.com/freethenation/node-falafel","last_synced_at":"2025-10-09T09:32:51.917Z","repository":{"id":57241516,"uuid":"4659126","full_name":"freethenation/node-falafel","owner":"freethenation","description":"transform the ast on a recursive walk","archived":false,"fork":false,"pushed_at":"2013-05-12T05:14:05.000Z","size":196,"stargazers_count":2,"open_issues_count":0,"forks_count":83,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-02T14:58:38.139Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"substack/node-falafel","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/freethenation.png","metadata":{"files":{"readme":"readme.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-14T04:03:14.000Z","updated_at":"2022-09-17T20:06:20.000Z","dependencies_parsed_at":"2022-11-04T15:03:13.052Z","dependency_job_id":null,"html_url":"https://github.com/freethenation/node-falafel","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/freethenation/node-falafel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freethenation%2Fnode-falafel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freethenation%2Fnode-falafel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freethenation%2Fnode-falafel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freethenation%2Fnode-falafel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freethenation","download_url":"https://codeload.github.com/freethenation/node-falafel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freethenation%2Fnode-falafel/sbom","scorecard":{"id":410946,"data":{"date":"2025-08-11","repo":{"name":"github.com/freethenation/node-falafel","commit":"25dd5b8fe05219003463db637068f81e1d46a02c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T22:41:34.605Z","repository_id":57241516,"created_at":"2025-08-18T22:41:34.605Z","updated_at":"2025-08-18T22:41:34.605Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001117,"owners_count":26083022,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-14T11:27:21.432Z","updated_at":"2025-10-09T09:32:51.881Z","avatar_url":"https://github.com/freethenation.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# free-falafel\n\nTransform the [ast](http://en.wikipedia.org/wiki/Abstract_syntax_tree) on a recursive walk.\n\n[![Build Status](https://travis-ci.org/freethenation/node-falafel.png?branch=master)](https://travis-ci.org/freethenation/node-falafel)\n\nThis module is like [burrito](https://github.com/substack/node-burrito),\nexcept that it uses [esprima](http://esprima.org) instead of\n[uglify](https://github.com/mishoo/UglifyJS) for friendlier-looking ast nodes.\n\n# Example\n\n## array.js\n\nPut a function wrapper around all array literals.\n\n``` js\nvar falafel = require('free-falafel');\n\nvar src = '(' + function () {\n    var xs = [ 1, 2, [ 3, 4 ] ];\n    var ys = [ 5, 6 ];\n    console.dir([ xs, ys ]);\n} + ')()';\n\nvar output = falafel(src, function (node) {\n    if (node.type === 'ArrayExpression') {\n        node.update('fn(' + node.source() + ')');\n    }\n});\nconsole.log(output);\n```\n\noutput:\n\n```\n(function () {\n    var xs = fn([ 1, 2, fn([ 3, 4 ]) ]);\n    var ys = fn([ 5, 6 ]);\n    console.dir(fn([ xs, ys ]));\n})()\n```\n\n# Methods\n\n``` js\nvar falafel = require('free-falafel')\n```\n\n## falafel(src, opts={}, fn, breadthFirstFn)\n\nTransform the string source `src` with the function `fn`, returning a\nstring-like transformed output object.\n\nFor every node in the ast, `fn(node)` fires. The recursive walk is \ndepth first, so children get called before their parents.\n\nPerforming the transforms during a depth first traversal makes it easier \nto write nested transforms since transforming parents often requires transforming \nall its children first.\n\nThe return value is string-like (it defines `.toString()` and `.inspect()`) so\nthat you can call `node.update()` asynchronously after the function has\nreturned and still capture the output.\n\nInstead of passing a `src` you can also pass `opts.source` or, if the source code\nhas already been parsed into an ast, you can pass `opts.ast`.\n\nAll of the `opts` will be passed directly to esprima except for `'range'` which\nis always turned on because falafel needs it.\n\nSome of the options you might want from esprima includes:\n`'loc'`, `'raw'`, `'comments'`, `'tokens'`, and `'tolerant'`.\n\nYou can optionally provide the function `breadthFirstFn`. This function will be\ncalled before `fn` during a breadth first traversal of the ast. This function allows\nyou to add additional properties to the `node` parameter so that you can easily do things\nlike not transforming any code inside of a function definition. There is an example of\nthis below.\n\n# Nodes\n\nAside from the regular [esprima](http://esprima.org) data, you can also call\nsome inserted methods on nodes.\n\nAside from updating the current node, you can also reach into sub-nodes to call\nupdate functions on children from parent nodes.\n\n## node.source()\n\nReturn the source for the given node, including any modifications made to\nchildren nodes.\n\n## node.update(s)\n\nTransform the source for the present node to the string `s`. This function is not\navailable during the breadth first traversal of the ast.\n\nNote that in `'ForStatement'` node types, there is an existing subnode called\n`update`. For those nodes all the properties are copied over onto the\n`node.update()` function.\n\n## node.parent\n\nReference to the parent element or `null` at the root element.\n\n# More Examples\n\n## breadthFirstFn example\nPut a function wrapper around all array literals that are not inside of a function definition.\n\n``` js\nvar falafel = require('free-falafel');\n\nvar src = '(' + function () {\n    var xs = [ 1, 2, [ 3, 4 ] ];\n    var ys = [ 5, 6 ];\n    somefunc([ xs, ys ]);\n} + ')();\\n';\nsrc += 'var g = [ 5, 6 ];';\n\nvar output = falafel(src, \n    function (node) {\n        if (node.type === 'ArrayExpression' \u0026\u0026 !node.inFunc) {\n            node.update('fn(' + node.source() + ')');\n        }\n    },\n    function (node) {\n        if (node.type === 'FunctionExpression') {\n            node.inFunc = true;\n        }\n        else if (node.parent \u0026\u0026 node.parent.inFunc) {\n            //inherit from parent\n            node.inFunc = node.parent.inFunc;\n        }\n        else { node.inFunc = false; }\n    });\nconsole.log(output.toString());\n```\n\noutput:\n\n```\n(function () {\n    var xs = [ 1, 2, [ 3, 4 ] ];\n    var ys = [ 5, 6 ];\n    somefunc([ xs, ys ]);\n})();\nvar g = fn([ 5, 6 ]);\n```\n\nYou can play with this example at JS Bin [here](http://jsbin.com/free-falafel/4/edit)\n\n# Install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install free-falafel\n```\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreethenation%2Fnode-falafel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreethenation%2Fnode-falafel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreethenation%2Fnode-falafel/lists"}