edfcore 0.3.57 → 0.3.59

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,44 @@ 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.59
10
+
11
+ - **Fixed** `mergeChunks`' exact-tick refusal calling an overlap "a discontinuity of **-0.2** s"
12
+ that "is a gap in TIME" — the fourth site of the defect 0.3.33 and 0.3.41 swept, forty lines below
13
+ the third, in the same function.
14
+ - `assertJoinable` has two refusal paths. The one on `next.precededByGap` was taught to branch on
15
+ the sign in 0.3.41. The tick comparison beside it was not — and it is the path an overlap
16
+ actually reaches after a bare `openEdf`, because a **probed** index reports no gaps at all, so
17
+ `precededByGap` is `undefined` and the branch that knows the difference never runs.
18
+ - It now says "an overlap of 0.2 s ... the records on either side of the join both claim that
19
+ time", the wording 0.3.41 settled on, and reports a positive magnitude. A gap of negative
20
+ duration is not a thing.
21
+ - The gap wording is unchanged, byte for byte, so nothing that reads the existing message moves.
22
+ The new test asserts on the tick path specifically, with `precededByGap` checked to be `undefined`
23
+ first — otherwise it would be testing the branch that was already right.
24
+
25
+ ## 0.3.58
26
+
27
+ - **Fixed** the `EdfAnnotation` table in `api-types.md`, which put `onsetTicks` on the wrong axis
28
+ and then told readers to compare event times with it and nothing else.
29
+ - The table said `onsetTicks` is "exact, in 100 ns units, on the same axis as the rebased value".
30
+ It is not: it is the number the file wrote, on the **header's** timebase. `src/types.ts` says so
31
+ in the docblock that generates the published `.d.ts`, and calls it "the wrong one for comparing
32
+ an annotation against a window".
33
+ - The rebased field, `onsetTicksFromFirstRecord`, was missing from the table altogether —
34
+ thirteen rows for a fourteen-field interface. So the page named the wrong field as the exact
35
+ one and omitted the right one, in the same three lines.
36
+ - A reader who followed it compared `onsetTicks` against `chunk.startTicks`, `segment.startTicks`
37
+ or a `readWindow` bound — all of which the same page puts on the `t = 0 = start of record 0`
38
+ axis — and every event landed up to a second late, with nothing to indicate it. On a file whose
39
+ record 0 starts 0.25 s in, an event written `+1.25` has `onsetTicks` 12500000 and
40
+ `onsetTicksFromFirstRecord` 10000000, which is exactly `chunk.startTicks` for record 1.
41
+ - `annotations.md` had it right in two places, so the package's two reference pages disagreed.
42
+ - `tests/integration/annotation-fields-doc.test.ts` reads the field list off a decoded annotation
43
+ rather than from a list written down beside it, so a field added to the interface fails the suite
44
+ until the table lists it. It builds a file whose two onset axes genuinely differ, which is what
45
+ makes the wording load-bearing rather than decorative.
46
+
9
47
  ## 0.3.57
10
48
 
11
49
  - **Fixed** the zero-record chunk's start time, which was read off a segment on the wrong axis and
@@ -1 +1 @@
1
- {"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,YAAY,CAAC;AA8G1E;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CA6EjE"}
1
+ {"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,YAAY,CAAC;AA4H1E;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CA6EjE"}
package/dist/chunks.js CHANGED
@@ -80,12 +80,26 @@ function assertJoinable(previous, next, index) {
80
80
  const previousEndTicks = previous.startTicks + previous.durationTicks;
81
81
  const nextStartTicks = next.startTicks;
82
82
  if (previousEndTicks !== nextStartTicks) {
83
- const gapSeconds = ticksToSeconds(nextStartTicks - previousEndTicks);
83
+ // Branched on the SIGN, like the `precededByGap` path above. A negative difference is an
84
+ // overlap, not a gap, and this path is the one that actually fires for an overlap after
85
+ // `openEdf`: a probed index reports no gaps at all, so `precededByGap` is `undefined` and the
86
+ // branch that was taught the distinction in 0.3.41 never runs. It printed "a discontinuity of
87
+ // -0.2 s ... this is a gap in TIME", which names the wrong thing twice — a fourth site of the
88
+ // defect 0.3.33 and 0.3.41 swept, forty lines below the third (fixed in 0.3.59).
89
+ const deltaTicks = nextStartTicks - previousEndTicks;
90
+ const overlapping = deltaTicks < 0n;
91
+ const magnitude = ticksToSeconds(overlapping ? -deltaTicks : deltaTicks);
84
92
  throw new RangeError(`mergeChunks: chunk ${index} starts at ${next.startSeconds} s, but the chunk before it ends ` +
85
- `at ${ticksToSeconds(previousEndTicks)} s — a discontinuity of ${gapSeconds} s. The two ` +
86
- 'are record-adjacent, so this is a gap in TIME that the record numbers cannot show: ' +
87
- 'either the index was never scanned, or these chunks came from separate reads. ' +
88
- 'Concatenating them would date every sample after the join wrong by that much. Next: ' +
93
+ `at ${ticksToSeconds(previousEndTicks)} s — ` +
94
+ (overlapping
95
+ ? `an overlap of ${magnitude} s. The two are record-adjacent, so the records on either ` +
96
+ 'side of the join both claim that time and the record numbers cannot show it. ' +
97
+ 'Concatenating them would store it twice and date every sample after the join late ' +
98
+ 'by it.'
99
+ : `a discontinuity of ${magnitude} s. The two are record-adjacent, so this is a gap in ` +
100
+ 'TIME that the record numbers cannot show. Concatenating them would date every ' +
101
+ 'sample after the join wrong by that much.') +
102
+ ' Either the index was never scanned, or these chunks came from separate reads. Next: ' +
89
103
  'await buildRecordIndex(recording) and merge each contiguous run separately.');
90
104
  }
91
105
  if (next.signals.length !== previous.signals.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"chunks.js","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gBA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,KAAK,CAAC,OAAO,CAAC,KAAK;YAC1B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK;SACrE;QACD,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,6FAA6F;QAC7F,0FAA0F;QAC1F,yFAAyF;QACzF,6DAA6D;QAC7D,aAAa,EAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU;QACtE,eAAe,EAAE,cAAc,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC;QACxF,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/B,wFAAwF;QACxF,sDAAsD;QACtD,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;KACxC,CAAC;AACJ,CAAC"}
@@ -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.57";
112
+ export declare const VERSION = "0.3.59";
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.57';
82
+ export const VERSION = '0.3.59';
83
83
  //# sourceMappingURL=constants.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.3.57",
3
+ "version": "0.3.59",
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/chunks.ts CHANGED
@@ -89,13 +89,27 @@ function assertJoinable(previous: EdfChunk, next: EdfChunk, index: number): void
89
89
  const previousEndTicks = previous.startTicks + previous.durationTicks;
90
90
  const nextStartTicks = next.startTicks;
91
91
  if (previousEndTicks !== nextStartTicks) {
92
- const gapSeconds = ticksToSeconds(nextStartTicks - previousEndTicks);
92
+ // Branched on the SIGN, like the `precededByGap` path above. A negative difference is an
93
+ // overlap, not a gap, and this path is the one that actually fires for an overlap after
94
+ // `openEdf`: a probed index reports no gaps at all, so `precededByGap` is `undefined` and the
95
+ // branch that was taught the distinction in 0.3.41 never runs. It printed "a discontinuity of
96
+ // -0.2 s ... this is a gap in TIME", which names the wrong thing twice — a fourth site of the
97
+ // defect 0.3.33 and 0.3.41 swept, forty lines below the third (fixed in 0.3.59).
98
+ const deltaTicks = nextStartTicks - previousEndTicks;
99
+ const overlapping = deltaTicks < 0n;
100
+ const magnitude = ticksToSeconds(overlapping ? -deltaTicks : deltaTicks);
93
101
  throw new RangeError(
94
102
  `mergeChunks: chunk ${index} starts at ${next.startSeconds} s, but the chunk before it ends ` +
95
- `at ${ticksToSeconds(previousEndTicks)} s — a discontinuity of ${gapSeconds} s. The two ` +
96
- 'are record-adjacent, so this is a gap in TIME that the record numbers cannot show: ' +
97
- 'either the index was never scanned, or these chunks came from separate reads. ' +
98
- 'Concatenating them would date every sample after the join wrong by that much. Next: ' +
103
+ `at ${ticksToSeconds(previousEndTicks)} s — ` +
104
+ (overlapping
105
+ ? `an overlap of ${magnitude} s. The two are record-adjacent, so the records on either ` +
106
+ 'side of the join both claim that time and the record numbers cannot show it. ' +
107
+ 'Concatenating them would store it twice and date every sample after the join late ' +
108
+ 'by it.'
109
+ : `a discontinuity of ${magnitude} s. The two are record-adjacent, so this is a gap in ` +
110
+ 'TIME that the record numbers cannot show. Concatenating them would date every ' +
111
+ 'sample after the join wrong by that much.') +
112
+ ' Either the index was never scanned, or these chunks came from separate reads. Next: ' +
99
113
  'await buildRecordIndex(recording) and merge each contiguous run separately.',
100
114
  );
101
115
  }
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.57';
96
+ export const VERSION = '0.3.59';