random-items-weight
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    random-items-weight

    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')
     

    Install

    npm i random-items-weight

    DownloadsWeekly Downloads

    16

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    11.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • dkkevincheng