edfcore 0.6.276 → 0.6.278

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.276";
112
+ export declare const VERSION = "0.6.278";
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.276';
82
+ export const VERSION = '0.6.278';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAI5F;;;;GAIG;AACH,8BAAsB,QAAS,SAAQ,KAAK;IAC1C,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAEjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAS3D;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,eAAe,GACf,aAAa,GACb,cAAc,GACd,cAAc,GACd,wBAAwB,GACxB,uBAAuB,CAAC;AAE5B;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI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/dist/errors.js CHANGED
@@ -116,10 +116,31 @@ export class EdfRangeError extends EdfError {
116
116
  * range is unchanged; a wrong shape keeps whatever it had under those two names and nothing
117
117
  * else, which is the same pair the message prints.
118
118
  */
119
+ /*
120
+ * And as NUMBERS, which the narrowing above did not make them.
121
+ *
122
+ * "A wrong shape keeps whatever it had under those two names" was the limit this stopped at, and
123
+ * the two names are declared `number`. A range refused for being the wrong TYPE — the case
124
+ * 0.6.243 wrote the `mistyped` branch for — put its string or its BigInt straight onto the
125
+ * error: `requested.start` was `'0'` or `0n` under a field a handler reads as a count.
126
+ *
127
+ * So `error.requested.start + error.requested.count` was `'01'`, or threw V8's "Cannot mix
128
+ * BigInt and other types" inside the handler. The message says the values cannot be counted —
129
+ * "this counts and adds them rather than using them as keys, so a BigInt or a string is not the
130
+ * same value here" — and the payload beside it handed them back as though they could be. A typed
131
+ * payload is the one part of an error a program acts on rather than reads, which is the whole
132
+ * reason `errors.ts` carries these fields at all.
133
+ *
134
+ * `NaN` rather than dropping the field: both are declared and required, `Number.isFinite` is
135
+ * already how a handler has to check them, and `NaN` is the one number that cannot be mistaken
136
+ * for a count. `Number('0')` is not used — coercing would make the payload agree with a value
137
+ * the call refused.
138
+ */
139
+ const numeric = (value) => (typeof value === 'number' ? value : Number.NaN);
119
140
  const requested = init.requested;
120
141
  const available = init.available;
121
- this.requested = { start: requested?.start, count: requested?.count };
122
- this.available = { start: available?.start, count: available?.count };
142
+ this.requested = { start: numeric(requested?.start), count: numeric(requested?.count) };
143
+ this.available = { start: numeric(available?.start), count: numeric(available?.count) };
123
144
  }
124
145
  }
125
146
  /** A `ByteSource` broke its contract: it returned a different number of bytes than asked. */
@@ -131,9 +152,25 @@ export class EdfSourceError extends EdfError {
131
152
  constructor(message, init) {
132
153
  super(message, { cause: init.cause });
133
154
  this.name = 'EdfSourceError';
134
- this.offset = init.offset;
135
- this.requestedLength = init.requestedLength;
136
- this.receivedLength = init.receivedLength;
155
+ /*
156
+ * As NUMBERS, for the reason `EdfRangeError` above gives for its own pair (0.6.277): these three
157
+ * are declared `number`, and the guards that build this error hand over the value they refused.
158
+ *
159
+ * `ByteSource.read` is the one that reaches it. Its own refusal says the argument "is not a
160
+ * non-negative safe integer" — and then put the string `'0'` or the BigInt `0n` on `offset`,
161
+ * under the field `a-request-that-went-out-on-the-global-fetch.test.ts` calls "the fields an
162
+ * EdfSourceError handler branches on". A handler adding `offset + requestedLength` to retry at
163
+ * the next block got `'04'`, or V8's "Cannot mix BigInt and other types".
164
+ *
165
+ * `receivedLength` is optional and keeps `undefined`, which is a declared value for it rather
166
+ * than a stand-in: it means no read completed, which is a different fact from a read that
167
+ * returned an unusable count.
168
+ */
169
+ const numeric = (value) => (typeof value === 'number' ? value : Number.NaN);
170
+ this.offset = numeric(init.offset);
171
+ this.requestedLength = numeric(init.requestedLength);
172
+ this.receivedLength =
173
+ init.receivedLength === undefined ? undefined : numeric(init.receivedLength);
137
174
  }
138
175
  }
139
176
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,MAAM,iBAAiB,GAA6B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,OAAgB,QAAS,SAAQ,KAAK;IAG1C,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAmC,CAAC,CAAC;QACpD,0FAA0F;QAC1F,wFAAwF;QACxF,yFAAyF;QACzF,0FAA0F;QAC1F,qFAAqF;QACrF,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAmBD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAoC,CAAC,YAAY,KAAK,QAAQ,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,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAC9C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IAC1C,YAAY,GAAG,SAAkB,CAAC;IAClC,QAAQ,CAAkB;IAC1B,eAAe,CAAoB;IAE5C,YACE,OAAe,EACf,IAAwF;QAExF,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC;;;;;;;;;;;;;;WAcG;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAmB,CAAC;QAC1C,MAAM,KAAK,GAAI,QAAmD,EAAE,KAAK,CAAC;QAC1E,IAAI,CAAC,QAAQ,GAAG,CACd,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC1D,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;gBACzB,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,SAAS,CACG,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAC9C,CAAC;CACF"}
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,40 @@ 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.278
10
+
11
+ - **Fixed** `EdfSourceError.offset` and `requestedLength` carrying a non-number under fields declared
12
+ `number`, which 0.6.277 closed on `EdfRangeError`'s pair. `ByteSource.read` is the guard that
13
+ reaches them: its refusal says the argument "is not a non-negative safe integer", and then put the
14
+ string `'0'` or the BigInt `0n` on `offset`.
15
+ - These are the fields a consumer branches on, and a handler adding `offset + requestedLength` to
16
+ retry at the next block got `'04'`, or V8's "Cannot mix BigInt and other types".
17
+ - `receivedLength` keeps `undefined`, which is a declared value for it rather than a stand-in: it
18
+ means no read completed, which is a different fact from a read that returned an unusable count.
19
+ - Every real read is unchanged — an out-of-range request still reports the offset and length it asked
20
+ for, because those were numbers — and the messages are untouched.
21
+
22
+ ## 0.6.277
23
+
24
+ - **Fixed** `EdfRangeError.requested` carrying a non-number under a field declared `number`. The
25
+ narrowing on this error stops at the two names — "a wrong shape keeps whatever it had under those
26
+ two names and nothing else" — and a range refused for being the wrong type put its string or its
27
+ BigInt straight onto the payload.
28
+ - So `error.requested.start + error.requested.count` was `'01'`, or threw V8's "Cannot mix BigInt and
29
+ other types" inside the handler. The message had already said the values cannot be counted — "this
30
+ counts and adds them rather than using them as keys, so a BigInt or a string is not the same value
31
+ here" — and the payload beside it handed them back as though they could be.
32
+ - A typed payload is the one part of an error a program acts on rather than reads, which is the whole
33
+ reason `errors.ts` carries these fields. A field that lies about its type is worse here than a
34
+ message that does, because nothing prints it for a human to notice.
35
+ - `NaN` rather than a dropped field or a coercion: both fields are declared and required,
36
+ `Number.isFinite` is already how a handler has to check them, `NaN` is the one number that cannot
37
+ be mistaken for a count, and `Number('0')` would make the payload agree with a value the call
38
+ refused. An absent bound reads `NaN` for the same reason.
39
+ - `requested` is still an object rather than `undefined`, still carries exactly those two names, and a
40
+ well-formed range still arrives as itself. The value a caller wrote is still named in the message,
41
+ through `describeRecordRange`.
42
+
9
43
  ## 0.6.276
10
44
 
11
45
  - **Fixed** `options.headers` accepting a container with no own enumerable values. `assertHeaders`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.276",
3
+ "version": "0.6.278",
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.276';
96
+ export const VERSION = '0.6.278';
package/src/errors.ts CHANGED
@@ -178,10 +178,31 @@ export class EdfRangeError extends EdfError {
178
178
  * range is unchanged; a wrong shape keeps whatever it had under those two names and nothing
179
179
  * else, which is the same pair the message prints.
180
180
  */
181
- const requested = init.requested as { start?: number; count?: number } | null | undefined;
182
- const available = init.available as { start?: number; count?: number } | null | undefined;
183
- this.requested = { start: requested?.start, count: requested?.count } as RecordRange;
184
- this.available = { start: available?.start, count: available?.count } as RecordRange;
181
+ /*
182
+ * And as NUMBERS, which the narrowing above did not make them.
183
+ *
184
+ * "A wrong shape keeps whatever it had under those two names" was the limit this stopped at, and
185
+ * the two names are declared `number`. A range refused for being the wrong TYPE — the case
186
+ * 0.6.243 wrote the `mistyped` branch for — put its string or its BigInt straight onto the
187
+ * error: `requested.start` was `'0'` or `0n` under a field a handler reads as a count.
188
+ *
189
+ * So `error.requested.start + error.requested.count` was `'01'`, or threw V8's "Cannot mix
190
+ * BigInt and other types" inside the handler. The message says the values cannot be counted —
191
+ * "this counts and adds them rather than using them as keys, so a BigInt or a string is not the
192
+ * same value here" — and the payload beside it handed them back as though they could be. A typed
193
+ * payload is the one part of an error a program acts on rather than reads, which is the whole
194
+ * reason `errors.ts` carries these fields at all.
195
+ *
196
+ * `NaN` rather than dropping the field: both are declared and required, `Number.isFinite` is
197
+ * already how a handler has to check them, and `NaN` is the one number that cannot be mistaken
198
+ * for a count. `Number('0')` is not used — coercing would make the payload agree with a value
199
+ * the call refused.
200
+ */
201
+ const numeric = (value: unknown): number => (typeof value === 'number' ? value : Number.NaN);
202
+ const requested = init.requested as { start?: unknown; count?: unknown } | null | undefined;
203
+ const available = init.available as { start?: unknown; count?: unknown } | null | undefined;
204
+ this.requested = { start: numeric(requested?.start), count: numeric(requested?.count) };
205
+ this.available = { start: numeric(available?.start), count: numeric(available?.count) };
185
206
  }
186
207
  }
187
208
 
@@ -203,9 +224,25 @@ export class EdfSourceError extends EdfError {
203
224
  ) {
204
225
  super(message, { cause: init.cause });
205
226
  this.name = 'EdfSourceError';
206
- this.offset = init.offset;
207
- this.requestedLength = init.requestedLength;
208
- this.receivedLength = init.receivedLength;
227
+ /*
228
+ * As NUMBERS, for the reason `EdfRangeError` above gives for its own pair (0.6.277): these three
229
+ * are declared `number`, and the guards that build this error hand over the value they refused.
230
+ *
231
+ * `ByteSource.read` is the one that reaches it. Its own refusal says the argument "is not a
232
+ * non-negative safe integer" — and then put the string `'0'` or the BigInt `0n` on `offset`,
233
+ * under the field `a-request-that-went-out-on-the-global-fetch.test.ts` calls "the fields an
234
+ * EdfSourceError handler branches on". A handler adding `offset + requestedLength` to retry at
235
+ * the next block got `'04'`, or V8's "Cannot mix BigInt and other types".
236
+ *
237
+ * `receivedLength` is optional and keeps `undefined`, which is a declared value for it rather
238
+ * than a stand-in: it means no read completed, which is a different fact from a read that
239
+ * returned an unusable count.
240
+ */
241
+ const numeric = (value: unknown): number => (typeof value === 'number' ? value : Number.NaN);
242
+ this.offset = numeric(init.offset);
243
+ this.requestedLength = numeric(init.requestedLength);
244
+ this.receivedLength =
245
+ init.receivedLength === undefined ? undefined : numeric(init.receivedLength);
209
246
  }
210
247
  }
211
248