babel-plugin-locals

1.0.1 • Public • Published

babel-plugin-locals

Python locals() in JavaScript.

Example

Transforms

var x;
let y = 42;
 
function z() {}
 
locals;

to

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

$ npm install babel-plugin-locals

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["locals"]
}

Via CLI

$ babel --plugins locals script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["locals"]
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    24
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    24
  • 1.0.0
    0

Package Sidebar

Install

npm i babel-plugin-locals

Weekly Downloads

24

Version

1.0.1

License

MIT

Last publish

Collaborators

  • onsetsu