🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array-mapcat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-mapcat

Curried function deriving new array values by applying provided function to each item/index of provided array then applying `concat` to the results. Fast and compatible with modern or old browsers.

0.1.3
Source
npm
Version published
Weekly downloads
7
-46.15%
Maintainers
1
Weekly downloads
 
Created
Source

array-mapcat

Curried function deriving new array values by applying provided function to each item/index of provided array then applying concat to the results. Fast and compatible with modern or old browsers.

Build Status Code Climate js-standard-style

npm install array-mapcat --save

You can also use Duo, Bower or download the files manually.

npm stats

npm NPM downloads David

Overview

  • This is similar to doing [].concat.apply([], [].map()) but in a more functional and compositionally friendly way.
  • Optionally, a dot-notation formatted string may be provided for item property access.

API Example

Basic
var mapcat = require('array-mapcat')
var splitword = (sentance) => sentance.split(/\s+/)
var sentences = [ 'two birds', 'three green peas' ]

mapcat(splitword, sentences)
//=> ['two', 'birds', 'three', 'green', 'peas']
Dot-notation object access
var mapcat = require('array-mapcat')
var listmodel = [
  { list: [1, 2, 3] },
  { list: [4, 5, 6] },
  { list: [7, 8, 9] }
]

mapcat('list', listmodel)
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
Pointfree Style
var mapcat = require('array-mapcat')
var listmodel = Promise.resolve([
  { list: [1, 2, 3] },
  { list: [4, 5, 6] },
  { list: [7, 8, 9] }
])

listmodel.then(mapcat('list'))
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]

API

mapcat(fn, list)

arguments
  • fn (Function|String) Function to apply to each item.
  • list (array) Array to iterate over.
returns
  • (array) Array resulting from applying provided function fn to each item of list then applying concat to the results.

Inspiration

Alternatives

Contributing

SEE: contributing.md

Licenses

GitHub license

Keywords

array

FAQs

Package last updated on 12 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts