biketrack-app/node_modules/@ethersphere/bee-js/dist/cjs/chunk/serialize.js

20 lines
552 B
JavaScript
Raw Normal View History

2022-07-11 10:27:11 +02:00
"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;