# sol-explore

> Traversal functions for solidity-parser generated AST

Latest version **1.6.2** (published 2016-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install sol-explore
pnpm add sol-explore
yarn add sol-explore
bun add sol-explore
```

## 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.6.2 |
| Published | 2016-08-29 |
| First published | 2016-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Raghav Dua |
| Maintainers | the-mad-king |
| Keywords | Abstract-Syntax-Tree, Traversal, Solidity |

## Links

- npm: https://www.npmjs.com/package/sol-explore
- Repository: https://github.com/duaraghav8/sol-explore
- Homepage: https://github.com/duaraghav8/sol-explore#readme
- Issues: https://github.com/duaraghav8/sol-explore/issues
- npm.io page: https://npm.io/package/sol-explore

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.6.2 (latest) — 2016-08-29
- 1.6.1 — 2016-08-04
- 1.6.0 — 2016-07-30
- 1.5.0 — 2016-07-27
- 1.4.0 — 2016-07-24
- 1.3.0 — 2016-07-24
- 1.2.2 — 2016-07-23
- 1.2.1 — 2016-07-23
- 1.2.0 — 2016-07-23
- 1.1.1 — 2016-07-23
- 1.1.0 — 2016-07-23
- 1.0.0 — 2016-07-23

## README

# sol-explore
Traversal functions for solidity-parser generated AST

#Documentation

sol-explore provides Depth-First Traversal of the abstract syntax tree that solidity-parser creates for your solidity code.
You provide the AST and specifiy the callbacks that get called upon entering and leaving a particular node during the traversal.

#Run in Browser
```html
<script src="sol-explore-bundle.js"></script>
```
Then access the object using ```window.SolExplore``` or simply ```SolExplore```

#Install in Node

```bash
npm install --save sol-explore
```

#API

```sol-explorer``` exports a function ```traverse``` and an object ```traversalOptions```. ```traverse``` expects 2 arguments - the first is the AST generated by solidity-parser (or any other parser of your choice which follows a similar Solidity Tree Pattern) and the second is either a function or an object.

If the 2nd argument is simply a function, it is treated as the callback to call when **entering** an un-explored node. If the argument is an object, the object must have 2 properties:

      object.enter = function () {...}  //callback to call when entering an un-explored node
      object.leave = function () {...}  //callback to call when leaving an explored node
      
You may use 2 additional features inside these functions:

      this.stopTraversal () /*OR*/ return solExplorer.traversalOptions.STOP_TRAVERSAL //stop tree traversal immediately
      this.skipNodesBelow () /*OR*/ return solExplorer.traversalOptions.SKIP_NODES_BELOW  //skip the child nodes of the current node

#Example
```js
/*
here, solExplore is the required()d object,
ast is the Abstract Syntax Tree created by solidity-parser
See examples/ directory for complete example with sample solidity code
*/
solExplore.traverse (ast, {
	enter: function (node, parent) {
		console.log ('Entering', node.type);
		if (node.type === 'StructDeclaration') {
			//this.skipNodesBelow ();
			this.stopTraversal ();
			
			//return solExplore.traversalOptions.STOP_TRAVERSAL;
			//return solExplore.traversalOptions.SKIP_NODES_BELOW;
		}
	},
	leave: function (node) {
		console.log ('Leaving', node.type);
	}
});
```

#License
##MIT

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