babel-plugin-implicit-this
v0.1.2
Published
Transform global variables to implicit this expressions
Downloads
51
Readme
babel-plugin-implicit-this
Ditch your global variables with this syntactic sugar
Transforms globals to implicit this expressions:
Before:
x = 10;
After:
this.x = 10;
Installation
$ npm install --save-dev babel-plugin-implicit-this
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["implicit-this", { "env": "node", "globals": "./path/to/globals.json" }]
}
Via CLI
$ babel --plugins implicit-this script.js
Via Node API
const globals = {
foo_global: false
}
require("babel-core").transform("code", {
plugins: ["implicit-this", { env: 'browser', globals }]
});
License
MIT
TODO
- add
const self = this
at the top of instance methods