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

@agarimo/cartesian

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

@agarimo/cartesian

Computes the cartesian product of arrays

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cartesian

Computes the cartesian product of arrays

Examples

const { cartesian } = require('@agarimo/cartesian');
const input = [[1, 2], [3, 4, 5], [6], [7, 8]];
const actual = cartesian(input);
console.log(actual);
// [
//   [ 1, 3, 6, 7 ], [ 1, 3, 6, 8 ],
//   [ 1, 4, 6, 7 ], [ 1, 4, 6, 8 ],
//   [ 1, 5, 6, 7 ], [ 1, 5, 6, 8 ],
//   [ 2, 3, 6, 7 ], [ 2, 3, 6, 8 ],
//   [ 2, 4, 6, 7 ], [ 2, 4, 6, 8 ],
//   [ 2, 5, 6, 7 ], [ 2, 5, 6, 8 ]
// ]

You can have elements that are not an array

const { cartesian } = require('@agarimo/cartesian');
const input = [[1, 2], [3, 4, 5], 6, [7, 8]];
const actual = cartesian(input);
console.log(actual);
// [
//   [ 1, 3, 6, 7 ], [ 1, 3, 6, 8 ],
//   [ 1, 4, 6, 7 ], [ 1, 4, 6, 8 ],
//   [ 1, 5, 6, 7 ], [ 1, 5, 6, 8 ],
//   [ 2, 3, 6, 7 ], [ 2, 3, 6, 8 ],
//   [ 2, 4, 6, 7 ], [ 2, 4, 6, 8 ],
//   [ 2, 5, 6, 7 ], [ 2, 5, 6, 8 ]
// ]

FAQs

Package last updated on 16 Apr 2022

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