1 | ## istanbul-lib-coverage
|
2 |
|
3 | [![Greenkeeper badge](https://badges.greenkeeper.io/istanbuljs/istanbul-lib-coverage.svg)](https://greenkeeper.io/)
|
4 | [![Build Status](https://travis-ci.org/istanbuljs/istanbul-lib-coverage.svg?branch=master)](https://travis-ci.org/istanbuljs/istanbul-lib-coverage)
|
5 |
|
6 | An API that provides a read-only view of coverage information with the ability
|
7 | to merge and summarize coverage info.
|
8 |
|
9 | Supersedes `object-utils` and `collector` from the v0 istanbul API.
|
10 |
|
11 | See the docs for the full API.
|
12 |
|
13 | ```js
|
14 | var libCoverage = require('istanbul-lib-coverage');
|
15 | var map = libCoverage.createCoverageMap(globalCoverageVar);
|
16 | var summary = libCoverage.createCoverageSummary();
|
17 |
|
18 | // merge another coverage map into the one we created
|
19 | map.merge(otherCoverageMap);
|
20 |
|
21 | // inspect and summarize all file coverage objects in the map
|
22 | map.files().forEach(function(f) {
|
23 | var fc = map.fileCoverageFor(f),
|
24 | s = fc.toSummary();
|
25 | summary.merge(s);
|
26 | });
|
27 |
|
28 | console.log('Global summary', summary);
|
29 | ```
|