(
chunk: Buffer | string,
encoding: BufferEncoding,
callback: (error?: Error | null) => void,
)
| 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) => { |
nothing calls this directly
no test coverage detected