https://github.com/nicolaisueper/array-smoosh
Array.prototype.smoosh and smooshMap for all!
https://github.com/nicolaisueper/array-smoosh
array flatmap flatten javascript smoosh smooshgate smooshmap
Last synced: 6 months ago
JSON representation
Array.prototype.smoosh and smooshMap for all!
- Host: GitHub
- URL: https://github.com/nicolaisueper/array-smoosh
- Owner: nicolaisueper
- License: mit
- Created: 2018-03-23T19:19:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:36:58.000Z (about 3 years ago)
- Last Synced: 2025-08-09T01:38:52.240Z (8 months ago)
- Topics: array, flatmap, flatten, javascript, smoosh, smooshgate, smooshmap
- Language: JavaScript
- Size: 308 KB
- Stars: 19
- Watchers: 2
- Forks: 2
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/nicolaisueper/array-smoosh)
[](https://codecov.io/gh/nicolaisueper/array-smoosh)












# array-smoosh
> [Array.prototype.smoosh and smooshMap](https://github.com/tc39/proposal-flatMap/pull/56) polyfill for all!
## Install
```
$ npm install --save array-smoosh
```
Then `import 'array-smoosh'` once, anywhere early inside your application, and you're good to go.
## Features
- Works on older browsers with no own map implementation
- No conditional monkey patching, so the web will never break your website π±
## API
### `Array.prototype.smoosh(level?): Array`
Smooshes the Array. If no level is given, the Array gets smooshed recursively.
```javascript
[1, [2, [3]]].smoosh(1); // => [1, 2, [3]]
['I', ['love', ['funny', ['method', ['names']]]]]
.smoosh()
.join(' '); // => 'I love funny method names'
```
### `Array.prototype.smooshMap(projectionFunction): Array`
Smooshes the Array recursively and applies the given projection function to each element.
```javascript
[1, [2, [3]]].smooshMap(n => n * 3); // => [3, 6, 9]
['smoosh', ['all', ['the', ['things']]]]
.smooshMap(s => s.toUpperCase() + '!')
.join(' ') // => 'SMOOSH! ALL! THE! THINGS!'
```
## Related
[#SmooshGate](https://developers.google.com/web/updates/2018/03/smooshgate) :scream_cat:
## License
MIT Β© Nicolai SΓΌper (nico@k40s.net)