# acorn-bfs

> Breadth-first search traversal of an acorn-generated AST.

Latest version **0.2.0** (published 2017-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install acorn-bfs
pnpm add acorn-bfs
yarn add acorn-bfs
bun add acorn-bfs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-03-12 |
| First published | 2015-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel St. Jules |
| Maintainers | danielstjules |
| Keywords | acorn, bfs, traverse, traversal, ast, tree |

## Links

- npm: https://www.npmjs.com/package/acorn-bfs
- Repository: https://github.com/danielstjules/acorn-bfs
- Issues: https://github.com/danielstjules/acorn-bfs/issues
- npm.io page: https://npm.io/package/acorn-bfs

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2017-03-12
- 0.1.0 — 2015-11-18
- 0.0.1 — 2015-07-06

## README

# acorn-bfs

``` javascript
/**
 * 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
 */
```

[![Build Status](https://travis-ci.org/danielstjules/acorn-bfs.svg?branch=master)](https://travis-ci.org/danielstjules/acorn-bfs)

#### Installation

```
npm install --save acorn-bfs
```

#### Example

``` javascript
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']
```

---
_Source: https://npm.io/package/acorn-bfs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
