UNPKG

793 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.u8aConcat = void 0;
4const toU8a_js_1 = require("./toU8a.js");
5/**
6 * @name u8aConcat
7 * @summary Creates a concatenated Uint8Array from the inputs.
8 * @description
9 * Concatenates the input arrays into a single `UInt8Array`.
10 * @example
11 * <BR>
12 *
13 * ```javascript
14 * import { { u8aConcat } from '@polkadot/util';
15 *
16 * u8aConcat(
17 * new Uint8Array([1, 2, 3]),
18 * new Uint8Array([4, 5, 6])
19 * ); // [1, 2, 3, 4, 5, 6]
20 * ```
21 */
22function u8aConcat(...list) {
23 const count = list.length;
24 const u8as = new Array(count);
25 for (let i = 0; i < count; i++) {
26 u8as[i] = (0, toU8a_js_1.u8aToU8a)(list[i]);
27 }
28 return Uint8Array.from(Buffer.concat(u8as));
29}
30exports.u8aConcat = u8aConcat;