# combinations

> find all combinations from array

Latest version **1.0.0** (published 2019-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install combinations
pnpm add combinations
yarn add combinations
bun add combinations
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-11-04 |
| First published | 2012-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/combinations) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Greg Allen |
| Maintainers | jga |
| Keywords | combination, combo, array |

## Links

- npm: https://www.npmjs.com/package/combinations
- Repository: https://github.com/jgallen23/combinations
- Homepage: https://github.com/jgallen23/combinations#readme
- Issues: https://github.com/jgallen23/combinations/issues
- npm.io page: https://npm.io/package/combinations

## Recent versions

- 1.0.0 (latest) — 2019-11-04
- 0.1.1 — 2016-06-06
- 0.1.0 — 2012-08-12

## README

Combinations [![Build Status](https://travis-ci.org/jgallen23/combinations.svg?branch=master)](https://travis-ci.org/jgallen23/combinations)
============

# Installation

    npm install combinations

# Usage

    combinations(array[, min_output_array_size])

*   takes in an array, and outputs an array of arrays, containing all possible combinations of values in the original array.
*   combinations are of all sizes: all combinations of one element, and all combinations of 2 elements, and so on
*   minimum number of elements in a combination can be specified (min_output_array_size)
*   maximum number of elements in a combination can be also specified
*   if maximum combination value is bigger than array elements it will be overridden to the array length

# Example

    var combinations = require('combinations');
    var myArray = ['red', 'orange', 'yellow', 'green'];
    
    combinations(myArray); 
  
    //Output:
    //  [ [ 'red' ],                      [ 'orange' ],    
    //    [ 'yellow' ],                   [ 'green' ],  
    //    [ 'red', 'orange' ],            [ 'red', 'yellow' ],
    //    [ 'red', 'green' ],             [ 'orange', 'yellow' ],
    //    [ 'orange', 'green' ],          [ 'yellow', 'green' ],
    //    [ 'red', 'orange', 'yellow' ],  [ 'red', 'orange', 'green' ],
    //    [ 'red', 'yellow', 'green' ],   [ 'orange', 'yellow', 'green' ],
    //    [ 'red', 'orange', 'yellow', 'green' ] ]

# Example with a minimum array size

    combinations(myArray, 2);
    
    //Output:
    //  [ [ 'red', 'orange' ],            [ 'red', 'yellow' ],
    //    [ 'red', 'green' ],             [ 'orange', 'yellow' ],
    //    [ 'orange', 'green' ],          [ 'yellow', 'green' ],
    //    [ 'red', 'orange', 'yellow' ],  [ 'red', 'orange', 'green' ],
    //    [ 'red', 'yellow', 'green' ],   [ 'orange', 'yellow', 'green' ],
    //    [ 'red', 'orange', 'yellow', 'green' ] ]

# Example with a minimum and maximum array size

    combinations(myArray, 2, 3);
    
    //Output:
    //  [ [ 'red', 'orange' ],            [ 'red', 'yellow' ],
    //    [ 'red', 'green' ],             [ 'orange', 'yellow' ],
    //    [ 'orange', 'green' ],          [ 'yellow', 'green' ],
    //    [ 'red', 'orange', 'yellow' ],  [ 'red', 'orange', 'green' ],
    //    [ 'red', 'yellow', 'green' ],   [ 'orange', 'yellow', 'green' ] ]

---
_Source: https://npm.io/package/combinations · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
