Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.combinations

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.combinations

Calculates all possible combinations without repetition of a certain size.

  • 18.11.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

lodash.combinations

_.combinations(collection, k)

Calculates all possible combinations without repetition of a certain size.

argumentdescription
collectionA collection of distinct values to calculate the groups from.
kA number as the size of each group.

Returns the calculated groups as an array of arrays.

setup

npm i lodash.combinations

import 'lodash.combinations';
import _ from 'lodash';

CDN

<script src="https://unpkg.com/lodash"></script>
<script src="https://unpkg.com/lodash.combinations"></script>

usage

let combinations = _.combinations([true, {a: 1}, null], 2);
// => [[true, {a: 1}], [true, null], [{a: 1}, null]]

Calculate all possible combinations of all possible sizes.

let combinations = _.flatMap([2, 4, 6], (v, i, a) => _.combinations(a, i + 1));
// => [[2], [4], [6], [2, 4], [2, 6], [4, 6], [2, 4, 6]]

see also

  • lodash.permutations
  • lodash.multicombinations
  • lodash.multipermutations
  • lodash.product

Keywords

FAQs

Package last updated on 05 Jun 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