lodash.combinations
Advanced tools
Comparing version
{ | ||
"name": "lodash.combinations", | ||
"version": "18.9.19", | ||
"version": "18.10.0", | ||
"description": "Calculates all possible combinations of a certain size.", | ||
@@ -8,2 +8,3 @@ "keywords": [ | ||
"collection", | ||
"combination", | ||
"combinatorics", | ||
@@ -15,4 +16,5 @@ "lodash", | ||
"author": "Sergej Sintschilin <seregpie@gmail.com>", | ||
"main": "lodash.combinations.js", | ||
"repository": "https://github.com/SeregPie/lodash.combinations.git", | ||
"files": [], | ||
"main": "index.js", | ||
"repository": "github:SeregPie/lodash.combinations", | ||
"scripts": { | ||
@@ -24,10 +26,12 @@ "build": "rollup -c", | ||
"devDependencies": { | ||
"@seregpie/rollup-plugin-resolve": "^18.6.13", | ||
"rollup": "^0.66.0", | ||
"rollup-plugin-babel-minify": "^6.0.0", | ||
"rollup-plugin-buble": "^0.19.2" | ||
"@rollup/plugin-buble": "^0.21.3", | ||
"eslint": "7.1.0", | ||
"eslint-config-seregpie": "^1.0.1", | ||
"lodash": "^4.17.15", | ||
"rollup": "^2.13.1", | ||
"rollup-plugin-terser": "^6.1.0" | ||
}, | ||
"peerDependencies": { | ||
"lodash": "^4.17.11" | ||
"lodash": "^4.0.0" | ||
} | ||
} |
@@ -10,10 +10,6 @@ # lodash.combinations | ||
| `collection` | A collection of distinct values to calculate the combinations from. | | ||
| `n` | The Number of values to combine. | | ||
| `n` | The number of values to combine. | | ||
Returns a new array of combinations. | ||
Returns a new array. | ||
## dependencies | ||
- [lodash](https://github.com/lodash/lodash) | ||
## setup | ||
@@ -24,3 +20,3 @@ | ||
```shell | ||
npm install lodash.combinations | ||
npm i lodash.combinations | ||
``` | ||
@@ -52,4 +48,4 @@ | ||
```javascript | ||
let combinations = _.combinations([{a: 11}, {b: 22}, {c: 33}], 2); | ||
// => [[{a: 11}, {b: 22}], [{a: 11}, {c: 33}], [{b: 22}, {c: 33}]] | ||
let combinations = _.combinations([true, {a: 1}, null], 2); | ||
// => [[true, {a: 1}], [true, null], [{a: 1}, null]] | ||
``` | ||
@@ -59,7 +55,7 @@ | ||
To calculate all possible combinations of all possible sizes use this code. | ||
Calculate all possible combinations of all possible sizes. | ||
```javascript | ||
let combinations = _.flatMap([1, 2, 3], (v, i, a) => _.combinations(a, i + 1)); | ||
// => [[1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] | ||
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]] | ||
``` | ||
@@ -69,7 +65,14 @@ | ||
Accepts also array-like values. | ||
Also accepts array-like values. | ||
```javascript | ||
let combinations = _.combinations('abcde', 3); | ||
// => [['a', 'b', 'c'], ['a', 'b', 'd'], ['a', 'b', 'e'], ['a', 'c', 'd'], ['a', 'c', 'e'], ['a', 'd', 'e'], ['b', 'c', 'd'], ['b', 'c', 'e'], ['b', 'd', 'e'], ['c', 'd', 'e']] | ||
let combinations = _('abcde').combinations(3).map(v => _.join(v, '')).value(); | ||
// => ['abc', 'abd', 'abe', 'acd', 'ace', 'ade', 'bcd', 'bce', 'bde', 'cde'] | ||
``` | ||
## see also | ||
- [lodash.permutations](https://github.com/SeregPie/lodash.permutations) | ||
- [lodash.multicombinations](https://github.com/SeregPie/lodash.multicombinations) | ||
- [lodash.multipermutations](https://github.com/SeregPie/lodash.multipermutations) | ||
- [lodash.product](https://github.com/SeregPie/lodash.product) |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3945
0.69%74
4.23%6
50%