| 55 | } |
| 56 | |
| 57 | public join(appendLength?: boolean, char?: string): Uint8Array { |
| 58 | let length = this.getByteLength() |
| 59 | if (appendLength) { |
| 60 | this.addInt32(length + 4, true) |
| 61 | return this.join(false, char) |
| 62 | } |
| 63 | if (char) { |
| 64 | this.addChar(char, true) |
| 65 | length++ |
| 66 | } |
| 67 | const result = new ArrayBuffer(length) |
| 68 | let index = 0 |
| 69 | this.buffers.forEach((buffer) => { |
| 70 | new Uint8Array(result).set(new Uint8Array(buffer), index) |
| 71 | index += buffer.byteLength |
| 72 | }) |
| 73 | return new Uint8Array(result) |
| 74 | } |
| 75 | |
| 76 | public static concat(...args: ArrayBuffer[]): Uint8Array { |
| 77 | const total = new BufferList() |