# wariai

> Randomly choose between weighted options

Latest version **1.0.3** (published 2019-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install wariai
pnpm add wariai
yarn add wariai
bun add wariai
```

## 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.3 |
| Published | 2019-06-25 |
| First published | 2019-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | thibautbessone |
| Maintainers | thibautbessone |
| Keywords | javascript, random, weight, picker |

## Links

- npm: https://www.npmjs.com/package/wariai
- Repository: https://github.com/thibautbessone/wariai
- Homepage: https://github.com/thibautbessone/wariai#readme
- Issues: https://github.com/thibautbessone/wariai/issues
- npm.io page: https://npm.io/package/wariai

## Recent versions

- 1.0.3 (latest) — 2019-06-25
- 1.0.2 — 2019-06-13
- 1.0.1 — 2019-06-12
- 1.0.0 — 2019-06-04

## README

# Wariai

#### Shuffles randomly a list or pick an option among several weighted ones

#### Install

With npm : `npm install wariai`

First, create a JSON string containing your options & weights following this pattern : 

```javascript
let obj = '[{ "option": "test1", "weight": 1},{ "option": "test2", "weight": 2},{ "option": "test3", "weight": 3},{ "option": "test4", "weight": 4}]';
```

Then, create the picker object : 

```javascript
let picker = new Picker(obj);
```

You can now pick an element or shuffle the list with the following code : 

```javascript
picker.pickOneWithWeight(); // Returns a random object from the list, taking weights into account
picker.getRandomizedList(); // Returns a randomly shuffled list of elements
```

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