Writer Class — react Architecture
Architecture documentation for the Writer class in PrintReactiveFunction.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD b243acad_c177_f3f5_fda5_38b82f61b907["Writer"] d77f9ffb_2d12_7d1f_126f_8c05214f0059["PrintReactiveFunction.ts"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|defined in| d77f9ffb_2d12_7d1f_126f_8c05214f0059 8a52692c_8193_dcb7_9fbe_d7318477cdc3["constructor()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| 8a52692c_8193_dcb7_9fbe_d7318477cdc3 afa33e13_3155_69d3_5b6a_8a49d72f5cf1["complete()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| afa33e13_3155_69d3_5b6a_8a49d72f5cf1 08b5ffb9_71a2_1b17_07aa_5fc920192756["append()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| 08b5ffb9_71a2_1b17_07aa_5fc920192756 134ef693_e561_ad46_e66b_04323b6d08cd["newline()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| 134ef693_e561_ad46_e66b_04323b6d08cd ccaebcb0_5128_cdb1_7336_203ff87e3e3c["write()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| ccaebcb0_5128_cdb1_7336_203ff87e3e3c d0290dff_c442_0216_dbb6_27657f40b130["writeLine()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| d0290dff_c442_0216_dbb6_27657f40b130 49a02012_cdfd_58a3_d7f3_fb778e20ab1b["indented()"] b243acad_c177_f3f5_fda5_38b82f61b907 -->|method| 49a02012_cdfd_58a3_d7f3_fb778e20ab1b
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts lines 409–457
export class Writer {
#out: Array<string> = [];
#line: string;
#depth: number;
constructor({depth}: {depth: number} = {depth: 0}) {
this.#depth = Math.max(depth, 0);
this.#line = '';
}
complete(): string {
const line = this.#line.trimEnd();
if (line.length > 0) {
this.#out.push(line);
}
return this.#out.join('\n');
}
append(s: string): void {
this.write(s);
}
newline(): void {
const line = this.#line.trimEnd();
if (line.length > 0) {
this.#out.push(line);
}
this.#line = '';
}
write(s: string): void {
if (this.#line.length === 0 && this.#depth > 0) {
// indent before writing
this.#line = ' '.repeat(this.#depth);
}
this.#line += s;
}
writeLine(s: string): void {
this.write(s);
this.newline();
}
indented(f: () => void): void {
this.#depth++;
f();
this.#depth--;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the Writer class?
Writer is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts.
Where is Writer defined?
Writer is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts at line 409.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free