Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/drwpow/babel-plugin-smoosh

Permission to smoosh: granted
https://github.com/drwpow/babel-plugin-smoosh

Last synced: 9 days ago
JSON representation

Permission to smoosh: granted

Awesome Lists containing this project

README

        

# babel-plugin-smoosh

Lets intellectuals use `Array.prototype.smoosh()` and
`Array.prototype.smooshMap()` instead of `Array.prototype.flat()` and
`Array.prototype.flatMap()`.

### Installation

```
npm i --save-dev babel-plugin-smoosh
```

Add the following to your `.babelrc` or `.babelrc.js` file:

```json
{
"plugins": ["smoosh"]
}
```

### Usage

```js
const myArray = [1, 2, [3, 4]];
myArray.smoosh(); // [1, 2, 3, 4]
```

```js
const myArray = [1, 2, [3, 4];
myArray.smooshMap(x => [x * 2]) // [2, 4, 6, 8]
```