1. concat-map
concatenative mapdashery
concat-map
Package: concat-map
Created by: ljharb
Last modified: Thu, 22 Jun 2023 16:31:35 GMT
Version: 0.0.2
License: MIT
Downloads: 192,892,119
Repository: https://github.com/ljharb/concat-map

Install

npm install concat-map
yarn add concat-map

concat-map Version Badge

github actions
coverage
License
Downloads

npm badge

Concatenative mapdashery.

example

 var concatMap = require('concat-map');
var xs = [ 1, 2, 3, 4, 5, 6 ];
var ys = concatMap(xs, function (x) {
    return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
});
console.dir(ys);
 [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]

methods

 var concatMap = require('concat-map')

concatMap(xs, fn)

Return an array of concatenated elements by calling fn(x, i) for each element
x and each index i in the array xs.

When fn(x, i) returns an array, its result will be concatenated with the
result array. If fn(x, i) returns anything else, that value will be pushed
onto the end of the result array.

install

With npm do:

 npm install concat-map

license

MIT

notes

This module was written while sitting high above the ground in a tree.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code