[6a3a178] | 1 | /*
|
---|
| 2 | Copyright 2012-2015, Yahoo Inc.
|
---|
| 3 | Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
---|
| 4 | */
|
---|
| 5 | 'use strict';
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * istanbul-lib-coverage exports an API that allows you to create and manipulate
|
---|
| 9 | * file coverage, coverage maps (a set of file coverage objects) and summary
|
---|
| 10 | * coverage objects. File coverage for the same file can be merged as can
|
---|
| 11 | * entire coverage maps.
|
---|
| 12 | *
|
---|
| 13 | * @module Exports
|
---|
| 14 | */
|
---|
| 15 | const { FileCoverage } = require('./lib/file-coverage');
|
---|
| 16 | const { CoverageMap } = require('./lib/coverage-map');
|
---|
| 17 | const { CoverageSummary } = require('./lib/coverage-summary');
|
---|
| 18 |
|
---|
| 19 | module.exports = {
|
---|
| 20 | /**
|
---|
| 21 | * creates a coverage summary object
|
---|
| 22 | * @param {Object} obj an argument with the same semantics
|
---|
| 23 | * as the one passed to the `CoverageSummary` constructor
|
---|
| 24 | * @returns {CoverageSummary}
|
---|
| 25 | */
|
---|
| 26 | createCoverageSummary(obj) {
|
---|
| 27 | if (obj && obj instanceof CoverageSummary) {
|
---|
| 28 | return obj;
|
---|
| 29 | }
|
---|
| 30 | return new CoverageSummary(obj);
|
---|
| 31 | },
|
---|
| 32 | /**
|
---|
| 33 | * creates a CoverageMap object
|
---|
| 34 | * @param {Object} obj optional - an argument with the same semantics
|
---|
| 35 | * as the one passed to the CoverageMap constructor.
|
---|
| 36 | * @returns {CoverageMap}
|
---|
| 37 | */
|
---|
| 38 | createCoverageMap(obj) {
|
---|
| 39 | if (obj && obj instanceof CoverageMap) {
|
---|
| 40 | return obj;
|
---|
| 41 | }
|
---|
| 42 | return new CoverageMap(obj);
|
---|
| 43 | },
|
---|
| 44 | /**
|
---|
| 45 | * creates a FileCoverage object
|
---|
| 46 | * @param {Object} obj optional - an argument with the same semantics
|
---|
| 47 | * as the one passed to the FileCoverage constructor.
|
---|
| 48 | * @returns {FileCoverage}
|
---|
| 49 | */
|
---|
| 50 | createFileCoverage(obj) {
|
---|
| 51 | if (obj && obj instanceof FileCoverage) {
|
---|
| 52 | return obj;
|
---|
| 53 | }
|
---|
| 54 | return new FileCoverage(obj);
|
---|
| 55 | }
|
---|
| 56 | };
|
---|
| 57 |
|
---|
| 58 | /** classes exported for reuse */
|
---|
| 59 | module.exports.classes = {
|
---|
| 60 | /**
|
---|
| 61 | * the file coverage constructor
|
---|
| 62 | */
|
---|
| 63 | FileCoverage
|
---|
| 64 | };
|
---|