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

tbc

v1.0.6

Published

Tiled Binary Container with O(1) offset addressing for fast range-based tile access

Readme

TBC

TBC is a minimal binary tile container designed for fast, range-based reads in both Browser and NodeJS.

It is optimized for delivery and random access, not for incremental writing.


Key ideas

  • Fixed-size payload per tile
  • O(1) offset calculation
  • HTTP Range friendly (CDN / browser cache friendly)
  • Same API for Browser and NodeJS
  • Stateless header-based access

Installation

npm install tbc

Data model

  • Tiles are addressed by ( x, y ) coordinates
  • Each tile has a fixed payload capacity
  • Actual data length is stored separately
  • Empty tiles occupy space but contain no data

API

Browser (HTTP Range-based, async)

  • readHeader( url, options? )Promise<Header>
  • inBounds( header, x, y )boolean
  • hasData( url, header, x, y, options? )Promise<boolean>
  • read( url, header, x, y, options? )Promise<Uint8Array | null>
  • readMany( url, header, tiles, options? )Promise<TileResult[]>

NodeJS (filesystem-based, sync) - Same signatures!

  • readHeader( filename )Header
  • inBounds( header, x, y )boolean
  • hasData( filename, header, x, y )boolean
  • read( filename, header, x, y )Buffer | null
  • readMany( filename, header, tiles )TileResult[]

Write operations (NodeJS only):

  • create( filename, payloadCapacity, minX, minY, maxX, maxY )void
  • write( filename, x, y, buffer )void
  • clearTile( filename, x, y )void
  • clearAll( filename )void
  • getWriter( filename )Writer

Examples

Browser (HTTP Range requests)

import * as TBC from "tbc"

// Read header from remote file
const header = await TBC.readHeader( "https://cdn.example.com/tiles.tbc" )

// Check if tile exists
if ( TBC.inBounds( header, 11, 10 ) ) {

  const hasData = await TBC.hasData( "https://cdn.example.com/tiles.tbc", header, 11, 10 )

  if ( hasData ) {

    const payload = await TBC.read( "https://cdn.example.com/tiles.tbc", header, 11, 10 )
    console.log( payload ) // Uint8Array
  }
}

// Read multiple tiles at once
const tiles = [ { x: 10, y: 10 }, { x: 11, y: 10 }, { x: 12, y: 10 } ]
const results = await TBC.readMany( "https://cdn.example.com/tiles.tbc", header, tiles )

for ( const tile of results ) {

  if ( tile.payload ) {

    console.log( tile.x, tile.y, tile.payload )
  }
}

NodeJS (filesystem access) - Same API as Browser!

import * as TBC from "tbc"

// Get header first (same as browser)
const header = TBC.readHeader( "example.tbc" )

// Same function signatures as browser (except sync)
if ( TBC.inBounds( header, 11, 10 ) ) {

  const hasData = TBC.hasData( "example.tbc", header, 11, 10 )

  if ( hasData ) {

    const payload = TBC.read( "example.tbc", header, 11, 10 )
    console.log( payload ) // Buffer (instead of Uint8Array)
  }
}

// Read multiple tiles (same as browser)
const tiles = [ { x: 10, y: 10 }, { x: 11, y: 10 }, { x: 12, y: 10 } ]
const results = TBC.readMany( "example.tbc", header, tiles )

for ( const tile of results ) {

  if ( tile.payload ) {

    console.log( tile.x, tile.y, tile.payload ) // Buffer
  }
}

Writing (NodeJS only)

Writing is supported in NodeJS only and is intended for build-time or backend usage.

One-shot writes

import * as TBC from "tbc"

// Create new TBC file
TBC.create(
  "example.tbc",
  16,     // payload capacity (bytes per tile)
  10, 10, // minX, minY
  12, 12  // maxX, maxY
)

// Write individual tiles
TBC.write( "example.tbc", 10, 10, Buffer.from( "Hello" ) )
TBC.write( "example.tbc", 11, 10, Buffer.from( "World" ) )

// Clear tiles
TBC.clearTile( "example.tbc", 12, 12 )
TBC.clearAll( "example.tbc" ) // clear all tiles

Streaming writer (recommended for large datasets)

// Create file first
TBC.create( "example.tbc", 16, 10, 10, 12, 12 )

// Get writer instance
const writer = TBC.getWriter( "example.tbc" )

writer.write( 10, 10, Buffer.from( "A" ) )
writer.write( 11, 10, Buffer.from( "B" ) )
writer.write( 12, 10, Buffer.from( "C" ) )

// Clear specific tile
writer.clear( 12, 12 )

// Always close when done
writer.close()

Notes

  • Fixed file size: Total file size determined at creation time and cannot be changed
  • Automatic padding: Payload padding to capacity is handled internally
  • Thread-safe reads: Reading operations are safe for concurrent access
  • CDN optimized: Designed for efficient HTTP Range requests and caching
  • Format-agnostic: TBC stores raw binary data without knowing the payload format (PNG, JSON, protobuf, etc.)
  • Zero-copy reads: Payload data returned as-is without parsing or transformation
  • O(1) performance: Tile access time is constant regardless of file size or tile position