1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.u8aConcatStrict = exports.u8aConcat = void 0;
|
4 | const toU8a_js_1 = require("./toU8a.js");
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function u8aConcat(...list) {
|
23 | const count = list.length;
|
24 | const u8as = new Array(count);
|
25 | let length = 0;
|
26 | for (let i = 0; i < count; i++) {
|
27 | u8as[i] = (0, toU8a_js_1.u8aToU8a)(list[i]);
|
28 | length += u8as[i].length;
|
29 | }
|
30 | return u8aConcatStrict(u8as, length);
|
31 | }
|
32 | exports.u8aConcat = u8aConcat;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | function u8aConcatStrict(u8as, length = 0) {
|
38 | const count = u8as.length;
|
39 | let offset = 0;
|
40 | if (!length) {
|
41 | for (let i = 0; i < count; i++) {
|
42 | length += u8as[i].length;
|
43 | }
|
44 | }
|
45 | const result = new Uint8Array(length);
|
46 | for (let i = 0; i < count; i++) {
|
47 | result.set(u8as[i], offset);
|
48 | offset += u8as[i].length;
|
49 | }
|
50 | return result;
|
51 | }
|
52 | exports.u8aConcatStrict = u8aConcatStrict;
|