Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xtuc/babel-plugin-transform-scala-lambda

Enable Scala lambda style
https://github.com/xtuc/babel-plugin-transform-scala-lambda

babel javascript lambda scala

Last synced: 17 days ago
JSON representation

Enable Scala lambda style

Awesome Lists containing this project

README

        

# Transform Scala lambda

[![Greenkeeper badge](https://badges.greenkeeper.io/xtuc/babel-plugin-transform-scala-lambda.svg)](https://greenkeeper.io/)

> 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](http://www.scala-js.org))

## Installation

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

## Usage

Add the following line to your .babelrc file:

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

## Examples

### Sum a list of numbers

#### Using lambda style

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

#### Without it

```js
const sum = [1, 1, 1].reduce((a, b) => a + b);
```

### Get property from object

#### Using lambda style

```js
const users = [{ name: "Sven" }, { name: "James" }];

const userNames = users.map(_.name);
```

#### Without it

```js
const users = [{ name: "Sven" }, { name: "James" }];

const userNames = users.map(u => u.name);
```