Nodejs Array Concatenate Map concatMap(fn)

Here you can find the source of concatMap(fn)

Method Source Code

/**//from w ww .j  a v a  2  s.  c  o m
 * Function does the same behavior as map and concatAll in action.
 * @param fn => fn is a callback.
 */
Array.prototype.concatMap = function(fn) {
    return this
        .map((item, index, arr) => fn(index))
        .concatAll();
};

Related

  1. concatMap()
    Array.prototype.concatMap = function() {
      return this.map(function(item) {
          return projectionFunction(item);
        }).concatAll();
    };
    
  2. concatMap(cb)
    'use strict';
    Array.prototype.concatMap = function (cb) {
        return this.map(cb).concatAll()
    
  3. concatMap(f)
    'use strict';
    var j = require('junify');
    Array.prototype.concatMap = function (f) {
      return Array.prototype.concat.apply([], this.map(f));
    };
    j.matchesAny = function (patterns) {
      return function (it) {
        return patterns.some(function (pattern) {
          return  j.unify(pattern, it);
    ...
    
  4. concatMap(f)
    'use strict';
    let j = require('junify');
    Array.prototype.concatMap = function (f) {
      return Array.prototype.concat.apply([], this.map(f));
    };
    j.matchesAny = function (patterns) {
      return (it) => patterns.some(pattern => j.unify(pattern, it));
    };
    j.match = function (arg, cases) {
    ...
    
  5. concatMap(modifierFunction)
    Array.prototype.concatMap = function (modifierFunction) {
        return this.map(modifierFunction).concatAll();
    
  6. concatMap(projectionFunction)
    Array.prototype.concatMap = function(projectionFunction){
      return this.map(function(item){
        return projectionFunction(item);
      }).concatAll();
    
  7. concatMap(projectionFunctionThatReturnsArray)
    Array.prototype.concatMap = function (projectionFunctionThatReturnsArray) {
      return this.
        map(function (item) {
          return projectionFunctionThatReturnsArray(item);
        }).
        concatAll();
    };
    
  8. concatMap(projectionFunctionThatReturnsArray)
    Array.prototype.concatMap = function(projectionFunctionThatReturnsArray) {
      return this.
        map(function(item) {
          return this.map((i) => {
            return i;
          }).concatAll();
        }).
        concatAll();
    };
    ...