# lodash.permutations

> Calculates all possible permutations of a certain size.

Latest version **1.0.0** (published 2020-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install lodash.permutations
pnpm add lodash.permutations
yarn add lodash.permutations
bun add lodash.permutations
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-06-04 |
| First published | 2020-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Sergej Sintschilin |
| Maintainers | seregpie |
| Keywords | array, collection, combinatorics, lodash, mixin, permutation |

## Links

- npm: https://www.npmjs.com/package/lodash.permutations
- Repository: https://github.com/SeregPie/lodash.permutations
- Homepage: https://github.com/SeregPie/lodash.permutations#readme
- Issues: https://github.com/SeregPie/lodash.permutations/issues
- npm.io page: https://npm.io/package/lodash.permutations

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-06-04

## README

# lodash.permutations

`_.permutations(collection, n)`

Calculates all possible permutations of a certain size.

| argument | description |
| ---: | :--- |
| `collection` | A collection of distinct values to calculate the permutations from. |
| `n` | The number of values to combine. |

Returns a new array.

## setup

### npm

```shell
npm i lodash.permutations
```

### ES module

```javascript
import 'lodash.permutations';
import _ from 'lodash';
```

### Node

```javascript
require('lodash.permutations');
let _ = require('lodash');
```

### browser

```html
<script src="https://unpkg.com/lodash"></script>
<script src="https://unpkg.com/lodash.permutations"></script>
```

## usage

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

---

Calculate all possible permutations of all possible sizes.

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

---

Also accepts array-like values.

```javascript
let permutations = _('abc').permutations(3).map(v => _.join(v, '')).value();
// => ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
```

## see also

- [lodash.combinations](https://github.com/SeregPie/lodash.combinations)
- [lodash.multicombinations](https://github.com/SeregPie/lodash.multicombinations)
- [lodash.multipermutations](https://github.com/SeregPie/lodash.multipermutations)
- [lodash.product](https://github.com/SeregPie/lodash.product)

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