Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
lodash.combinations
Advanced tools
_.combinations(values, n)
Calculates all possible combinations of certain size.
argument | description |
---|---|
values | An iterable of distinct values to calculate the combinations from. |
n | The Number of values to combine. |
Returns a new array of combinations.
let combinations = _.combinations([{a: 11}, {b: 22}, {c: 33}], 2);
// => [[{a: 11}, {b: 22}], [{a: 11}, {c: 33}], [{b: 22}, {c: 33}]]
To calculate all possible combinations of all possible sizes use this code.
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]]
Accepts also array-like values.
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']]
The package can be installed via npm and used as a Node.js module.
const _ = require('lodash');
require('lodash.combinations');
FAQs
Calculates all possible combinations without repetition of a certain size.
The npm package lodash.combinations receives a total of 4,608 weekly downloads. As such, lodash.combinations popularity was classified as popular.
We found that lodash.combinations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.