@f/flat-map

1.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @f/flat-map

Weekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • f