Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

random-elements

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-elements - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

package.json
{
"name": "random-elements",
"version": "0.4.1",
"version": "0.4.2",
"description": "Utility for picking one or more elements from any array",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -28,3 +28,3 @@ # Random Element picker

## Weighted distributions:
Sometimes you want to weight certain outcomes more or less likely than others. This library lets you pass a Map of keys with relative probabilities (weights), and each time you call the function, you will get a single key back but with the probabilities stacked in favour of the ones you weighted higher.
Sometimes you want to weight certain outcomes more or less likely than others. This library lets you pass a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of keys with relative probabilities (weights), and each time you call the function, you will get a single key back but with the probabilities stacked in favour of the ones you weighted higher.

@@ -45,3 +45,5 @@ - `pickKeysWithWeights`

// Expect to get "three" roughly twice as often compared to "one" or "two". The chances of getting "three" any given time is 50%, however - that's probability, folks!
// Expect to get "three" roughly twice as often compared to "one" or "two".
// The chances of getting "three" any given time is 50%, however -
// that's probability, folks!
```

@@ -59,5 +61,6 @@

// Expect to get "heads" roughly twice as often as "tails". That means 66.6% chance vs 33.3% chance, right?
// Expect to get "heads" roughly twice as often as "tails". That means
// 66.6% chance vs 33.3% chance, right?
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc