edfcore 0.6.100 → 0.6.101
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-locate.d.ts.map +1 -1
- package/dist/sample-locate.js +15 -3
- package/dist/sample-locate.js.map +1 -1
- package/docs/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/sample-locate.ts +15 -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.101";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-locate.d.ts","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"sample-locate.d.ts","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAyB,MAAM,YAAY,CAAC;AAgGzF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,SAAS,CAgE/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAwCR;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAQR"}
|
package/dist/sample-locate.js
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { EdfChannelNotFoundError } from './errors.js';
|
|
35
35
|
import { segmentAt } from './record-index.js';
|
|
36
|
+
import { assertRecording } from './recording.js';
|
|
36
37
|
import { floorDiv, secondsToTicks, ticksToSeconds } from './tal/ticks.js';
|
|
37
38
|
import { describeValue } from './text/describe.js';
|
|
38
39
|
/**
|
|
@@ -41,7 +42,12 @@ import { describeValue } from './text/describe.js';
|
|
|
41
42
|
* to `sampleStartTicksOf`, so a hard-coded name here reached a caller who never wrote it
|
|
42
43
|
* (completed in 0.3.134; 0.3.133 fixed only the three messages outside this function).
|
|
43
44
|
*/
|
|
44
|
-
function resolveSignal(recording, signalIndex) {
|
|
45
|
+
function resolveSignal(recording, signalIndex, call) {
|
|
46
|
+
// The three entry points in this module all arrive here, and none of them checked the recording.
|
|
47
|
+
// Every function in `sample-grid.ts` — the pure counterpart this module exists beside — takes the
|
|
48
|
+
// SIGNAL, so reaching for `header` or for one of its signals is the mistake this file invites, and
|
|
49
|
+
// it earned V8's `Cannot read properties of undefined (reading 'signals')` (fixed in 0.6.101).
|
|
50
|
+
assertRecording(recording, call);
|
|
45
51
|
const signal = recording.header.signals[signalIndex];
|
|
46
52
|
if (signal === undefined) {
|
|
47
53
|
throw new EdfChannelNotFoundError(`signalIndex ${signalIndex} is outside the ` +
|
|
@@ -123,7 +129,7 @@ function probedIndexNeedsScan(recording) {
|
|
|
123
129
|
* running when that time arrives.
|
|
124
130
|
*/
|
|
125
131
|
export function sampleAt(recording, signalIndex, seconds) {
|
|
126
|
-
const signal = resolveSignal(recording, signalIndex);
|
|
132
|
+
const signal = resolveSignal(recording, signalIndex, 'sampleAt');
|
|
127
133
|
if (!Number.isFinite(seconds)) {
|
|
128
134
|
throw new RangeError(`sampleAt(): seconds must be a finite number, received ${describeValue(seconds)}. ` +
|
|
129
135
|
`Next: pass a time on ` +
|
|
@@ -193,7 +199,7 @@ export function sampleAt(recording, signalIndex, seconds) {
|
|
|
193
199
|
* previous sample.
|
|
194
200
|
*/
|
|
195
201
|
export function sampleStartTicksOf(recording, signalIndex, sampleIndex) {
|
|
196
|
-
const signal = resolveSignal(recording, signalIndex);
|
|
202
|
+
const signal = resolveSignal(recording, signalIndex, 'sampleStartTicksOf');
|
|
197
203
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
198
204
|
throw new RangeError(`sampleIndex must be a whole number, received ${describeValue(sampleIndex)}. ` +
|
|
199
205
|
`Next: index by ` +
|
|
@@ -225,6 +231,12 @@ export function sampleStartTicksOf(recording, signalIndex, sampleIndex) {
|
|
|
225
231
|
}
|
|
226
232
|
/** `sampleStartTicksOf` as float64 seconds. Compare with the ticks, never with this. */
|
|
227
233
|
export function sampleStartSecondsOf(recording, signalIndex, sampleIndex) {
|
|
234
|
+
// Its own guard, before the delegation, so the refusal names the call the caller wrote. This is
|
|
235
|
+
// the one function here that is a one-line wrapper, and it is `secondsToTicks`'s rule applied to
|
|
236
|
+
// a whole call: "`name` is the caller's own word for the value, and it is required rather than
|
|
237
|
+
// defaulted" — a reader who wrote `sampleStartSecondsOf` should not be told about
|
|
238
|
+
// `sampleStartTicksOf` (0.6.101).
|
|
239
|
+
assertRecording(recording, 'sampleStartSecondsOf');
|
|
228
240
|
return ticksToSeconds(sampleStartTicksOf(recording, signalIndex, sampleIndex));
|
|
229
241
|
}
|
|
230
242
|
//# sourceMappingURL=sample-locate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-locate.js","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM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AAK,CAAC,QAAQ,KAAK,SAAS,IAAI,oBAAoB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9E,MAAM,IAAI,UAAU,CAClB,qEAAqE;YACnE,0FAA0F;YAC1F,qCAAqC,CACxC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;IAChG,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACpC,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,yCAAyC;IACzC,OAAO,KAAK,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAClC,SAAuB,EACvB,WAAmB,EACnB,WAAmB;IAEnB,gGAAgG;IAChG,iGAAiG;IACjG,+FAA+F;IAC/F,kFAAkF;IAClF,kCAAkC;IAClC,eAAe,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IACnD,OAAO,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ 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.101
|
|
10
|
+
|
|
11
|
+
- **Fixed** `sampleAt`, `sampleStartTicksOf` and `sampleStartSecondsOf` dying with V8's `Cannot read
|
|
12
|
+
properties of undefined (reading 'signals')` when handed a header, or the Promise `openEdf`
|
|
13
|
+
returns, instead of a recording.
|
|
14
|
+
- `sample-grid.ts` is the pure counterpart these exist beside and every function in it takes the
|
|
15
|
+
SIGNAL, so reaching for the header — or for one of its signals — is the mistake the pair invites.
|
|
16
|
+
All three arrive at one private helper, so all three are now answered by the guard 0.6.89 added.
|
|
17
|
+
- `sampleStartSecondsOf` got its own, before it delegates: it is a one-line wrapper, and a reader who
|
|
18
|
+
wrote it should not be told about `sampleStartTicksOf`. That is `secondsToTicks`'s rule about
|
|
19
|
+
naming the caller's own word, applied to a whole call.
|
|
20
|
+
|
|
9
21
|
## 0.6.100
|
|
10
22
|
|
|
11
23
|
- **Fixed** the CLI page's explanation of why a signal entry in `edfcore json` has no `scale`. It
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/sample-locate.ts
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
import { EdfChannelNotFoundError } from './errors.js';
|
|
36
36
|
import { segmentAt } from './record-index.js';
|
|
37
|
+
import { assertRecording } from './recording.js';
|
|
37
38
|
import { floorDiv, secondsToTicks, ticksToSeconds } from './tal/ticks.js';
|
|
38
39
|
import { describeValue } from './text/describe.js';
|
|
39
40
|
import type { EdfRecording, EdfSampleLocation, EdfSegment, EdfSignal } from './types.js';
|
|
@@ -44,7 +45,12 @@ import type { EdfRecording, EdfSampleLocation, EdfSegment, EdfSignal } from './t
|
|
|
44
45
|
* to `sampleStartTicksOf`, so a hard-coded name here reached a caller who never wrote it
|
|
45
46
|
* (completed in 0.3.134; 0.3.133 fixed only the three messages outside this function).
|
|
46
47
|
*/
|
|
47
|
-
function resolveSignal(recording: EdfRecording, signalIndex: number): EdfSignal {
|
|
48
|
+
function resolveSignal(recording: EdfRecording, signalIndex: number, call: string): EdfSignal {
|
|
49
|
+
// The three entry points in this module all arrive here, and none of them checked the recording.
|
|
50
|
+
// Every function in `sample-grid.ts` — the pure counterpart this module exists beside — takes the
|
|
51
|
+
// SIGNAL, so reaching for `header` or for one of its signals is the mistake this file invites, and
|
|
52
|
+
// it earned V8's `Cannot read properties of undefined (reading 'signals')` (fixed in 0.6.101).
|
|
53
|
+
assertRecording(recording, call);
|
|
48
54
|
const signal = recording.header.signals[signalIndex];
|
|
49
55
|
if (signal === undefined) {
|
|
50
56
|
throw new EdfChannelNotFoundError(
|
|
@@ -144,7 +150,7 @@ export function sampleAt(
|
|
|
144
150
|
signalIndex: number,
|
|
145
151
|
seconds: number,
|
|
146
152
|
): EdfSampleLocation | undefined {
|
|
147
|
-
const signal = resolveSignal(recording, signalIndex);
|
|
153
|
+
const signal = resolveSignal(recording, signalIndex, 'sampleAt');
|
|
148
154
|
if (!Number.isFinite(seconds)) {
|
|
149
155
|
throw new RangeError(
|
|
150
156
|
`sampleAt(): seconds must be a finite number, received ${describeValue(seconds)}. ` +
|
|
@@ -226,7 +232,7 @@ export function sampleStartTicksOf(
|
|
|
226
232
|
signalIndex: number,
|
|
227
233
|
sampleIndex: number,
|
|
228
234
|
): bigint {
|
|
229
|
-
const signal = resolveSignal(recording, signalIndex);
|
|
235
|
+
const signal = resolveSignal(recording, signalIndex, 'sampleStartTicksOf');
|
|
230
236
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
231
237
|
throw new RangeError(
|
|
232
238
|
`sampleIndex must be a whole number, received ${describeValue(sampleIndex)}. ` +
|
|
@@ -273,5 +279,11 @@ export function sampleStartSecondsOf(
|
|
|
273
279
|
signalIndex: number,
|
|
274
280
|
sampleIndex: number,
|
|
275
281
|
): number {
|
|
282
|
+
// Its own guard, before the delegation, so the refusal names the call the caller wrote. This is
|
|
283
|
+
// the one function here that is a one-line wrapper, and it is `secondsToTicks`'s rule applied to
|
|
284
|
+
// a whole call: "`name` is the caller's own word for the value, and it is required rather than
|
|
285
|
+
// defaulted" — a reader who wrote `sampleStartSecondsOf` should not be told about
|
|
286
|
+
// `sampleStartTicksOf` (0.6.101).
|
|
287
|
+
assertRecording(recording, 'sampleStartSecondsOf');
|
|
276
288
|
return ticksToSeconds(sampleStartTicksOf(recording, signalIndex, sampleIndex));
|
|
277
289
|
}
|