Nodejs Array Concatenate Map concatMap()

Here you can find the source of concatMap()

Method Source Code

Array.prototype.concatMap = function() {
   return this.map(function(item) {
         return projectionFunction(item);
      }).concatAll();//from  w  w  w . j a  va2s.c om
      // apply the concatAll function to flatten the two-dimensional array
//      allWords.concatAll();
};

Related

  1. concatMap(cb)
    'use strict';
    Array.prototype.concatMap = function (cb) {
        return this.map(cb).concatAll()
    
  2. 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);
    ...
    
  3. 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) {
    ...
    
  4. concatMap(fn)
    Array.prototype.concatMap = function(fn) {
        return this
            .map((item, index, arr) => fn(index))
            .concatAll();
    };