Skip to content
Array.prototype.smoosh and smooshMap for all!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
src
.gitignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json

README.md

Build Status Coverage Zero Dependencies smooshGate Blazing Fast For Humans Enterprise Grade Production Ready Future proof Modern Extremely Lightweight Totally Secure Bug Free Just Works

array-smoosh

Array.prototype.smoosh and smooshMap polyfill for all!

Install

$ npm install --save array-smoosh

Then import 'array-smoosh' anywhere 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.

[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.

[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 🙀

License

MIT © Nicolai Süper (nico@k40s.net)

You can’t perform that action at this time.