1.0.3 • Published 6 years ago

random-items-weight v1.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

random-items-weight

npm.io

Randomly pick a item from an array of items by a weight callback

Usage

npm i -S random-items-weight
import rdwt from 'random-items-weight'

let items = [
    {
        name: 'Alex',
        weight: 3
    },
    {
        name: 'John',
        weight: 2
    },
    {
        name: 'Tom',
        weight: 1
    }
]

console.log(rdwt(items,i => i.weight).name,' is picked')
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago