index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * istanbul-lib-coverage exports an API that allows you to create and manipulate
  8. * file coverage, coverage maps (a set of file coverage objects) and summary
  9. * coverage objects. File coverage for the same file can be merged as can
  10. * entire coverage maps.
  11. *
  12. * @module Exports
  13. */
  14. const { FileCoverage } = require('./lib/file-coverage');
  15. const { CoverageMap } = require('./lib/coverage-map');
  16. const { CoverageSummary } = require('./lib/coverage-summary');
  17. module.exports = {
  18. /**
  19. * creates a coverage summary object
  20. * @param {Object} obj an argument with the same semantics
  21. * as the one passed to the `CoverageSummary` constructor
  22. * @returns {CoverageSummary}
  23. */
  24. createCoverageSummary(obj) {
  25. if (obj && obj instanceof CoverageSummary) {
  26. return obj;
  27. }
  28. return new CoverageSummary(obj);
  29. },
  30. /**
  31. * creates a CoverageMap object
  32. * @param {Object} obj optional - an argument with the same semantics
  33. * as the one passed to the CoverageMap constructor.
  34. * @returns {CoverageMap}
  35. */
  36. createCoverageMap(obj) {
  37. if (obj && obj instanceof CoverageMap) {
  38. return obj;
  39. }
  40. return new CoverageMap(obj);
  41. },
  42. /**
  43. * creates a FileCoverage object
  44. * @param {Object} obj optional - an argument with the same semantics
  45. * as the one passed to the FileCoverage constructor.
  46. * @returns {FileCoverage}
  47. */
  48. createFileCoverage(obj) {
  49. if (obj && obj instanceof FileCoverage) {
  50. return obj;
  51. }
  52. return new FileCoverage(obj);
  53. }
  54. };
  55. /** classes exported for reuse */
  56. module.exports.classes = {
  57. /**
  58. * the file coverage constructor
  59. */
  60. FileCoverage
  61. };