ts-weighted-random
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

ts-weighted-random

Picks a random value from a list based on the weights.

Installation

  npm install ts-weighted-random

Usage

import weightedRandom from "ts-weighted-random";

const map = new Map([
  [1, 1],
  [2, 1],
  [3, 5], // This item has 5 times more chances of being picked
]);

weightedRandom(map);

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i ts-weighted-random

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

4.33 kB

Total Files

10

Last publish

Collaborators

  • evandrolg