Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
rei1024/ca-tsRun Length Encoded (RLE) file format parser and writer (Cellular automaton)
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
100%
Published
a month ago (0.11.3)
Run Length Encoded (RLE) file format parser and writer
RLE is a file format for storing cellular automaton patterns used by programs such as Golly.
Example
import { parseRLE, stringifyRLE, type RLE } from "@ca-ts/rle"; import { assertEquals } from "@std/assert"; const source = [ `#N Glider`, `x = 3, y = 3, rule = B3/S23`, `bob$2bo$3o!` ].join("\n"); // Parse RLE const rle: RLE = parseRLE(source); assertEquals( rle, { cells: [ { position: { x: 1, y: 0 }, state: 1 }, { position: { x: 2, y: 1 }, state: 1 }, { position: { x: 0, y: 2 }, state: 1 }, { position: { x: 1, y: 2 }, state: 1 }, { position: { x: 2, y: 2 }, state: 1 }, ], comments: [ "#N Glider", ], size: { width: 3, height: 3, }, ruleString: "B3/S23", XRLE: null, trailingComment: "", }, ); // Convert to a string assertEquals( stringifyRLE({ cells: [ { position: { x: 0, y: 0 }, state: 1 }, { position: { x: 1, y: 0 }, state: 1 }, { position: { x: 2, y: 0 }, state: 1 }, ], comments: ["#N Blinker"], ruleString: "B3/S23", size: { width: 3, height: 1, }, }), `#N Blinker x = 3, y = 1, rule = B3/S23 3o! `, );
Reference
Built and signed on
GitHub Actions
Add Package
deno add jsr:@ca-ts/rle
Import symbol
import * as rle from "@ca-ts/rle";
Import directly with a jsr specifier
import * as rle from "jsr:@ca-ts/rle";
Add Package
pnpm i jsr:@ca-ts/rle
pnpm dlx jsr add @ca-ts/rle
Import symbol
import * as rle from "@ca-ts/rle";
Add Package
yarn add jsr:@ca-ts/rle
yarn dlx jsr add @ca-ts/rle
Import symbol
import * as rle from "@ca-ts/rle";
Add Package
npx jsr add @ca-ts/rle
Import symbol
import * as rle from "@ca-ts/rle";
Add Package
bunx jsr add @ca-ts/rle
Import symbol
import * as rle from "@ca-ts/rle";