edfcore 0.6.111 → 0.6.112
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/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/sample-grid.d.ts.map +1 -1
- package/dist/sample-grid.js +27 -3
- package/dist/sample-grid.js.map +1 -1
- package/docs/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/sample-grid.ts +31 -3
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.6.
|
|
112
|
+
export declare const VERSION = "0.6.112";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-grid.d.ts","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sample-grid.d.ts","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyD/D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,GAC1B,iBAAiB,CAoBnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAiBR;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAQR"}
|
package/dist/sample-grid.js
CHANGED
|
@@ -43,7 +43,28 @@
|
|
|
43
43
|
import { TICKS_PER_SECOND } from './constants.js';
|
|
44
44
|
import { secondsToTicks } from './tal/ticks.js';
|
|
45
45
|
import { describeValue } from './text/describe.js';
|
|
46
|
-
function assertGrid(signal, recordDurationTicks) {
|
|
46
|
+
function assertGrid(signal, recordDurationTicks, call) {
|
|
47
|
+
/*
|
|
48
|
+
* Both arguments, before either is read. `signal.kind` on a chunk signal — the per-signal shape a
|
|
49
|
+
* reader holds after a read, and the one whose samples they are indexing — is `undefined`, so the
|
|
50
|
+
* whole family answered V8's `Cannot read properties of undefined (reading 'kind')`.
|
|
51
|
+
*
|
|
52
|
+
* The ticks are the sharper of the two. `recordDurationSeconds` sits beside
|
|
53
|
+
* `recordDurationTicks` on the same header, is a float, and reads as the obvious thing to pass;
|
|
54
|
+
* it reached `recordDurationTicks <= 0n` and threw "Cannot mix BigInt and other types, use
|
|
55
|
+
* explicit conversions", which names neither the argument nor the call nor which of the two
|
|
56
|
+
* fields to use (fixed in 0.6.112).
|
|
57
|
+
*/
|
|
58
|
+
if (typeof signal?.kind !== 'string') {
|
|
59
|
+
throw new RangeError(`${call}(): the signal is ${describeValue(signal)}, not one of header.signals — a chunk ` +
|
|
60
|
+
'signal carries the samples rather than the grid they sit on. Next: pass ' +
|
|
61
|
+
'header.signals[chunkSignal.signalIndex], or resolve it with getSignal(header, label).');
|
|
62
|
+
}
|
|
63
|
+
if (typeof recordDurationTicks !== 'bigint') {
|
|
64
|
+
throw new RangeError(`${call}(): recordDurationTicks is ${describeValue(recordDurationTicks)}, not a BigInt. ` +
|
|
65
|
+
'Next: pass header.recordDurationTicks — the seconds beside it on the same header are a ' +
|
|
66
|
+
'float, and this family is exact on purpose.');
|
|
67
|
+
}
|
|
47
68
|
if (signal.kind === 'annotations') {
|
|
48
69
|
throw new RangeError(`signal ${signal.index} (${JSON.stringify(signal.label)}) is an annotations channel, ` +
|
|
49
70
|
'whose region holds TAL text rather than samples, so it has no sample grid. Next: use ' +
|
|
@@ -74,7 +95,7 @@ function assertGrid(signal, recordDurationTicks) {
|
|
|
74
95
|
* NEXT sample for anything past the halfway point, which puts a window boundary one sample late.
|
|
75
96
|
*/
|
|
76
97
|
export function gridSampleIndexAt(signal, seconds, recordDurationTicks) {
|
|
77
|
-
assertGrid(signal, recordDurationTicks);
|
|
98
|
+
assertGrid(signal, recordDurationTicks, 'gridSampleIndexAt');
|
|
78
99
|
const ticks = secondsToTicks(seconds, 'seconds');
|
|
79
100
|
const perRecord = BigInt(signal.samplesPerRecord);
|
|
80
101
|
// Exact integer arithmetic throughout: ticks * samplesPerRecord / recordDurationTicks, floored
|
|
@@ -106,7 +127,7 @@ export function gridSampleIndexAt(signal, seconds, recordDurationTicks) {
|
|
|
106
127
|
* tick at or after the exact start keeps the two functions inverse for every index.
|
|
107
128
|
*/
|
|
108
129
|
export function gridSampleStartTicks(signal, sampleIndex, recordDurationTicks) {
|
|
109
|
-
assertGrid(signal, recordDurationTicks);
|
|
130
|
+
assertGrid(signal, recordDurationTicks, 'gridSampleStartTicks');
|
|
110
131
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
111
132
|
throw new RangeError(`gridSampleStartTicks(): sampleIndex must be a whole number, received ` +
|
|
112
133
|
`${describeValue(sampleIndex)}. ` +
|
|
@@ -124,6 +145,9 @@ export function gridSampleStartTicks(signal, sampleIndex, recordDurationTicks) {
|
|
|
124
145
|
}
|
|
125
146
|
/** `gridSampleStartTicks` in seconds, for display. Compare ticks, not this. */
|
|
126
147
|
export function gridSampleStartSeconds(signal, sampleIndex, recordDurationTicks) {
|
|
148
|
+
// Its own, before the delegation, for the reason `sampleStartSecondsOf` grew one in 0.6.101: a
|
|
149
|
+
// reader who wrote this call should not be told about `gridSampleStartTicks`.
|
|
150
|
+
assertGrid(signal, recordDurationTicks, 'gridSampleStartSeconds');
|
|
127
151
|
const ticks = gridSampleStartTicks(signal, sampleIndex, recordDurationTicks);
|
|
128
152
|
const whole = ticks / TICKS_PER_SECOND;
|
|
129
153
|
const remainder = 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,SAAS,UAAU,CAAC,MAAiB,EAAE,mBAA2B;
|
|
1
|
+
{"version":3,"file":"sample-grid.js","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,SAAS,UAAU,CAAC,MAAiB,EAAE,mBAA2B,EAAE,IAAY;IAC9E;;;;;;;;;;OAUG;IACH,IAAI,OAAQ,MAAgD,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;QAChF,MAAM,IAAI,UAAU,CAClB,GAAG,IAAI,qBAAqB,aAAa,CAAC,MAAM,CAAC,wCAAwC;YACvF,0EAA0E;YAC1E,uFAAuF,CAC1F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AO,QAAQ,CAAC;IAClD,OAAO,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AACnD,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,WAAmB,EACnB,mBAA2B;IAE3B,+FAA+F;IAC/F,8EAA8E;IAC9E,UAAU,CAAC,MAAM,EAAE,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,KAAK,GAAG,gBAAgB,CAAC;IACvC,MAAM,SAAS,GAAG,KAAK,GAAG,gBAAgB,CAAC;IAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACtE,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,22 @@ 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.6.112
|
|
10
|
+
|
|
11
|
+
- **Fixed** the sample-grid family checking neither of its two arguments.
|
|
12
|
+
- A chunk signal has no `kind` — it is the per-signal shape a reader holds after a read, and the one
|
|
13
|
+
whose samples they are indexing — so `gridSampleStartTicks`, `gridSampleStartSeconds` and
|
|
14
|
+
`gridSampleIndexAt` all answered `Cannot read properties of undefined (reading 'kind')` for one.
|
|
15
|
+
- The record duration is the sharper of the two. `recordDurationSeconds` sits beside
|
|
16
|
+
`recordDurationTicks` on the same header, is a float, and reads as the obvious thing to pass; it
|
|
17
|
+
reached `recordDurationTicks <= 0n` and threw "Cannot mix BigInt and other types, use explicit
|
|
18
|
+
conversions", which names neither the argument, nor the call, nor which of the two fields to use.
|
|
19
|
+
- **Behaviour change**: a hand-built partial signal is now refused. `{ samplesPerRecord: 128 }` cast
|
|
20
|
+
to `EdfSignal` reached the arithmetic before; it has no `kind`, and that is the field the
|
|
21
|
+
annotations refusal reads. Pass a signal from `header.signals`.
|
|
22
|
+
- This is 0.6.101's fix on the pure half of the pair, and `gridSampleStartSeconds` got its own guard
|
|
23
|
+
before it delegates, for the same reason `sampleStartSecondsOf` did.
|
|
24
|
+
|
|
9
25
|
## 0.6.111
|
|
10
26
|
|
|
11
27
|
- **Fixed** the five reading entry points 0.6.89's recording guard did not cover: `readAnnotations`,
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/sample-grid.ts
CHANGED
|
@@ -46,7 +46,32 @@ import { secondsToTicks } from './tal/ticks.js';
|
|
|
46
46
|
import { describeValue } from './text/describe.js';
|
|
47
47
|
import type { EdfSampleLocation, EdfSignal } from './types.js';
|
|
48
48
|
|
|
49
|
-
function assertGrid(signal: EdfSignal, recordDurationTicks: bigint): void {
|
|
49
|
+
function assertGrid(signal: EdfSignal, recordDurationTicks: bigint, call: string): void {
|
|
50
|
+
/*
|
|
51
|
+
* Both arguments, before either is read. `signal.kind` on a chunk signal — the per-signal shape a
|
|
52
|
+
* reader holds after a read, and the one whose samples they are indexing — is `undefined`, so the
|
|
53
|
+
* whole family answered V8's `Cannot read properties of undefined (reading 'kind')`.
|
|
54
|
+
*
|
|
55
|
+
* The ticks are the sharper of the two. `recordDurationSeconds` sits beside
|
|
56
|
+
* `recordDurationTicks` on the same header, is a float, and reads as the obvious thing to pass;
|
|
57
|
+
* it reached `recordDurationTicks <= 0n` and threw "Cannot mix BigInt and other types, use
|
|
58
|
+
* explicit conversions", which names neither the argument nor the call nor which of the two
|
|
59
|
+
* fields to use (fixed in 0.6.112).
|
|
60
|
+
*/
|
|
61
|
+
if (typeof (signal as { kind?: unknown } | null | undefined)?.kind !== 'string') {
|
|
62
|
+
throw new RangeError(
|
|
63
|
+
`${call}(): the signal is ${describeValue(signal)}, not one of header.signals — a chunk ` +
|
|
64
|
+
'signal carries the samples rather than the grid they sit on. Next: pass ' +
|
|
65
|
+
'header.signals[chunkSignal.signalIndex], or resolve it with getSignal(header, label).',
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (typeof recordDurationTicks !== 'bigint') {
|
|
69
|
+
throw new RangeError(
|
|
70
|
+
`${call}(): recordDurationTicks is ${describeValue(recordDurationTicks)}, not a BigInt. ` +
|
|
71
|
+
'Next: pass header.recordDurationTicks — the seconds beside it on the same header are a ' +
|
|
72
|
+
'float, and this family is exact on purpose.',
|
|
73
|
+
);
|
|
74
|
+
}
|
|
50
75
|
if (signal.kind === 'annotations') {
|
|
51
76
|
throw new RangeError(
|
|
52
77
|
`signal ${signal.index} (${JSON.stringify(signal.label)}) is an annotations channel, ` +
|
|
@@ -88,7 +113,7 @@ export function gridSampleIndexAt(
|
|
|
88
113
|
seconds: number,
|
|
89
114
|
recordDurationTicks: bigint,
|
|
90
115
|
): EdfSampleLocation {
|
|
91
|
-
assertGrid(signal, recordDurationTicks);
|
|
116
|
+
assertGrid(signal, recordDurationTicks, 'gridSampleIndexAt');
|
|
92
117
|
|
|
93
118
|
const ticks = secondsToTicks(seconds, 'seconds');
|
|
94
119
|
const perRecord = BigInt(signal.samplesPerRecord);
|
|
@@ -127,7 +152,7 @@ export function gridSampleStartTicks(
|
|
|
127
152
|
sampleIndex: number,
|
|
128
153
|
recordDurationTicks: bigint,
|
|
129
154
|
): bigint {
|
|
130
|
-
assertGrid(signal, recordDurationTicks);
|
|
155
|
+
assertGrid(signal, recordDurationTicks, 'gridSampleStartTicks');
|
|
131
156
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
132
157
|
throw new RangeError(
|
|
133
158
|
`gridSampleStartTicks(): sampleIndex must be a whole number, received ` +
|
|
@@ -151,6 +176,9 @@ export function gridSampleStartSeconds(
|
|
|
151
176
|
sampleIndex: number,
|
|
152
177
|
recordDurationTicks: bigint,
|
|
153
178
|
): number {
|
|
179
|
+
// Its own, before the delegation, for the reason `sampleStartSecondsOf` grew one in 0.6.101: a
|
|
180
|
+
// reader who wrote this call should not be told about `gridSampleStartTicks`.
|
|
181
|
+
assertGrid(signal, recordDurationTicks, 'gridSampleStartSeconds');
|
|
154
182
|
const ticks = gridSampleStartTicks(signal, sampleIndex, recordDurationTicks);
|
|
155
183
|
const whole = ticks / TICKS_PER_SECOND;
|
|
156
184
|
const remainder = ticks % TICKS_PER_SECOND;
|