# multi-weighted-random

> Randomly select multiple entries from a weighted list.

Latest version **1.0.1** (published 2019-01-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install multi-weighted-random
pnpm add multi-weighted-random
yarn add multi-weighted-random
bun add multi-weighted-random
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-01-01 |
| First published | 2019-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shawn Johnson |
| Maintainers | shawrkbait |
| Keywords | random, weighted, list |

## Links

- npm: https://www.npmjs.com/package/multi-weighted-random
- Repository: https://github.com/shawrkbait/multi-weighted-random
- Homepage: https://github.com/shawrkbait/multi-weighted-random#readme
- Issues: https://github.com/shawrkbait/multi-weighted-random/issues
- npm.io page: https://npm.io/package/multi-weighted-random

## Recent versions

- 1.0.1 (latest) — 2019-01-01

## README

# multi-weighted-random

Randomly select multiple entries from a weighted list.

## Usage

```js
var weightedRandom = require('multi-weighted-random');

var options = [
    { weight: 2.0, name: 'option1' },
    { weight: 1.5, name: 'option2' },
    { weight: 3.2, name: 'option3' }
];

var weights = options.map(function (opt) {
    return opt.weight;
}); // [2.0, 1.5, 3.2]

// Select 2 item indices from the options
var selections = weightedRandom(weights,2);

for(var i=0; i<selections.length; i++) {
  console.log("Chose " + options[selections[i]].name);
}
```

## License

Copyright &copy; 2018 Shawn Johnson. All rights reserved. Licensed under the terms of the MIT license, the full text of which is available in [LICENSE](LICENSE).

---
_Source: https://npm.io/package/multi-weighted-random · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
