Options
All
  • Public
  • Public/Protected
  • All
Menu

Class representing a block directory, providing functionality for adding blocks and block identifier resolution.

Hierarchy

  • Directory

Index

Constructors

constructor

Properties

Private _blocks

_blocks: Record<string, Block> = {}

Private _selectableBlocks

_selectableBlocks: Set<string> = ...

Methods

addBlock

  • addBlock(prefix: string, block: Block): void
  • Adds a block into the directory.

    This function handles the decomposition of blocks into properties and subblocks. The parent block and each of its subblocks are added to the block directory, with an appropriate prefix prepended to the block identifiers.

    For example, by passing in prefix as "foobar" and block as a block with subblocks foo and bar, three blocks will be added to the directory with identifiers foobar, foobar/foo and foobar/bar.

    Note that each block in the directory will have its subblocks stripped away. If it is necessary to access a subblock, the find function should be used with prefix set to the identifier of the parent block and id set to the (partial) identifier of the subblock.

    Parameters

    • prefix: string

      A prefix string representing the full identifier of the block.

    • block: Block

      The block to be added to the directory.

    Returns void

find

  • find(prefix: string, id: string): [string, Block]
  • Finds a block in the directory.

    This function attempts to find a block with the exact same full identifier as id. If no such block exists, it will search for a block with id directly under prefix.

    For example, if prefix is set to "abc" and id to "ghi", the function will check if either of the blocks ghi or abc/ghi exist.

    Parameters

    • prefix: string

      A prefix string representing the full identifier of the parent block, if any.

    • id: string

      The identifier of the desired block. This may either be a full identifier or a partial identifier under the parent block.

    Returns [string, Block]

    A pair with the first element as the full identifier of the desired block and the second element as the desired block itself.

retrieveSelectable

  • retrieveSelectable(): string[]
  • Retrieves all selectable block identifiers in the directory.

    Returns string[]

    A list of full identifiers of all selectable blocks in the directory.

Generated using TypeDoc