random-wight-elements
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

random-weight-elements

Randomly pick an arry item by weight callbacl

Usage

import rnd from 'random-weight-elements'
let items = [
  {
    name: 'Alex',
    weight: 1
  },
  {
    name: 'Jonny',
    weight: 2
  }
]

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

Readme

Keywords

none

Package Sidebar

Install

npm i random-wight-elements

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

11.1 kB

Total Files

8

Last publish

Collaborators

  • hold-bailong