edfcore 0.3.44 → 0.3.46

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,43 @@ 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.46
10
+
11
+ - **Fixed** the two documented code examples that did not compile under the compiler settings
12
+ edfcore itself builds with. Both are on the pages that tell a reader to go and write their own
13
+ code, which is the worst place for a snippet that has to be debugged before it can be used.
14
+ - `api-sources.md`, the custom `FetchLike` adapter: `return fetch(url, { ...init, signal })` is
15
+ rejected under `exactOptionalPropertyTypes`, because `RequestInit.signal` is
16
+ `AbortSignal | null` and the local is `AbortSignal | undefined`. It now writes
17
+ `signal: signal ?? null`, and says why.
18
+ - `api-primitives.md`, the duplicate-label resolver: `getSignal(header, error.matchingIndices[0])`
19
+ is rejected under `noUncheckedIndexedAccess`, which types the element `number | undefined`. It
20
+ now destructures and narrows first.
21
+ - Neither was wrong at runtime; both compiled cleanly with the flag off. This is specifically the
22
+ strict-mode shape, and `tsconfig.json` and `tsconfig.build.json` both set both flags.
23
+ - `tests/types/documented-examples.test-d.ts` holds a copy of each snippet as REAL code, so
24
+ `npm run typecheck` compiles them, and then reads the fenced blocks back out of the pages and
25
+ asserts every line is present in that copy. Editing a snippet in the docs without editing the
26
+ compiled copy now fails, in both directions.
27
+
28
+ ## 0.3.45
29
+
30
+ - **Fixed** `formatAnnotations` printing a NEGATIVE onset as an instant slightly **after** the
31
+ event, which is the one thing the function's own docblock promises it never does.
32
+ - The clock took the magnitude of the tick count and then truncated it, so the truncation ran
33
+ toward zero rather than toward -Infinity. `-1.5009 s` printed `-00:00:01.500` — 0.9 ms after
34
+ the event. The positive twin `+1.5009` printed `00:00:01.500`, correctly *before* its event, so
35
+ the guarantee held for exactly the half of the range that never needed it.
36
+ - It now floors with `floorDiv` before splitting into fields: `-1.5009` prints `-00:00:01.501`.
37
+ Positive onsets, zero, and exact milliseconds are unchanged — flooring only moves a value with
38
+ a remainder, and only downward.
39
+ - Negative onsets are not an edge case here: EDF+ measures onsets from the header start time and a
40
+ recording may begin after its first annotation, which is why 0.2.63 made them print as negatives
41
+ rather than clamp to zero. Sub-millisecond digits are equally ordinary — the parser keeps seven
42
+ fractional decimal places on purpose. As this module's own comment says, an event list is exactly
43
+ where someone reads a number off the screen and types it into something else.
44
+ - The docblock said "truncates"; it now says "floors", which is what makes the promise true.
45
+
9
46
  ## 0.3.44
10
47
 
11
48
  - **Added** the types each subpath's own signatures need, so a consumer taking one part of the
@@ -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.44";
112
+ export declare const VERSION = "0.3.46";
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.44';
82
+ export const VERSION = '0.3.46';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAqCD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAgCR"}
1
+ {"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AA0CD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAgCR"}
@@ -15,19 +15,25 @@
15
15
  * file says. Clamping it to zero would silently move an event.
16
16
  */
17
17
  import { TICKS_PER_SECOND } from './constants.js';
18
+ import { floorDiv } from './tal/ticks.js';
18
19
  import { printable } from './text/printable.js';
19
20
  const TICKS_PER_MILLISECOND = TICKS_PER_SECOND / 1000n;
20
21
  /**
21
22
  * `hh:mm:ss.mmm`, from exact ticks.
22
23
  *
23
- * Truncates to the millisecond rather than rounding, so the printed time never names an instant
24
- * later than the event. Hours are not wrapped at 24 — a 30-hour recording is a real thing and
25
- * `30:12:00.000` is more useful than `06:12:00.000` on day two.
24
+ * FLOORS to the millisecond rather than rounding, so the printed time never names an instant later
25
+ * than the event — in either direction. Hours are not wrapped at 24 — a 30-hour recording is a
26
+ * real thing and `30:12:00.000` is more useful than `06:12:00.000` on day two.
26
27
  */
27
28
  function clock(ticks) {
28
- const negative = ticks < 0n;
29
- const absolute = negative ? -ticks : ticks;
30
- const totalMilliseconds = absolute / TICKS_PER_MILLISECOND;
29
+ // Floored toward -Infinity, not truncated toward zero. Taking the magnitude first and then
30
+ // truncating moves a NEGATIVE onset LATER: `-1.5009 s` printed as `-00:00:01.500`, 0.9 ms after
31
+ // the event. The positive twin `+1.5009` printed `00:00:01.500`, correctly before its event, so
32
+ // the guarantee held for exactly the half of the range that the paragraph below says is the
33
+ // unusual one. `-1.5009` now prints `-00:00:01.501` (fixed in 0.3.45).
34
+ const flooredMilliseconds = floorDiv(ticks, TICKS_PER_MILLISECOND);
35
+ const negative = flooredMilliseconds < 0n;
36
+ const totalMilliseconds = negative ? -flooredMilliseconds : flooredMilliseconds;
31
37
  const milliseconds = totalMilliseconds % 1000n;
32
38
  const totalSeconds = totalMilliseconds / 1000n;
33
39
  const seconds = totalSeconds % 60n;
@@ -1 +1 @@
1
- {"version":3,"file":"format-annotations.js","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUhD,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,KAAK,CAAC;AAEvD;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,KAAa;IAC1B,MAAM,QAAQ,GAAG,KAAK,GAAG,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAE3C,MAAM,iBAAiB,GAAG,QAAQ,GAAG,qBAAqB,CAAC;IAC3D,MAAM,YAAY,GAAG,iBAAiB,GAAG,KAAK,CAAC;IAC/C,MAAM,YAAY,GAAG,iBAAiB,GAAG,KAAK,CAAC;IAC/C,MAAM,OAAO,GAAG,YAAY,GAAG,GAAG,CAAC;IACnC,MAAM,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC;IACxC,MAAM,OAAO,GAAG,YAAY,GAAG,GAAG,CAAC;IACnC,MAAM,KAAK,GAAG,YAAY,GAAG,GAAG,CAAC;IAEjC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,E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,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG,KAAK,CAAC;IAC1C,mFAAmF;IACnF,IAAI,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,WAAW,MAAM,OAAO,CAAC,CAAC;IAEpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.3.44",
3
+ "version": "0.3.46",
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.44';
96
+ export const VERSION = '0.3.46';
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import { TICKS_PER_SECOND } from './constants.js';
19
+ import { floorDiv } from './tal/ticks.js';
19
20
  import { printable } from './text/printable.js';
20
21
  import type { EdfAnnotation } from './types.js';
21
22
 
@@ -31,15 +32,20 @@ const TICKS_PER_MILLISECOND = TICKS_PER_SECOND / 1000n;
31
32
  /**
32
33
  * `hh:mm:ss.mmm`, from exact ticks.
33
34
  *
34
- * Truncates to the millisecond rather than rounding, so the printed time never names an instant
35
- * later than the event. Hours are not wrapped at 24 — a 30-hour recording is a real thing and
36
- * `30:12:00.000` is more useful than `06:12:00.000` on day two.
35
+ * FLOORS to the millisecond rather than rounding, so the printed time never names an instant later
36
+ * than the event — in either direction. Hours are not wrapped at 24 — a 30-hour recording is a
37
+ * real thing and `30:12:00.000` is more useful than `06:12:00.000` on day two.
37
38
  */
38
39
  function clock(ticks: bigint): string {
39
- const negative = ticks < 0n;
40
- const absolute = negative ? -ticks : ticks;
40
+ // Floored toward -Infinity, not truncated toward zero. Taking the magnitude first and then
41
+ // truncating moves a NEGATIVE onset LATER: `-1.5009 s` printed as `-00:00:01.500`, 0.9 ms after
42
+ // the event. The positive twin `+1.5009` printed `00:00:01.500`, correctly before its event, so
43
+ // the guarantee held for exactly the half of the range that the paragraph below says is the
44
+ // unusual one. `-1.5009` now prints `-00:00:01.501` (fixed in 0.3.45).
45
+ const flooredMilliseconds = floorDiv(ticks, TICKS_PER_MILLISECOND);
46
+ const negative = flooredMilliseconds < 0n;
47
+ const totalMilliseconds = negative ? -flooredMilliseconds : flooredMilliseconds;
41
48
 
42
- const totalMilliseconds = absolute / TICKS_PER_MILLISECOND;
43
49
  const milliseconds = totalMilliseconds % 1000n;
44
50
  const totalSeconds = totalMilliseconds / 1000n;
45
51
  const seconds = totalSeconds % 60n;