edfcore 0.6.220 → 0.6.221

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.
@@ -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.220";
112
+ export declare const VERSION = "0.6.221";
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.6.220';
82
+ export const VERSION = '0.6.221';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAoBhG;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAuC9F;AAiHD;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CA0CrB"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAoBhG;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAuC9F;AA4ID;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CA0CrB"}
package/dist/io/read.js CHANGED
@@ -151,9 +151,36 @@ function assertRecordRange(header, records) {
151
151
  const countValid = Number.isSafeInteger(range.count) && range.count >= 0;
152
152
  if (startValid && countValid && range.start + range.count <= header.recordCount)
153
153
  return;
154
+ /*
155
+ * A CLAMP is advice you can only follow when there are two numbers to clamp.
156
+ *
157
+ * The two branches above are each documented as a fix for this sentence, and both name the same
158
+ * half of it: "advice to clamp it against `header.recordCount`, which no clamp can satisfy". Each
159
+ * carved out one shape. Every other range with no numbers in it still got the clamp — the
160
+ * `records ?? {}` stand-in at the top of this guard, which exists because `undefined` and `null`
161
+ * are "the likeliest two"; a half-built `{ start: 0 }`; a range whose fields arrived as strings
162
+ * from JSON.
163
+ *
164
+ * The belief behind writing one is the part no message addressed. `readRecords` refuses a missing
165
+ * SELECTION with "pass { records, signalIndices }", and 0.6.88 refuses one carrying
166
+ * `startSeconds` instead, so a selection holding only `signalIndices` passes both guards and
167
+ * arrives here with nothing — written that way because the range reads as optional. It is not,
168
+ * deliberately, and `readAnnotations` gives the reason: a full-file scan "is a legitimate thing to
169
+ * want and an expensive thing to do by accident, so it is always visible in the caller's source".
170
+ * So the advice for a range with no numbers is the range itself, counted for this file.
171
+ *
172
+ * Only the advice differs. The sentence naming the range and the file's record count is what
173
+ * every caller of this guard is pinned on, and it is true of both.
174
+ */
175
+ const clampable = typeof range.start === 'number' && typeof range.count === 'number';
154
176
  throw new EdfRangeError(`records ${describeRecordRange(range)} is not inside the ` +
155
- `${header.recordCount} data records this file contains. Next: clamp the range against ` +
156
- 'header.recordCount, or call index.locate(seconds) to find a record index for a time.', { requested: range, available });
177
+ `${header.recordCount} data records this file contains. Next: ` +
178
+ (clampable
179
+ ? 'clamp the range against header.recordCount, or call index.locate(seconds) to find a ' +
180
+ 'record index for a time.'
181
+ : 'pass a start and a count — there is no default, so a whole-file read is written out ' +
182
+ `rather than implied, and here that is start 0, count ${header.recordCount}. Or call ` +
183
+ 'readWindow(), which takes seconds and resolves the records itself.'), { requested: range, available });
157
184
  }
158
185
  /**
159
186
  * Refused BEFORE the allocation, never during it.
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,WAAuB;IAC9C,IAAI,WAAW,CAAC,MAAM,GAAG,sBAAsB;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,EAAE,MAAM,EAAE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,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACrF,OAAO,eAAe,CACpB,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAClD,UAAU,EACV,UAAU,CACX,CAAC;AACJ,CAAC"}
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ 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.221
10
+
11
+ - **Fixed** the record-range refusal advising a clamp to a caller who passed no numbers to clamp.
12
+ `assertRecordRange` sits behind `readRecords`, `readAnnotations` and `readRecordBytes`, and its
13
+ two shape branches are each documented as a fix for the sentence beneath them, both naming the
14
+ same half of it: advice "to clamp it against `header.recordCount`, which no clamp can satisfy".
15
+ A chunk got its own sentence in 0.4.443 and an array of ranges one in 0.6.212 — one shape each.
16
+ - Every other range with no numbers in it kept the clamp: the `records ?? {}` stand-in at the top
17
+ of the guard, a half-built `{ start: 0 }`, a range whose fields arrived from JSON as strings.
18
+ And a caller need not pass any of those literally — `readRecords` refuses a missing selection
19
+ with "pass { records, signalIndices }", 0.6.88 refuses one carrying `startSeconds` instead, and
20
+ a selection holding only `signalIndices` passes both guards and arrives here with nothing.
21
+ - It is written that way because the range reads as optional. It is not, deliberately, and
22
+ `readAnnotations` gives the reason: a full-file scan "is a legitimate thing to want and an
23
+ expensive thing to do by accident, so it is always visible in the caller's source". The clause
24
+ now asks for the two numbers and spells that range out, counted for the file in hand.
25
+ - Only the advice changed. A range that is two numbers and lands outside the file still gets the
26
+ clamp, the sentence naming the range and the record count is unchanged, and the absent range and
27
+ the half-built one still answer identically, as `missing-record-range.test.ts` has required
28
+ since 0.4.443.
29
+
9
30
  ## 0.6.220
10
31
 
11
32
  - **Fixed** `readEnvelope` offering the whole plot's pixel width for a count that is per run.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.220",
3
+ "version": "0.6.221",
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.6.220';
96
+ export const VERSION = '0.6.221';
package/src/io/read.ts CHANGED
@@ -165,10 +165,37 @@ function assertRecordRange(header: EdfHeader, records: RecordRange): void {
165
165
  const startValid = Number.isSafeInteger(range.start) && range.start >= 0;
166
166
  const countValid = Number.isSafeInteger(range.count) && range.count >= 0;
167
167
  if (startValid && countValid && range.start + range.count <= header.recordCount) return;
168
+ /*
169
+ * A CLAMP is advice you can only follow when there are two numbers to clamp.
170
+ *
171
+ * The two branches above are each documented as a fix for this sentence, and both name the same
172
+ * half of it: "advice to clamp it against `header.recordCount`, which no clamp can satisfy". Each
173
+ * carved out one shape. Every other range with no numbers in it still got the clamp — the
174
+ * `records ?? {}` stand-in at the top of this guard, which exists because `undefined` and `null`
175
+ * are "the likeliest two"; a half-built `{ start: 0 }`; a range whose fields arrived as strings
176
+ * from JSON.
177
+ *
178
+ * The belief behind writing one is the part no message addressed. `readRecords` refuses a missing
179
+ * SELECTION with "pass { records, signalIndices }", and 0.6.88 refuses one carrying
180
+ * `startSeconds` instead, so a selection holding only `signalIndices` passes both guards and
181
+ * arrives here with nothing — written that way because the range reads as optional. It is not,
182
+ * deliberately, and `readAnnotations` gives the reason: a full-file scan "is a legitimate thing to
183
+ * want and an expensive thing to do by accident, so it is always visible in the caller's source".
184
+ * So the advice for a range with no numbers is the range itself, counted for this file.
185
+ *
186
+ * Only the advice differs. The sentence naming the range and the file's record count is what
187
+ * every caller of this guard is pinned on, and it is true of both.
188
+ */
189
+ const clampable = typeof range.start === 'number' && typeof range.count === 'number';
168
190
  throw new EdfRangeError(
169
191
  `records ${describeRecordRange(range)} is not inside the ` +
170
- `${header.recordCount} data records this file contains. Next: clamp the range against ` +
171
- 'header.recordCount, or call index.locate(seconds) to find a record index for a time.',
192
+ `${header.recordCount} data records this file contains. Next: ` +
193
+ (clampable
194
+ ? 'clamp the range against header.recordCount, or call index.locate(seconds) to find a ' +
195
+ 'record index for a time.'
196
+ : 'pass a start and a count — there is no default, so a whole-file read is written out ' +
197
+ `rather than implied, and here that is start 0, count ${header.recordCount}. Or call ` +
198
+ 'readWindow(), which takes seconds and resolves the records itself.'),
172
199
  { requested: range, available },
173
200
  );
174
201
  }