20 lines
552 B
JavaScript
20 lines
552 B
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.serializeBytes = void 0;
|
||
|
/**
|
||
|
* Helper function for serialize byte arrays
|
||
|
*
|
||
|
* @param arrays Any number of byte array arguments
|
||
|
*/
|
||
|
function serializeBytes(...arrays) {
|
||
|
const length = arrays.reduce((prev, curr) => prev + curr.length, 0);
|
||
|
const buffer = new Uint8Array(length);
|
||
|
let offset = 0;
|
||
|
arrays.forEach(arr => {
|
||
|
buffer.set(arr, offset);
|
||
|
offset += arr.length;
|
||
|
});
|
||
|
return buffer;
|
||
|
}
|
||
|
exports.serializeBytes = serializeBytes;
|