babel-plugin-transform-scala-lambda

1.0.0 • Public • Published

Transform Scala lambda

Enable Scala lambda style

Motivations

  • Allow a more consice syntax for simple things.
  • Scala is a great language (you should take a look at Scala.js)

Installation

npm install --save-dev babel-plugin-transform-scala-lambda

Usage

Add the following line to your .babelrc file:

{
    "plugins": ["transform-scala-lambda"]
}

Examples

Sum a list of numbers

Using lambda style

const sum = [1, 1, 1].reduce(+ _);

Without it

const sum = [1, 1, 1].reduce((a, b) => {
    return a + b;
});

Get property from object

Using lambda style

const users = [{ name: "Sven" }, { name: "James" }];
 
const userNames = users.map(_.name);

Without it

const users = [{ name: "Sven" }, { name: "James" }];
 
const userNames = users.map(u => {
    return u.name;
});

Package Sidebar

Install

npm i babel-plugin-transform-scala-lambda

Weekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • xtuc