New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mapmany

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapmany

maps one to many instead of one to one

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

mapMany

just a simple function to achieve results like so:

let data = [{foo: 'b', stuff: [1,2]},{foo: 'c', stuff: [3,4]}]
let mappedData = mapMany(data,(item)=>{
    return item['stuff'].map((stuff)=>{
        let obj = {}
        obj['foo'] = item['foo']
        obj['thing'] = stuff
        return obj
    })
})

mappedData now looks like this:

[ { foo: 'b', thing: 1 },
  { foo: 'b', thing: 2 },
  { foo: 'c', thing: 3 },
  { foo: 'c', thing: 4 } ]

FAQs

Package last updated on 08 Oct 2017

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