@foxglove/ros1
Version:
Standalone TypeScript implementation of the ROS 1 (Robot Operating System) protocol with a pluggable transport layer
24 lines • 759 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.concatData = concatData;
function concatData(chunks) {
if (chunks.length === 1 && chunks[0] != null) {
return chunks[0];
}
const totalLength = chunks.reduce((len, chunk) => len + chunk.length, 0);
let result;
try {
result = new Uint8Array(totalLength);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
}
catch (_err) {
throw new Error(`failed to allocate ${totalLength} bytes to concatenate ${chunks.length} chunks`);
}
let idx = 0;
for (const chunk of chunks) {
result.set(chunk, idx);
idx += chunk.length;
}
return result;
}
//# sourceMappingURL=concatData.js.map