binary draft
This commit is contained in:
parent
7f9a1e2c7a
commit
973f97cc09
38 changed files with 906 additions and 312 deletions
|
@ -0,0 +1,18 @@
|
|||
function concat(arrays) {
|
||||
// sum of individual array lengths
|
||||
let totalLength = arrays.reduce((acc, value) => acc + value.length, 0);
|
||||
|
||||
if (!arrays.length) return null;
|
||||
|
||||
let result = new Uint8Array(totalLength);
|
||||
|
||||
// for each array - copy it over result
|
||||
// next array is copied right after the previous one
|
||||
let length = 0;
|
||||
for(let array of arrays) {
|
||||
result.set(array, length);
|
||||
length += array.length;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue