edfcore 0.6.156 → 0.6.157

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.156";
112
+ export declare const VERSION = "0.6.157";
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.156';
82
+ export const VERSION = '0.6.157';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/io/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAGrE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CA+BrD"}
1
+ {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/io/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAGrE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAuDrD"}
package/dist/io/blob.js CHANGED
@@ -31,6 +31,27 @@ export function blobSource(blob) {
31
31
  `${describeValue(blob)}. Next: pass the File an <input type="file"> or a drop event hands ` +
32
32
  'you, or byteSource(bytes) if you already have the bytes in memory.', { offset: 0, requestedLength: 0 });
33
33
  }
34
+ /*
35
+ * The SIZE, which the check above only established is a number.
36
+ *
37
+ * `fileHandleSource` refuses a `byteLength` that is not a byte count (0.6.85) and `fileSource`
38
+ * refuses the one it reads off the handle; this is the third adapter that takes a size and the
39
+ * one that took whatever arrived. `BlobLike` is a structural shim precisely so a caller can
40
+ * IMPLEMENT it — a stream-backed file, a mocked blob in a test, a wrapper around a native file
41
+ * picker — and an implementation is where a computed `size` comes from.
42
+ *
43
+ * A `NaN` did not fail; it disabled the range guard. `assertReadRange` compares every read
44
+ * against `byteLength`, every comparison against `NaN` is false, so the check silently stopped
45
+ * happening and the source advertised `byteLength: NaN` to everything downstream. A negative or
46
+ * fractional size passed the same way. `options.ts` names this shape exactly: "a guard written
47
+ * as `if (value < 1)` simply does not fire".
48
+ */
49
+ if (!Number.isSafeInteger(blob.size) || blob.size < 0) {
50
+ throw new EdfSourceError(`blobSource() was given ${describeValue(blob.size)} as the blob's size, which is not a ` +
51
+ 'byte count edfcore can address, so no read could be bounded by it. Next: pass a real ' +
52
+ 'Blob or File, whose size the platform sets, or byteSource(bytes) if you built the ' +
53
+ 'bytes yourself.', { offset: 0, requestedLength: 0 });
54
+ }
34
55
  const byteLength = blob.size;
35
56
  return {
36
57
  byteLength,
@@ -1 +1 @@
1
- {"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/io/blob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC;;;;;;OAMG;IACH,MAAM,KAAK,GAAG,IAAmC,CAAC;IAClD,IAAI,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QACzE,MAAM,IAAI,cAAc,CACtB,2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,MAAM,IAAI,cAAc,CACtB,2FAA2F;YACzF,GAAG,aAAa,CAAC,IAAI,CAAC,qEAAqE;YAC3F,oEAAoE,EACtE,EAAE,MAAM,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAClC,CAAC;IACJ,CAAC;IACD;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,cAAc,CACtB,0BAA0B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,sCAAsC;YACtF,uFAAuF;YACvF,oFAAoF;YACpF,iBAAiB,EACnB,EAAE,MAAM,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAClC,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;IAE7B,OAAO;QACL,UAAU;QACV,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAc,EAAE,OAAqB;YAC9D,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YAC5C,IAAI,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAC3C,kEAAkE;YAClE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YACvE,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,OAAO,eAAe,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,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.157
10
+
11
+ - **Fixed** `blobSource` accepting a `size` that is not a byte count. A `NaN` did not fail — it
12
+ disabled the range guard, since `assertReadRange` compares every read against `byteLength` and
13
+ every comparison against `NaN` is false — and the source then advertised `byteLength: NaN`
14
+ downstream.
15
+ - Negative and fractional sizes passed the same way. `fileHandleSource` has refused all of them
16
+ since 0.6.85 and `fileSource` validates the size it reads off the handle; this was the third
17
+ adapter that takes one.
18
+ - `BlobLike` is a structural shim so a caller can implement it, which is where a computed size
19
+ comes from.
20
+
9
21
  ## 0.6.156
10
22
 
11
23
  - **Fixed** `decodeAnnotations` and `readAnnotations` walking a `signalIndices` that is not a list.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.156",
3
+ "version": "0.6.157",
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.156';
96
+ export const VERSION = '0.6.157';
package/src/io/blob.ts CHANGED
@@ -37,6 +37,30 @@ export function blobSource(blob: BlobLike): ByteSource {
37
37
  { offset: 0, requestedLength: 0 },
38
38
  );
39
39
  }
40
+ /*
41
+ * The SIZE, which the check above only established is a number.
42
+ *
43
+ * `fileHandleSource` refuses a `byteLength` that is not a byte count (0.6.85) and `fileSource`
44
+ * refuses the one it reads off the handle; this is the third adapter that takes a size and the
45
+ * one that took whatever arrived. `BlobLike` is a structural shim precisely so a caller can
46
+ * IMPLEMENT it — a stream-backed file, a mocked blob in a test, a wrapper around a native file
47
+ * picker — and an implementation is where a computed `size` comes from.
48
+ *
49
+ * A `NaN` did not fail; it disabled the range guard. `assertReadRange` compares every read
50
+ * against `byteLength`, every comparison against `NaN` is false, so the check silently stopped
51
+ * happening and the source advertised `byteLength: NaN` to everything downstream. A negative or
52
+ * fractional size passed the same way. `options.ts` names this shape exactly: "a guard written
53
+ * as `if (value < 1)` simply does not fire".
54
+ */
55
+ if (!Number.isSafeInteger(blob.size) || blob.size < 0) {
56
+ throw new EdfSourceError(
57
+ `blobSource() was given ${describeValue(blob.size)} as the blob's size, which is not a ` +
58
+ 'byte count edfcore can address, so no read could be bounded by it. Next: pass a real ' +
59
+ 'Blob or File, whose size the platform sets, or byteSource(bytes) if you built the ' +
60
+ 'bytes yourself.',
61
+ { offset: 0, requestedLength: 0 },
62
+ );
63
+ }
40
64
  const byteLength = blob.size;
41
65
 
42
66
  return {