Skip to content

Instantly share code, notes, and snippets.

@semlinker
Created July 25, 2022 10:32
Show Gist options
  • Save semlinker/dd9d21a106d8ea42f9e3d5394aae1cd1 to your computer and use it in GitHub Desktop.
Save semlinker/dd9d21a106d8ea42f9e3d5394aae1cd1 to your computer and use it in GitHub Desktop.
Concatenate Function
function concatenate(arrays) {
if (!arrays.length) return null;
let totalLength = arrays.reduce((acc, value) => acc + value.length, 0);
let result = new Uint8Array(totalLength);
let length = 0;
for (let array of arrays) {
result.set(array, length);
length += array.length;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment