# read-lcov-safe

> Read and parse an lcov file without try catch

Latest version **1.0.2** (published 2020-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install read-lcov-safe
pnpm add read-lcov-safe
yarn add read-lcov-safe
bun add read-lcov-safe
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-09-30 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Connor White |
| Maintainers | bconnorwhite |
| Keywords | lcov, read, file, safe, try, catch, without, parse, json |

## Links

- npm: https://www.npmjs.com/package/read-lcov-safe
- Repository: https://github.com/bconnorwhite/read-lcov-safe
- Homepage: https://connorwhite.org/github/read-lcov-safe
- Issues: https://github.com/bconnorwhite/read-lcov-safe/issues
- npm.io page: https://npm.io/package/read-lcov-safe

## Dependencies (2)

- [parse-lcov](https://npm.io/package/parse-lcov.md) ^1.0.2
- [read-file-safe](https://npm.io/package/read-file-safe.md) ^1.0.5

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-09-30
- 1.0.1 — 2020-09-29
- 1.0.0 — 2020-09-28

## README

<div align="center">
  <h1>read-lcov-safe</h1>
  <a href="https://npmjs.com/package/read-lcov-safe">
    <img alt="NPM" src="https://img.shields.io/npm/v/read-lcov-safe.svg">
  </a>
  <a href="https://github.com/bconnorwhite/read-lcov-safe">
    <img alt="TypeScript" src="https://img.shields.io/github/languages/top/bconnorwhite/read-lcov-safe.svg">
  </a>
  <a href='https://coveralls.io/github/bconnorwhite/read-lcov-safe?branch=master'>
    <img alt="Coverage Status" src="https://img.shields.io/coveralls/github/bconnorwhite/read-lcov-safe.svg?branch=master">
  </a>
  <a href="https://github.com/bconnorwhite/read-lcov-safe">
    <img alt="GitHub Stars" src="https://img.shields.io/github/stars/bconnorwhite/read-lcov-safe?label=Stars%20Appreciated%21&style=social">
  </a>
  <a href="https://twitter.com/bconnorwhite">
    <img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/bconnorwhite.svg?label=%40bconnorwhite&style=social">
  </a>
</div>

<br />

> Read and parse an lcov file without try catch.

## Installation

```bash
yarn add read-lcov-safe
```

```bash
npm install read-lcov-safe
```

## API

### Usage
```ts
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
```ts
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;
}
```

<br />

<h2>Dependencies<img align="right" alt="dependencies" src="https://img.shields.io/david/bconnorwhite/read-lcov-safe.svg"></h2>

- [parse-lcov](https://www.npmjs.com/package/parse-lcov): Parse LCOV
- [read-file-safe](https://www.npmjs.com/package/read-file-safe): Read files without try catch.

<br />

<h2>Dev Dependencies<img align="right" alt="David" src="https://img.shields.io/david/dev/bconnorwhite/read-lcov-safe.svg"></h2>

- [@bconnorwhite/bob](https://www.npmjs.com/package/@bconnorwhite/bob): undefined

<br />

<h2>License <img align="right" alt="license" src="https://img.shields.io/npm/l/read-lcov-safe.svg"></h2>

[MIT](https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/read-lcov-safe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
