edfcore 0.6.167 → 0.6.168

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.
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
109
109
  readonly reserved: 224;
110
110
  };
111
111
  /** Published package version. Kept in sync with package.json by a test. */
112
- export declare const VERSION = "0.6.167";
112
+ export declare const VERSION = "0.6.168";
113
113
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -79,5 +79,5 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
79
79
  reserved: 224,
80
80
  };
81
81
  /** Published package version. Kept in sync with package.json by a test. */
82
- export const VERSION = '0.6.167';
82
+ export const VERSION = '0.6.168';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IACxC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CA8ChG"}
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IACxC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AA+BD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CA+ChG"}
@@ -17,6 +17,30 @@
17
17
  */
18
18
  /** Descending, so the first entry is the worst thing in the list. */
19
19
  const SEVERITY_RANK = { error: 3, warning: 2, info: 1 };
20
+ /**
21
+ * One ELEMENT, before it is counted.
22
+ *
23
+ * The check above refuses the summary itself; it cannot refuse the summary's own rows, because
24
+ * those are an array. `byCode` carries `code` and `severity` — both of the fields this loop reads —
25
+ * so `summarizeDiagnostics(summary.byCode)` counted them and returned a summary that is wrong in
26
+ * the two numbers the call exists for: `total` became the number of distinct codes rather than of
27
+ * diagnostics, and every `count` became 1. On a file where one code fired four hundred times that
28
+ * reads as a file with one of it.
29
+ *
30
+ * `formatDiagnostics` refused the same rows in 0.6.160, one directory over, and threw on the third
31
+ * field it reads. This one reads only the two a row has, so it answered instead — and the answer is
32
+ * itself a well-formed summary, which is the outcome this package treats as the worst kind.
33
+ *
34
+ * Said in words rather than through `describeValue`, for the reason the check above gives.
35
+ */
36
+ function assertDiagnostic(diagnostic, index) {
37
+ if (typeof diagnostic?.message === 'string')
38
+ return;
39
+ throw new RangeError(`summarizeDiagnostics(): the value at ${index} carries no message, so it is not a ` +
40
+ 'diagnostic — a row of a by-code summary counts a code rather than being one, and counting ' +
41
+ 'those again reports the number of distinct codes as the number of diagnostics. Next: pass ' +
42
+ 'header.diagnostics, or the diagnostics on the chunk or the report you have.');
43
+ }
20
44
  /**
21
45
  * Counts by severity and by code.
22
46
  *
@@ -45,7 +69,8 @@ export function summarizeDiagnostics(diagnostics) {
45
69
  let infos = 0;
46
70
  let worst;
47
71
  const counts = new Map();
48
- for (const diagnostic of diagnostics) {
72
+ for (const [index, diagnostic] of diagnostics.entries()) {
73
+ assertDiagnostic(diagnostic, index);
49
74
  if (diagnostic.severity === 'error')
50
75
  errors += 1;
51
76
  else if (diagnostic.severity === 'warning')
@@ -1 +1 @@
1
- {"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA+BH,qEAAqE;AACrE,MAAM,aAAa,GAAgC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAErF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAqC;IACxE,2FAA2F;IAC3F,8FAA8F;IAC9F,mGAAmG;IACnG,0EAA0E;IAC1E,8FAA8F;IAC9F,kFA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AC,OAAO,EAAE,EAAE,CAAC;QACxD,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,QAAQ,KAAK,OAAO;YAAE,MAAM,IAAI,CAAC,CAAC;aAC5C,IAAI,UAAU,CAAC,QAAQ,KAAK,SAAS;YAAE,QAAQ,IAAI,CAAC,CAAC;;YACrD,KAAK,IAAI,CAAC,CAAC;QAEhB,IAAI,KAAK,KAAK,SAAS,IAAI,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACrF,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC;QAC9B,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE;YAC1B,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,qFAAqF;YACrF,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAI,UAAU,CAAC,QAAQ;YACnD,KAAK,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK,EAAE,WAAW,CAAC,MAAM;QACzB,MAAM;QACN,QAAQ;QACR,KAAK;QACL,KAAK;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;KAC9E,CAAC;AACJ,CAAC"}
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ alone does not tell you whether you were affected.
6
6
  edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
7
7
  defect; those are called out below.
8
8
 
9
+ ## 0.6.168
10
+
11
+ - **Fixed** a by-code summary counted as a diagnostics list. `summarizeDiagnostics` reads `code`
12
+ and `severity`, which are exactly the two fields a `byCode` row carries, so
13
+ `summarizeDiagnostics(summary.byCode)` did not fail — it returned a summary.
14
+ - A well-formed one, and wrong in the two numbers the call exists to produce: `total` became the
15
+ number of distinct codes rather than of diagnostics, and every `count` became 1. A file where one
16
+ code fired four hundred times reads, on the second pass, as a file with one thing wrong with it.
17
+ - 0.6.160 refused the same rows in `formatDiagnostics`, one directory over; that one reads a third
18
+ field and threw. The elements are now checked here too, per element and by position.
19
+
9
20
  ## 0.6.167
10
21
 
11
22
  - **Fixed** an array passed as the selection walking past the check added in 0.6.79. An array is an
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.167",
3
+ "version": "0.6.168",
4
4
  "description": "Modern, typed, zero-dependency reader for EDF, EDF+, BDF and BDF+ biosignal files. Works in browsers and Node with true random access.",
5
5
  "keywords": [
6
6
  "edf",
package/src/constants.ts CHANGED
@@ -93,4 +93,4 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
93
93
  } as const;
94
94
 
95
95
  /** Published package version. Kept in sync with package.json by a test. */
96
- export const VERSION = '0.6.167';
96
+ export const VERSION = '0.6.168';
@@ -48,6 +48,32 @@ export interface EdfDiagnosticSummary {
48
48
  /** Descending, so the first entry is the worst thing in the list. */
49
49
  const SEVERITY_RANK: Record<EdfSeverity, number> = { error: 3, warning: 2, info: 1 };
50
50
 
51
+ /**
52
+ * One ELEMENT, before it is counted.
53
+ *
54
+ * The check above refuses the summary itself; it cannot refuse the summary's own rows, because
55
+ * those are an array. `byCode` carries `code` and `severity` — both of the fields this loop reads —
56
+ * so `summarizeDiagnostics(summary.byCode)` counted them and returned a summary that is wrong in
57
+ * the two numbers the call exists for: `total` became the number of distinct codes rather than of
58
+ * diagnostics, and every `count` became 1. On a file where one code fired four hundred times that
59
+ * reads as a file with one of it.
60
+ *
61
+ * `formatDiagnostics` refused the same rows in 0.6.160, one directory over, and threw on the third
62
+ * field it reads. This one reads only the two a row has, so it answered instead — and the answer is
63
+ * itself a well-formed summary, which is the outcome this package treats as the worst kind.
64
+ *
65
+ * Said in words rather than through `describeValue`, for the reason the check above gives.
66
+ */
67
+ function assertDiagnostic(diagnostic: EdfDiagnostic, index: number): void {
68
+ if (typeof (diagnostic as { message?: unknown } | null | undefined)?.message === 'string') return;
69
+ throw new RangeError(
70
+ `summarizeDiagnostics(): the value at ${index} carries no message, so it is not a ` +
71
+ 'diagnostic — a row of a by-code summary counts a code rather than being one, and counting ' +
72
+ 'those again reports the number of distinct codes as the number of diagnostics. Next: pass ' +
73
+ 'header.diagnostics, or the diagnostics on the chunk or the report you have.',
74
+ );
75
+ }
76
+
51
77
  /**
52
78
  * Counts by severity and by code.
53
79
  *
@@ -79,7 +105,8 @@ export function summarizeDiagnostics(diagnostics: readonly EdfDiagnostic[]): Edf
79
105
  let worst: EdfSeverity | undefined;
80
106
 
81
107
  const counts = new Map<EdfDiagnosticCode, EdfCodeCount>();
82
- for (const diagnostic of diagnostics) {
108
+ for (const [index, diagnostic] of diagnostics.entries()) {
109
+ assertDiagnostic(diagnostic, index);
83
110
  if (diagnostic.severity === 'error') errors += 1;
84
111
  else if (diagnostic.severity === 'warning') warnings += 1;
85
112
  else infos += 1;