@mcap/nodejs
v1.0.2
Published
Support library for using MCAP in Node.js
Downloads
1,699
Readme
@mcap/nodejs
MCAP is a modular container format and logging library for pub/sub messages with arbitrary message serialization. It is primarily intended for use in robotics applications, and works well under various workloads, resource constraints, and durability requirements.
The @mcap/nodejs
package provides utilities for working with MCAP files from Node.js.
Usage examples
Reading MCAP files in Node.js
import { loadDecompressHandlers } from "@mcap/support";
import { FileHandleReadable } from "@mcap/nodejs";
import { McapIndexedReader } from "@mcap/core";
import { open } from "fs/promises";
const decompressHandlers = await loadDecompressHandlers();
const fileHandle = await open("file.mcap", "r");
const reader = await McapIndexedReader.Initialize({
readable: new FileHandleReadable(fileHandle),
decompressHandlers,
});
Writing MCAP files in Node.js
import zstd from "@foxglove/wasm-zstd";
import { FileHandleWritable } from "@mcap/nodejs";
import { McapWriter } from "@mcap/core";
import { open } from "fs/promises";
await zstd.isLoaded;
const fileHandle = await open("file.mcap", "wx");
const writer = new McapWriter({
writable: new FileHandleWritable(fileHandle),
compressChunk: (data) => ({
compression: "zstd",
compressedData: zstd.compress(data),
}),
});
License
@mcap/nodejs
is licensed under the MIT License.
Stay in touch
Join our Discord community to ask questions, share feedback, and stay up to date on what our team is working on.