Nodejs Array Flat Map flatMap(projection)

Here you can find the source of flatMap(projection)

Method Source Code

Array.prototype.flatMap = function(projection) {
    return this./*  ww  w .j  a v a 2 s . co m*/
        map(function(item) {
            return projection(item);
        }).
        mergeAll();
}

Related

  1. flatMap(fn, ctx)
    Array.prototype.flatMap = function(fn, ctx) {
      return this.reduce((k, v) => k.concat(fn.call(ctx, v)), []);
    };
    
  2. flatMap(lambda)
    Array.prototype.flatMap = function(lambda) { 
          return Array.prototype.concat.apply([], this.map(lambda)); 
    };
    
  3. flatMap(lambda)
    Array.prototype.flatMap = function(lambda) {
        return [].concat(this.map(lambda));
    };
    
  4. flatMap(lambda)
    Array.prototype.flatMap = Array.prototype.flatMap || function(lambda) {
      return Array.prototype.concat.apply([], this.map(lambda));
    
  5. flatMap(mapFunc)
    Array.prototype.flatMap = function(mapFunc) {
      var result = []
      for (let item of this) {
        let tokens = mapFunc(item)
        result = result.concat(tokens)
      return result