rodr
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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)}%`);

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i rodr

    Weekly Downloads

    0

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    10.4 kB

    Total Files

    8

    Last publish

    Collaborators

    • qiao195423