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

array-combos

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-combos

A function to get the unique item combinations from an array

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37
decreased by-39.34%
Maintainers
1
Weekly downloads
 
Created
Source

Array Combos

A function to get the unique item combinations from an array

  • Plain old vanilla JS
  • Just 0.6kb gzipped
  • Does not use generators

Installation

npm install array-combos

Usage

import combos from 'array-combos'

const arr = [ 1, 2, 3 ]

console.log(combos(arr))

// [
//   [],
//   [ 1 ],
//   [ 2 ],
//   [ 3 ],
//   [ 1, 2 ],
//   [ 1, 3 ],
//   [ 2, 3 ],
//   [ 1, 2, 3 ]
// ]

An optional second argument will restrict results to combinations with that number of items.

import combos from 'array-combos'

const arr = [ 1, 2, 3 ]

console.log(combos(arr, 2))

// [
//   [ 1, 2 ],
//   [ 1, 3 ],
//   [ 2, 3 ],
// ]

Browser support

Array Combos is packaged with Babel, and makes use of Array.from. If you want Array Combos to work on browsers that don't support this method (e.g. IE11), then you will need to polyfill Array.from before using combos.

Keywords

FAQs

Package last updated on 26 Nov 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

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