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: 8 months ago
JSON representation
Enable Scala lambda style
- Host: GitHub
- URL: https://github.com/xtuc/babel-plugin-transform-scala-lambda
- Owner: xtuc
- Created: 2016-12-03T16:58:47.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-21T23:16:08.000Z (almost 7 years ago)
- Last Synced: 2025-04-19T01:31:45.588Z (8 months ago)
- Topics: babel, javascript, lambda, scala
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 54
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-babel - transform-scala-lambda - Enable Scala-style lambdas (using `_`). 🔧 (Plugins / Alternative Programming Paradigms)
README
# Transform Scala lambda
[](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);
```