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 🙏

© 2025 – Pkg Stats / Ryan Hefner

xcore-betkit

v0.0.12

Published

XCore Betting Kit

Downloads

24

Readme

XCore BetKit

npm version License: MIT

A TypeScript library that provides WebAssembly-based casino game logic, optimized for web applications.

Features

  • 🎮 Game Logic: Implements casino game rules and calculations in WebAssembly
  • 🚀 Performance: Uses WebAssembly for high-performance computations
  • 📐 Type Safety: Full TypeScript support with accurate type definitions
  • 🔌 Simple API: Clean, intuitive API for game operations
  • 🧩 Modular Design: Focused components for different games and operations

Installation

npm install xcore-betkit

Usage

Basic Setup

import XCoreBetKit from 'xcore-betkit';

// Configure and initialize the library
XCoreBetKit.configure({ 
  wasmPath: './assets/betkit.wasm'
});

// Load the WebAssembly module asynchronously
await XCoreBetKit.asyncLoad();

// Now you can use the library

Baccarat Example

// Define a hand for Baccarat
const hand = {
  p1: { number: 10, color: 1 }, // King of Hearts (value 0)
  p2: { number: 9, color: 2 },  // 9 of Diamonds (value 9)
  b1: { number: 6, color: 3 },  // 6 of Clubs (value 6)
  b2: { number: 2, color: 4 },  // 2 of Spades (value 2)
  p3: { number: 0, color: 0 },  // No card
  b3: { number: 0, color: 0 }   // No card
};

// Determine the result of a hand
const result = await XCoreBetKit.baccarat.determineResult(hand);
console.log(`Result index: ${result.data}`);

// Get the detailed result information
const resultInfo = await XCoreBetKit.baccarat.idxToResultInfo(result.data);
console.log(`Winner: ${resultInfo.data.win}`);

Roadmaps Example

// Array of game result indices (from determineResult calls)
const resultIndices = [1, 2, 0, 1, 1, 0, 2];

// Generate roadmaps data
const roadmapsData = await XCoreBetKit.baccarat.roadmaps(resultIndices);

// Access the various roadmap types
console.log(roadmapsData.data.bigroad);      // Main Big Road
console.log(roadmapsData.data.bigeyeboy);    // Big Eye Boy Road
console.log(roadmapsData.data.smallroad);    // Small Road
console.log(roadmapsData.data.cockroach);    // Cockroach Road

// Access statistics
console.log(`Banker wins: ${roadmapsData.data.statistics.banker}`);
console.log(`Player wins: ${roadmapsData.data.statistics.player}`);
console.log(`Ties: ${roadmapsData.data.statistics.tie}`);

API Reference

Configuration

XCoreBetKit.configure(options: {
  wasmPath: string;         // Path to the WebAssembly module
  debug?: boolean;          // Enable debug logging (default: false)
  logLevel?: LogLevel;      // Set logging level (default: INFO)
  scriptTimeout?: number;   // Timeout for script loading (default: 30000ms)
  onProgress?: (status: string) => void; // Progress callback
});

Loading

// Asynchronously load the WebAssembly module
await XCoreBetKit.asyncLoad();

// Check if the module is loaded
const isLoaded = XCoreBetKit.isLoaded();

// Force reload of the module
await XCoreBetKit.forceReload();

// Get environment information
const envInfo = XCoreBetKit.getEnvironmentInfo();

Baccarat Module

The Baccarat module provides the following methods:

// Determine the result of a hand (returns result index)
const result = await XCoreBetKit.baccarat.determineResult(hand);

// Rank a baccarat hand (returns numeric rank)
const rank = await XCoreBetKit.baccarat.rankHand(hand);

// Convert index to hand
const unrankedHand = await XCoreBetKit.baccarat.unrankHand(index);

// Check if player or banker can draw
const drawPossibilities = await XCoreBetKit.baccarat.canDraw(hand);

// Convert index to result info
const resultInfo = await XCoreBetKit.baccarat.idxToResultInfo(index);

// Convert result info to index
const resultIndex = await XCoreBetKit.baccarat.resultInfoToIdx(resultInfo);

// Get card information and metadata
const cardsInfo = await XCoreBetKit.baccarat.cardsInfo();

// Generate roadmaps from game results
const roadmaps = await XCoreBetKit.baccarat.roadmaps(resultIndices);

Data Types

// Card object
interface Card {
  number: number; // 1-13 (Ace=1, Jack=11, Queen=12, King=13)
  color: number;  // 1-4 (Hearts=1, Diamonds=2, Clubs=3, Spades=4)
}

// Baccarat hand
interface BaccaratHands {
  p1: Card; // Player card 1
  p2: Card; // Player card 2
  p3: Card; // Player card 3 (if drawn)
  b1: Card; // Banker card 1
  b2: Card; // Banker card 2
  b3: Card; // Banker card 3 (if drawn)
}

// Result info
interface BaccaratResultInfo {
  index: number;  // Result index
  win: "banker" | "player" | "tie"; // Winner
  banker_natural: boolean; // Banker has natural
  player_natural: boolean; // Player has natural
  player_dragon_bonus_count: number; // Player dragon bonus point count
  banker_dragon_bonus_count: number; // Banker dragon bonus point count
  perfect_pair: boolean; // Perfect pair occurred
  banker_dragon_bonus: boolean; // Banker dragon bonus
  super6: boolean; // Super 6 occurred
  super6_count: number; // Super 6 count
  size: "small" | "big"; // Size
  player_pair: boolean; // Player pair
  player_dragon_bonus: boolean; // Player dragon bonus
  banker_pair: boolean; // Banker pair
  any_pair: boolean; // Any pair
}

// Draw possibilities
interface DrawPossibilities {
  player: boolean; // Player can draw
  banker: boolean; // Banker can draw
}

// Response format
interface WasmResponse<T> {
  code: number;     // 0 for success, non-zero for error
  message: string;  // Success or error message
  data: T;          // Response data
}

// Roadmaps data
interface BaccaratRoadmaps {
  history: number[];      // History of game results
  bigroad: number[][];    // Big Road data
  bigeyeboy: number[][]; // Big Eye Boy Road data
  smallroad: number[][]; // Small Road data
  cockroach: number[][]; // Cockroach Road data
  prediction: BaccaratPrediction; // Predictions
  statistics: BaccaratStatistics; // Game statistics
  threeroad: number[][]; // Three Road data
}

Browser Support

XCore BetKit supports all modern browsers with WebAssembly capabilities:

  • Chrome 57+
  • Firefox 53+
  • Safari 11+
  • Edge 16+