MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / _write

Method _write

packages/bench/src/io.ts:162–188  ·  view source on GitHub ↗
(
    chunk: Buffer | string,
    encoding: BufferEncoding,
    callback: (error?: Error | null) => void,
  )

Source from the content-addressed store, hash-verified

160 private readonly writeResolvers: Array<() => void> = [];
161
162 override _write(
163 chunk: Buffer | string,
164 encoding: BufferEncoding,
165 callback: (error?: Error | null) => void,
166 ): void {
167 this.writeCount++;
168 this.totalBytes +=
169 typeof chunk === "string" ? Buffer.byteLength(chunk, encoding) : chunk.byteLength;
170
171 const done = (err?: Error | null) => {
172 const r = this.writeResolvers.shift();
173 if (r) r();
174 callback(err ?? null);
175 };
176
177 try {
178 // Forward to the real TTY.
179 const out = process.stdout as unknown as NodeJS.WriteStream;
180 if (typeof chunk === "string") {
181 out.write(chunk, encoding, done);
182 } else {
183 out.write(chunk, done);
184 }
185 } catch (err) {
186 done(err instanceof Error ? err : new Error(String(err)));
187 }
188 }
189
190 waitForWrite(): Promise<void> {
191 return new Promise<void>((resolve) => {

Callers

nothing calls this directly

Calls 3

doneFunction · 0.85
writeMethod · 0.65
byteLengthMethod · 0.45

Tested by

no test coverage detected