# babel-plugin-locals

> Python-style locals() in JavaScript

Latest version **1.0.1** (published 2016-08-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-locals
pnpm add babel-plugin-locals
yarn add babel-plugin-locals
bun add babel-plugin-locals
```

## 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.1 |
| Published | 2016-08-02 |
| First published | 2016-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stefan Ramson |
| Maintainers | onsetsu |
| Keywords | babel-plugin, babel, plugin, transform, locals, scope |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-locals
- Repository: https://github.com/active-expressions/babel-plugin-locals
- Homepage: https://github.com/active-expressions/babel-plugin-locals#readme
- Issues: https://github.com/active-expressions/babel-plugin-locals/issues
- npm.io page: https://npm.io/package/babel-plugin-locals

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-08-02
- 1.0.0 — 2016-08-02

## README

# babel-plugin-locals

Python locals() in JavaScript.

## Example

Transforms
```js
var x;
let y = 42;

function z() {}

locals;
```

to
```js
var x;
let y = 42;

function z() {}

({
  x,
  y,
  z
});
```

This transformation has potential usages for meta programming(e.g. interpreting a function using a JavaScript interpreter requires explicit access to the local scope of the function).

## Installation

```sh
$ npm install babel-plugin-locals
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "plugins": ["locals"]
}
```

### Via CLI

```sh
$ babel --plugins locals script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
  plugins: ["locals"]
});
```

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