File
Blob: src/worker/git/receive/bytes.ts
| 1 | /** Shared byte-manipulation helpers for the streaming receive modules. */ |
| 2 | |
| 3 | export function appendBytes( |
| 4 | left: Uint8Array<ArrayBufferLike>, |
| 5 | right: Uint8Array<ArrayBufferLike> |
| 6 | ): Uint8Array<ArrayBufferLike> { |
| 7 | const merged = new Uint8Array(left.byteLength + right.byteLength); |
| 8 | merged.set(left, 0); |
| 9 | merged.set(right, left.byteLength); |
| 10 | return merged; |
| 11 | } |
| 12 | |
| 13 | export function cloneBytes(bytes: Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike> { |
| 14 | const cloned = new Uint8Array(bytes.byteLength); |
| 15 | cloned.set(bytes); |
| 16 | return cloned; |
| 17 | } |