@foxglove/ros1
Version:
Standalone TypeScript implementation of the ROS 1 (Robot Operating System) protocol with a pluggable transport layer
24 lines • 717 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.concatData = void 0;
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);
}
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;
}
exports.concatData = concatData;
//# sourceMappingURL=concatData.js.map