Skip to main content

Built and signed on GitHub Actions

An API wrapper for One Billion Checkboxes by Alula

This package works with Cloudflare Workers, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a month ago (2.0.0)

JSR Deno TypeScript CI License: MIT

An API wrapper for One Billion Checkboxes

Implements 100% of the protocol.

Examples

/** A bot that disables all checkboxes in a chunk and quits
 * @module
 */
import { Client } from "jsr:@iluha168/obcb";

// Note: the website starts indexes from 1, while the API - from 0.
// This would correspond to page 51 on the site.
const CHUNK_INDEX = 50

new Client({
    // Called when the server has initialized our connection
    // You can safely call API methods past this point
    onHello(client) {
        client.chunkRequest(CHUNK_INDEX)
    },

    // Called when a chunk has been received
    onChunkUpdateFull(chunk) {
        // Iterate over received checkboxes
        for(const [i, checkbox] of chunk.boxes.entries()){
            // If the checkbox is on, disable it
            if(checkbox) chunk.toggle(i)
        }
        console.log("Chunk", chunk.index, "is now off")
        // Close the WebSocket once we are done
        // This should automatically stop this script
        chunk.client.disconnect()
    },
})
// Don't forget to connect!
.connect()

For more examples, such as rendering the entire bitmap as a square image, visit examples folder on GitHub.

Compatibility

Depends on WebSocket from WebAPI in the global scope. Every runtime that satisfies this requirement can use this library. It is possible to polyfill WebSocket in before calling Client.prototype.connect.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@iluha168/obcb

Import symbol

import * as obcb from "@iluha168/obcb";

---- OR ----

Import directly with a jsr specifier

import * as obcb from "jsr:@iluha168/obcb";

Add Package

bunx jsr add @iluha168/obcb

Import symbol

import * as obcb from "@iluha168/obcb";