lodash.combinations
Advanced tools
Comparing version 18.10.0 to 18.11.0
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],n):n((e=e||self)._)}(this,(function(e){"use strict";(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).mixin({combinations:function(n,t){var f=e.values(n);if(f.length<t)return[];var i=function(e,n){if(--n<0)return[[]];var t=[];e=e.slice();for(var f=function(){var f=e.shift();i(e,n).forEach((function(e){e.unshift(f),t.push(e)}))};e.length-n;)f();return t};return i(f,t)}})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)._)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);n.default.mixin({combinations:function(e,t){let f=n.default.values(e);if(f.length<t)return[];let i=(e,t)=>{if(--t<0)return[[]];let n=[];for(e=e.slice();e.length-t;){let f=e.shift();i(e,t).forEach((e=>{e.unshift(f),n.push(e)}))}return n};return i(f,t)}})})); |
{ | ||
"name": "lodash.combinations", | ||
"version": "18.10.0", | ||
"description": "Calculates all possible combinations of a certain size.", | ||
"version": "18.11.0", | ||
"description": "Calculates all possible combinations without repetition of a certain size.", | ||
"keywords": [ | ||
@@ -17,2 +17,3 @@ "array", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"repository": "github:SeregPie/lodash.combinations", | ||
@@ -25,12 +26,21 @@ "scripts": { | ||
"devDependencies": { | ||
"@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" | ||
"@babel/core": "^7.17.12", | ||
"@babel/preset-env": "^7.17.12", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@types/lodash": "^4.14.182", | ||
"eslint": "^8.15.0", | ||
"eslint-config-seregpie": "^1.2.1", | ||
"lodash": "^4.17.21", | ||
"rollup": "^2.73.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
"peerDependencies": { | ||
"lodash": "^4.0.0" | ||
"@types/lodash": "^4", | ||
"lodash": "^4" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@types/lodash": { | ||
"optional": true | ||
} | ||
} | ||
} |
# lodash.combinations | ||
`_.combinations(collection, n)` | ||
`_.combinations(collection, k)` | ||
Calculates all possible combinations of a certain size. | ||
Calculates all possible combinations without repetition of a certain size. | ||
| argument | description | | ||
| ---: | :--- | | ||
| `collection` | A collection of distinct values to calculate the combinations from. | | ||
| `n` | The number of values to combine. | | ||
| `collection` | A collection of distinct values to calculate the groups from. | | ||
| `k` | A number as the size of each group. | | ||
Returns a new array. | ||
Returns the calculated groups as an array of arrays. | ||
## setup | ||
### npm | ||
```shell | ||
@@ -22,3 +20,3 @@ npm i lodash.combinations | ||
### ES module | ||
--- | ||
@@ -30,11 +28,5 @@ ```javascript | ||
### Node | ||
```javascript | ||
require('lodash.combinations'); | ||
let _ = require('lodash'); | ||
``` | ||
### CDN | ||
### browser | ||
```html | ||
@@ -61,11 +53,2 @@ <script src="https://unpkg.com/lodash"></script> | ||
--- | ||
Also accepts array-like values. | ||
```javascript | ||
let combinations = _('abcde').combinations(3).map(v => _.join(v, '')).value(); | ||
// => ['abc', 'abd', 'abe', 'acd', 'ace', 'ade', 'bcd', 'bce', 'bde', 'cde'] | ||
``` | ||
## see also | ||
@@ -72,0 +55,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3946
2
9
57