Skip to content

friedemannsommer/lcov-parser

Repository files navigation

LCOV parser

A LCOV file parser, written in TypeScript.

npm CI codecov node-current

This parser is built for the LCOV trace file format, which can be found here: github.com/linux-test-project/lcov/man/geninfo.1.

You're able to use different field names, if necessary.

Installation

npm install --save-dev --save-exact @friedemannsommer/lcov-parser

or the shorter equivalent:

npm i -DE @friedemannsommer/lcov-parser

Basic usage

string data

import lcovParser from "@friedemannsommer/lcov-parser"

const sections = await lcovParser({from: "<LCOV data>"})

Buffer / ArrayBuffer

import lcovParser from "@friedemannsommer/lcov-parser"

const sections = await 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.