# map-ast

> Makes it easy to transform a JavaScript AST

Latest version **0.0.5** (published 2015-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install map-ast
pnpm add map-ast
yarn add map-ast
bun add map-ast
```

## 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.0.5 |
| Published | 2015-11-06 |
| First published | 2015-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jake Rosoman |
| Maintainers | jkroso |
| Keywords | ast, transform, map, transpile |

## Links

- npm: https://www.npmjs.com/package/map-ast
- Repository: https://github.com/jkroso/map-ast.js
- Homepage: https://github.com/jkroso/map-ast.js#readme
- Issues: https://github.com/jkroso/map-ast.js/issues
- npm.io page: https://npm.io/package/map-ast

## Dependencies (1)

- [ast-children](https://npm.io/package/ast-children.md) 1

## 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.0.5 (latest) — 2015-11-06
- 0.0.4 — 2015-11-06
- 0.0.3 — 2015-10-12
- 0.0.2 — 2015-09-18
- 0.0.1 — 2015-09-06
- 0.0.0 — 2015-09-05

## README

# map-ast

Makes it easy to transform a JavaScript AST. There are heaps of other projects trying to solve this same problem. But I think they are all either gross, don't provide variable tracking, or both. This project provides variable and hierarchy tracking while being less gross than any other project I've seen. Here's my thoughts on the ones I am aware of:

- [Facebook/jstransform](https://github.com/facebook/jstransform): `utils.append('WTF!', state)`
- [substack/node-falafel](https://github.com/substack/node-falafel): `node.update('MVPish')`
- [estools/estraverse](https://github.com/estools/estraverse): subtly complicated and MVPish
- [babel](https://github.com/babel/babel) embedded in a larger tool and too complicated anyway

## Roadmap

Replace the `env` parameter with a linked list of `[env, parent]` values

## Installation

`npm install map-ast`

then in your app:

```js
const map = require('map-ast')
```

## API


### `map(transforms::Object, env::Object, ast::Object)`

Transform `node` by passing it though `transforms[node.type]` if its defined. Otherwise it recurs into node's children and maps them. The transformer will be passed the AST node and the variable environment it lives in.

```js
map({
  JSXElement({openingElement:{name}}, env) {
    return {
      type: 'CallExpression',
      callee: {type: 'Identifier', name: 'JSX'},
      arguments: [name.name in env
                    ? {type: 'Identifier', name: name.name}
                    : {type: 'Literal', value: name.name}]
    }
  }
}, null, parse('<a/>')) // => parse('JSX("a")')
```

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