A data structure representing a tree of string nodes with arbitrary object leaves.

Hierarchy (view full)

Properties

#root: object = ...

The tree's root.

Accessors

  • get leaves(): symbol
  • The key symbol that stores the leaves of any given node.

    Returns symbol

Methods

  • Insert an entry into the tree.

    Parameters

    • strings: string[]

      The string parents for the entry.

    • entry: any

      The entry to store.

    Returns object

    The node the entry was added to.

  • Traverse the tree along the given string path and return any entries reachable from the node.

    Parameters

    • strings: string[]

      The string path to the desired node.

    • Optional options: {
          limit: number;
          filterEntries: StringTreeEntryFilter;
      } = {}
      • limit: number

        The maximum number of items to retrieve.

      • filterEntries: StringTreeEntryFilter

        A filter function to apply to each candidate entry.

    Returns any[]

  • Returns the node at the given path through the tree.

    Parameters

    • strings: string[]

      The string path to the desired node.

    • Optional options: {
          hasLeaves: boolean;
      } = {}
      • hasLeaves: boolean

        Only return the most recently visited node that has leaves, otherwise return the exact node at the prefix, if it exists.

    Returns void | object

  • Protected

    Perform a breadth-first search starting from the given node and retrieving any entries reachable from that node, until we reach the limit.

    Parameters

    • node: object

      The starting node.

    • entries: any[]

      The accumulated entries.

    • queue: object[]

      The working queue of nodes to search.

    • Optional options: {
          limit: number;
          filterEntries: StringTreeEntryFilter;
      } = {}
      • limit: number

        The maximum number of entries to retrieve before stopping.

      • filterEntries: StringTreeEntryFilter

        A filter function to apply to each candidate entry.

    Returns void

  • Create a new node.

    Returns object