### istanbul-lib-coverage

`1.0.0-alpha.2`

## Exports

istanbul-lib-coverage exports an API that allows you to create and manipulate file coverage, coverage maps (a set of file coverage objects) and summary coverage objects. File coverage for the same file can be merged as can entire coverage maps.

#### Static members

`.classes`

classes exported for reuse

## classes

classes exported for reuse

#### Static members

`.FileCoverage`

the file coverage constructor

## FileCoverage

the file coverage constructor

`.createCoverageMap(obj)`

creates a CoverageMap object

## createCoverageMap(obj)

creates a CoverageMap object

#### Parameters

- `Object` obj :

  optional - an argument with the same semantics as the one passed to the CoverageMap constructor.

#### Returns

``CoverageMap``
`.createCoverageSummary(obj)`

creates a coverage summary object

## createCoverageSummary(obj)

creates a coverage summary object

#### Parameters

- `Object` obj :

  an argument with the same semantics as the one passed to the `CoverageSummary` constructor

#### Returns

``CoverageSummary``
`.createFileCoverage(obj)`

creates a FileCoverage object

## createFileCoverage(obj)

creates a FileCoverage object

#### Parameters

- `Object` obj :

  optional - an argument with the same semantics as the one passed to the FileCoverage constructor.

#### Returns

``FileCoverage``

## CoverageMap([obj])

CoverageMap is a map of `FileCoverage` objects keyed by file paths.

#### Parameters

- `[`Object`]` obj (default `undefined`) :

  obj A coverage map from which to initialize this map's contents. This can be the raw global coverage object.

#### Instance members

`#addFileCoverage(fc)`

adds a file coverage object to this map. If the path for the object, already exists in the map, it is merged with the existing coverage otherwise a new key is added to the map.

## addFileCoverage(fc)

adds a file coverage object to this map. If the path for the object, already exists in the map, it is merged with the existing coverage otherwise a new key is added to the map.

#### Parameters

- `FileCoverage` fc :

  the file coverage to add

`#fileCoverageFor(file)`

returns the file coverage for the specified file.

## fileCoverageFor(file)

returns the file coverage for the specified file.

#### Parameters

- `String` file :

#### Returns

``FileCoverage``
`#files`

returns an array for file paths for which this map has coverage

## files

returns an array for file paths for which this map has coverage

`#getCoverageSummary`

returns the coverage summary for all the file coverage objects in this map.

## getCoverageSummary

returns the coverage summary for all the file coverage objects in this map.

#### Returns

``CoverageSummary``
`#merge(obj)`

merges a second coverage map into this one

## merge(obj)

merges a second coverage map into this one

#### Parameters

- `CoverageMap` obj :

  a CoverageMap or its raw data. Coverage is merged correctly for the same files and additional file coverage keys are created as needed.

`#toJSON`

returns a JSON-serializable POJO for this coverage map

## toJSON

returns a JSON-serializable POJO for this coverage map

#### Returns

``Object``

## CoverageSummary([obj])

CoverageSummary provides a summary of code coverage . It exposes 4 properties, `lines`, `statements`, `branches`, and `functions`. Each of these properties is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. `pct` is a percentage number (0-100).

#### Parameters

- `[`Object` or `CoverageSummary`]` obj (default `undefined`) :

  an optional data object or another coverage summary to initialize this object with.

#### Instance members

`#merge(obj)`

merges a second summary coverage object into this one

## merge(obj)

merges a second summary coverage object into this one

#### Parameters

- `CoverageSummary` obj :

  another coverage summary object

`#toJSON`

returns a POJO that is JSON serializable. May be used to get the raw summary object.

## toJSON

returns a POJO that is JSON serializable. May be used to get the raw summary object.

## FileCoverage(pathOrObj)

provides a read-only view of coverage for a single file. The deep structure of this object is documented elsewhere. It has the following properties:

- `path` - the file path for which coverage is being tracked
- `statementMap` - map of statement locations keyed by statement index
- `functionMap` - map of function metadata keyed by function index
- `branchMap` - map of branch metadata keyed by branch index
- `s` - hit counts for statements
- `f` - hit count for functions
- `b` - hit count for branches

#### Parameters

- `Object` or `FileCoverage` or `String` pathOrObj :

  is a string that initializes and empty coverage object with the specified file path or a data object that has all the required properties for a file coverage object.

#### Instance members

`#getBranchCoverageByLine`

returns a map of branch coverage by source line number.

## getBranchCoverageByLine

returns a map of branch coverage by source line number.

#### Returns

``Object`` :

an object keyed by line number. Each object has a `covered`, `total` and `coverage` (percentage) property.

`#getLineCoverage`

returns computed line coverage from statement coverage. This is a map of hits keyed by line number in the source.

## getLineCoverage

returns computed line coverage from statement coverage. This is a map of hits keyed by line number in the source.

`#getUncoveredLines`

returns an array of uncovered line numbers.

## getUncoveredLines

returns an array of uncovered line numbers.

#### Returns

``Array`` :

an array of line numbers for which no hits have been collected.

`#merge(other)`

merges a second coverage object into this one, updating hit counts

## merge(other)

merges a second coverage object into this one, updating hit counts

#### Parameters

- `FileCoverage` other :

  the coverage object to be merged into this one. Note that the other object should have the same structure as this one (same file).

`#resetHits`

resets hit counts for all statements, functions and branches in this coverage object resulting in zero coverage.

## resetHits

resets hit counts for all statements, functions and branches in this coverage object resulting in zero coverage.

`#toJSON`

return a JSON-serializable POJO for this file coverage object

## toJSON

return a JSON-serializable POJO for this file coverage object

`#toSummary`

returns a CoverageSummary for this file coverage object

## toSummary

returns a CoverageSummary for this file coverage object

#### Returns

``CoverageSummary``