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

15 lines
387 B
JavaScript

/**
* Helper function for serialize byte arrays
*
* @param arrays Any number of byte array arguments
*/
export 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;
}