JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q34550F
  • License MIT

Pick random items from an array within given weights

Package Exports

  • random-pick-js
  • random-pick-js/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (random-pick-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

random-pick-js

Picks random items from an array within given weights

Installation

npm i random-pick-js

Usage

import { randomPick } from 'random-pick-js'

const picked = randomPick(['icecream', 'cookie', 'anything', 'chicken', 'pizza'], { 
    cnt: 2,
    weights: [1, 3, 10, 2, 7]
});

console.log(picked); // example output: ['anything', 'chicken']