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

@paradoxlab/spr

v0.2.0

Published

A TypeScript parser and writer for OTServers `.spr` binary format.

Readme

@paradoxlab/spr

npm license

Parser and writer for .spr binary format. Reads 32×32 RGBA sprites with RLE decompression, transparent-magenta decoding, and lazy loading.

Installation

npm install @paradoxlab/spr

How to Use

import { readFileSync, writeFileSync } from 'node:fs'
import { Spr } from '@paradoxlab/spr'

// Parse
const file = Spr().load(readFileSync('772.spr'))

console.log(file.count) // total sprite count

// Access a sprite by ID (1-indexed)
const sprite = file.get(1)
// → { id: 1, rgba: Uint8ClampedArray(4096), width: 32, height: 32 }

// Iterate all sprites (lazy-decoded on access)
for (const sprite of file.entries()) {
  const { id, rgba } = sprite
  // rgba is RGBA: [ r, g, b, a, r, g, b, a, ... ] 4096 bytes (32×32×4)
  process(id, rgba)
}

// Write back to binary (round-trip)
const sprites = [...file.entries()]
writeFileSync('out.spr', Spr(772).write(sprites))

// Validate without loading
const result = Spr(772).validate(readFileSync('772.spr'))
// → { ok: true } | { ok: false, error: string }

API

Spr(version?: number)

Factory returning { load, write, validate }. Omit version for auto-detection.

.load(buffer: ArrayBuffer | Uint8Array): SprFile

Parse a .spr binary. Sprites are decoded lazily — pixel data is only decompressed on first access.

.write(sprites: SprWriteInput): Uint8Array

Serialize sprites back to binary. Accepts the same Sprite[] shape returned by .entries().

.validate(buffer: ArrayBuffer | Uint8Array): { ok: boolean; error?: string }

Validate the signature and offset table without decoding any sprite.

SprFile

| Property | Type | Description | |---|---|---| | version | number | Detected client version | | signature | number | 32-bit file signature | | count | number | Total number of sprites | | .get(id) | Sprite \| undefined | Decode and return sprite by ID (1-indexed) | | .entries() | Iterable<Sprite> | Iterate all sprites in ID order |

Sprite

type Sprite = {
  id: number              // 1-indexed sprite ID
  rgba: Uint8ClampedArray // 32×32 RGBA pixels, row-major
  width: 32
  height: 32
}

Transparent sprites (ID maps to a null offset) return rgba filled with zeros.

Format Notes

  • Magenta (#FF00FF) pixels are the transparency color. The parser converts them to alpha = 0.
  • Pixel data is RLE-compressed: each run is (transparent_count: u16, colored_count: u16, colored_bytes...). The decoder expands this into flat RGBA.
  • An offset table at the start of the file stores one u32 per sprite pointing to its raw data position. Null offsets (0x00000000) indicate empty/transparent-only sprites.
  • Extended sprite IDs (versions >= 960) use u32 IDs; older versions use u16. The version flag extendedSprites in @paradoxlab/utils controls which is used.

← Back to paradox-toolkit