babel-plugin-auto-argument
v0.0.2
Published
[![GitHub stars](https://img.shields.io/github/stars/HuQingyang/babel-plugin-auto-argument.svg?style=social&label=Stars&style=plastic)](https://github.com/HuQingyang/babel-plugin-auto-argument) [![GitHub forks](https://img.shields.io/github/forks/HuQingya
Downloads
4
Readme
Using auto argument in JavaScript like Scala
See Also:
- Using two-way data binding in JSX: babel-plugin-jsx-two-way-binding
- Using for-directive in JSX: babel-plugin-jsx-for-directive
- Using if-directive in JSX: babel-plugin-jsx-if-directive
1. Install
npm install --save-dev babel-plugin-auto-argument
2. Basic Usage
Edit your .babelrc file:
{
"plugins": [
"auto-argument"
]
}
In your js file:
[1, 2, 3].map(_ * 2)
And it will be compiled to:
[1, 2, 3].map(function (_) {
return _ * 2
})
In your js file:
const a = [
[1, 2],
[3, 4, 5],
[6, 7, 8, 9]
].filter(_.length <= 3).map(_.filter(10 % _ === 0));
console.log(a);
And it will print:
[
[1, 2],
[5]
]
3. Usage with custom variable name
Edit your .babelrc file:
{
"plugins": [
"auto-argument",
{
"variableName": "$"
}
]
}
In your js file:
[1, 2, 3].map($ * 2)