Skip to content

Instantly share code, notes, and snippets.

@AWilco
Forked from samgiles/flatMap.js
Created September 7, 2016 12:14
Show Gist options
  • Save AWilco/9f6aa88406a7f26687a368e389ebf672 to your computer and use it in GitHub Desktop.
Save AWilco/9f6aa88406a7f26687a368e389ebf672 to your computer and use it in GitHub Desktop.
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Object.defineProperties(Array.prototype, {
'flatMap': {
value: function (lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
},
writeable: false,
enumerable: false
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment