Skip to content

Instantly share code, notes, and snippets.

@ErnestoBorio
Created November 14, 2024 11:34
Show Gist options
  • Save ErnestoBorio/270266218b754b63e8196b827a6eaa79 to your computer and use it in GitHub Desktop.
Save ErnestoBorio/270266218b754b63e8196b827a6eaa79 to your computer and use it in GitHub Desktop.
let output = new ArrayBuffer(0, { maxByteLength: 0x10000 });
let data = new Uint8Array([1, 2]);
let offset = output.byteLength; // append data in this position
output.resize(offset + data.length); // grow buffer
let view = new Uint8Array(output); // get a data view for .set()
view.set(data, offset); // copy appended data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment