edfcore 0.6.226 → 0.6.228

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.
@@ -1 +1 @@
1
- {"version":3,"file":"annotations-query.d.ts","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAmDrE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,MAAM,EAAE,mBAAmB,GAC1B,SAAS,aAAa,EAAE,CAwD1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GACnD,SAAS,aAAa,EAAE,CAiB1B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,SAAS,aAAa,EAAE,GACpC,aAAa,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CASlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,EAAE,MAAM,GACd,SAAS,aAAa,EAAE,CAU1B"}
1
+ {"version":3,"file":"annotations-query.d.ts","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAmDrE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,MAAM,EAAE,mBAAmB,GAC1B,SAAS,aAAa,EAAE,CA6E1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GACnD,SAAS,aAAa,EAAE,CAiB1B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,SAAS,aAAa,EAAE,GACpC,aAAa,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CASlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,EAAE,MAAM,GACd,SAAS,aAAa,EAAE,CA2B1B"}
@@ -82,8 +82,29 @@ export function filterAnnotationsByTime(annotations, window) {
82
82
  // Cannot read properties of undefined (reading 'startSeconds')`, naming a field rather than the
83
83
  // argument, with no `Next:` clause.
84
84
  if (typeof window !== 'object' || window === null) {
85
- throw new RangeError(`filterAnnotationsByTime(): the window is ${describeValue(window)}, not an object. ` +
86
- 'Next: pass a window carrying startSeconds and durationSeconds.');
85
+ /*
86
+ * A NUMBER, which is an INSTANT, and the one wrong window whose advice led somewhere worse than
87
+ * where it started.
88
+ *
89
+ * "Pass a window carrying startSeconds and durationSeconds" is followable: a reader holding a
90
+ * cursor position writes `{ startSeconds: t, durationSeconds: 0 }`, because a window over one
91
+ * instant has no length. `annotationsAt`'s own docblock says what that does — the window form
92
+ * "works — a zero-length window — except that `filterAnnotationsByTime` returns nothing for a
93
+ * non-positive duration, so the obvious call returns an empty list at every position" — and it
94
+ * is why that function exists at all. So the advice ended in silence rather than in an error,
95
+ * at the call a viewer makes on every mouse move.
96
+ *
97
+ * The sibling is one export away and takes exactly what was passed. 0.6.88 made this argument
98
+ * for `readWindow` and `readRecords`, the other pair in this package that differ only in the
99
+ * unit they bound by.
100
+ */
101
+ throw new RangeError(`filterAnnotationsByTime(): the window is ${describeValue(window)}, not an object.` +
102
+ (typeof window === 'number'
103
+ ? ' That is an instant, and this call bounds events by an interval — a zero-length one ' +
104
+ 'returns nothing, so a cursor position asked for as a window reads as no annotations ' +
105
+ 'at every position. Next: call annotationsAt(annotations, seconds), which takes the ' +
106
+ 'instant, or pass a window carrying startSeconds and durationSeconds.'
107
+ : ' Next: pass a window carrying startSeconds and durationSeconds.'));
87
108
  }
88
109
  /*
89
110
  * An ARRAY, which is an object and therefore walked straight past the check above.
@@ -178,6 +199,21 @@ export function countAnnotationsByText(annotations) {
178
199
  */
179
200
  export function annotationsAt(annotations, seconds) {
180
201
  assertAnnotations(annotations, 'annotationsAt');
202
+ /*
203
+ * And the OTHER WAY. `filterAnnotationsByTime` is the neighbour this function's docblock names,
204
+ * the two differ only in whether they bound by an instant or by an interval, and a window here
205
+ * reached `secondsToTicks` — which answered "seconds must be a number of seconds, and was given
206
+ * an object. Next: convert it first". There is no conversion: a window is not a number spelled
207
+ * differently, and the reader was being sent to invent one.
208
+ */
209
+ const given = seconds;
210
+ if (typeof given === 'object' && given !== null && !Array.isArray(given)) {
211
+ if ('startSeconds' in given || 'durationSeconds' in given) {
212
+ throw new RangeError('annotationsAt(): that is a time window, and this call takes a single instant in seconds. ' +
213
+ 'Next: pass window.startSeconds for the instant under a cursor, or call ' +
214
+ 'filterAnnotationsByTime(annotations, window), which is the one that takes an interval.');
215
+ }
216
+ }
181
217
  const at = secondsToTicks(seconds, 'seconds');
182
218
  return Object.freeze(annotations.filter((annotation) => {
183
219
  const onset = annotation.onsetTicksFromFirstRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"annotations-query.js","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EA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sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,YAAY,CAAC;AA+L1E;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CAmGjE"}
1
+ {"version":3,"file":"chunks.d.ts","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAiC,MAAM,YAAY,CAAC;AA8M1E;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CAmGjE"}
package/dist/chunks.js CHANGED
@@ -27,9 +27,24 @@ import { describeValue } from './text/describe.js';
27
27
  /** Reads as one line at the call site, and keeps the `chunks[i]` non-null assertions out of it. */
28
28
  function at(chunks, index) {
29
29
  const chunk = chunks[index];
30
- if (chunk === undefined) {
30
+ /*
31
+ * `null` as well as `undefined`, because JSON is how a hole arrives.
32
+ *
33
+ * The advice below is about a hole, and the transport that produces one spells it `null`:
34
+ * `JSON.stringify` writes an absent element as `null`, so a chunk array crossing a worker
35
+ * boundary, a cache or a message channel comes back with `null` where nothing was. That is the
36
+ * same route `a-selection-from-json.test.ts` follows for the selection, and
37
+ * `design-decisions.md` follows for a chunk — "what parses back has no `.length` where a caller
38
+ * expects one".
39
+ *
40
+ * `undefined` was refused here in a sentence; `null` reached `chunk.records` on the next check
41
+ * and threw V8's `Cannot read properties of null (reading 'records')`. Every other wrong element
42
+ * — a number, a string, an object, one signal of a chunk — already had a sentence of its own, so
43
+ * `null` was the one value in this array that left the package without a `Next:` clause.
44
+ */
45
+ if (chunk === undefined || chunk === null) {
31
46
  throw new RangeError(`mergeChunks: no chunk at ${index}. Next: pass the array readWindow() returned, with no ` +
32
- 'holes and nothing spliced out of it.');
47
+ 'holes and nothing spliced out of it — JSON writes one as null.');
33
48
  }
34
49
  /*
35
50
  * The ELEMENTS, which the array guard below never reached.
@@ -1 +1 @@
1
- {"version":3,"file":"chunks.js","sourceRoot":"","sources":["../src/chunks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,mGAAmG;AACnG,SAAS,EAAE,CAAC,MAA2B,EAAE,KAAa;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAClB,4BAA4B,KAAK,wDAAwD;YACvF,sCAAsC,CACzC,CAAC;IACJ,CAAC;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjE,MAAM,IAAI,UAAU,CAClB,6BAA6B,KAAK,OAChC,OAAQ,KAAmC,CAAC,WAAW,KAAK,QAAQ;YAClE,CAAC,CAAC,2CAA2C;YAC7C,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,eAC7B,2FAA2F;YACzF,6DAA6D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAS,cAAc,CAAC,QAAkB,EAAE,IAAc,EAAE,KAAa;IACvE,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,+FAA+F;QAC/F,4FAA4F;QAC5F,yFAAyF;QACzF,6FAA6F;QAC7F,qEAAqE;QACrE,EAAE;Q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MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/B,wFAAwF;QACxF,sDAAsD;QACtD,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;KACxC,CAAC;AACJ,CAAC"}
@@ -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.226";
112
+ export declare const VERSION = "0.6.228";
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.226';
82
+ export const VERSION = '0.6.228';
83
83
  //# sourceMappingURL=constants.js.map
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,38 @@ 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.228
10
+
11
+ - **Fixed** `mergeChunks` throwing V8's `Cannot read properties of null (reading 'records')` for a
12
+ `null` element. Every other wrong element in that array already had a sentence — `undefined` is
13
+ "no chunk at 0", a number, a string and an object are "the value at 0 is …, not a chunk", and one
14
+ signal of a chunk is named as that — so `null` was the one value in it that left the package with
15
+ no `Next:` clause.
16
+ - It is also how a hole actually arrives. The advice already says "with no holes and nothing
17
+ spliced out of it", and the transport that makes one spells it `null`: `JSON.stringify` writes an
18
+ absent element that way, so a chunk array that crossed a worker boundary, a cache or a message
19
+ channel comes back with `null` where nothing was.
20
+ - Same sentence as `undefined`, because it is the same mistake, with the spelling named.
21
+
22
+ ## 0.6.227
23
+
24
+ - **Fixed** `annotationsAt` and `filterAnnotationsByTime` refusing each other's argument without
25
+ naming each other. They differ in one thing — an instant or an interval — and `annotationsAt`
26
+ exists because of it: the window form "works — a zero-length window — except that
27
+ `filterAnnotationsByTime` returns nothing for a non-positive duration, so the obvious call
28
+ returns an empty list at every position".
29
+ - A number where the window belongs was the costly direction, because its advice was followable. A
30
+ reader holding a cursor position, told to "pass a window carrying startSeconds and
31
+ durationSeconds", writes `{ startSeconds: t, durationSeconds: 0 }` — and gets `[]` at every
32
+ position, with no error, at the call a viewer makes on every mouse move. The sibling that takes
33
+ the number is one export away and is now named.
34
+ - A window where the instant belongs reached `secondsToTicks` and was told to "convert it first".
35
+ A window is not a number spelled differently, so there was nothing to convert; it now names
36
+ `window.startSeconds` and `filterAnnotationsByTime`. 0.6.88 made the same argument for
37
+ `readWindow` and `readRecords`, the other pair that differ only in the unit they bound by.
38
+ - Every other wrong window keeps the refusal it had, including the array one that names
39
+ `resolveTimeWindow`, and neither function's answer changes.
40
+
9
41
  ## 0.6.226
10
42
 
11
43
  - **Fixed** `sampleAt`, `sampleStartTicksOf` and `sampleStartSecondsOf` calling the canonical
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.226",
3
+ "version": "0.6.228",
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",
@@ -92,9 +92,30 @@ export function filterAnnotationsByTime(
92
92
  // Cannot read properties of undefined (reading 'startSeconds')`, naming a field rather than the
93
93
  // argument, with no `Next:` clause.
94
94
  if (typeof window !== 'object' || window === null) {
95
+ /*
96
+ * A NUMBER, which is an INSTANT, and the one wrong window whose advice led somewhere worse than
97
+ * where it started.
98
+ *
99
+ * "Pass a window carrying startSeconds and durationSeconds" is followable: a reader holding a
100
+ * cursor position writes `{ startSeconds: t, durationSeconds: 0 }`, because a window over one
101
+ * instant has no length. `annotationsAt`'s own docblock says what that does — the window form
102
+ * "works — a zero-length window — except that `filterAnnotationsByTime` returns nothing for a
103
+ * non-positive duration, so the obvious call returns an empty list at every position" — and it
104
+ * is why that function exists at all. So the advice ended in silence rather than in an error,
105
+ * at the call a viewer makes on every mouse move.
106
+ *
107
+ * The sibling is one export away and takes exactly what was passed. 0.6.88 made this argument
108
+ * for `readWindow` and `readRecords`, the other pair in this package that differ only in the
109
+ * unit they bound by.
110
+ */
95
111
  throw new RangeError(
96
- `filterAnnotationsByTime(): the window is ${describeValue(window)}, not an object. ` +
97
- 'Next: pass a window carrying startSeconds and durationSeconds.',
112
+ `filterAnnotationsByTime(): the window is ${describeValue(window)}, not an object.` +
113
+ (typeof window === 'number'
114
+ ? ' That is an instant, and this call bounds events by an interval — a zero-length one ' +
115
+ 'returns nothing, so a cursor position asked for as a window reads as no annotations ' +
116
+ 'at every position. Next: call annotationsAt(annotations, seconds), which takes the ' +
117
+ 'instant, or pass a window carrying startSeconds and durationSeconds.'
118
+ : ' Next: pass a window carrying startSeconds and durationSeconds.'),
98
119
  );
99
120
  }
100
121
  /*
@@ -213,6 +234,23 @@ export function annotationsAt(
213
234
  seconds: number,
214
235
  ): readonly EdfAnnotation[] {
215
236
  assertAnnotations(annotations, 'annotationsAt');
237
+ /*
238
+ * And the OTHER WAY. `filterAnnotationsByTime` is the neighbour this function's docblock names,
239
+ * the two differ only in whether they bound by an instant or by an interval, and a window here
240
+ * reached `secondsToTicks` — which answered "seconds must be a number of seconds, and was given
241
+ * an object. Next: convert it first". There is no conversion: a window is not a number spelled
242
+ * differently, and the reader was being sent to invent one.
243
+ */
244
+ const given = seconds as { startSeconds?: unknown; durationSeconds?: unknown } | null | undefined;
245
+ if (typeof given === 'object' && given !== null && !Array.isArray(given)) {
246
+ if ('startSeconds' in given || 'durationSeconds' in given) {
247
+ throw new RangeError(
248
+ 'annotationsAt(): that is a time window, and this call takes a single instant in seconds. ' +
249
+ 'Next: pass window.startSeconds for the instant under a cursor, or call ' +
250
+ 'filterAnnotationsByTime(annotations, window), which is the one that takes an interval.',
251
+ );
252
+ }
253
+ }
216
254
  const at = secondsToTicks(seconds, 'seconds');
217
255
  return Object.freeze(
218
256
  annotations.filter((annotation) => {
package/src/chunks.ts CHANGED
@@ -30,10 +30,25 @@ import type { EdfChunk, EdfChunkSignal, EdfDiagnostic } from './types.js';
30
30
  /** Reads as one line at the call site, and keeps the `chunks[i]` non-null assertions out of it. */
31
31
  function at(chunks: readonly EdfChunk[], index: number): EdfChunk {
32
32
  const chunk = chunks[index];
33
- if (chunk === undefined) {
33
+ /*
34
+ * `null` as well as `undefined`, because JSON is how a hole arrives.
35
+ *
36
+ * The advice below is about a hole, and the transport that produces one spells it `null`:
37
+ * `JSON.stringify` writes an absent element as `null`, so a chunk array crossing a worker
38
+ * boundary, a cache or a message channel comes back with `null` where nothing was. That is the
39
+ * same route `a-selection-from-json.test.ts` follows for the selection, and
40
+ * `design-decisions.md` follows for a chunk — "what parses back has no `.length` where a caller
41
+ * expects one".
42
+ *
43
+ * `undefined` was refused here in a sentence; `null` reached `chunk.records` on the next check
44
+ * and threw V8's `Cannot read properties of null (reading 'records')`. Every other wrong element
45
+ * — a number, a string, an object, one signal of a chunk — already had a sentence of its own, so
46
+ * `null` was the one value in this array that left the package without a `Next:` clause.
47
+ */
48
+ if (chunk === undefined || chunk === null) {
34
49
  throw new RangeError(
35
50
  `mergeChunks: no chunk at ${index}. Next: pass the array readWindow() returned, with no ` +
36
- 'holes and nothing spliced out of it.',
51
+ 'holes and nothing spliced out of it — JSON writes one as null.',
37
52
  );
38
53
  }
39
54
  /*
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.226';
96
+ export const VERSION = '0.6.228';