# tree-visitor-async

> Visit nodes in the tree asynchronously and sequentially. Supports promises.

Latest version **1.0.0** (published 2013-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install tree-visitor-async
pnpm add tree-visitor-async
yarn add tree-visitor-async
bun add tree-visitor-async
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2013-08-19 |
| First published | 2013-07-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Glen Huang |
| Maintainers | curvedmark |
| Keywords | ast, tree, visitor, async, compiler |

## Links

- npm: https://www.npmjs.com/package/tree-visitor-async
- Repository: https://github.com/curvedmark/tree-visitor-async
- Issues: https://github.com/curvedmark/tree-visitor-async/issues
- npm.io page: https://npm.io/package/tree-visitor-async

## Dependencies (2)

- [promise-now](https://npm.io/package/promise-now.md) 1.x
- [tree-visitor](https://npm.io/package/tree-visitor.md) *

## 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

- 1.0.0 (latest) — 2013-08-19
- 0.4.0 — 2013-08-02
- 0.3.0 — 2013-08-01
- 0.1.0 — 2013-07-28

## README

# Tree Visitor Async

Visit nodes in the tree asynchronously and sequentially. Support promises.

Asynchronous version of [Tree Visitor](https://github.com/curvedmark/tree-visitor). Actions can return a promise and `.visit()` returns a promise.

## API

```javascript
var fs = require('fs');
var Q = require('q');
var VisitorAsync = require('tree-visitor-async');
var nodes = [
	{ type: 'import', value: 'path/to/file1' },
	{ type: 'import', value: 'path/to/file2' },
];

function MyVisitorAsync() {}
MyVisitorAsync.prototype = new VisitorAsync();

MyVisitorAsync.prototype.visit_import = function (importNode) {
	var deferred = Q.defer();
	fs.readFile(importNode.value, 'utf8', deferred.makeNodeResolver());
	return deferred.promise.then(function (content) {
		console.log(content);
	});
};

new MyVisitorAsync().visit(nodes).then(function () {
	console.log('done');
});
```

Methods are passed to the returned promise as fulfill callbacks. So, for example, if a method throws an error or returns a rejected promise, subsequent nodes won't be visited.

`this` keyword in the fulfill & reject callbacks refers the created visitor object (e.g., `new MyVisitorAsync()` in the previous example).

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