MCPcopy Index your code
hub / github.com/codeaashu/claude-code / #queueToBuffers

Method #queueToBuffers

src/utils/task/diskOutput.ts:189–205  ·  view source on GitHub ↗

Keep this in a separate method so that GC doesn't keep it alive for any longer than it should.

()

Source from the content-addressed store, hash-verified

187
188 /** Keep this in a separate method so that GC doesn't keep it alive for any longer than it should. */
189 #queueToBuffers(): Buffer {
190 // Use .splice to in-place mutate the array, informing the GC it can free it.
191 const queue = this.#queue.splice(0, this.#queue.length)
192
193 let totalLength = 0
194 for (const str of queue) {
195 totalLength += Buffer.byteLength(str, 'utf8')
196 }
197
198 const buffer = Buffer.allocUnsafe(totalLength)
199 let offset = 0
200 for (const str of queue) {
201 offset += buffer.write(str, offset, 'utf8')
202 }
203
204 return buffer
205 }
206
207 async #drain(): Promise<void> {
208 try {

Callers 1

#writeAllChunksMethod · 0.95

Calls 2

spliceMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected