random-weighted-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

random-weight

Randomly pick an array item by weight callback

Usage

import rndw from "random-weighted-ts";
let items = [
  { name: "Alex", weight: 1 },
  { name: "Jonny", weight: 2 },
  { name: "Tom", weight: 3 },
];

console.log(rndw(items, (i) => i.weight).name, " is picked!");

Readme

Keywords

none

Package Sidebar

Install

npm i random-weighted-ts

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

14.9 kB

Total Files

8

Last publish

Collaborators

  • skycoco