percent.js 371 B

123456789101112131415
  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. module.exports = function percent(covered, total) {
  7. let tmp;
  8. if (total > 0) {
  9. tmp = (1000 * 100 * covered) / total + 5;
  10. return Math.floor(tmp / 10) / 100;
  11. } else {
  12. return 100.0;
  13. }
  14. };