(string: string)
| 37 | } |
| 38 | |
| 39 | public addCString(string: string): Writer { |
| 40 | if (!string) { |
| 41 | this.ensure(1) |
| 42 | } else { |
| 43 | const len = Buffer.byteLength(string) |
| 44 | this.ensure(len + 1) // +1 for null terminator |
| 45 | this.buffer.write(string, this.offset, 'utf-8') |
| 46 | this.offset += len |
| 47 | } |
| 48 | |
| 49 | this.buffer[this.offset++] = 0 // null terminator |
| 50 | return this |
| 51 | } |
| 52 | |
| 53 | public addString(string: string = ''): Writer { |
| 54 | const len = Buffer.byteLength(string) |
no test coverage detected