Skip to main content
Home

@ca-ts/rle@0.11.3
Built and signed on GitHub Actions

Run Length Encoded (RLE) file format parser and writer (Cellular automaton)

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with 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

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@ca-ts/rle

Import symbol

import * as rle from "@ca-ts/rle";
or

Import directly with a jsr specifier

import * as rle from "jsr:@ca-ts/rle";

Add Package

pnpm i jsr:@ca-ts/rle
or (using pnpm 10.8 or older)
pnpm dlx jsr add @ca-ts/rle

Import symbol

import * as rle from "@ca-ts/rle";

Add Package

yarn add jsr:@ca-ts/rle
or (using Yarn 4.8 or older)
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";