Hello everyone I'm trying to figure out the fastest way to aggregate two typed arrays into a single array.
Imagine data looks like this [Int8Array, Int8Array]
and I want to end up with a single
Int8Array
Currently i'm trying to loop through the parent array and through the subarray since the typed arrays do not support concat method I can't do my normal reduce and concat way.
for (var i = 0, len = input.length; i < len; i++) {
for (var n = 0, len = input[i].length; n < len; n++) {
output.push(input[i][n]);
}
}
But i just feel like there has to be a more efficient way to do this.
Attempting to use the set method it appears to be faster but not applicable to more than 2.
Please refer to the following link. How can I merge TypedArrays in JavaScript?
They use the set method which does not require to use a loop