read-lcov-safe
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

read-lcov-safe

NPM TypeScript Coverage Status GitHub Stars Twitter Follow

Read and parse an lcov file without try catch.

Installation

yarn add read-lcov-safe
npm install read-lcov-safe

API

Usage

import {
  readLCOV,
  readLCOVSync,
  LCOVRecord,
  FunctionsDetails,
  BranchesDetails,
  LinesDetails
} from "read-lcov-safe";
 
readLCOV(path).then((lcov) => {
  console.log(lcov);
  // Example output:
  // [{
  //   title: "",
  //   file: "source/file.ts",
  //   functions: {
  //     found: 2,
  //     hit: 2,
  //     details: [{
  //       line: 5,
  //       hit: 2,
  //       name: "functionA"
  //     }, {
  //       hit: 16,
  //       line: 8,
  //       name: "functionB"
  //     }]
  //   },
  //   branches: {
  //     found: 3,
  //     hit: 3,
  //     details: [{
  //       block: 0,
  //       branch: 0,
  //       line: 5,
  //       taken: 1
  //     }, {
  //       block: 1,
  //       branch: 0,
  //       line: 9,
  //       taken: 0
  //     }]
  //   },
  //   lines: {
  //     found: 13,
  //     hit: 13,
  //     details: [{
  //       hit: 1,
  //       line: 1
  //     }]
  //   }
  // }]
});

Types

import { readLCOV, readLCOVSync } from "read-lcov-safe";
 
function readLCOV(path: string): Promise<LCOVRecord[]>;
 
function readLCOVSync(path: string): LCOVRecord[];
 
type LCOVRecord = {
  title: string;
  file: string;
  functions: LCOVStats & {
    details: FunctionsDetails[];
  };
  branches: LCOVStats & {
    details: BranchesDetails[];
  };
  lines: LCOVStats & {
    details: LinesDetails[];
  };
}
 
type LCOVStats = {
  found: number;
  hit: number;
}
 
type FunctionsDetails = {
  name: string;
  line: number;
  hit?: number;
}
 
type BranchesDetails = {
  line: number;
  block: number;
  branch: number;
  taken: number;
};
 
type LinesDetails = {
  line: number;
  hit: number;
}

Dependenciesdependencies


Dev DependenciesDavid


License license

MIT

Package Sidebar

Install

npm i read-lcov-safe

Weekly Downloads

59

Version

1.0.2

License

MIT

Unpacked Size

7.77 kB

Total Files

5

Last publish

Collaborators

  • bconnorwhite