Skip to content

active-expressions/babel-plugin-locals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-locals Build Status

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"]
});

About

Python locals() in JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published