edfcore 0.3.92 → 0.3.93

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,22 @@ 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.93
10
+
11
+ - **Fixed** `fileHandleSource` handing a short read the advice written for a source the CALLER
12
+ wrote.
13
+ - When the bytes run out — `fileSource` stat'd the file and it was then truncated or rotated, a
14
+ caller passed a `byteLength` larger than the file, or a picked `File`'s backing file shrank —
15
+ the read fell through to `assertExactRead`, whose message ends "Next: make read() loop until
16
+ `length` bytes have arrived, and reject if they never do." The loop it asks for is twelve lines
17
+ above it, edfcore wrote it, and it already reads until EOF. No amount of looping produces bytes
18
+ the file does not contain.
19
+ - It now says what happened: the file ended after N of the bytes asked for, the source was built
20
+ for M, and the two ways that happens. `assertExactRead` still backstops the return.
21
+ - Same shape as 0.3.75, which fixed it on the HTTP buffered-body path. The guard is for a
22
+ `ByteSource` edfcore did not write; when the source IS edfcore's, its advice names a `read()` the
23
+ caller does not have.
24
+
9
25
  ## 0.3.92
10
26
 
11
27
  - **Fixed** three statements of `readTriggers`' `precededByGap` rule that describe the behaviour
@@ -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.92";
112
+ export declare const VERSION = "0.3.93";
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.92';
82
+ export const VERSION = '0.3.93';
83
83
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,YAAY,CAAC;AAE1D;;;;;;GAMG;AACH,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CACF,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAgCvF;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAqBlE"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,YAAY,CAAC;AAE1D;;;;;;GAMG;AACH,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CACF,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAqDvF;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAqBlE"}
package/dist/node.js CHANGED
@@ -81,6 +81,24 @@ export function fileHandleSource(handle, byteLength) {
81
81
  // `blobSource` has always rejected in that situation, and one adapter honouring a signal
82
82
  // that another quietly ignores is worse than either rule on its own.
83
83
  throwIfAborted(options);
84
+ /*
85
+ * Diagnosed HERE rather than left to `assertExactRead`. That guard exists for a `ByteSource`
86
+ * the CALLER wrote — its message ends "make read() loop until `length` bytes have arrived" —
87
+ * and the loop it asks for is the one twelve lines above, which already reads until EOF. No
88
+ * amount of looping produces bytes the file does not contain.
89
+ *
90
+ * The real cause is that this source was built for more bytes than the file holds:
91
+ * `fileSource` stats the file and the file was then truncated or rotated, or a caller passed
92
+ * a `byteLength` larger than the file, or a picked `File`'s backing file shrank. Same shape
93
+ * as the HTTP buffered-body path, fixed in 0.3.75 (fixed here in 0.3.93).
94
+ */
95
+ if (filled < length) {
96
+ throw new EdfSourceError(`Reading bytes ${offset}..${offset + length - 1}: the file ended after ${filled} of ` +
97
+ `them. This source was built for ${byteLength} bytes, so the range asked for is past ` +
98
+ 'the end of the file as it is now. Next: the file was truncated or replaced after it ' +
99
+ 'was opened, or options.byteLength is larger than the file — re-open it, or pass the ' +
100
+ 'size the file actually has.', { offset, requestedLength: length, receivedLength: filled });
101
+ }
84
102
  return assertExactRead(buffer.subarray(0, filled), offset, length);
85
103
  },
86
104
  async close() {
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG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AC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.3.92",
3
+ "version": "0.3.93",
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.92';
96
+ export const VERSION = '0.3.93';
package/src/node.ts CHANGED
@@ -117,6 +117,27 @@ export function fileHandleSource(handle: FileHandleLike, byteLength: number): By
117
117
  // `blobSource` has always rejected in that situation, and one adapter honouring a signal
118
118
  // that another quietly ignores is worse than either rule on its own.
119
119
  throwIfAborted(options);
120
+ /*
121
+ * Diagnosed HERE rather than left to `assertExactRead`. That guard exists for a `ByteSource`
122
+ * the CALLER wrote — its message ends "make read() loop until `length` bytes have arrived" —
123
+ * and the loop it asks for is the one twelve lines above, which already reads until EOF. No
124
+ * amount of looping produces bytes the file does not contain.
125
+ *
126
+ * The real cause is that this source was built for more bytes than the file holds:
127
+ * `fileSource` stats the file and the file was then truncated or rotated, or a caller passed
128
+ * a `byteLength` larger than the file, or a picked `File`'s backing file shrank. Same shape
129
+ * as the HTTP buffered-body path, fixed in 0.3.75 (fixed here in 0.3.93).
130
+ */
131
+ if (filled < length) {
132
+ throw new EdfSourceError(
133
+ `Reading bytes ${offset}..${offset + length - 1}: the file ended after ${filled} of ` +
134
+ `them. This source was built for ${byteLength} bytes, so the range asked for is past ` +
135
+ 'the end of the file as it is now. Next: the file was truncated or replaced after it ' +
136
+ 'was opened, or options.byteLength is larger than the file — re-open it, or pass the ' +
137
+ 'size the file actually has.',
138
+ { offset, requestedLength: length, receivedLength: filled },
139
+ );
140
+ }
120
141
  return assertExactRead(buffer.subarray(0, filled), offset, length);
121
142
  },
122
143
  async close(): Promise<void> {