lodash.combinations
Advanced tools
Comparing version 17.8.19 to 17.12.17
@@ -1,24 +0,1 @@ | ||
(function(_) { | ||
_.mixin({combinations: function(values, n) { | ||
values = _.values(values); | ||
var combinations = []; | ||
(function f(combination, index) { | ||
if (combination.length < n) { | ||
_.find(values, function(value, index) { | ||
f(_.concat(combination, [value]), index + 1); | ||
}, index); | ||
} else { | ||
combinations.push(combination); | ||
} | ||
})([], 0); | ||
return combinations; | ||
}}); | ||
})((function() { | ||
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && this === exports) { | ||
return require('lodash'); | ||
} else { | ||
return _; | ||
} | ||
}).call(this)); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],t):t(n._)}(this,function(n){"use strict";(n=n&&n.hasOwnProperty("default")?n.default:n).mixin({combinations:function(t,e){t=n.values(t);var o=[];return function(n){var t=function(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];return n.call.apply(n,[this,t].concat(e))};return t}(function(i,f,u){f.length<e?n.find(t,function(t,e){i(n.concat(f,[t]),e+1)},u):o.push(f)})([],0),o}})}); |
{ | ||
"name": "lodash.combinations", | ||
"version": "17.8.19", | ||
"description": "Calculates all possible combinations of certain size.", | ||
"main": "lodash.combinations.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/SeregPie/lodash.combinations.git" | ||
}, | ||
"author": "Sergej Sintschilin", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/SeregPie/lodash.combinations/issues" | ||
}, | ||
"homepage": "https://github.com/SeregPie/lodash.combinations#readme", | ||
"dependencies": { | ||
"lodash": "latest" | ||
} | ||
"name": "lodash.combinations", | ||
"version": "17.12.17", | ||
"description": "Calculates all possible combinations of certain size.", | ||
"main": "lodash.combinations.js", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/SeregPie/lodash.combinations.git" | ||
}, | ||
"keywords": [ | ||
"array", | ||
"collection", | ||
"combinatorics", | ||
"lodash", | ||
"mixin" | ||
], | ||
"author": "Sergej Sintschilin", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/SeregPie/lodash.combinations/issues" | ||
}, | ||
"homepage": "https://github.com/SeregPie/lodash.combinations#readme", | ||
"dependencies": { | ||
"lodash": "^4.17.4" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.13.1", | ||
"rollup": "^0.52.2", | ||
"rollup-plugin-buble": "^0.18.0", | ||
"rollup-plugin-uglify": "^2.0.1" | ||
} | ||
} |
@@ -20,3 +20,3 @@ # lodash.combinations | ||
Install the [package](https://www.npmjs.com/package/lodash.combinations) via npm. | ||
### npm | ||
@@ -29,13 +29,22 @@ ```sh | ||
Import the module into your Node.js project. | ||
### ES module | ||
```javascript | ||
```js | ||
import _ from 'lodash'; | ||
import 'lodash.combinations'; | ||
``` | ||
### Node | ||
```js | ||
const _ = require('lodash'); | ||
require('lodash.combinations'); | ||
``` | ||
--- | ||
### browser | ||
Include the code in your page via a CDN. | ||
```html | ||
@@ -50,5 +59,7 @@ | ||
```javascript | ||
```js | ||
let combinations = _.combinations([{a: 11}, {b: 22}, {c: 33}], 2); | ||
// => [[{a: 11}, {b: 22}], [{a: 11}, {c: 33}], [{b: 22}, {c: 33}]] | ||
``` | ||
@@ -60,5 +71,7 @@ | ||
```javascript | ||
```js | ||
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]] | ||
``` | ||
@@ -70,5 +83,7 @@ | ||
```javascript | ||
```js | ||
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']] | ||
``` |
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
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
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
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
85
3850
4
4
3
1
Updatedlodash@^4.17.4