Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BunnyNabbit/celaria-formats/llms.txt

Use this file to discover all available pages before exploring further.

OrderedSet is a generic, insertion-ordered set used internally by celaria-formats to track the sequence of checkpoint blocks in a map. You access it through the checkpointOrder property on any parsed map instance — it is not exported from the main entry point directly. The last block in checkpointOrder is treated as the goal block during serialization. When you call serialize() on a map, the library reads checkpointOrder.toArray() and uses the final element as the goal.
OrderedSet is not exported from celaria-formats’ main entry point (index.mjs). You interact with it only through map.checkpointOrder, which is an instance of OrderedSet<Block>.

Example

import { CelariaMap, Block } from "celaria-formats"

const map = CelariaMap.parse(buffer)

// Inspect checkpoint order
const checkpoints = map.checkpointOrder.toArray()

// Find position of a specific block
const index = map.checkpointOrder.indexOf(someBlock)

// Remove a checkpoint
map.checkpointOrder.delete(someBlock)

// Add a new checkpoint (at end)
map.checkpointOrder.add(newCheckpointBlock)
For a full walkthrough of managing checkpoint ordering when writing maps, see the writing maps guide.

Methods

add(element)

Adds an element to the set. If the element is already present, the call has no effect — the element’s position in the insertion order is unchanged.
map.checkpointOrder.add(checkpoint1)
map.checkpointOrder.add(checkpoint2)
map.checkpointOrder.add(checkpoint1) // no-op; checkpoint1 stays first
add is idempotent with respect to order. Calling add on an element that is already in the set does not move it to the end — the original insertion position is preserved.
Parameters
element
Value
required
The element to add. Type is generic — for checkpointOrder this is a Block instance.
Returns: void

delete(element)

Removes an element from the set.
const removed = map.checkpointOrder.delete(someBlock)
console.log(removed) // true if the block was in the set, false otherwise
Parameters
element
Value
required
The element to remove.
Returns: booleantrue if the element was present and removed, false if it was not in the set.

toArray()

Returns all elements in insertion order as a plain array.
const ordered = map.checkpointOrder.toArray()
// ordered[0] is the first checkpoint added
// ordered[ordered.length - 1] is the goal block during serialization
Returns: Value[] — elements sorted by insertion order.

indexOf(element)

Returns the position of an element in the ordered array (0-indexed). Returns -1 if the element is not in the set.
const pos = map.checkpointOrder.indexOf(someBlock)
if (pos === -1) {
  console.log("block is not a checkpoint")
} else {
  console.log(`checkpoint is at position ${pos}`)
}
Parameters
element
any
required
The element to search for.
Returns: number — the 0-based index of the element, or -1 if not found.

Build docs developers (and LLMs) love