1.0.1 • Published 3 years ago
random-weight-list v1.0.1
random-weight-list
根据权重取列表中的选项
How to use
import randomWeightList from 'random-weight-list'
let arr = [{name: 1, weight: 1}, {name: 2, weight: 2}]
const result = randomWeightList(arr, item => item.weight).name
console.log(result)