MCPcopy
hub / github.com/codeaashu/claude-code / append

Method append

src/utils/stringUtils.ts:156–176  ·  view source on GitHub ↗

* Appends data to the accumulator. If the total size exceeds maxSize, * the end is truncated to maintain the size limit. * @param data The string data to append

(data: string | Buffer)

Source from the content-addressed store, hash-verified

154 * @param data The string data to append
155 */
156 append(data: string | Buffer): void {
157 const str = typeof data === 'string' ? data : data.toString()
158 this.totalBytesReceived += str.length
159
160 // If already at capacity and truncated, don't modify content
161 if (this.isTruncated && this.content.length >= this.maxSize) {
162 return
163 }
164
165 // Check if adding the string would exceed the limit
166 if (this.content.length + str.length > this.maxSize) {
167 // Only append what we can fit
168 const remainingSpace = this.maxSize - this.content.length
169 if (remainingSpace > 0) {
170 this.content += str.slice(0, remainingSpace)
171 }
172 this.isTruncated = true
173 } else {
174 this.content += str
175 }
176 }
177
178 /**
179 * Returns the accumulated string, with truncation marker if truncated

Callers 2

callFunction · 0.95
callFunction · 0.95

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected