rodr
v1.0.1
Published
Randomly pick a element from an array of objects by a weight callback
Downloads
2
Readme
rodr
Randomly pick a element from an array of objects by a weight callback
Usage
import rdr from 'rodr';
let items = [
{ name: 'Alex', weight: 1 },
{ name: 'Jonny', weight: 2 },
{ name: 'Tom', weight: 3 },
]
console.log(`${items[i].name}: ${(items[i].count / ITERATION * 100).toFixed(2)}%`);