index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. * @module Exports
  8. */
  9. const summarizer = require('./lib/summarizer');
  10. const context = require('./lib/context');
  11. const watermarks = require('./lib/watermarks');
  12. module.exports = {
  13. /**
  14. * returns a reporting context for the supplied options
  15. * @param {Object} [opts=null] opts
  16. * @returns {Context}
  17. */
  18. createContext(opts) {
  19. return context.create(opts);
  20. },
  21. /**
  22. * returns the default watermarks that would be used when not
  23. * overridden
  24. * @returns {Object} an object with `statements`, `functions`, `branches`,
  25. * and `line` keys. Each value is a 2 element array that has the low and
  26. * high watermark as percentages.
  27. */
  28. getDefaultWatermarks() {
  29. return watermarks.getDefault();
  30. }
  31. };
  32. /**
  33. * standard summary functions
  34. */
  35. module.exports.summarizers = {
  36. /**
  37. * a summarizer that creates a flat tree with one root node and bunch of
  38. * files directly under it
  39. */
  40. flat: summarizer.createFlatSummary,
  41. /**
  42. * a summarizer that creates a hierarchical tree where the coverage summaries
  43. * of each directly reflect the summaries of all subdirectories and files in it
  44. */
  45. nested: summarizer.createNestedSummary,
  46. /**
  47. * a summarizer that creates a tree in which directories are not nested.
  48. * Every subdirectory is a child of the root node and only reflects the
  49. * coverage numbers for the files in it (i.e. excludes subdirectories).
  50. * This is the default summarizer.
  51. */
  52. pkg: summarizer.createPackageSummary
  53. };