(chunk: Buffer | String)
| 29 | } |
| 30 | |
| 31 | public append(chunk: Buffer | String): void { |
| 32 | var toAppend: Buffer = <Buffer>chunk; |
| 33 | if (typeof (chunk) == 'string') { |
| 34 | var str = <string>chunk; |
| 35 | var bufferLen = Buffer.byteLength(str, this.encoding); |
| 36 | toAppend = new Buffer(bufferLen); |
| 37 | toAppend.write(str, 0, bufferLen, this.encoding); |
| 38 | } |
| 39 | if (this.buffer.length - this.index >= toAppend.length) { |
| 40 | toAppend.copy(this.buffer, this.index, 0, toAppend.length); |
| 41 | } else { |
| 42 | var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize; |
| 43 | if (this.index === 0) { |
| 44 | this.buffer = new Buffer(newSize); |
| 45 | toAppend.copy(this.buffer, 0, 0, toAppend.length); |
| 46 | } else { |
| 47 | this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize); |
| 48 | } |
| 49 | } |
| 50 | this.index += toAppend.length; |
| 51 | } |
| 52 | |
| 53 | public tryReadHeaders(): { [key: string]: string; } | undefined { |
| 54 | let result: { [key: string]: string; } | undefined = undefined; |
no test coverage detected