Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
/**
* Returns an array of nodes in the passed AST, traversed using BFS. Accepts an
* optional maximum number, n, of nodes to return. The returned array always
* begins with the root node.
*
* @param {Node} node The root node of the AST to traverse
* @param {int} [n] Optional max number of nodes to return
*/
npm install --save acorn-bfs
var acorn = require('acorn');
var bfs = require('acorn-bfs');
var ast = acorn.parse('function test() {\n' +
' return true;\n' +
'}\n');
bfs(ast).map(function(node) {
return node.type;
});
// =>
// ['Program', 'FunctionDeclaration', 'BlockStatement',
// 'ReturnStatement', 'Literal']
FAQs
Breadth-first search traversal of an acorn-generated AST.
We found that acorn-bfs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.