Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/xtuc/babel-plugin-transform-scala-lambda
- Owner: xtuc
- Created: 2016-12-03T16:58:47.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-21T23:16:08.000Z (over 5 years ago)
- Last Synced: 2024-10-10T12:17:26.828Z (29 days ago)
- Topics: babel, javascript, lambda, scala
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 54
- Watchers: 4
- 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
[![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);
```