
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
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.
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.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.