edfcore 0.3.44 → 0.3.45
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 +18 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/format-annotations.d.ts.map +1 -1
- package/dist/format-annotations.js +12 -6
- package/dist/format-annotations.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/format-annotations.ts +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,24 @@ 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.45
|
|
10
|
+
|
|
11
|
+
- **Fixed** `formatAnnotations` printing a NEGATIVE onset as an instant slightly **after** the
|
|
12
|
+
event, which is the one thing the function's own docblock promises it never does.
|
|
13
|
+
- The clock took the magnitude of the tick count and then truncated it, so the truncation ran
|
|
14
|
+
toward zero rather than toward -Infinity. `-1.5009 s` printed `-00:00:01.500` — 0.9 ms after
|
|
15
|
+
the event. The positive twin `+1.5009` printed `00:00:01.500`, correctly *before* its event, so
|
|
16
|
+
the guarantee held for exactly the half of the range that never needed it.
|
|
17
|
+
- It now floors with `floorDiv` before splitting into fields: `-1.5009` prints `-00:00:01.501`.
|
|
18
|
+
Positive onsets, zero, and exact milliseconds are unchanged — flooring only moves a value with
|
|
19
|
+
a remainder, and only downward.
|
|
20
|
+
- Negative onsets are not an edge case here: EDF+ measures onsets from the header start time and a
|
|
21
|
+
recording may begin after its first annotation, which is why 0.2.63 made them print as negatives
|
|
22
|
+
rather than clamp to zero. Sub-millisecond digits are equally ordinary — the parser keeps seven
|
|
23
|
+
fractional decimal places on purpose. As this module's own comment says, an event list is exactly
|
|
24
|
+
where someone reads a number off the screen and types it into something else.
|
|
25
|
+
- The docblock said "truncates"; it now says "floors", which is what makes the promise true.
|
|
26
|
+
|
|
9
27
|
## 0.3.44
|
|
10
28
|
|
|
11
29
|
- **Added** the types each subpath's own signatures need, so a consumer taking one part of the
|
package/dist/constants.d.ts
CHANGED
|
@@ -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.
|
|
112
|
+
export declare const VERSION = "0.3.45";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
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
|
-
*
|
|
24
|
-
*
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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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B,CAAC;YAC3C,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;SAC3B,CAAC;QACF,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC9E,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,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
package/src/constants.ts
CHANGED
|
@@ -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
|
-
*
|
|
35
|
-
*
|
|
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
|
-
|
|
40
|
-
|
|
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;
|