edfcore 0.6.104 → 0.6.105

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.104";
112
+ export declare const VERSION = "0.6.105";
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.104';
82
+ export const VERSION = '0.6.105';
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;AASH,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,CAwB9F;AAqED;;;;;;;;;;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,CAYrB"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH,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,CA8B9F;AAqED;;;;;;;;;;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,CAarB"}
package/dist/io/read.js CHANGED
@@ -28,7 +28,7 @@ import { EdfBudgetError, EdfRangeError } from '../errors.js';
28
28
  import { parseHeader } from '../header/parse.js';
29
29
  import { resolveMaterializeBudget } from '../options.js';
30
30
  import { pluralise } from '../text/counted.js';
31
- import { assertExactRead } from './source.js';
31
+ import { assertByteSource, assertExactRead } from './source.js';
32
32
  /**
33
33
  * The signal count, read leniently and reported to nobody.
34
34
  *
@@ -56,6 +56,12 @@ function signalCountHint(fixedHeader) {
56
56
  * the file's problem.
57
57
  */
58
58
  export async function readHeader(source, options) {
59
+ // The refusal `openEdf` gives, in the two functions it is the convenience wrapper over.
60
+ // `api-primitives.md` sends a reader who has outgrown the top layer to exactly these, and neither
61
+ // checked its source: both read a field off it on their first line, so `readHeader(bytes)` — the
62
+ // same mistake 0.4.444 named `openEdf(bytes)` for — came back as V8's `Cannot read properties of
63
+ // undefined (reading 'byteLength')` (fixed in 0.6.105).
64
+ assertByteSource(source);
59
65
  const sourceByteLength = source.byteLength;
60
66
  const firstLength = Math.min(EDF_HEADER_BLOCK_BYTES, sourceByteLength);
61
67
  const fixedHeader = assertExactRead(await source.read(0, firstLength, options), 0, firstLength);
@@ -141,6 +147,7 @@ function assertWithinBudget(requiredBytes, records, options) {
141
147
  * honest than asking for it.
142
148
  */
143
149
  export async function readRecordBytes(source, header, records, options) {
150
+ assertByteSource(source);
144
151
  assertRecordRange(header, records);
145
152
  const byteLength = records.count * header.recordBy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IACnC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3D,IAAI,UAAU,KAAK,CAAC;QAAE,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAE/C,kBAAkB,CAAC,UAAU,EAAE,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,17 @@ 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.105
10
+
11
+ - **Fixed** `readHeader` and `readRecordBytes` — the two functions `openEdf` is the convenience
12
+ wrapper over — accepting anything as their source.
13
+ - `api-primitives.md` sends a reader who has outgrown the top layer to exactly these two, and both
14
+ read a field off the source on their first line. So `readHeader(bytes)`, the same mistake 0.4.444
15
+ named `openEdf(bytes)` for, made one layer down by someone who has just been told to drop a layer,
16
+ came back as `Cannot read properties of undefined (reading 'byteLength')`.
17
+ - Both now call `assertByteSource`, so all three entry points give the same refusal — including the
18
+ clause that recognises a path string and names `fileSource`.
19
+
9
20
  ## 0.6.104
10
21
 
11
22
  - **Fixed** `toPhysical`, `physicalRangeOf` and `clampToDigitalRange` when handed a chunk signal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.104",
3
+ "version": "0.6.105",
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.104';
96
+ export const VERSION = '0.6.105';
package/src/io/read.ts CHANGED
@@ -30,7 +30,7 @@ import { parseHeader } from '../header/parse.js';
30
30
  import { resolveMaterializeBudget } from '../options.js';
31
31
  import { pluralise } from '../text/counted.js';
32
32
  import type { ByteSource, EdfHeader, OpenOptions, ReadOptions, RecordRange } from '../types.js';
33
- import { assertExactRead } from './source.js';
33
+ import { assertByteSource, assertExactRead } from './source.js';
34
34
 
35
35
  /**
36
36
  * The signal count, read leniently and reported to nobody.
@@ -58,6 +58,12 @@ function signalCountHint(fixedHeader: Uint8Array): number | undefined {
58
58
  * the file's problem.
59
59
  */
60
60
  export async function readHeader(source: ByteSource, options?: OpenOptions): Promise<EdfHeader> {
61
+ // The refusal `openEdf` gives, in the two functions it is the convenience wrapper over.
62
+ // `api-primitives.md` sends a reader who has outgrown the top layer to exactly these, and neither
63
+ // checked its source: both read a field off it on their first line, so `readHeader(bytes)` — the
64
+ // same mistake 0.4.444 named `openEdf(bytes)` for — came back as V8's `Cannot read properties of
65
+ // undefined (reading 'byteLength')` (fixed in 0.6.105).
66
+ assertByteSource(source);
61
67
  const sourceByteLength = source.byteLength;
62
68
  const firstLength = Math.min(EDF_HEADER_BLOCK_BYTES, sourceByteLength);
63
69
  const fixedHeader = assertExactRead(await source.read(0, firstLength, options), 0, firstLength);
@@ -167,6 +173,7 @@ export async function readRecordBytes(
167
173
  records: RecordRange,
168
174
  options?: ReadOptions,
169
175
  ): Promise<Uint8Array> {
176
+ assertByteSource(source);
170
177
  assertRecordRange(header, records);
171
178
  const byteLength = records.count * header.recordByteLength;
172
179
  if (byteLength === 0) return new Uint8Array(0);