edfcore 0.3.10 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,39 @@ 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.3.12
10
+
11
+ - **Fixed** `error.name` becoming a mangled identifier in any minified consumer bundle. Every
12
+ edfcore error took its name from `new.target.name`, which reads `Function.prototype.name` — and
13
+ a minifier rewrites `class EdfFormatError` to `class t`, so the name follows it. Bundled with
14
+ `esbuild --minify`, `new EdfFormatError(...).name` came out as `"t"`.
15
+ - That is exactly the build where it matters. `error.name` is what a consumer branches on in a
16
+ browser, `api-errors.md` states the value, and the package's own test asserts it — but the suite
17
+ runs against unminified source, so it could not see this. Each class now assigns its name as a
18
+ string literal.
19
+ - The guard renames the class binding with `Object.defineProperty(cls, 'name', …)` before
20
+ constructing, which is an exact simulation of the rewrite: `Function.prototype.name` is the one
21
+ property `new.target.name` reads. Verified separately against a real `esbuild --minify` bundle
22
+ of `dist/`; the test needs no bundler, and edfcore keeps its five dev dependencies.
23
+ - `new.target.name` remains in the abstract base as the fallback for a consumer who subclasses
24
+ `EdfError` themselves. Nothing else changed: `edfErrorKind` is still the supported discriminator,
25
+ because `instanceof` is false across a realm boundary and a name is not a type.
26
+
27
+ ## 0.3.11
28
+
29
+ - **Changed** `formatHeader` to stop calling the declared coverage the "duration" on a file that
30
+ says it has gaps. `recordCount * recordDuration` is what the records COVER; on an EDF+D or BDF+D
31
+ file the recording reaches further by whatever the gaps add up to. A four-record file with an
32
+ hour-long hole in it printed `duration 00:00:04` for a recording spanning 3604 s — and this
33
+ string exists to be pasted into a bug report, where it reads as "a 4-second file".
34
+ - The line is now labelled `covered` on those files, with two lines under it saying that the gaps
35
+ are not in the number and that `buildRecordIndex(recording)` is what reports the span and where
36
+ the gaps are. Continuous files are untouched and still say `duration`.
37
+ - The number itself has not changed and was never wrong; only its name was. A header ALONE cannot
38
+ report the span — that is the last record's onset minus the first's, and those live in the
39
+ timekeeping TALs, which `formatHeader` has never read. Saying which of the two quantities is on
40
+ screen is the whole fix, and it is the same fix 0.3.0 made to the sample-grid function names.
41
+
9
42
  ## 0.3.10
10
43
 
11
44
  - **Changed** `toPhysicalEnvelope` to return `NaN` for a bucket no sample landed in, instead of a
@@ -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.3.10";
112
+ export declare const VERSION = "0.3.12";
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.3.10';
82
+ export const VERSION = '0.3.12';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE5F,8BAAsB,QAAS,SAAQ,KAAK;IAC1C,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAEjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,eAAe,GACf,aAAa,GAC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C/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAG,qBAAqB,CAAU;gBAGnD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAOxE;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,QAAQ;IACpD,QAAQ,CAAC,YAAY,EAAG,SAAS,CAAU;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;gBAG1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAO/E;AAED,qBAAa,uBAAwB,SAAQ,QAAQ;IACnD,QAAQ,CAAC,YAAY,EAAG,SAAS,CAAU;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;gBAG1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAO3F"}
package/dist/errors.js CHANGED
@@ -11,6 +11,11 @@
11
11
  export class EdfError extends Error {
12
12
  constructor(message, options) {
13
13
  super(message, options);
14
+ // `new.target.name` is the FALLBACK, for a consumer who subclasses `EdfError` themselves.
15
+ // Every class in this file overwrites it with a literal in its own constructor, because
16
+ // `new.target.name` reads `Function.prototype.name` — which a minifier rewrites. Bundled
17
+ // with esbuild --minify, `new EdfFormatError(...).name` came out as `"t"`, in exactly the
18
+ // browser build where `error.name` is what a consumer branches on (fixed in 0.3.12).
14
19
  this.name = new.target.name;
15
20
  }
16
21
  }
@@ -45,6 +50,7 @@ export class EdfFormatError extends EdfError {
45
50
  recordIndex;
46
51
  constructor(message, init) {
47
52
  super(message, { cause: init.cause });
53
+ this.name = 'EdfFormatError';
48
54
  this.code = init.code;
49
55
  this.diagnostic = init.diagnostic;
50
56
  this.field = init.field ?? init.diagnostic?.field;
@@ -64,6 +70,7 @@ export class EdfScalingError extends EdfError {
64
70
  label;
65
71
  constructor(message, init) {
66
72
  super(message, { cause: init.cause });
73
+ this.name = 'EdfScalingError';
67
74
  this.code = init.code;
68
75
  this.signalIndex = init.signalIndex;
69
76
  this.label = init.label;
@@ -76,6 +83,7 @@ export class EdfRangeError extends EdfError {
76
83
  available;
77
84
  constructor(message, init) {
78
85
  super(message, { cause: init.cause });
86
+ this.name = 'EdfRangeError';
79
87
  this.requested = init.requested;
80
88
  this.available = init.available;
81
89
  }
@@ -88,6 +96,7 @@ export class EdfSourceError extends EdfError {
88
96
  receivedLength;
89
97
  constructor(message, init) {
90
98
  super(message, { cause: init.cause });
99
+ this.name = 'EdfSourceError';
91
100
  this.offset = init.offset;
92
101
  this.requestedLength = init.requestedLength;
93
102
  this.receivedLength = init.receivedLength;
@@ -104,6 +113,7 @@ export class EdfBudgetError extends EdfError {
104
113
  optionName = 'maxMaterializeBytes';
105
114
  constructor(message, init) {
106
115
  super(message, { cause: init.cause });
116
+ this.name = 'EdfBudgetError';
107
117
  this.requiredBytes = init.requiredBytes;
108
118
  this.budgetBytes = init.budgetBytes;
109
119
  }
@@ -118,6 +128,7 @@ export class EdfAmbiguousChannelError extends EdfError {
118
128
  matchingIndices;
119
129
  constructor(message, init) {
120
130
  super(message, { cause: init.cause });
131
+ this.name = 'EdfAmbiguousChannelError';
121
132
  this.label = init.label;
122
133
  this.matchingIndices = init.matchingIndices;
123
134
  }
@@ -128,6 +139,7 @@ export class EdfChannelNotFoundError extends EdfError {
128
139
  availableLabels;
129
140
  constructor(message, init) {
130
141
  super(message, { cause: init.cause });
142
+ this.name = 'EdfChannelNotFoundError';
131
143
  this.selector = init.selector;
132
144
  this.availableLabels = init.availableLabels;
133
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,OAAgB,QAAS,SAAQ,KAAK;IAG1C,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAmC,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAmBD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAoC,CAAC,YAAY,KAAK,QAAQ,CACvE,CAAC;AACJ,CAAC;AAYD;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IACjC,YAAY,GAAG,QAAiB,CAAC;IACjC,IAAI,CAAoB;IACxB,UAAU,CAA4B;IACtC,KAAK,CAAqB;IAC1B,UAAU,CAAqB;IAC/B,WAAW,CAAqB;IAChC,WAAW,CAAqB;IAEzC,YAAY,OAAe,EAAE,IAAwB;QACnD,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,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;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IAC1C,YAAY,GAAG,SAAkB,CAAC;IAClC,QAAQ,CAAkB;IAC1B,eAAe,CAAoB;IAE5C,YACE,OAAe,EACf,IAAwF;QAExF,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAC9C,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-header.d.ts","sourceRoot":"","sources":["../src/format-header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAmB,SAAS,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgClF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAsErF"}
1
+ {"version":3,"file":"format-header.d.ts","sourceRoot":"","sources":["../src/format-header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAmB,SAAS,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgClF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAoFrF"}
@@ -59,8 +59,22 @@ export function formatHeader(header, options) {
59
59
  ` (local, no timezone)`);
60
60
  lines.push(`record ${header.recordDurationSeconds} s · ${header.recordByteLength} bytes · ` +
61
61
  `${header.bytesPerSample} bytes/sample`);
62
- lines.push(`duration ${formatDurationTicks(header.recordDurationTicks * BigInt(header.recordCount))} ` +
62
+ // "duration" is only honest for a file whose records run end to end. On an EDF+D file this
63
+ // number is what the records COVER, and the recording reaches further by however much the gaps
64
+ // add up to — a four-record file with an hour-long hole in it printed `duration 00:00:04` for a
65
+ // recording that spans 3604 s. Someone pasting that into a bug report says "a 4-second file".
66
+ //
67
+ // A header alone cannot know the span: it is the last record's onset minus the first's, and
68
+ // those live in the timekeeping TALs. What a header does know is that this file claims to have
69
+ // gaps, so the label says what the number is and the next line says where the span comes from.
70
+ const discontinuous = header.continuity === 'discontinuous';
71
+ const label = discontinuous ? 'covered ' : 'duration ';
72
+ lines.push(`${label} ${formatDurationTicks(header.recordDurationTicks * BigInt(header.recordCount))} ` +
63
73
  `(${header.recordCount} × ${header.recordDurationSeconds} s)`);
74
+ if (discontinuous) {
75
+ lines.push(' what the records cover; the gaps between them are not in it');
76
+ lines.push(' buildRecordIndex(recording) reports the span and where the gaps are');
77
+ }
64
78
  if (header.recordCountSource === 'sourceByteLength') {
65
79
  // Worth saying out loud: the count came from the file size, not from the header field.
66
80
  lines.push(' record count recovered from the source length');
@@ -1 +1 @@
1
- {"version":3,"file":"format-header.js","sourceRoot":"","sources":["../src/format-header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,SAAS,UAAU,CAAC,IAAiC;IACnD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,KAAK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AAC;QAClC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,8FAA8F;QAC9F,sFAAsF;QACtF,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACzD,MAAM,OAAO,GACX;YACE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;YACzB,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;YAC7B,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SAE1B;aACE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;aAC9B,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC;aAClD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,mBAAmB,OAAO,EAAE,CAAC,CAAC;QACrE,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
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.3.10';
96
+ export const VERSION = '0.3.12';
package/src/errors.ts CHANGED
@@ -18,6 +18,11 @@ export abstract class EdfError extends Error {
18
18
 
19
19
  constructor(message: string, options?: { cause?: unknown }) {
20
20
  super(message, options as ErrorOptions | undefined);
21
+ // `new.target.name` is the FALLBACK, for a consumer who subclasses `EdfError` themselves.
22
+ // Every class in this file overwrites it with a literal in its own constructor, because
23
+ // `new.target.name` reads `Function.prototype.name` — which a minifier rewrites. Bundled
24
+ // with esbuild --minify, `new EdfFormatError(...).name` came out as `"t"`, in exactly the
25
+ // browser build where `error.name` is what a consumer branches on (fixed in 0.3.12).
21
26
  this.name = new.target.name;
22
27
  }
23
28
  }
@@ -84,6 +89,7 @@ export class EdfFormatError extends EdfError {
84
89
 
85
90
  constructor(message: string, init: EdfFormatErrorInit) {
86
91
  super(message, { cause: init.cause });
92
+ this.name = 'EdfFormatError';
87
93
  this.code = init.code;
88
94
  this.diagnostic = init.diagnostic;
89
95
  this.field = init.field ?? init.diagnostic?.field;
@@ -108,6 +114,7 @@ export class EdfScalingError extends EdfError {
108
114
  init: { code: EdfDiagnosticCode; signalIndex: number; label: string; cause?: unknown },
109
115
  ) {
110
116
  super(message, { cause: init.cause });
117
+ this.name = 'EdfScalingError';
111
118
  this.code = init.code;
112
119
  this.signalIndex = init.signalIndex;
113
120
  this.label = init.label;
@@ -125,6 +132,7 @@ export class EdfRangeError extends EdfError {
125
132
  init: { requested: RecordRange; available: RecordRange; cause?: unknown },
126
133
  ) {
127
134
  super(message, { cause: init.cause });
135
+ this.name = 'EdfRangeError';
128
136
  this.requested = init.requested;
129
137
  this.available = init.available;
130
138
  }
@@ -147,6 +155,7 @@ export class EdfSourceError extends EdfError {
147
155
  },
148
156
  ) {
149
157
  super(message, { cause: init.cause });
158
+ this.name = 'EdfSourceError';
150
159
  this.offset = init.offset;
151
160
  this.requestedLength = init.requestedLength;
152
161
  this.receivedLength = init.receivedLength;
@@ -168,6 +177,7 @@ export class EdfBudgetError extends EdfError {
168
177
  init: { requiredBytes: number; budgetBytes: number; cause?: unknown },
169
178
  ) {
170
179
  super(message, { cause: init.cause });
180
+ this.name = 'EdfBudgetError';
171
181
  this.requiredBytes = init.requiredBytes;
172
182
  this.budgetBytes = init.budgetBytes;
173
183
  }
@@ -187,6 +197,7 @@ export class EdfAmbiguousChannelError extends EdfError {
187
197
  init: { label: string; matchingIndices: readonly number[]; cause?: unknown },
188
198
  ) {
189
199
  super(message, { cause: init.cause });
200
+ this.name = 'EdfAmbiguousChannelError';
190
201
  this.label = init.label;
191
202
  this.matchingIndices = init.matchingIndices;
192
203
  }
@@ -202,6 +213,7 @@ export class EdfChannelNotFoundError extends EdfError {
202
213
  init: { selector: string | number; availableLabels: readonly string[]; cause?: unknown },
203
214
  ) {
204
215
  super(message, { cause: init.cause });
216
+ this.name = 'EdfChannelNotFoundError';
205
217
  this.selector = init.selector;
206
218
  this.availableLabels = init.availableLabels;
207
219
  }
@@ -70,10 +70,24 @@ export function formatHeader(header: EdfHeader, options?: FormatHeaderOptions):
70
70
  `record ${header.recordDurationSeconds} s · ${header.recordByteLength} bytes · ` +
71
71
  `${header.bytesPerSample} bytes/sample`,
72
72
  );
73
+ // "duration" is only honest for a file whose records run end to end. On an EDF+D file this
74
+ // number is what the records COVER, and the recording reaches further by however much the gaps
75
+ // add up to — a four-record file with an hour-long hole in it printed `duration 00:00:04` for a
76
+ // recording that spans 3604 s. Someone pasting that into a bug report says "a 4-second file".
77
+ //
78
+ // A header alone cannot know the span: it is the last record's onset minus the first's, and
79
+ // those live in the timekeeping TALs. What a header does know is that this file claims to have
80
+ // gaps, so the label says what the number is and the next line says where the span comes from.
81
+ const discontinuous = header.continuity === 'discontinuous';
82
+ const label = discontinuous ? 'covered ' : 'duration ';
73
83
  lines.push(
74
- `duration ${formatDurationTicks(header.recordDurationTicks * BigInt(header.recordCount))} ` +
84
+ `${label} ${formatDurationTicks(header.recordDurationTicks * BigInt(header.recordCount))} ` +
75
85
  `(${header.recordCount} × ${header.recordDurationSeconds} s)`,
76
86
  );
87
+ if (discontinuous) {
88
+ lines.push(' what the records cover; the gaps between them are not in it');
89
+ lines.push(' buildRecordIndex(recording) reports the span and where the gaps are');
90
+ }
77
91
  if (header.recordCountSource === 'sourceByteLength') {
78
92
  // Worth saying out loud: the count came from the file size, not from the header field.
79
93
  lines.push(' record count recovered from the source length');