JS Random Urn Draw
A simple js-class to put an array into an urn and draw random items from it - with or without replacement.
Installation
Download this project via Github and add it manually to your project or install the JSON File Storage npm / yarn package:
npm i js-random-urn-draw
/
yarn add js-random-urn-draw
How to Use / API
const Urn = ; // adjust the require path, if not installed via npm/yarn const items = "🍏" "🍒" "🍌"; // urn WITH replacementconst urn = items; urn; // "🍌"urn; // ["🍒", "🍏", "🍒", "🍌", "🍌"] urn; // ["🍌", "🍏", "🍒"] // urn WITHOUT replacementconst urn_without = items false; urn_without; // "🍌"urn_withoutcontent; // ["🍏", "🍒"]urn_withoutextractedContent; // ["🍌"] urn; // ["🍏", "🍒"]urn_withoutcontent; // []urn_withoutextractedContent; // ["🍏", "🍒", "🍌"]
Donate
If you like the project and it saved you a while of coding, spend me a coffee (or all of your savings) to keep me motivated: paypal.me