Add array concat util (#9306)
This commit is contained in:
parent
c182c1c706
commit
516b4f0ff8
3 changed files with 39 additions and 4 deletions
|
@ -304,3 +304,12 @@ export class GroupedArray<K, T> {
|
|||
return new ArrayUtil(a);
|
||||
}
|
||||
}
|
||||
|
||||
export const concat = (...arrays: Uint8Array[]): Uint8Array => {
|
||||
return arrays.reduce((concatenatedSoFar: Uint8Array, toBeConcatenated: Uint8Array) => {
|
||||
const concatenated = new Uint8Array(concatenatedSoFar.length + toBeConcatenated.length);
|
||||
concatenated.set(concatenatedSoFar, 0);
|
||||
concatenated.set(toBeConcatenated, concatenatedSoFar.length);
|
||||
return concatenated;
|
||||
}, new Uint8Array(0));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue