Skip to main content
utils-slots provides the low-level reel and board primitives for slot machine games. It ships two reel types (spinning and cascading), a board enhancement layer, and shared slot state.

Reel types

createReelForSpinning()

Creates a reel that animates by sliding symbols downward into view — the classic slot machine spin mechanic.
Options (SpinningReelCreateOptions):
Return value:
reelState fields:
Spin type options (SpinningReelSpinOptions):

createReelForCascading()

Creates a reel that animates symbols falling out downward and new symbols falling in from above — the cascade/tumble mechanic.
The API surface is identical to createReelForSpinning (same preSpin, prepareToSpin, spin, stop, setSymbolsWithRawSymbols, readyToSpinEffect methods). The cascading reel exposes a CascadingReelMotion state: 'fallingOut' | 'hanging' | 'fallingIn' | 'stopped'. Cascading spin options (CascadingReelSpinOptions):

Board enhancement layer

The board enhancement layer wraps an array of reels and coordinates spin timing, anticipation, and pre-spin across all columns.

createEnhanceBoard()

Returns an enhanceBoard function that adds preSpin, spin, settle, stop, and readyToSpinEffect to any array of reels:

preSpin (createEnhanceBoardPreSpin)

Starts the pre-spin animation loop on all reels simultaneously. Sets stateSlots.isPreSpinning = true:
The pre-spin loop continues until spin() is called. Turbo mode is captured at pre-spin start so it applies uniformly to all reels.

spin (createEnhanceBoardSpin)

Stops the pre-spin loop and drives all reels to their target symbols. Handles anticipation and turbo automatically:
Anticipation is driven by revealEvent.anticipation — an array of numbers, one per reel. Reels after the first anticipated reel set noStop = true so they keep spinning until explicitly released.

settle

Resets all reels to the provided raw board without animation (used after bonus entry, tumble settle, etc.):

stateSlots

Shared slot state readable from any component:

createGetEmptyPaddedBoard()

Utility to create an empty board grid (with 2 padding rows per reel for cascading reels):

Type reference