CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-symbol-tree

Efficient tree and linked list data structure using ES6 Symbols for DOM tree backing

Pending
Overview
Eval results
Files

tree-construction.mddocs/

Tree Construction

Object initialization and SymbolTree instance creation for optimal performance.

Capabilities

SymbolTree Constructor

Creates a new SymbolTree instance with an optional description for the internal Symbol.

/**
 * Create a new SymbolTree instance
 * @param {string} [description='SymbolTree data'] - Description used for the internal Symbol
 */
class SymbolTree {
  constructor(description?: string);
}

Usage Examples:

const SymbolTree = require("symbol-tree");

// Create with default description
const tree = new SymbolTree();

// Create with custom description for debugging
const domTree = new SymbolTree("DOM tree data");

Object Initialization

Initialize an object right after creation to take advantage of V8's fast properties and enable object freezing.

/**
 * Initialize an object for tree operations (optional performance optimization)
 * Time Complexity: O(1)
 * @param {Object} object - Object to initialize
 * @returns {Object} The same object that was passed in
 */
initialize(object: Object): Object;

Usage Examples:

const tree = new SymbolTree();

// Basic initialization
const node = tree.initialize({ id: "node1", data: "value" });

// Initialize before freezing (common pattern)
const frozenNode = Object.freeze(
  tree.initialize({ id: "node2", readonly: true })
);

// Initialize immediately after creation
class DOMNode {
  constructor(tagName) {
    this.tagName = tagName;
    tree.initialize(this); // Optimize for tree operations
  }
}

Performance Notes:

  • Calling initialize() is optional but recommended for objects that will be heavily used in tree operations
  • Helps V8 optimize property access patterns
  • Particularly useful when you plan to freeze objects after tree setup
  • Has no effect on tree functionality, only on performance characteristics

Install with Tessl CLI

npx tessl i tessl/npm-symbol-tree

docs

array-conversion.md

index.md

tree-analysis.md

tree-construction.md

tree-iterators.md

tree-modification.md

tree-navigation.md

tree-traversal.md

tile.json