UNPKG

996 BMarkdownView Raw
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
6An API that provides a read-only view of coverage information with the ability
7to merge and summarize coverage info.
8
9Supersedes `object-utils` and `collector` from the v0 istanbul API.
10
11See the docs for the full API.
12
13```js
14var libCoverage = require('istanbul-lib-coverage');
15var map = libCoverage.createCoverageMap(globalCoverageVar);
16var summary = libCoverage.createCoverageSummary();
17
18// merge another coverage map into the one we created
19map.merge(otherCoverageMap);
20
21// inspect and summarize all file coverage objects in the map
22map.files().forEach(function(f) {
23 var fc = map.fileCoverageFor(f),
24 s = fc.toSummary();
25 summary.merge(s);
26});
27
28console.log('Global summary', summary);
29```