1.0.0 • Published 7 years ago

@f/flat-map v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

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