aboutsummaryrefslogtreecommitdiff
path: root/src/formats.ts
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2019-11-23 12:29:32 -0500
committerKevin J Hoerr <kjhoerr@protonmail.com>2019-11-23 12:29:32 -0500
commit5964ec16673bd1474d32ffe87a2009b823c36f12 (patch)
tree4248f81604f326c364aff0e9a74989ad034a9e34 /src/formats.ts
parent62a6c312a19824a284d95d6f81d3eb5da86dbf5a (diff)
downloadao-coverage-5964ec16673bd1474d32ffe87a2009b823c36f12.tar.gz
ao-coverage-5964ec16673bd1474d32ffe87a2009b823c36f12.tar.bz2
ao-coverage-5964ec16673bd1474d32ffe87a2009b823c36f12.zip
Add Prettier to project
Signed-off-by: Kevin J Hoerr <kjhoerr@protonmail.com>
Diffstat (limited to 'src/formats.ts')
-rw-r--r--src/formats.ts66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/formats.ts b/src/formats.ts
index db9a188..34f97df 100644
--- a/src/formats.ts
+++ b/src/formats.ts
@@ -1,46 +1,52 @@
interface Format {
- // returns the coverage value as %: Number(90.0), Number(100.0), Number(89.5)
- parse_coverage: (file: Document) => number,
- match_color: (coverage: number, stage_1: number, stage_2: number) => string,
+ // returns the coverage value as %: Number(90.0), Number(100.0), Number(89.5)
+ parse_coverage: (file: Document) => number;
+ match_color: (coverage: number, stage_1: number, stage_2: number) => string;
}
interface FormatList {
- [key: string]: Format
+ [key: string]: Format;
}
interface FormatObj {
- formats: FormatList,
- list_formats: () => string[],
- get_format: (format: string) => Format,
+ formats: FormatList;
+ list_formats: () => string[];
+ get_format: (format: string) => Format;
}
// color is a gradient from green (>=stage_1) -> yellow (stage_2) -> red. Stage values should come from metadata.
-const default_color_matches = (coverage: number, stage_1: number, stage_2: number) => {
- const gradient = coverage >= stage_1 ? 15 :
- (coverage >= stage_2 ?
- (Math.floor(coverage) - stage_2) * 16 + 15 :
- 240 + Math.floor(coverage / (stage_2 / 15)));
- return gradient.toString(16) + "0";
+const default_color_matches = (
+ coverage: number,
+ stage_1: number,
+ stage_2: number
+) => {
+ const gradient =
+ coverage >= stage_1
+ ? 15
+ : coverage >= stage_2
+ ? (Math.floor(coverage) - stage_2) * 16 + 15
+ : 240 + Math.floor(coverage / (stage_2 / 15));
+ return gradient.toString(16) + "0";
};
const FormatsObj: FormatObj = {
- formats: {
- tarpaulin: {
- parse_coverage: (file: Document) => {
- //TODO parse coverage from file (example?)
- return 0.0;
- },
- match_color: default_color_matches,
- },
- },
+ formats: {
+ tarpaulin: {
+ parse_coverage: (file: Document) => {
+ //TODO parse coverage from file (example?)
+ return 0.0;
+ },
+ match_color: default_color_matches
+ }
+ },
- list_formats: function () {
- return Object.keys(this.formats);
- },
+ list_formats: function() {
+ return Object.keys(this.formats);
+ },
- get_format: function (format: string) {
- return this.formats[format];
- }
-}
+ get_format: function(format: string) {
+ return this.formats[format];
+ }
+};
-export default FormatsObj; \ No newline at end of file
+export default FormatsObj;