Home / Class/ Node Class — react Architecture

Node Class — react Architecture

Architecture documentation for the Node class in Stack.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  279e1d0b_8d8a_c438_9e96_20699aec2836["Node"]
  a4f6856b_1fb6_fbaa_dad2_faf7da011133["Stack.ts"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|defined in| a4f6856b_1fb6_fbaa_dad2_faf7da011133
  f16bc5e9_1f20_eb6c_5ee5_8198d30561b7["constructor()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| f16bc5e9_1f20_eb6c_5ee5_8198d30561b7
  358cdfdf_e03f_e4de_133c_5b70e0a98d45["push()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| 358cdfdf_e03f_e4de_133c_5b70e0a98d45
  6a49e893_9e21_81a7_6317_29730acf93c2["pop()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| 6a49e893_9e21_81a7_6317_29730acf93c2
  3d5b98eb_196e_b05c_5771_3d21805eef0c["find()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| 3d5b98eb_196e_b05c_5771_3d21805eef0c
  c70c54ad_9358_2a8e_bac4_d782e47bef4d["contains()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| c70c54ad_9358_2a8e_bac4_d782e47bef4d
  74898d26_a363_cc1f_3e69_ee0694fdc9b7["each()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| 74898d26_a363_cc1f_3e69_ee0694fdc9b7
  a7cf81cc_da78_f8b3_e4be_7459fa1543d3["value()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| a7cf81cc_da78_f8b3_e4be_7459fa1543d3
  c97ce213_80bd_521f_b9ba_d42d80c1d1a9["print()"]
  279e1d0b_8d8a_c438_9e96_20699aec2836 -->|method| c97ce213_80bd_521f_b9ba_d42d80c1d1a9

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Utils/Stack.ts lines 45–84

class Node<T> implements StackInterface<T> {
  #value: T;
  #next: Stack<T>;

  constructor(value: T, next: Stack<T> = EMPTY as any) {
    this.#value = value;
    this.#next = next;
  }

  push(value: T): Node<T> {
    return new Node(value, this);
  }

  pop(): Stack<T> {
    return this.#next;
  }

  find(fn: (value: T) => boolean): boolean {
    return fn(this.#value) ? true : this.#next.find(fn);
  }

  contains(value: T): boolean {
    return (
      value === this.#value ||
      (this.#next !== null && this.#next.contains(value))
    );
  }
  each(fn: (value: T) => void): void {
    fn(this.#value);
    this.#next.each(fn);
  }

  get value(): T {
    return this.#value;
  }

  print(fn: (node: T) => string): string {
    return fn(this.#value) + this.#next.print(fn);
  }
}

Domain

Frequently Asked Questions

What is the Node class?
Node is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Utils/Stack.ts.
Where is Node defined?
Node is defined in compiler/packages/babel-plugin-react-compiler/src/Utils/Stack.ts at line 45.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free