New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

array-product

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

array-product

Returns an array of all combinations of elements from all arrays.

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

array-product

Returns an array of all combinations of elements from all arrays.

A simple function to duplicate Ruby's Array#product, but without extending the function on Array's prototype.

Support

This makes use of Array.prototype.flatMap which has limited support in both Node and browsers. For Node this means for native flatMap support you need to be above Node 10.x. If you are using this for browsers either polyfill the functionality with your favorite tool or core-js.

Caniuse browser support.

Use

const product = require('array-product');

product([1,2,3], [4,5])     // [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]]
product([1,2], [1,2])       // [[1,1],[1,2],[2,1],[2,2]]
product([1,2], [3,4],[5,6]) // [[1,3,5],[1,3,6],[1,4,5],[1,4,6],
                            //     [2,3,5],[2,3,6],[2,4,5],[2,4,6]]
product([1,2], nil)         // [[1],[2]]
product([1,2], [])          // []

FAQs

Package last updated on 08 Sep 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc