Skip to content

Instantly share code, notes, and snippets.

@ErnestoBorio
Created November 14, 2024 11:33
Show Gist options
  • Save ErnestoBorio/62953c74d97d3fe193790b1885aceb12 to your computer and use it in GitHub Desktop.
Save ErnestoBorio/62953c74d97d3fe193790b1885aceb12 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