# ast-redeclare

> Hoist variable declarations to the top of scope.

Latest version **1.0.4** (published 2015-02-17) · Unlicensed license · 0 weekly downloads

## Install

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

## 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.4 |
| Published | 2015-02-17 |
| First published | 2015-02-17 |
| Weekly downloads | 0 |
| License | Unlicensed |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Deema Ywanov |
| Maintainers | dfcreative |
| Keywords | ast, hoist, ast-hoist, esparse, hoister, redeclare, variables, declarations, constants, folding, fold, constants-folding, optimization, compilation, esprima, escodegen, analysis, data-flow, dataflow |

## Links

- npm: https://www.npmjs.com/package/ast-redeclare
- Repository: https://github.com/dfcreative/ast-redeclare
- Issues: https://github.com/dfcreative/ast-redeclare/issues
- npm.io page: https://npm.io/package/ast-redeclare

## Dependencies (2)

- [escope](https://npm.io/package/escope.md) ^2.0.4
- [ast-types](https://npm.io/package/ast-types.md) ^0.6.12

## 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.4 (latest) — 2015-02-17
- 1.0.3 — 2015-02-17
- 1.0.2 — 2015-02-17
- 1.0.1 — 2015-02-17

## README

# ast-redeclare [![Build Status](https://travis-ci.org/dfcreative/ast-redeclare.svg?branch=master)](https://travis-ci.org/dfcreative/ast-redeclare)

Hoist and fold variable declarations within scopes, so that each variable has only one declaration per scope. Don’t touch functions.
Useful to normalize code before analysis, like data-flow etc.


## Usage

```sh
npm install ast-redeclare
```

```js
var parse = require('esprima').parse;
var generate = require('escodegen').generate;
var redeclare = require('ast-redeclare');

var ast = parse(
	'var a = 1, b = 2; if (a > 1) { var c = b; } else {var c = 3;} var d = 4;'
);
ast = redeclare(ast);

generate(ast);
//var a, b, c, d; a = 1; b = 2; if (a > 1) { c = b; } else { c = 3; }; d = 4;

```

## API

#### redeclare(Node) → Node


## Analogs

* [ast-hoist](https://www.npmjs.com/package/ast-hoist)
* [hoister](https://www.npmjs.com/package/hoister)


[![NPM](https://nodei.co/npm/ast-redeclare.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/ast-redeclare/)

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