1 | import { u8aToU8a } from './toU8a.js';
|
2 | /**
|
3 | * @name u8aConcat
|
4 | * @summary Creates a concatenated Uint8Array from the inputs.
|
5 | * @description
|
6 | * Concatenates the input arrays into a single `UInt8Array`.
|
7 | * @example
|
8 | * <BR>
|
9 | *
|
10 | * ```javascript
|
11 | * import { { u8aConcat } from '@polkadot/util';
|
12 | *
|
13 | * u8aConcat(
|
14 | * new Uint8Array([1, 2, 3]),
|
15 | * new Uint8Array([4, 5, 6])
|
16 | * ); // [1, 2, 3, 4, 5, 6]
|
17 | * ```
|
18 | */
|
19 | export function u8aConcat(...list) {
|
20 | const count = list.length;
|
21 | const u8as = new Array(count);
|
22 | for (let i = 0; i < count; i++) {
|
23 | u8as[i] = u8aToU8a(list[i]);
|
24 | }
|
25 | return Uint8Array.from(Buffer.concat(u8as));
|
26 | }
|