monocart-coverage-reports 2.12.10 → 2.12.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,7 @@ const applyBytesToLines = (bytes, locator, lineMap) => {
89
89
  } = lineItem;
90
90
 
91
91
  // default count to 1, both js and css
92
- let count = 1;
92
+ let count;
93
93
  // full covered true/false for entire line
94
94
  let covered = true;
95
95
 
@@ -288,9 +288,9 @@ const collectFileCoverage = (v8Data, state, options) => {
288
288
  sortRanges(data.functions);
289
289
 
290
290
  // branch group with locations to flat branches
291
- data.branches = branches.map((info) => {
291
+ data.branches = branches.flatMap((info) => {
292
292
  return info.getRanges();
293
- }).flat();
293
+ });
294
294
  sortRanges(data.branches);
295
295
 
296
296
  data.statements = statements.map((info) => {
@@ -326,21 +326,36 @@ const collectFileCoverage = (v8Data, state, options) => {
326
326
  b: {}
327
327
  };
328
328
 
329
- statements.filter((it) => !it.ignored).forEach((statement, index) => {
329
+ let index = 0;
330
+ for (const statement of statements) {
331
+ if (statement.ignored) {
332
+ continue;
333
+ }
330
334
  istanbulData.statementMap[`${index}`] = statement.generate(locator);
331
335
  istanbulData.s[`${index}`] = statement.count;
332
- });
336
+ index += 1;
337
+ }
333
338
 
334
- functions.filter((it) => !it.ignored).forEach((fn, index) => {
339
+ index = 0;
340
+ for (const fn of functions) {
341
+ if (fn.ignored) {
342
+ continue;
343
+ }
335
344
  istanbulData.fnMap[`${index}`] = fn.generate(locator, index);
336
345
  istanbulData.f[`${index}`] = fn.count;
337
- });
346
+ index += 1;
347
+ }
338
348
 
339
- branches.filter((it) => !it.ignored).forEach((branch, index) => {
349
+ index = 0;
350
+ for (const branch of branches) {
351
+ if (branch.ignored) {
352
+ continue;
353
+ }
340
354
  const { map, counts } = branch.generate(locator);
341
355
  istanbulData.branchMap[`${index}`] = map;
342
356
  istanbulData.b[`${index}`] = counts;
343
- });
357
+ index += 1;
358
+ }
344
359
 
345
360
  return istanbulData;
346
361
 
@@ -1610,7 +1625,7 @@ const mergeV8Data = (state, stateList) => {
1610
1625
 
1611
1626
  // ===========================================================
1612
1627
  // functions
1613
- const allFunctions = stateList.map((it) => it.functions).flat();
1628
+ const allFunctions = stateList.flatMap((it) => it.functions);
1614
1629
  const functionComparer = (lastRange, range) => {
1615
1630
  // if (lastRange.start === range.start && lastRange.end === range.end) {
1616
1631
  // return true;
@@ -1649,7 +1664,7 @@ const mergeV8Data = (state, stateList) => {
1649
1664
 
1650
1665
  // ===========================================================
1651
1666
  // statements
1652
- const allStatements = stateList.map((it) => it.statements).flat();
1667
+ const allStatements = stateList.flatMap((it) => it.statements);
1653
1668
  const statementComparer = (lastRange, range) => {
1654
1669
  // exact matched because the statement range is generated from ast
1655
1670
  return lastRange.start === range.start && lastRange.end === range.end;
@@ -1663,7 +1678,7 @@ const mergeV8Data = (state, stateList) => {
1663
1678
 
1664
1679
  // ===========================================================
1665
1680
  // branches
1666
- const allBranches = stateList.map((it) => it.branches).flat();
1681
+ const allBranches = stateList.flatMap((it) => it.branches);
1667
1682
  const branchComparer = (lastRange, range) => {
1668
1683
  // exact matched because the branch range is generated from ast
1669
1684
  return lastRange.start === range.start && lastRange.end === range.end;
@@ -1743,7 +1758,7 @@ const generateV8DataList = (stateList, options) => {
1743
1758
 
1744
1759
  // merge istanbul and v8(converted)
1745
1760
  const mergeMap = new Map();
1746
- allOriginalList.flat().forEach((originalState) => {
1761
+ allOriginalList.flatMap((arr) => arr).forEach((originalState) => {
1747
1762
  const { v8Data } = originalState;
1748
1763
  const id = v8Data.id;
1749
1764
  // exists item
package/lib/index.d.ts CHANGED
@@ -36,7 +36,7 @@ declare namespace MCR {
36
36
  export type Watermarks = [number, number] | {
37
37
  /** V8 only */
38
38
  bytes?: [number, number];
39
- statements: [number, number];
39
+ statements?: [number, number];
40
40
  branches?: [number, number];
41
41
  functions?: [number, number];
42
42
  lines?: [number, number];
@@ -134,7 +134,7 @@ declare namespace MCR {
134
134
  } | ((file: CoverageFile) => boolean);
135
135
  }] |
136
136
  ['markdown-summary'] | ['markdown-summary', {
137
- color: 'unicode' | 'html' | 'tex' | string;
137
+ color?: 'unicode' | 'html' | 'tex' | string;
138
138
  metrics?: Array<"bytes" | "statements" | "branches" | "functions" | "lines">;
139
139
  /**
140
140
  * defaults to `coverage-summary.md`
@@ -143,7 +143,7 @@ declare namespace MCR {
143
143
  }] |
144
144
  ['markdown-details'] | ['markdown-details', {
145
145
  baseUrl?: string;
146
- color: 'unicode' | 'html' | 'tex' | string;
146
+ color?: 'unicode' | 'html' | 'tex' | string;
147
147
  maxCols?: number;
148
148
  skipPercent?: number;
149
149
  metrics?: Array<"bytes" | "statements" | "branches" | "functions" | "lines">;
@@ -207,7 +207,7 @@ declare namespace MCR {
207
207
  */
208
208
  none?: boolean;
209
209
  /** function only, function name */
210
- name?: boolean;
210
+ name?: string;
211
211
  }
212
212
 
213
213
  export interface IgnoredRange {
@@ -422,10 +422,10 @@ declare namespace MCR {
422
422
  sourceMapResolver?: (url: string, defaultResolver: Function) => Promise<any>;
423
423
 
424
424
  /** (V8 only) {function} onEntry hook */
425
- onEntry?: (entry: V8CoverageEntry) => Promise<void>;
425
+ onEntry?: (entry: V8CoverageEntry) => void | Promise<void>;
426
426
 
427
427
  /** {function} onEnd hook */
428
- onEnd?: (coverageResults: CoverageResults | undefined) => Promise<void>;
428
+ onEnd?: (coverageResults: CoverageResults | undefined) => void | Promise<void>;
429
429
 
430
430
  [key: string]: any;
431
431
  }
@@ -433,13 +433,13 @@ declare namespace MCR {
433
433
  export interface McrCliOptions extends CoverageReportOptions {
434
434
 
435
435
  /** (CLI only) {function} onStart hook */
436
- onStart?: (coverageReport: CoverageReport) => Promise<void>;
436
+ onStart?: (coverageReport: CoverageReport) => void | Promise<void>;
437
437
 
438
438
  /** (CLI only) {function} onReady hook before adding coverage data.
439
- *
439
+ *
440
440
  * Sometimes, the child process has not yet finished writing the coverage data, and it needs to wait here.
441
441
  */
442
- onReady?: (coverageReport: CoverageReport, nodeV8CoverageDir: string, subprocess: any) => Promise<void>;
442
+ onReady?: (coverageReport: CoverageReport, nodeV8CoverageDir: string, subprocess: any) => void | Promise<void>;
443
443
 
444
444
  }
445
445