
Research
/Security News
Compromised npm Packages in the AsyncAPI Namespace Deliver Miasma Botnet Loader
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.
items-picker
Advanced tools
Get a random combination from a list of items.
You can install this library using npm:
npm install items-picker
getRandomCombination<T>(items: T[], key: keyof T, maxSum: number, allowDuplicates: boolean = true): T[]Retrieves a random combination of items from the provided array. The combination's sum is constrained to be less than or equal to maxSum. The function retrieves items until no more valid items can be found.
| Parameter | Type | Description |
|---|---|---|
items | T[] | Array of items to select from. |
key | keyof T | The key of the item object which has a numeric value. |
maxSum | number | Maximum allowed sum of the values associated with the key. |
allowDuplicates | boolean | Flag indicating whether duplicate items are allowed. Defaults to true. |
An array containing the combination of items based on the constraints.
import { getRandomCombination } from "random-item-picker";
const items = [
{ id: 1, value: 100 },
{ id: 2, value: 200 },
{ id: 3, value: 300 },
];
// Get a random combination of items with a total value of up to 500
const randomCombination = getRandomCombination(items, "value", 500, false);
console.log(randomCombination);
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Get a random combination from a list of items.
The npm package items-picker receives a total of 4 weekly downloads. As such, items-picker popularity was classified as not popular.
We found that items-picker 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
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.

Research
/Security News
A malicious .NET package is typosquatting the Braintree SDK to steal live payment card data, merchant API keys, and host secrets from production apps.