edfcore 0.2.14 → 0.2.15

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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ 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.2.15
10
+
11
+ - **Added** `summarizeDiagnostics(diagnostics)` — counts by severity and by code, plus `worst`.
12
+ `formatDiagnostics` produces text for a person; there was nothing that produced numbers for a
13
+ program, and `validateRecording`'s `report.ok` needs a full scan. `worst` is `undefined` for an
14
+ empty list rather than `'info'`, so `worst !== undefined` means "anything to report at all".
15
+ Documented with the warning that `errors > 0` does NOT mean the file failed to read: a deferred
16
+ code carries `error` severity while every signal but one decodes perfectly.
17
+ - **Changed** `formatValidationReport` to print severity counts in a fixed error-warning-info
18
+ order rather than in whichever order they first appeared, and to share one counting
19
+ implementation with `summarizeDiagnostics` instead of keeping a second copy.
20
+
9
21
  ## 0.2.14
10
22
 
11
23
  - **Added** `segmentAt(index, seconds)` — the pure, synchronous form of `index.locate()`. A viewer
@@ -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.2.14";
112
+ export declare const VERSION = "0.2.15";
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.2.14';
82
+ export const VERSION = '0.2.15';
83
83
  //# sourceMappingURL=constants.js.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Diagnostics, counted.
3
+ *
4
+ * `formatDiagnostics` turns a list into text for a human. This turns the same list into numbers
5
+ * for a program: the question "is anything wrong with this header, and how wrong" has no answer
6
+ * on `EdfHeader` — `validateRecording` produces a `report.ok`, but that needs a full scan, and a
7
+ * caller who has only just parsed the header has nothing to test but `diagnostics.length`.
8
+ *
9
+ * The one thing worth knowing before acting on `errors > 0`: an `error` here does not mean the
10
+ * file failed to read. It means at least one diagnostic has `error` severity, and the `deferred`
11
+ * codes — a signal whose gain cannot be computed — carry that severity while the file parses,
12
+ * reads and decodes perfectly. `signal.scale` is `undefined` for that one signal and every other
13
+ * signal is fine. Refusing the whole recording on that count throws away good data.
14
+ */
15
+ import type { EdfDiagnostic, EdfDiagnosticCode, EdfSeverity } from '../types.js';
16
+ export interface EdfCodeCount {
17
+ readonly code: EdfDiagnosticCode;
18
+ readonly severity: EdfSeverity;
19
+ readonly count: number;
20
+ }
21
+ export interface EdfDiagnosticSummary {
22
+ readonly total: number;
23
+ readonly errors: number;
24
+ readonly warnings: number;
25
+ readonly infos: number;
26
+ /** The highest severity present, or `undefined` when there are no diagnostics at all. */
27
+ readonly worst: EdfSeverity | undefined;
28
+ /** Distinct codes, most frequent first. Ties keep first-seen order. */
29
+ readonly byCode: readonly EdfCodeCount[];
30
+ }
31
+ /**
32
+ * Counts by severity and by code.
33
+ *
34
+ * `worst` is by severity rank, not by insertion order and not alphabetical — `error` beats
35
+ * `warning` beats `info`. It is `undefined` for an empty list rather than `'info'`, which would
36
+ * claim a note exists when none does.
37
+ *
38
+ * `byCode` is ordered by count, descending: on a damaged file one code usually accounts for most
39
+ * of the list — `TIMEKEEPING_TAL_MISSING` is reported per record — and that is the one to look at
40
+ * first. `Array.prototype.sort` is stable, so equal counts keep the order they were first seen.
41
+ */
42
+ export declare function summarizeDiagnostics(diagnostics: readonly EdfDiagnostic[]): EdfDiagnosticSummary;
43
+ //# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,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,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,CAiChG"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Diagnostics, counted.
3
+ *
4
+ * `formatDiagnostics` turns a list into text for a human. This turns the same list into numbers
5
+ * for a program: the question "is anything wrong with this header, and how wrong" has no answer
6
+ * on `EdfHeader` — `validateRecording` produces a `report.ok`, but that needs a full scan, and a
7
+ * caller who has only just parsed the header has nothing to test but `diagnostics.length`.
8
+ *
9
+ * The one thing worth knowing before acting on `errors > 0`: an `error` here does not mean the
10
+ * file failed to read. It means at least one diagnostic has `error` severity, and the `deferred`
11
+ * codes — a signal whose gain cannot be computed — carry that severity while the file parses,
12
+ * reads and decodes perfectly. `signal.scale` is `undefined` for that one signal and every other
13
+ * signal is fine. Refusing the whole recording on that count throws away good data.
14
+ */
15
+ /** Descending, so the first entry is the worst thing in the list. */
16
+ const SEVERITY_RANK = { error: 3, warning: 2, info: 1 };
17
+ /**
18
+ * Counts by severity and by code.
19
+ *
20
+ * `worst` is by severity rank, not by insertion order and not alphabetical — `error` beats
21
+ * `warning` beats `info`. It is `undefined` for an empty list rather than `'info'`, which would
22
+ * claim a note exists when none does.
23
+ *
24
+ * `byCode` is ordered by count, descending: on a damaged file one code usually accounts for most
25
+ * of the list — `TIMEKEEPING_TAL_MISSING` is reported per record — and that is the one to look at
26
+ * first. `Array.prototype.sort` is stable, so equal counts keep the order they were first seen.
27
+ */
28
+ export function summarizeDiagnostics(diagnostics) {
29
+ let errors = 0;
30
+ let warnings = 0;
31
+ let infos = 0;
32
+ let worst;
33
+ const counts = new Map();
34
+ for (const diagnostic of diagnostics) {
35
+ if (diagnostic.severity === 'error')
36
+ errors += 1;
37
+ else if (diagnostic.severity === 'warning')
38
+ warnings += 1;
39
+ else
40
+ infos += 1;
41
+ if (worst === undefined || SEVERITY_RANK[diagnostic.severity] > SEVERITY_RANK[worst]) {
42
+ worst = diagnostic.severity;
43
+ }
44
+ const existing = counts.get(diagnostic.code);
45
+ counts.set(diagnostic.code, {
46
+ code: diagnostic.code,
47
+ // The severity of a code is fixed by `severityOf`, so the first one seen is the one.
48
+ severity: existing?.severity ?? diagnostic.severity,
49
+ count: (existing?.count ?? 0) + 1,
50
+ });
51
+ }
52
+ return {
53
+ total: diagnostics.length,
54
+ errors,
55
+ warnings,
56
+ infos,
57
+ worst,
58
+ byCode: Object.freeze([...counts.values()].sort((a, b) => b.count - a.count)),
59
+ };
60
+ }
61
+ //# sourceMappingURL=summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAqBH,qEAAqE;AACrE,MAAM,aAAa,GAAgC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAErF;;;;;;;;;;GAUG;AACH,M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AC,CAAC,KAAK,CAAC,CAAC;KAC9E,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-report.d.ts","sourceRoot":"","sources":["../src/format-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AASnF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,MAAM,CAuDR;AAED,qFAAqF;AACrF,YAAY,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"format-report.d.ts","sourceRoot":"","sources":["../src/format-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AASnF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,MAAM,CA4DR;AAED,qFAAqF;AACrF,YAAY,EAAE,SAAS,EAAE,CAAC"}
@@ -11,6 +11,7 @@
11
11
  * thing are wrong and how much of the file is affected.
12
12
  */
13
13
  import { formatDiagnostics } from './diagnostics/format.js';
14
+ import { summarizeDiagnostics } from './diagnostics/summary.js';
14
15
  /** Enough to see the pattern, few enough to read. Override with `maxItems`. */
15
16
  const DEFAULT_MAX_ITEMS = 20;
16
17
  function pluralise(count, noun) {
@@ -25,24 +26,27 @@ function pluralise(count, noun) {
25
26
  export function formatValidationReport(report, options) {
26
27
  const lines = [];
27
28
  const header = options?.header;
28
- const bySeverity = new Map();
29
- const byCode = new Map();
30
- for (const diagnostic of report.diagnostics) {
31
- bySeverity.set(diagnostic.severity, (bySeverity.get(diagnostic.severity) ?? 0) + 1);
32
- byCode.set(diagnostic.code, (byCode.get(diagnostic.code) ?? 0) + 1);
33
- }
29
+ // One counting implementation, shared with the public `summarizeDiagnostics`.
30
+ const summary = summarizeDiagnostics(report.diagnostics);
34
31
  const verdict = report.ok ? 'PASS' : 'FAIL';
35
- const severities = bySeverity.size === 0
32
+ const severities = summary.total === 0
36
33
  ? 'no diagnostics'
37
- : [...bySeverity].map(([severity, count]) => `${count} ${severity}`).join(', ');
34
+ : [
35
+ [summary.errors, 'error'],
36
+ [summary.warnings, 'warning'],
37
+ [summary.infos, 'info'],
38
+ ]
39
+ .filter(([count]) => count > 0)
40
+ .map(([count, severity]) => `${count} ${severity}`)
41
+ .join(', ');
38
42
  lines.push(`${verdict} — ${severities}`);
39
43
  lines.push(`scanned ${pluralise(report.recordsScanned, 'record')}, ` +
40
44
  `read ${report.bytesRead.toLocaleString('en-US')} bytes`);
41
- if (byCode.size > 0) {
45
+ if (summary.byCode.length > 0) {
42
46
  lines.push('');
43
47
  lines.push('by code:');
44
- // Descending by count: the code affecting most of the file is the one to look at first.
45
- for (const [code, count] of [...byCode].sort((a, b) => b[1] - a[1])) {
48
+ // Already descending by count: the code affecting most of the file comes first.
49
+ for (const { code, count } of summary.byCode) {
46
50
  lines.push(` ${String(count).padStart(7)} ${code}`);
47
51
  }
48
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"format-report.js","sourceRoot":"","sources":["../src/format-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,+EAA+E;AAC/E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,SAAS,SAAS,CAAC,KAAa,EAAE,IAAY;IAC5C,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAwB,EACxB,OAA6B;I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C;QACf,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACtC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAClD,MAAM,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YACjF,MAAM,QAAQ,GACZ,KAAK,CAAC,sBAAsB,GAAG,CAAC;gBAC9B,CAAC,CAAC,KAAK,KAAK,CAAC,sBAAsB,6BAA6B;gBAChE,CAAC,CAAC,EAAE,CAAC;YACT,KAAK,CAAC,IAAI,CACR,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,kBAAkB,KAAK,KAAK,CAAC,kBAAkB,EAAE;gBACzF,SAAS,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,QAAQ,EAAE,CAC1E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,iBAAiB,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  /** The trailing `options` argument shared by every primitive that can allocate. */
23
23
  export type { MaterializeOptions } from './decode/digital.js';
24
24
  export type { FormatDiagnosticsOptions } from './diagnostics/format.js';
25
+ export type { EdfCodeCount, EdfDiagnosticSummary } from './diagnostics/summary.js';
25
26
  export type { AbortSignalLike, BlobLike, BuildIndexOptions, ByteSource, CacheOptions, DecodeAnnotationsOptions, EdfAnnotation, EdfAnnotationsResult, EdfAnnotationWindow, EdfCalendarDate, EdfChunk, EdfChunkSignal, EdfClockTime, EdfDiagnostic, EdfDiagnosticCode, EdfEnvelopeChunk, EdfEnvelopeSignal, EdfGap, EdfHeader, EdfInspection, EdfKnownDiagnosticCode, EdfLocation, EdfPatientId, EdfPhysicalEnvelope, EdfRawHeaderFields, EdfRawSignalFields, EdfRecordIndex, EdfRecording, EdfRecordingId, EdfSampleLocation, EdfScale, EdfSegment, EdfSeverity, EdfSignal, EdfStartTime, EdfStatusWord, EdfTimeline, EdfTriggerEvent, EdfVariant, EnvelopeSelection, FetchLike, FormatHeaderOptions, HttpResponseLike, HttpSourceOptions, OpenOptions, ParseOptions, ReadOptions, RecordRange, RecordSelection, StreamSelection, TriggerSelection, WindowSelection, } from './types.js';
26
27
  export type { AnyEdfError, EdfErrorKind, EdfFormatErrorInit } from './errors.js';
27
28
  export { EdfAmbiguousChannelError, EdfBudgetError, EdfChannelNotFoundError, EdfError, EdfFormatError, EdfRangeError, EdfScalingError, EdfSourceError, isEdfError, } from './errors.js';
@@ -30,6 +31,7 @@ export { decodeHeaderLatin1 } from './bytes/latin1.js';
30
31
  export { decodeDigital } from './decode/digital.js';
31
32
  export { clampToDigitalRange, physicalRangeOf, toPhysical } from './decode/physical.js';
32
33
  export { formatDiagnostics } from './diagnostics/format.js';
34
+ export { summarizeDiagnostics } from './diagnostics/summary.js';
33
35
  export { formatStartTimeNaive } from './header/dates.js';
34
36
  export { declaredDurationSeconds, findSignals, getSignal, isAnnotationLabel, matchSignals, } from './header/lookup.js';
35
37
  export { parseHeader } from './header/parse.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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AAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,mFAAmF;AACnF,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACnF,YAAY,EACV,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,SAAS,EACT,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,WAAW,EACX,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,G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,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAM7F,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ export { decodeHeaderLatin1 } from './bytes/latin1.js';
32
32
  export { decodeDigital } from './decode/digital.js';
33
33
  export { clampToDigitalRange, physicalRangeOf, toPhysical } from './decode/physical.js';
34
34
  export { formatDiagnostics } from './diagnostics/format.js';
35
+ export { summarizeDiagnostics } from './diagnostics/summary.js';
35
36
  export { formatStartTimeNaive } from './header/dates.js';
36
37
  export { declaredDurationSeconds, findSignals, getSignal, isAnnotationLabel, matchSignals, } from './header/lookup.js';
37
38
  export { parseHeader } from './header/parse.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;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BAAmB,CAAC;AAE7F,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
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.2.14';
96
+ export const VERSION = '0.2.15';
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Diagnostics, counted.
3
+ *
4
+ * `formatDiagnostics` turns a list into text for a human. This turns the same list into numbers
5
+ * for a program: the question "is anything wrong with this header, and how wrong" has no answer
6
+ * on `EdfHeader` — `validateRecording` produces a `report.ok`, but that needs a full scan, and a
7
+ * caller who has only just parsed the header has nothing to test but `diagnostics.length`.
8
+ *
9
+ * The one thing worth knowing before acting on `errors > 0`: an `error` here does not mean the
10
+ * file failed to read. It means at least one diagnostic has `error` severity, and the `deferred`
11
+ * codes — a signal whose gain cannot be computed — carry that severity while the file parses,
12
+ * reads and decodes perfectly. `signal.scale` is `undefined` for that one signal and every other
13
+ * signal is fine. Refusing the whole recording on that count throws away good data.
14
+ */
15
+
16
+ import type { EdfDiagnostic, EdfDiagnosticCode, EdfSeverity } from '../types.js';
17
+
18
+ export interface EdfCodeCount {
19
+ readonly code: EdfDiagnosticCode;
20
+ readonly severity: EdfSeverity;
21
+ readonly count: number;
22
+ }
23
+
24
+ export interface EdfDiagnosticSummary {
25
+ readonly total: number;
26
+ readonly errors: number;
27
+ readonly warnings: number;
28
+ readonly infos: number;
29
+ /** The highest severity present, or `undefined` when there are no diagnostics at all. */
30
+ readonly worst: EdfSeverity | undefined;
31
+ /** Distinct codes, most frequent first. Ties keep first-seen order. */
32
+ readonly byCode: readonly EdfCodeCount[];
33
+ }
34
+
35
+ /** Descending, so the first entry is the worst thing in the list. */
36
+ const SEVERITY_RANK: Record<EdfSeverity, number> = { error: 3, warning: 2, info: 1 };
37
+
38
+ /**
39
+ * Counts by severity and by code.
40
+ *
41
+ * `worst` is by severity rank, not by insertion order and not alphabetical — `error` beats
42
+ * `warning` beats `info`. It is `undefined` for an empty list rather than `'info'`, which would
43
+ * claim a note exists when none does.
44
+ *
45
+ * `byCode` is ordered by count, descending: on a damaged file one code usually accounts for most
46
+ * of the list — `TIMEKEEPING_TAL_MISSING` is reported per record — and that is the one to look at
47
+ * first. `Array.prototype.sort` is stable, so equal counts keep the order they were first seen.
48
+ */
49
+ export function summarizeDiagnostics(diagnostics: readonly EdfDiagnostic[]): EdfDiagnosticSummary {
50
+ let errors = 0;
51
+ let warnings = 0;
52
+ let infos = 0;
53
+ let worst: EdfSeverity | undefined;
54
+
55
+ const counts = new Map<EdfDiagnosticCode, EdfCodeCount>();
56
+ for (const diagnostic of diagnostics) {
57
+ if (diagnostic.severity === 'error') errors += 1;
58
+ else if (diagnostic.severity === 'warning') warnings += 1;
59
+ else infos += 1;
60
+
61
+ if (worst === undefined || SEVERITY_RANK[diagnostic.severity] > SEVERITY_RANK[worst]) {
62
+ worst = diagnostic.severity;
63
+ }
64
+
65
+ const existing = counts.get(diagnostic.code);
66
+ counts.set(diagnostic.code, {
67
+ code: diagnostic.code,
68
+ // The severity of a code is fixed by `severityOf`, so the first one seen is the one.
69
+ severity: existing?.severity ?? diagnostic.severity,
70
+ count: (existing?.count ?? 0) + 1,
71
+ });
72
+ }
73
+
74
+ return {
75
+ total: diagnostics.length,
76
+ errors,
77
+ warnings,
78
+ infos,
79
+ worst,
80
+ byCode: Object.freeze([...counts.values()].sort((a, b) => b.count - a.count)),
81
+ };
82
+ }
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import { formatDiagnostics } from './diagnostics/format.js';
15
+ import { summarizeDiagnostics } from './diagnostics/summary.js';
15
16
  import type { EdfHeader, FormatReportOptions, ValidationReport } from './types.js';
16
17
 
17
18
  /** Enough to see the pattern, few enough to read. Override with `maxItems`. */
@@ -34,29 +35,34 @@ export function formatValidationReport(
34
35
  const lines: string[] = [];
35
36
  const header = options?.header;
36
37
 
37
- const bySeverity = new Map<string, number>();
38
- const byCode = new Map<string, number>();
39
- for (const diagnostic of report.diagnostics) {
40
- bySeverity.set(diagnostic.severity, (bySeverity.get(diagnostic.severity) ?? 0) + 1);
41
- byCode.set(diagnostic.code, (byCode.get(diagnostic.code) ?? 0) + 1);
42
- }
38
+ // One counting implementation, shared with the public `summarizeDiagnostics`.
39
+ const summary = summarizeDiagnostics(report.diagnostics);
43
40
 
44
41
  const verdict = report.ok ? 'PASS' : 'FAIL';
45
42
  const severities =
46
- bySeverity.size === 0
43
+ summary.total === 0
47
44
  ? 'no diagnostics'
48
- : [...bySeverity].map(([severity, count]) => `${count} ${severity}`).join(', ');
45
+ : (
46
+ [
47
+ [summary.errors, 'error'],
48
+ [summary.warnings, 'warning'],
49
+ [summary.infos, 'info'],
50
+ ] as const
51
+ )
52
+ .filter(([count]) => count > 0)
53
+ .map(([count, severity]) => `${count} ${severity}`)
54
+ .join(', ');
49
55
  lines.push(`${verdict} — ${severities}`);
50
56
  lines.push(
51
57
  `scanned ${pluralise(report.recordsScanned, 'record')}, ` +
52
58
  `read ${report.bytesRead.toLocaleString('en-US')} bytes`,
53
59
  );
54
60
 
55
- if (byCode.size > 0) {
61
+ if (summary.byCode.length > 0) {
56
62
  lines.push('');
57
63
  lines.push('by code:');
58
- // Descending by count: the code affecting most of the file is the one to look at first.
59
- for (const [code, count] of [...byCode].sort((a, b) => b[1] - a[1])) {
64
+ // Already descending by count: the code affecting most of the file comes first.
65
+ for (const { code, count } of summary.byCode) {
60
66
  lines.push(` ${String(count).padStart(7)} ${code}`);
61
67
  }
62
68
  }
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@
28
28
  /** The trailing `options` argument shared by every primitive that can allocate. */
29
29
  export type { MaterializeOptions } from './decode/digital.js';
30
30
  export type { FormatDiagnosticsOptions } from './diagnostics/format.js';
31
+ export type { EdfCodeCount, EdfDiagnosticSummary } from './diagnostics/summary.js';
31
32
  export type {
32
33
  AbortSignalLike,
33
34
  BlobLike,
@@ -130,6 +131,7 @@ export { decodeHeaderLatin1 } from './bytes/latin1.js';
130
131
  export { decodeDigital } from './decode/digital.js';
131
132
  export { clampToDigitalRange, physicalRangeOf, toPhysical } from './decode/physical.js';
132
133
  export { formatDiagnostics } from './diagnostics/format.js';
134
+ export { summarizeDiagnostics } from './diagnostics/summary.js';
133
135
  export { formatStartTimeNaive } from './header/dates.js';
134
136
  export {
135
137
  declaredDurationSeconds,