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

thailottojs

v1.0.3

Published

Data Matrix Parser for Thai lottery tickets

Readme

Thai Lotto JS

ไทยล็อตโต้เจเอส — Parse Thai lottery ticket data matrix codes

npm Ko-fi

Installation

npm install thailottojs

Browser

<script type="module">
  import { Lotto } from 'https://unpkg.com/thailottojs/main.js';
  const ticket = new Lotto('62-10-21-123456');
  console.log(ticket.number);
</script>

Usage

import { Lotto, LottoRewards } from 'thailottojs';

// Parse a lottery ticket code from data matrix scan
const ticket = new Lotto('62-10-21-123456');

console.log(ticket.number);   // "123456"
console.log(ticket.year);     // 2019 (CE)
console.log(ticket.year_BE);  // 2562 (Buddhist Era)
console.log(ticket.round);    // 10
console.log(ticket.pack);     // 21

API

Lotto Class

Parse a Thai lottery ticket code from data matrix.

Constructor: new Lotto(code: string)

Code format: YY-RR-PP-NNNNNN

  • YY - Year (Buddhist Era, last 2 digits)
  • RR - Round number
  • PP - Pack number
  • NNNNNN - Ticket number (6 digits)

Properties: | Property | Type | Description | |----------|------|-------------| | code | string | Original code | | number | string | 6-digit ticket number | | year | number | Year in CE (e.g., 2019) | | year_BE | number | Year in Buddhist Era (e.g., 2562) | | round | number | Draw round | | pack | number | Pack number |

LottoReward Class

Represents a lottery prize tier.

Properties: | Property | Type | Description | |----------|------|-------------| | name | string | Thai prize name | | price | number | Prize amount (THB) | | direction_matching | string | "front", "back", or "whole" |

LottoRewards

Array of all prize tiers:

| Prize | Amount (THB) | |-------|-------------| | รางวัลที่ 1 | 6,000,000 | | รางวัลข้างเคียง | 100,000 | | รางวัลที่ 2 | 200,000 | | รางวัลที่ 3 | 80,000 | | รางวัลที่ 4 | 40,000 | | รางวัลที่ 5 | 20,000 | | เลขหน้า 3 ตัว | 4,000 | | เลขท้าย 3 ตัว | 4,000 | | เลขท้าย 2 ตัว | 2,000 |

Utility Functions

import { generateRandomLottoes, generateOrderLottoes } from 'thailottojs';

// Generate random test tickets
const randomTickets = generateRandomLottoes(10);

// Generate sequential test tickets
const orderedTickets = generateOrderLottoes(10);

Support

Ko-fi

License

MIT