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

@tgim/chess-utils

v0.1.2

Published

Utilities for chess-related projects.

Downloads

112

Readme

chess-utils

TypeScript utilities for chess-related projects.

Install

pnpm add chess-utils

Data Types

| Type | Description | | --- | --- | | Square | 0–63 index (a1 = 0, h8 = 63). | | Piece | Pawn, Knight, Bishop, Rook, Queen, King enum. | | Color | White or Black enum. | | PieceOnBoard | { kind: Piece; color: Color }. | | MoveRaw | Minimal move: { from, to, piece?, capture?, promotion, flags? }. | | Move | Fully resolved move with piece, capture, promotion, and flags filled. | | Board64 | 64-length array of PieceOnBoard | null indexed by Square. | | GameState | { board, sideToMove, castling, enPassant, halfmoveClock, fullmoveNumber }. | | Notation | 'san' | 'lan' | 'uci'. | | PGNMetadata | { [tag: string]: string } key/value tags. | | PGNResult | '1-0' | '0-1' | '1/2-1/2' | '*'. |

Exports

| Export | Role | Example | | --- | --- | --- | | initialGameState | Standard chess starting state. | const state = initialGameState(); | | parseFEN / formatFEN | FEN <-> GameState. | formatFEN(parseFEN(fen)) | | parseSAN / formatSAN | SAN parsing/formatting (needs state for disambiguation). | formatSAN(state, parseSAN(state, 'Nf3')) | | parseUCI / formatUCI | UCI parsing/formatting. | formatUCI(parseUCI('e2e4')) | | parseLAN / formatLAN | LAN parsing/formatting. | formatLAN(parseLAN('e2-e4')) | | convertNotation | Convert a single move between SAN/LAN/UCI. | convertNotation(state, 'e4', 'san', 'uci') | | parseMoveList | Parse a move list into { start, moves, final, result? }. | parseMoveList('e4 e5 Nf3') | | formatMoveList | Format MoveRaw[] back into text with optional numbers. | formatMoveList(start, moves) | | buildMoveTuples | Expand MoveRaw[] into [GameState, MoveRaw][] for UI/trees. | buildMoveTuples(start, moves) | | normalizeMoveText | Strip PGN tags/comments/nums/results into SAN list. | normalizeMoveText(pgn) | | moveListToFEN | Move list -> final FEN. | moveListToFEN('e2e4 e7e5', { notation: 'uci' }) | | moveListToPGN | Move list -> PGN with metadata. | moveListToPGN('e4 e5', { outputNotation: 'uci' }) | | parsePGN | PGN -> { metadata, start, moves, final, result? }. | parsePGN(pgn) | | formatPGN | Metadata + moves -> PGN text. | formatPGN(meta, start, moves) | | extractMetadata / formatPGNMetadata | Read/write PGN tag pairs. | extractMetadata(pgn) | | stripVariations / extractResultToken | PGN text helpers (remove variations, pull result). | stripVariations(pgn) | | clamp | Number clamping helper. | clamp(12, 0, 8) |

Quick Recipes

Parse PGN and get final FEN

import { parsePGN, formatFEN } from 'chess-utils';

const parsed = parsePGN(pgnText);
const fen = formatFEN(parsed.final);

Convert SAN list to UCI list

import { parseMoveList, formatMoveList } from 'chess-utils';

const { start, moves } = parseMoveList('e4 e5 Nf3');
const uci = formatMoveList(start, moves, { notation: 'uci', includeMoveNumbers: false });

Convert move list to PGN with metadata

import { moveListToPGN } from 'chess-utils';

const pgn = moveListToPGN('e4 e5 Nf3', {
  metadata: { Event: 'Casual', Result: '1-0' },
});

Normalize PGN move text

import { normalizeMoveText } from 'chess-utils';

const moves = normalizeMoveText(pgnText);
// "e4 e5 Nf3 Nc6 ..."