edfcore 0.2.61 → 0.2.62
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 +13 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/sample-grid.d.ts +26 -5
- package/dist/sample-grid.d.ts.map +1 -1
- package/dist/sample-grid.js +26 -5
- package/dist/sample-grid.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/sample-grid.ts +26 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ 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.61
|
|
10
|
+
|
|
11
|
+
- **Deprecated** `sampleIndexAt`, `sampleStartTicks` and `sampleStartSeconds`, which are renamed
|
|
12
|
+
to `gridSampleIndexAt`, `gridSampleStartTicks` and `gridSampleStartSeconds` in **0.3.0**. The
|
|
13
|
+
behaviour does not change and neither do the arguments — only the name, which never said which of
|
|
14
|
+
two different quantities it returns. Six releases of this project were spent on exactly that
|
|
15
|
+
confusion elsewhere, and the `grid` prefix is what stops the seventh.
|
|
16
|
+
- The tag is folded into each function's existing documentation rather than added as a second
|
|
17
|
+
comment above it, so an editor shows the original prose AND the replacement instead of replacing
|
|
18
|
+
one with the other.
|
|
19
|
+
- Nothing is removed here. An editor will point at the replacement a release before the rename
|
|
20
|
+
lands, and for a contiguous file the rename is the only thing that affects a caller.
|
|
21
|
+
|
|
9
22
|
## 0.2.60
|
|
10
23
|
|
|
11
24
|
- **Added** `sampleAt`, `sampleStartTicksOf` and `sampleStartSecondsOf` — the recording-aware
|
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.2.
|
|
112
|
+
export declare const VERSION = "0.2.62";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/dist/sample-grid.d.ts
CHANGED
|
@@ -28,10 +28,16 @@
|
|
|
28
28
|
* count, and are not being modest about it: the information is not in their arguments.
|
|
29
29
|
*
|
|
30
30
|
* So the contract is stated rather than guessed at. For a file that may be discontinuous, use
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf` from `sample-locate.ts`, which take
|
|
32
|
+
* the recording and can therefore see a gap. `contiguityOf(index)` answers which regime you are
|
|
33
|
+
* in. On a contiguous file — the common case, and every plain EDF or EDF+C — these are exact and
|
|
34
|
+
* are what you want.
|
|
35
|
+
*
|
|
36
|
+
* RENAMED IN 0.3.0. These three keep their behaviour and lose their misleading names: they become
|
|
37
|
+
* `gridSampleIndexAt`, `gridSampleStartTicks` and `gridSampleStartSeconds`. The `grid` prefix is
|
|
38
|
+
* the whole fix — the functions were never wrong, the names simply did not say which of two
|
|
39
|
+
* different quantities they returned, and six releases of this project were spent on exactly that
|
|
40
|
+
* confusion in other places. Nothing about the arithmetic changes.
|
|
35
41
|
*/
|
|
36
42
|
import type { EdfSampleLocation, EdfSignal } from './types.js';
|
|
37
43
|
/**
|
|
@@ -40,6 +46,11 @@ import type { EdfSampleLocation, EdfSignal } from './types.js';
|
|
|
40
46
|
* Floor, not round: a sample covers the half-open interval from its own start to the next one's,
|
|
41
47
|
* so the sample "at" a time is the one whose interval contains it. Rounding would return the
|
|
42
48
|
* NEXT sample for anything past the halfway point, which puts a window boundary one sample late.
|
|
49
|
+
*
|
|
50
|
+
* @deprecated Renamed to `gridSampleIndexAt` in 0.3.0. The behaviour is unchanged — only the
|
|
51
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
52
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
53
|
+
* recording and can therefore see one.
|
|
43
54
|
*/
|
|
44
55
|
export declare function sampleIndexAt(signal: EdfSignal, seconds: number, recordDurationTicks: bigint): EdfSampleLocation;
|
|
45
56
|
/**
|
|
@@ -54,8 +65,18 @@ export declare function sampleIndexAt(signal: EdfSignal, seconds: number, record
|
|
|
54
65
|
* edfcore has. Truncating would return 23,437 — a tick that lies inside sample 0 — so
|
|
55
66
|
* `sampleIndexAt` would send it straight back to the previous sample. Taking the first whole
|
|
56
67
|
* tick at or after the exact start keeps the two functions inverse for every index.
|
|
68
|
+
*
|
|
69
|
+
* @deprecated Renamed to `gridSampleStartTicks` in 0.3.0. The behaviour is unchanged — only the
|
|
70
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
71
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
72
|
+
* recording and can therefore see one.
|
|
57
73
|
*/
|
|
58
74
|
export declare function sampleStartTicks(signal: EdfSignal, sampleIndex: number, recordDurationTicks: bigint): bigint;
|
|
59
|
-
/** `sampleStartTicks` in seconds, for display. Compare ticks, not this.
|
|
75
|
+
/** `sampleStartTicks` in seconds, for display. Compare ticks, not this. *
|
|
76
|
+
* @deprecated Renamed to `gridSampleStartSeconds` in 0.3.0. The behaviour is unchanged — only the
|
|
77
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
78
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
79
|
+
* recording and can therefore see one.
|
|
80
|
+
*/
|
|
60
81
|
export declare function sampleStartSeconds(signal: EdfSignal, sampleIndex: number, recordDurationTicks: bigint): number;
|
|
61
82
|
//# sourceMappingURL=sample-grid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-grid.d.ts","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sample-grid.d.ts","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA0B/D;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,GAC1B,iBAAiB,CAoBnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAcR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAKR"}
|
package/dist/sample-grid.js
CHANGED
|
@@ -28,10 +28,16 @@
|
|
|
28
28
|
* count, and are not being modest about it: the information is not in their arguments.
|
|
29
29
|
*
|
|
30
30
|
* So the contract is stated rather than guessed at. For a file that may be discontinuous, use
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf` from `sample-locate.ts`, which take
|
|
32
|
+
* the recording and can therefore see a gap. `contiguityOf(index)` answers which regime you are
|
|
33
|
+
* in. On a contiguous file — the common case, and every plain EDF or EDF+C — these are exact and
|
|
34
|
+
* are what you want.
|
|
35
|
+
*
|
|
36
|
+
* RENAMED IN 0.3.0. These three keep their behaviour and lose their misleading names: they become
|
|
37
|
+
* `gridSampleIndexAt`, `gridSampleStartTicks` and `gridSampleStartSeconds`. The `grid` prefix is
|
|
38
|
+
* the whole fix — the functions were never wrong, the names simply did not say which of two
|
|
39
|
+
* different quantities they returned, and six releases of this project were spent on exactly that
|
|
40
|
+
* confusion in other places. Nothing about the arithmetic changes.
|
|
35
41
|
*/
|
|
36
42
|
import { TICKS_PER_SECOND } from './constants.js';
|
|
37
43
|
import { secondsToTicks } from './tal/ticks.js';
|
|
@@ -58,6 +64,11 @@ function assertGrid(signal, recordDurationTicks) {
|
|
|
58
64
|
* Floor, not round: a sample covers the half-open interval from its own start to the next one's,
|
|
59
65
|
* so the sample "at" a time is the one whose interval contains it. Rounding would return the
|
|
60
66
|
* NEXT sample for anything past the halfway point, which puts a window boundary one sample late.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Renamed to `gridSampleIndexAt` in 0.3.0. The behaviour is unchanged — only the
|
|
69
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
70
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
71
|
+
* recording and can therefore see one.
|
|
61
72
|
*/
|
|
62
73
|
export function sampleIndexAt(signal, seconds, recordDurationTicks) {
|
|
63
74
|
assertGrid(signal, recordDurationTicks);
|
|
@@ -90,6 +101,11 @@ export function sampleIndexAt(signal, seconds, recordDurationTicks) {
|
|
|
90
101
|
* edfcore has. Truncating would return 23,437 — a tick that lies inside sample 0 — so
|
|
91
102
|
* `sampleIndexAt` would send it straight back to the previous sample. Taking the first whole
|
|
92
103
|
* tick at or after the exact start keeps the two functions inverse for every index.
|
|
104
|
+
*
|
|
105
|
+
* @deprecated Renamed to `gridSampleStartTicks` in 0.3.0. The behaviour is unchanged — only the
|
|
106
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
107
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
108
|
+
* recording and can therefore see one.
|
|
93
109
|
*/
|
|
94
110
|
export function sampleStartTicks(signal, sampleIndex, recordDurationTicks) {
|
|
95
111
|
assertGrid(signal, recordDurationTicks);
|
|
@@ -105,7 +121,12 @@ export function sampleStartTicks(signal, sampleIndex, recordDurationTicks) {
|
|
|
105
121
|
return quotient;
|
|
106
122
|
return numerator > 0n ? quotient + 1n : quotient;
|
|
107
123
|
}
|
|
108
|
-
/** `sampleStartTicks` in seconds, for display. Compare ticks, not this.
|
|
124
|
+
/** `sampleStartTicks` in seconds, for display. Compare ticks, not this. *
|
|
125
|
+
* @deprecated Renamed to `gridSampleStartSeconds` in 0.3.0. The behaviour is unchanged — only the
|
|
126
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
127
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
128
|
+
* recording and can therefore see one.
|
|
129
|
+
*/
|
|
109
130
|
export function sampleStartSeconds(signal, sampleIndex, recordDurationTicks) {
|
|
110
131
|
const ticks = sampleStartTicks(signal, sampleIndex, recordDurationTicks);
|
|
111
132
|
const whole = ticks / TICKS_PER_SECOND;
|
package/dist/sample-grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-grid.js","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sample-grid.js","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,SAAS,UAAU,CAAC,MAAiB,EAAE,mBAA2B;IAChE,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAClC,MAAM,IAAI,UAAU,CAClB,UAAU,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B;YACpF,uFAAuF;YACvF,2CAA2C,CAC9C,CAAC;I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
28
28
|
* count, and are not being modest about it: the information is not in their arguments.
|
|
29
29
|
*
|
|
30
30
|
* So the contract is stated rather than guessed at. For a file that may be discontinuous, use
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf` from `sample-locate.ts`, which take
|
|
32
|
+
* the recording and can therefore see a gap. `contiguityOf(index)` answers which regime you are
|
|
33
|
+
* in. On a contiguous file — the common case, and every plain EDF or EDF+C — these are exact and
|
|
34
|
+
* are what you want.
|
|
35
|
+
*
|
|
36
|
+
* RENAMED IN 0.3.0. These three keep their behaviour and lose their misleading names: they become
|
|
37
|
+
* `gridSampleIndexAt`, `gridSampleStartTicks` and `gridSampleStartSeconds`. The `grid` prefix is
|
|
38
|
+
* the whole fix — the functions were never wrong, the names simply did not say which of two
|
|
39
|
+
* different quantities they returned, and six releases of this project were spent on exactly that
|
|
40
|
+
* confusion in other places. Nothing about the arithmetic changes.
|
|
35
41
|
*/
|
|
36
42
|
|
|
37
43
|
import { TICKS_PER_SECOND } from './constants.js';
|
|
@@ -68,6 +74,11 @@ function assertGrid(signal: EdfSignal, recordDurationTicks: bigint): void {
|
|
|
68
74
|
* Floor, not round: a sample covers the half-open interval from its own start to the next one's,
|
|
69
75
|
* so the sample "at" a time is the one whose interval contains it. Rounding would return the
|
|
70
76
|
* NEXT sample for anything past the halfway point, which puts a window boundary one sample late.
|
|
77
|
+
*
|
|
78
|
+
* @deprecated Renamed to `gridSampleIndexAt` in 0.3.0. The behaviour is unchanged — only the
|
|
79
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
80
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
81
|
+
* recording and can therefore see one.
|
|
71
82
|
*/
|
|
72
83
|
export function sampleIndexAt(
|
|
73
84
|
signal: EdfSignal,
|
|
@@ -107,6 +118,11 @@ export function sampleIndexAt(
|
|
|
107
118
|
* edfcore has. Truncating would return 23,437 — a tick that lies inside sample 0 — so
|
|
108
119
|
* `sampleIndexAt` would send it straight back to the previous sample. Taking the first whole
|
|
109
120
|
* tick at or after the exact start keeps the two functions inverse for every index.
|
|
121
|
+
*
|
|
122
|
+
* @deprecated Renamed to `gridSampleStartTicks` in 0.3.0. The behaviour is unchanged — only the
|
|
123
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
124
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
125
|
+
* recording and can therefore see one.
|
|
110
126
|
*/
|
|
111
127
|
export function sampleStartTicks(
|
|
112
128
|
signal: EdfSignal,
|
|
@@ -128,7 +144,12 @@ export function sampleStartTicks(
|
|
|
128
144
|
return numerator > 0n ? quotient + 1n : quotient;
|
|
129
145
|
}
|
|
130
146
|
|
|
131
|
-
/** `sampleStartTicks` in seconds, for display. Compare ticks, not this.
|
|
147
|
+
/** `sampleStartTicks` in seconds, for display. Compare ticks, not this. *
|
|
148
|
+
* @deprecated Renamed to `gridSampleStartSeconds` in 0.3.0. The behaviour is unchanged — only the
|
|
149
|
+
* name, which never said which of two different quantities it returns. For a file that may
|
|
150
|
+
* have gaps, use `sampleAt` / `sampleStartTicksOf` / `sampleStartSecondsOf`, which take the
|
|
151
|
+
* recording and can therefore see one.
|
|
152
|
+
*/
|
|
132
153
|
export function sampleStartSeconds(
|
|
133
154
|
signal: EdfSignal,
|
|
134
155
|
sampleIndex: number,
|