edfcore 0.3.132 → 0.3.134

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,20 @@ 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.134
10
+
11
+ - **Completed** 0.3.133, which fixed only the three messages outside `resolveSignal`. That helper
12
+ is shared by `sampleAt` and `sampleStartTicksOf` and took a `caller` string, so its four messages
13
+ still said `sampleStartTicksOf():` when reached through `sampleStartSecondsOf`. The parameter is
14
+ gone and the messages name no function, which is what `envelope.ts` already does for its own
15
+ shared helpers.
16
+
17
+ ## 0.3.133
18
+
19
+ - **Removed** the hard-coded `sampleStartTicksOf():` prefix from that function's three messages, the
20
+ other half of 0.3.132. `sampleStartSecondsOf` is a one-line delegation to it, so every caller of
21
+ the seconds variant was told about a function they never called.
22
+
9
23
  ## 0.3.132
10
24
 
11
25
  - **Removed** the hard-coded `decodeAnnotations():` prefix from the three caller-error messages in
@@ -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.132";
112
+ export declare const VERSION = "0.3.134";
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.132';
82
+ export const VERSION = '0.3.134';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sample-locate.d.ts","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAyB,MAAM,YAAY,CAAC;AAqFzF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,SAAS,CA4D/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAsCR;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER"}
1
+ {"version":3,"file":"sample-locate.d.ts","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAyB,MAAM,YAAY,CAAC;AA2FzF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,SAAS,CA4D/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAoCR;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER"}
@@ -28,10 +28,16 @@
28
28
  import { EdfChannelNotFoundError } from './errors.js';
29
29
  import { segmentAt } from './record-index.js';
30
30
  import { floorDiv, secondsToTicks, ticksToSeconds } from './tal/ticks.js';
31
- function resolveSignal(recording, signalIndex, caller) {
31
+ /**
32
+ * Shared by `sampleAt` and `sampleStartTicksOf`, so the messages name NO function — the rule
33
+ * `envelope.ts` states for its own shared helpers. `sampleStartSecondsOf` is a one-line delegation
34
+ * to `sampleStartTicksOf`, so a hard-coded name here reached a caller who never wrote it
35
+ * (completed in 0.3.134; 0.3.133 fixed only the three messages outside this function).
36
+ */
37
+ function resolveSignal(recording, signalIndex) {
32
38
  const signal = recording.header.signals[signalIndex];
33
39
  if (signal === undefined) {
34
- throw new EdfChannelNotFoundError(`${caller}(): signalIndex ${signalIndex} is outside the ` +
40
+ throw new EdfChannelNotFoundError(`signalIndex ${signalIndex} is outside the ` +
35
41
  `${recording.header.signals.length} signals this file declares. Next: pass an index from ` +
36
42
  'header.dataSignalIndices, or resolve one with getSignal(header, label).', {
37
43
  selector: signalIndex,
@@ -39,17 +45,17 @@ function resolveSignal(recording, signalIndex, caller) {
39
45
  });
40
46
  }
41
47
  if (signal.kind === 'annotations') {
42
- throw new RangeError(`${caller}(): signal ${signalIndex} (${JSON.stringify(signal.label)}) is an annotations ` +
48
+ throw new RangeError(`signal ${signalIndex} (${JSON.stringify(signal.label)}) is an annotations ` +
43
49
  'channel, whose region holds TAL text rather than samples, so it has no sample grid. ' +
44
50
  'Next: use onsetTicksFromFirstRecord on the annotations themselves.');
45
51
  }
46
52
  if (signal.samplesPerRecord <= 0) {
47
- throw new RangeError(`${caller}(): signal ${signalIndex} (${JSON.stringify(signal.label)}) declares ` +
53
+ throw new RangeError(`signal ${signalIndex} (${JSON.stringify(signal.label)}) declares ` +
48
54
  `${signal.samplesPerRecord} samples per record, so it has no sample grid to index. ` +
49
55
  'Next: check header.diagnostics for ZERO_SAMPLES_PER_RECORD.');
50
56
  }
51
57
  if (recording.header.recordDurationTicks <= 0n) {
52
- throw new RangeError(`${caller}(): this file declares a record duration of zero, so records do not advance in ` +
58
+ throw new RangeError('this file declares a record duration of zero, so records do not advance in ' +
53
59
  'time and no elapsed time maps to a sample. This is legal EDF and a scoring file relies ' +
54
60
  'on it. Next: index by record with readRecords().');
55
61
  }
@@ -110,7 +116,7 @@ function probedIndexNeedsScan(recording) {
110
116
  * running when that time arrives.
111
117
  */
112
118
  export function sampleAt(recording, signalIndex, seconds) {
113
- const signal = resolveSignal(recording, signalIndex, 'sampleAt');
119
+ const signal = resolveSignal(recording, signalIndex);
114
120
  if (!Number.isFinite(seconds)) {
115
121
  throw new RangeError(`sampleAt(): seconds must be a finite number, received ${seconds}.`);
116
122
  }
@@ -178,9 +184,9 @@ export function sampleAt(recording, signalIndex, seconds) {
178
184
  * previous sample.
179
185
  */
180
186
  export function sampleStartTicksOf(recording, signalIndex, sampleIndex) {
181
- const signal = resolveSignal(recording, signalIndex, 'sampleStartTicksOf');
187
+ const signal = resolveSignal(recording, signalIndex);
182
188
  if (!Number.isSafeInteger(sampleIndex)) {
183
- throw new RangeError(`sampleStartTicksOf(): sampleIndex must be a whole number, received ${sampleIndex}.`);
189
+ throw new RangeError(`sampleIndex must be a whole number, received ${sampleIndex}.`);
184
190
  }
185
191
  const perRecord = signal.samplesPerRecord;
186
192
  const duration = recording.header.recordDurationTicks;
@@ -191,12 +197,12 @@ export function sampleStartTicksOf(recording, signalIndex, sampleIndex) {
191
197
  // sample 24 of a 24-sample file reported 6.75 s before sample 23. Refusing is the only honest
192
198
  // answer for a sample that does not exist.
193
199
  if (sampleIndex < 0 || recordIndex >= recording.header.recordCount) {
194
- throw new RangeError(`sampleStartTicksOf(): sample ${sampleIndex} is outside the ` +
200
+ throw new RangeError(`sample ${sampleIndex} is outside the ` +
195
201
  `${recording.header.recordCount * perRecord} samples signal ${signalIndex} has. ` +
196
202
  'Next: clamp the index, or read signal.sampleCount first.');
197
203
  }
198
204
  if (recording.index.segments === undefined && probedIndexNeedsScan(recording)) {
199
- throw new RangeError('sampleStartTicksOf(): this file has gaps and its index has not been scanned, so the true ' +
205
+ throw new RangeError('this file has gaps and its index has not been scanned, so the true ' +
200
206
  'start of a record after a gap is not known. Next: await buildRecordIndex(recording) and ' +
201
207
  'read the result into the recording.');
202
208
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sample-locate.js","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG1E,SAAS,aAAa,CAAC,SAAuB,EAAE,WAAmB,EAAE,MAAc;IACjF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,uBAAuB,CAC/B,GAAG,MAAM,mBAAmB,WAAW,kBAAkB;YACvD,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,wDAAwD;YAC1F,yEAAyE,EAC3E;YACE,QAAQ,EAAE,WAAW;YACrB,eAAe,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;SAC9D,CACF,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAClC,MAAM,IAAI,UAAU,CAClB,GAAG,MAAM,cAAc,WAAW,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB;YACvF,sFAAsF;YACtF,oEAAoE,CACvE,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,gBAAgB,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,UAAU,CAClB,GAAG,MAAM,cAAc,WAAW,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KA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M,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,OAAO,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AACjF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.3.132",
3
+ "version": "0.3.134",
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.132';
96
+ export const VERSION = '0.3.134';
@@ -31,11 +31,17 @@ import { segmentAt } from './record-index.js';
31
31
  import { floorDiv, secondsToTicks, ticksToSeconds } from './tal/ticks.js';
32
32
  import type { EdfRecording, EdfSampleLocation, EdfSegment, EdfSignal } from './types.js';
33
33
 
34
- function resolveSignal(recording: EdfRecording, signalIndex: number, caller: string): EdfSignal {
34
+ /**
35
+ * Shared by `sampleAt` and `sampleStartTicksOf`, so the messages name NO function — the rule
36
+ * `envelope.ts` states for its own shared helpers. `sampleStartSecondsOf` is a one-line delegation
37
+ * to `sampleStartTicksOf`, so a hard-coded name here reached a caller who never wrote it
38
+ * (completed in 0.3.134; 0.3.133 fixed only the three messages outside this function).
39
+ */
40
+ function resolveSignal(recording: EdfRecording, signalIndex: number): EdfSignal {
35
41
  const signal = recording.header.signals[signalIndex];
36
42
  if (signal === undefined) {
37
43
  throw new EdfChannelNotFoundError(
38
- `${caller}(): signalIndex ${signalIndex} is outside the ` +
44
+ `signalIndex ${signalIndex} is outside the ` +
39
45
  `${recording.header.signals.length} signals this file declares. Next: pass an index from ` +
40
46
  'header.dataSignalIndices, or resolve one with getSignal(header, label).',
41
47
  {
@@ -46,21 +52,21 @@ function resolveSignal(recording: EdfRecording, signalIndex: number, caller: str
46
52
  }
47
53
  if (signal.kind === 'annotations') {
48
54
  throw new RangeError(
49
- `${caller}(): signal ${signalIndex} (${JSON.stringify(signal.label)}) is an annotations ` +
55
+ `signal ${signalIndex} (${JSON.stringify(signal.label)}) is an annotations ` +
50
56
  'channel, whose region holds TAL text rather than samples, so it has no sample grid. ' +
51
57
  'Next: use onsetTicksFromFirstRecord on the annotations themselves.',
52
58
  );
53
59
  }
54
60
  if (signal.samplesPerRecord <= 0) {
55
61
  throw new RangeError(
56
- `${caller}(): signal ${signalIndex} (${JSON.stringify(signal.label)}) declares ` +
62
+ `signal ${signalIndex} (${JSON.stringify(signal.label)}) declares ` +
57
63
  `${signal.samplesPerRecord} samples per record, so it has no sample grid to index. ` +
58
64
  'Next: check header.diagnostics for ZERO_SAMPLES_PER_RECORD.',
59
65
  );
60
66
  }
61
67
  if (recording.header.recordDurationTicks <= 0n) {
62
68
  throw new RangeError(
63
- `${caller}(): this file declares a record duration of zero, so records do not advance in ` +
69
+ 'this file declares a record duration of zero, so records do not advance in ' +
64
70
  'time and no elapsed time maps to a sample. This is legal EDF and a scoring file relies ' +
65
71
  'on it. Next: index by record with readRecords().',
66
72
  );
@@ -131,7 +137,7 @@ export function sampleAt(
131
137
  signalIndex: number,
132
138
  seconds: number,
133
139
  ): EdfSampleLocation | undefined {
134
- const signal = resolveSignal(recording, signalIndex, 'sampleAt');
140
+ const signal = resolveSignal(recording, signalIndex);
135
141
  if (!Number.isFinite(seconds)) {
136
142
  throw new RangeError(`sampleAt(): seconds must be a finite number, received ${seconds}.`);
137
143
  }
@@ -209,11 +215,9 @@ export function sampleStartTicksOf(
209
215
  signalIndex: number,
210
216
  sampleIndex: number,
211
217
  ): bigint {
212
- const signal = resolveSignal(recording, signalIndex, 'sampleStartTicksOf');
218
+ const signal = resolveSignal(recording, signalIndex);
213
219
  if (!Number.isSafeInteger(sampleIndex)) {
214
- throw new RangeError(
215
- `sampleStartTicksOf(): sampleIndex must be a whole number, received ${sampleIndex}.`,
216
- );
220
+ throw new RangeError(`sampleIndex must be a whole number, received ${sampleIndex}.`);
217
221
  }
218
222
 
219
223
  const perRecord = signal.samplesPerRecord;
@@ -227,7 +231,7 @@ export function sampleStartTicksOf(
227
231
  // answer for a sample that does not exist.
228
232
  if (sampleIndex < 0 || recordIndex >= recording.header.recordCount) {
229
233
  throw new RangeError(
230
- `sampleStartTicksOf(): sample ${sampleIndex} is outside the ` +
234
+ `sample ${sampleIndex} is outside the ` +
231
235
  `${recording.header.recordCount * perRecord} samples signal ${signalIndex} has. ` +
232
236
  'Next: clamp the index, or read signal.sampleCount first.',
233
237
  );
@@ -235,7 +239,7 @@ export function sampleStartTicksOf(
235
239
 
236
240
  if (recording.index.segments === undefined && probedIndexNeedsScan(recording)) {
237
241
  throw new RangeError(
238
- 'sampleStartTicksOf(): this file has gaps and its index has not been scanned, so the true ' +
242
+ 'this file has gaps and its index has not been scanned, so the true ' +
239
243
  'start of a record after a gap is not known. Next: await buildRecordIndex(recording) and ' +
240
244
  'read the result into the recording.',
241
245
  );