npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

slot-machine

v2.1.0

Published

A slot machine.

Downloads

453

Readme

About

A slot machine that's not accurate to real life at all.

Example

const { SlotMachine, SlotSymbol } = require('../src/index');

const cherry = new SlotSymbol('cherry', {
    display: '🍒',
    points: 10,
    weight: 100
});

const money = new SlotSymbol('money', {
    display: '💰',
    points: 100,
    weight: 50
});

const wild = new SlotSymbol('wild', {
    display: '❔',
    points: 10,
    weight: 50,
    wildcard: true
});

const machine = new SlotMachine(3, [cherry, money, wild]);
const results = machine.play();

console.log(results.visualize());

Docs

SlotSymbol(name[, options])

  • name A unique name for the symbol.
  • options.display A character to use for displaying.
  • options.points Amount of points the symbol gives.
  • options.weight Chance of symbol appearing relative to others.
  • options.wildcard Whether or not the symbol is a wildcard.

Creates a new SlotSymbol instance:

  • name The symbol's name.
  • display The character for display.
  • points Amount of points the symbol gives.
  • weight Chance of symbol appearing.
  • wildcard Whether or not the symbol is a wildcard.

SlotMachine(size, symbols[, random])

  • size Size of grid, must be odd number above 3.
  • symbols Array of SlotSymbols to use.
  • random Function returning number [0, 1).

Creates a new SlotMachine instance:

  • size Size of grid.
  • symbols Symbols to be used.
  • random Function returning number [0, 1).
<SlotMachine>.play()

Plays the slot machine and returns the results.
=> Results

<SlotMachine>.chanceOf(name)
  • name Name of a SlotSymbol.

Gets the chance of a symbol appearing.
=> number

<Results>

The results of a slot machine play:

  • lines The lines generated from the play, where the last two are the major and minor diagonals.
  • totalPoints Total amount of points from won lines.
  • winCount Amount of lines that have been won.
<Results>.visualize([includeDiagonals])
  • includeDiagonals Whether or not to include diagonals in the visualization.

Creates a formatted string from the results.
=> string

<EvaluatedLine>

The lines from a slot machine play:

  • symbols The symbols in the line.
  • diagonal Whether or not the line is a diagonal.
  • isWon Whether or not the line is won.
  • points The amount of points this line would give.