@friedemannsommer/lcov-parser
v8.0.0
Published
A fast, zero-dependency parser for LCOV coverage reports, written in TypeScript for Node.js, with ESM/CommonJS support and a streaming API.
Readme
LCOV parser
A fast, zero-dependency parser for LCOV coverage reports, written in TypeScript for Node.js, with ESM/CommonJS support and a streaming API.
This parser is built for the LCOV trace file format, which can be found here: github.com/linux-test-project/lcov/docs/man/geninfo.rst.
You're able to use different field names, if necessary.
Why this parser?
| | lcov-parse | parse-lcov | @friedemannsommer/lcov-parser |
| ------------- | ------------------------------------------------------ | ------------------------------- | ---------------------------------------------------- |
| Last updated | 2017 | 2020 | 2026 |
| LCOV version | 1.x | 1.x | up to 2.5 |
| TypeScript | No (community @types/lcov-parse) | Yes (native) | Yes (native) |
| Module format | CommonJS only | CommonJS only | ESM + CommonJS (dual package) |
| Dependencies | 0 | 0 | 0 |
| Input types | string (file path or content) | string | string, Buffer, ArrayBuffer, Readable stream |
| API style | callback | sync | sync, promise, stream |
Installation
npm install --save-dev --save-exact @friedemannsommer/lcov-parseror the shorter equivalent:
npm i -DE @friedemannsommer/lcov-parserBasic usage
string data
import lcovParser from "@friedemannsommer/lcov-parser/sync";
const sections = lcovParser({ from: "<LCOV data>" });import lcovParser from "@friedemannsommer/lcov-parser/sync";
const sections = lcovParser({ from: Buffer.from("<LCOV data>") });Readable streams
import lcovParser from "@friedemannsommer/lcov-parser";
import { createReadStream } from "node:fs";
const lcovFile = createReadStream(new URL("path/to/lcov.info", import.meta.url));
const sections = await lcovParser({ from: lcovFile });For more details, take a look at the documentation, which can be found here: friedemannsommer.github.io/lcov-parser.
