Skip to content

micro-js/flat-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flat-map

Build status Git tag NPM version Code style

Map over a (possibly nested) list, executing a function on each scalar item, and returning the result as a flat list

Installation

$ npm install @f/flat-map

Usage

var flatMap = require('@f/flat-map')

flatMap(n => n + 1, [[2, 3], [4, 5]]) // -> [3, 4, 5, 6]

API

flatMap(fn, arr)

  • fn - Function to map the elements of arr and its sublists over
  • arr - Possibly nested array to be mapped over fn

Returns: Returns a flat list, with each scalar element in arr (no matter how deeply nested) replaced with the result of fn(value).

License

MIT

About

Map over a (possibly nested) list, executing a function on each scalar item, and returning the result as a flat list

Resources

Stars

Watchers

Forks

Packages

No packages published