Here you can find the source of concatMap(f)
'use strict';/*from w w w .j a va2 s. co m*/ 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); }); }; }; j.match = function (arg, cases) { for (var i = 0; i < cases.length; i++) { var pattern = cases[i][0]; var callback = cases[i][1]; var match = j.unify(pattern, arg); if (match) { return callback(match); } } throw new Error('Non exhaustive pattern-matching: ' + JSON.stringify(arg)); }; j.case = function (pattern, action) { return [pattern, action]; }; module.exports = { j: j };
Array.prototype.concatMap = function() { return this.map(function(item) { return projectionFunction(item); }).concatAll(); };
'use strict'; Array.prototype.concatMap = function (cb) { return this.map(cb).concatAll()
'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) { ...
Array.prototype.concatMap = function(fn) { return this .map((item, index, arr) => fn(index)) .concatAll(); };
Array.prototype.concatMap = function (modifierFunction) { return this.map(modifierFunction).concatAll();
Array.prototype.concatMap = function(projectionFunction){ return this.map(function(item){ return projectionFunction(item); }).concatAll();