@leetcoderoulette/roulette
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Welcome to Leetcoderoulette Roulette 👋

Build status code coverage install size

Roulette class that returns a random value similar to a roulette table.

Installing

Using npm:

$ npm install @leetcoderoulette/roulette

Example

note: CommonJS usage

In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require() use the following approach:

const Roulette = require('@leetcoderoulette/roulette');

// Roulette.<method> will now provide autocomplete and parameter typings

Creating a new Roulette object and getting problems

const roulette = new Roulette(["Hello", "World"]);

const values = roulette.values; // Returns ["Hello", "World"]
const value = roulette.pop(); // Returns either "Hello" or "World"

Adding a new set

roulette.values = ["New", "Problems"];

const values = roulette.values; // Returns ["New", "Problems"]

Roulette API

A roulette object can be made by passing in an array of values to Roulette.

Roulette(values, options?)
// Create a new Roulette object.
new Roulette(["value1", "value2"]);

Instance methods

The available instance methods are listed below.

roulette.pop()
get roulette.values()
set roulette.values(values)

TypeScript

Roulette includes TypeScript definitions and a type guard for roulette errors.

let roulette: Roulette<string> = new Roulette(["Hello", "World"]);

const values: string[] = roulette.values; // Returns ["Hello", "World"]
const value: string = roulette.pop(); // Returns "Hello" or "World"

roulette.values = ["New", "Problems"];

🤝 Contributing

Contributions, issues and feature requests are welcome.
Feel free to check issues page if you want to contribute.
Check the contributing guide.

Author

👤 Leetcode Roulette

📝 License

Copyright © 2022 Leetcode Roulette.
This project is MIT licensed.


Package Sidebar

Install

npm i @leetcoderoulette/roulette

Weekly Downloads

9

Version

1.3.0

License

MIT

Unpacked Size

13.5 kB

Total Files

9

Last publish

Collaborators

  • leetcoderoulette