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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dreams-engine/slot-flow

v0.1.2

Published

Command-based presentation framework for orchestrating visual effects and animations in slot machine games with support for cancellation and parallel execution.

Downloads

414

Readme

Slot Flow

Command-based presentation framework for orchestrating visual effects and animations in slot machine games with support for cancellation and parallel execution.

Features

  • Command pattern for atomic visual actions
  • Sequential and parallel execution with Runner
  • Presenter pattern for complex visual sequences
  • Cooperative cancellation via AbortSignal
  • Built-in commands for common slot effects

Installation

npm i @dreams-engine/slot-flow

Core Architecture

ICommand

Atomic visual action with execution and cancellation:

interface ICommand {
  readonly name: string;
  execute(signal: AbortSignal): Promise<void>;
  cancel?(reason?: string): void;
}

Runner

Executes command plans sequentially or in parallel:

const runner = new Runner();
await runner.run([
  command1,                    // Sequential
  [command2, command3],        // Parallel
  command4                     // Sequential
]);

IPresenter

High-level strategy for presentation sequences:

interface IPresenter<TPlanInput, TMachine> {
  present(input: TPlanInput, signal?: AbortSignal): Promise<void>;
  cancel(reason?: string): void;
}

Built-in Commands

DimCommand

Dims non-target symbols (default alpha: 0.4), with clear mode to restore all symbols:

new DimCommand(machine, positions, { alpha: 0.4, clear: false });

HighlightCommand

Ensures target symbols are fully visible (alpha: 1.0):

new HighlightCommand(machine, positions);

PlayWinCommand

Plays win animations with configurable duration:

new PlayWinCommand(machine, positions, { durationMs: 1200, revertToIdle: false });

Built-in Presenters

WinPresenter

Orchestrates standard win sequences: dim → highlight/animate → clear

const presenter = new WinPresenter(machine);
await presenter.present(winData);

Usage Examples

Basic Command Execution

import { Runner, DimCommand, HighlightCommand } from '@dreams-engine/slot-flow';

const runner = new Runner();
await runner.run([
  new DimCommand(machine, winMatrix),
  [
    new HighlightCommand(machine, winMatrix),
    new PlayWinCommand(machine, winMatrix)
  ],
  new DimCommand(machine, [], { clear: true })
]);

Win Presentation

const winData = [{
  symbolId: 'A',
  matrix: [0, 0, 0, null, null], // Win on first 3 reels, row 0
  amount: 100,
  total: 100
}];

const presenter = new WinPresenter(machine);
await presenter.present(winData);

Cancellation

const controller = new AbortController();
const execution = runner.run(plan, controller.signal);

// Cancel execution
setTimeout(() => {
  controller.abort();
  runner.cancel('timeout');
}, 2000);

Data Types

WinMatrix

Defines symbol positions for commands:

type WinMatrix = (number | number[] | null)[];

// Examples:
[0, 0, 0, null, null]           // Single row win
[[0, 1], [1, 2], 0, null, null] // Multiple positions

WinData

Win information for presentations:

interface WinData {
  symbolId: string;
  matrix: WinMatrix;
  amount: number;
  total: number;
  multiplier?: number;
  lineNumber?: number | null;
  cascade?: CascadeMatrix | null;
  wildWin?: boolean;
  meta?: Record<string, unknown>;
}

Symbol States

Commands manipulate symbols through:

  • Visual properties: alpha and resetFilter()
  • Animation states: setState('win') and setState('idle')
  • Position calculation: Uses reel.extraCount + row formula

Dependencies

  • @dreams-engine/slot: Core slot machine interfaces
  • TypeScript: Full type safety support

Zero runtime dependencies beyond peer dependencies.