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

array-cartesian-product

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-cartesian-product

return the cartesian product combinations of a two-entries array

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-76.47%
Maintainers
1
Weekly downloads
 
Created
Source

array-cartesian-product

array-cartesian-product is a method to get the cartesian product combinations of a two-entries array

Install

npm install array-cartesian-product

It can be linked as a script into the browser or used as a npm module

Example

I have 3 sets of filters to combine together

const arrayCartesianProduct = require('arrayCartesianProduct');

const filters = [
    [{filter:'A0'}, {filter:'A1'}, {filter:'A2'}],
    [{filter:'B0'}, {filter:'B1'}, {filter:'B2'}, {filter:'B3'}],
    [{filter:'C0'}, {filter:'C1'}],
];

const combinations = arrayCartesianProduct(filters);
console.log(combinations);

the result

[ [ { filter: 'A0' }, { filter: 'B0' }, { filter: 'C0' } ],
  [ { filter: 'A0' }, { filter: 'B0' }, { filter: 'C1' } ],
  [ { filter: 'A0' }, { filter: 'B1' }, { filter: 'C0' } ],
  [ { filter: 'A0' }, { filter: 'B1' }, { filter: 'C1' } ],
  [ { filter: 'A0' }, { filter: 'B2' }, { filter: 'C0' } ],
  [ { filter: 'A0' }, { filter: 'B2' }, { filter: 'C1' } ],
  [ { filter: 'A0' }, { filter: 'B3' }, { filter: 'C0' } ],
  [ { filter: 'A0' }, { filter: 'B3' }, { filter: 'C1' } ],
  [ { filter: 'A1' }, { filter: 'B0' }, { filter: 'C0' } ],
  [ { filter: 'A1' }, { filter: 'B0' }, { filter: 'C1' } ],
  [ { filter: 'A1' }, { filter: 'B1' }, { filter: 'C0' } ],
  [ { filter: 'A1' }, { filter: 'B1' }, { filter: 'C1' } ],
  [ { filter: 'A1' }, { filter: 'B2' }, { filter: 'C0' } ],
  [ { filter: 'A1' }, { filter: 'B2' }, { filter: 'C1' } ],
  [ { filter: 'A1' }, { filter: 'B3' }, { filter: 'C0' } ],
  [ { filter: 'A1' }, { filter: 'B3' }, { filter: 'C1' } ],
  [ { filter: 'A2' }, { filter: 'B0' }, { filter: 'C0' } ],
  [ { filter: 'A2' }, { filter: 'B0' }, { filter: 'C1' } ],
  [ { filter: 'A2' }, { filter: 'B1' }, { filter: 'C0' } ],
  [ { filter: 'A2' }, { filter: 'B1' }, { filter: 'C1' } ],
  [ { filter: 'A2' }, { filter: 'B2' }, { filter: 'C0' } ],
  [ { filter: 'A2' }, { filter: 'B2' }, { filter: 'C1' } ],
  [ { filter: 'A2' }, { filter: 'B3' }, { filter: 'C0' } ],
  [ { filter: 'A2' }, { filter: 'B3' }, { filter: 'C1' } ] ]

Keywords

FAQs

Package last updated on 15 Mar 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

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