edfcore 0.6.106 → 0.6.108
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/dist/annotations-query.d.ts.map +1 -1
- package/dist/annotations-query.js +25 -0
- package/dist/annotations-query.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/diagnostics/summary.d.ts.map +1 -1
- package/dist/diagnostics/summary.js +11 -0
- package/dist/diagnostics/summary.js.map +1 -1
- package/dist/header/lookup.d.ts.map +1 -1
- package/dist/header/lookup.js +20 -0
- package/dist/header/lookup.js.map +1 -1
- package/docs/CHANGELOG.md +25 -0
- package/package.json +1 -1
- package/src/annotations-query.ts +27 -0
- package/src/constants.ts +1 -1
- package/src/diagnostics/summary.ts +13 -0
- package/src/header/lookup.ts +24 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations-query.d.ts","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
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;AAwBrE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,MAAM,EAAE,mBAAmB,GAC1B,SAAS,aAAa,EAAE,CAuB1B;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"}
|
|
@@ -20,6 +20,27 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { assertMatcher, matchesText } from './header/lookup.js';
|
|
22
22
|
import { secondsToTicks } from './tal/ticks.js';
|
|
23
|
+
import { describeValue } from './text/describe.js';
|
|
24
|
+
/**
|
|
25
|
+
* The list itself, before it is filtered or walked.
|
|
26
|
+
*
|
|
27
|
+
* `readAnnotations` returns `{ annotations, recordOnsetTicks, diagnostics }`, so the whole result is
|
|
28
|
+
* what a caller has in hand and `filterAnnotationsByTime(result, window)` is the call the variable
|
|
29
|
+
* name suggests. It reached `annotations.filter` and threw V8's "annotations.filter is not a
|
|
30
|
+
* function"; `countAnnotationsByText` walks its argument instead and said "annotations is not
|
|
31
|
+
* iterable". Neither names the argument, and neither mentions the one field that fixes it.
|
|
32
|
+
*
|
|
33
|
+
* 0.6.95 did this for the two formatters, whose `''` is an answer. These throw, so the cost is a
|
|
34
|
+
* message rather than a wrong result — but it is the same argument, four functions over (fixed in
|
|
35
|
+
* 0.6.107).
|
|
36
|
+
*/
|
|
37
|
+
function assertAnnotations(annotations, call) {
|
|
38
|
+
if (Array.isArray(annotations))
|
|
39
|
+
return;
|
|
40
|
+
throw new RangeError(`${call}(): the annotations are ${describeValue(annotations)}, not an array. Next: pass the ` +
|
|
41
|
+
'`annotations` field of what readAnnotations(recording, records) resolved to, which is a ' +
|
|
42
|
+
'result object rather than the list itself.');
|
|
43
|
+
}
|
|
23
44
|
/**
|
|
24
45
|
* The annotations that overlap a time window, in the recording's own timebase.
|
|
25
46
|
*
|
|
@@ -29,6 +50,7 @@ import { secondsToTicks } from './tal/ticks.js';
|
|
|
29
50
|
* adjacent windows partition the recording without double-counting the boundary.
|
|
30
51
|
*/
|
|
31
52
|
export function filterAnnotationsByTime(annotations, window) {
|
|
53
|
+
assertAnnotations(annotations, 'filterAnnotationsByTime');
|
|
32
54
|
const from = secondsToTicks(window.startSeconds, 'window.startSeconds');
|
|
33
55
|
const to = from + secondsToTicks(window.durationSeconds, 'window.durationSeconds');
|
|
34
56
|
if (to <= from)
|
|
@@ -66,6 +88,7 @@ export function filterAnnotationsByTime(annotations, window) {
|
|
|
66
88
|
* pass the predicate that says what you mean — `(text) => text.trim() === label`.
|
|
67
89
|
*/
|
|
68
90
|
export function filterAnnotationsByText(annotations, match) {
|
|
91
|
+
assertAnnotations(annotations, 'filterAnnotationsByText');
|
|
69
92
|
const test = typeof match === 'string'
|
|
70
93
|
? (text) => text === match
|
|
71
94
|
: match instanceof RegExp
|
|
@@ -83,6 +106,7 @@ export function filterAnnotationsByText(annotations, match) {
|
|
|
83
106
|
* often. Ties keep insertion order, so the output is deterministic for a given input.
|
|
84
107
|
*/
|
|
85
108
|
export function countAnnotationsByText(annotations) {
|
|
109
|
+
assertAnnotations(annotations, 'countAnnotationsByText');
|
|
86
110
|
const counts = new Map();
|
|
87
111
|
for (const annotation of annotations) {
|
|
88
112
|
counts.set(annotation.text, (counts.get(annotation.text) ?? 0) + 1);
|
|
@@ -99,6 +123,7 @@ export function countAnnotationsByText(annotations) {
|
|
|
99
123
|
* only its own onset.
|
|
100
124
|
*/
|
|
101
125
|
export function annotationsAt(annotations, seconds) {
|
|
126
|
+
assertAnnotations(annotations, 'annotationsAt');
|
|
102
127
|
const at = secondsToTicks(seconds, 'seconds');
|
|
103
128
|
return Object.freeze(annotations.filter((annotation) => {
|
|
104
129
|
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,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"annotations-query.js","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;;;;;;;;GAYG;AACH,SAAS,iBAAiB,CAAC,WAAqC,EAAE,IAAY;IAC5E,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO;IACvC,MAAM,IAAI,UAAU,CAClB,GAAG,IAAI,2BAA2B,aAAa,CAAC,WAAW,CAAC,iCAAiC;QAC3F,0FAA0F;QAC1F,4CAA4C,CAC/C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAqC,EACrC,MAA2B;IAE3B,iBAAiB,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC;IACnF,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC,MAAM,CAClB,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,UAAU,CAAC,y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EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CACxF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,WAAqC,EACrC,OAAe;IAEf,iBAAiB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAChD,MAAM,EAAE,GAAG,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,MAAM,CAClB,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,UAAU,CAAC,yBAAyB,CAAC;QACnD,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,IAAI,EAAE,CAAC;QAChD,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC/E,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -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.
|
|
112
|
+
export declare const VERSION = "0.6.108";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IACxC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IACxC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CA8ChG"}
|
|
@@ -29,6 +29,17 @@ const SEVERITY_RANK = { error: 3, warning: 2, info: 1 };
|
|
|
29
29
|
* first. `Array.prototype.sort` is stable, so equal counts keep the order they were first seen.
|
|
30
30
|
*/
|
|
31
31
|
export function summarizeDiagnostics(diagnostics) {
|
|
32
|
+
// Described in words rather than by type, because this module "imports one type module and
|
|
33
|
+
// nothing else" and that is the property that lets any layer summarise. Without the check the
|
|
34
|
+
// `for..of` below answered `diagnostics is not iterable`: an internal name, no `Next:` clause, and
|
|
35
|
+
// no mention of the three places a caller gets a list (fixed in 0.6.107).
|
|
36
|
+
// Cast in the test, not on the value: `Array.isArray` over a `readonly T[]` narrows the whole
|
|
37
|
+
// parameter to `any[]` and the element type is lost for the rest of the function.
|
|
38
|
+
if (!Array.isArray(diagnostics)) {
|
|
39
|
+
throw new RangeError('summarizeDiagnostics(): the diagnostics are not an array, so there is nothing to ' +
|
|
40
|
+
'summarise. Next: pass header.diagnostics, or the diagnostics on the chunk or the ' +
|
|
41
|
+
'report you have.');
|
|
42
|
+
}
|
|
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AG,OAAO,
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAaxD;AAwBD,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAIlF;AA6CD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgDjF;AAED;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAM5F;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAQpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAC3C,SAAS,SAAS,EAAE,CAetB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAgBjE"}
|
package/dist/header/lookup.js
CHANGED
|
@@ -23,6 +23,14 @@ import { describeValue } from '../text/describe.js';
|
|
|
23
23
|
* expose a text channel as if it held samples.
|
|
24
24
|
*/
|
|
25
25
|
export function isAnnotationLabel(label) {
|
|
26
|
+
// The label, not the signal that carries it. `header.signals.filter(isAnnotationLabel)` is the
|
|
27
|
+
// shape a predicate invites, and it reached `trimEdfField` and threw "text.slice is not a
|
|
28
|
+
// function" — an internal name, from the one function in this module that takes a plain string
|
|
29
|
+
// (fixed in 0.6.108).
|
|
30
|
+
if (typeof label !== 'string') {
|
|
31
|
+
throw new RangeError(`isAnnotationLabel(): the label is ${describeValue(label)}, not a string. Next: pass ` +
|
|
32
|
+
'signal.label, which is the field this asks about.');
|
|
33
|
+
}
|
|
26
34
|
const trimmed = trimEdfField(label);
|
|
27
35
|
return trimmed === EDF_ANNOTATIONS_LABEL || trimmed === BDF_ANNOTATIONS_LABEL;
|
|
28
36
|
}
|
|
@@ -221,6 +229,18 @@ export function matchSignals(header, match) {
|
|
|
221
229
|
* gaps between records are not covered by any record; `timeline.spanSeconds` is that number.
|
|
222
230
|
*/
|
|
223
231
|
export function declaredDurationSeconds(header) {
|
|
232
|
+
/*
|
|
233
|
+
* The header, which this module's other four entry points also take and which none of them
|
|
234
|
+
* checked. It is the one function here whose name says RECORDING, and `declaredDurationSeconds`
|
|
235
|
+
* is the sort of thing a reader asks of one — so the mistake it invites is passing it, and
|
|
236
|
+
* `BigInt(undefined)` answered "Cannot convert undefined to a BigInt": not edfcore's voice, no
|
|
237
|
+
* `Next:` clause, and nothing about the argument (fixed in 0.6.108).
|
|
238
|
+
*/
|
|
239
|
+
if (!Number.isInteger(header?.recordCount)) {
|
|
240
|
+
throw new RangeError('declaredDurationSeconds(): that is not a header — it has no recordCount. Next: pass ' +
|
|
241
|
+
'recording.header, or what parseHeader(bytes, sourceByteLength) returned. For the span of ' +
|
|
242
|
+
'a discontinuous file, which is longer, read timeline.spanSeconds.');
|
|
243
|
+
}
|
|
224
244
|
return ticksToSeconds(BigInt(header.recordCount) * header.recordDurationTicks);
|
|
225
245
|
}
|
|
226
246
|
//# sourceMappingURL=lookup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceR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AG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACjF,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ 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.108
|
|
10
|
+
|
|
11
|
+
- **Fixed** the last two entry points in `header/lookup.ts` that took anything at all.
|
|
12
|
+
- `declaredDurationSeconds` is the one function there whose name says RECORDING — "the recording's
|
|
13
|
+
total declared length in seconds" — so passing the recording is what it invites, and
|
|
14
|
+
`BigInt(undefined)` answered "Cannot convert undefined to a BigInt": not edfcore's voice, no
|
|
15
|
+
`Next:` clause, and nothing about the argument. It now names `recording.header`, and
|
|
16
|
+
`timeline.spanSeconds` for the reader who wanted the longer number.
|
|
17
|
+
- `isAnnotationLabel` is the module's only plain-string argument and reads as a predicate, so
|
|
18
|
+
`header.signals.filter(isAnnotationLabel)` is the shape it invites. That threw "text.slice is not a
|
|
19
|
+
function"; it now names `signal.label`.
|
|
20
|
+
- The timeline is still accepted by `declaredDurationSeconds`, and a test records why: it declares
|
|
21
|
+
`recordCount` and `recordDurationTicks` with the same meanings, so the answer is the same one.
|
|
22
|
+
|
|
23
|
+
## 0.6.107
|
|
24
|
+
|
|
25
|
+
- **Fixed** the four annotation queries and `summarizeDiagnostics` throwing V8's "is not iterable" or
|
|
26
|
+
"is not a function" for a list argument that is not a list.
|
|
27
|
+
- `readAnnotations` resolves to `{ annotations, recordOnsetTicks, diagnostics }`, so the whole result
|
|
28
|
+
is what a caller has in hand and `filterAnnotationsByTime(result, window)` is the call the variable
|
|
29
|
+
name suggests. The refusal now names the field inside the result, which is the one thing that fixes
|
|
30
|
+
it.
|
|
31
|
+
- 0.6.95 did this for the two formatters, whose `''` is an answer. These throw, so the cost was a
|
|
32
|
+
message rather than a wrong result — the same argument, five functions over.
|
|
33
|
+
|
|
9
34
|
## 0.6.106
|
|
10
35
|
|
|
11
36
|
- **Fixed** `buildTimeline` and `buildRecordIndex` dying with the same V8 message when handed each
|
package/package.json
CHANGED
package/src/annotations-query.ts
CHANGED
|
@@ -21,8 +21,31 @@
|
|
|
21
21
|
|
|
22
22
|
import { assertMatcher, matchesText } from './header/lookup.js';
|
|
23
23
|
import { secondsToTicks } from './tal/ticks.js';
|
|
24
|
+
import { describeValue } from './text/describe.js';
|
|
24
25
|
import type { EdfAnnotation, EdfAnnotationWindow } from './types.js';
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The list itself, before it is filtered or walked.
|
|
29
|
+
*
|
|
30
|
+
* `readAnnotations` returns `{ annotations, recordOnsetTicks, diagnostics }`, so the whole result is
|
|
31
|
+
* what a caller has in hand and `filterAnnotationsByTime(result, window)` is the call the variable
|
|
32
|
+
* name suggests. It reached `annotations.filter` and threw V8's "annotations.filter is not a
|
|
33
|
+
* function"; `countAnnotationsByText` walks its argument instead and said "annotations is not
|
|
34
|
+
* iterable". Neither names the argument, and neither mentions the one field that fixes it.
|
|
35
|
+
*
|
|
36
|
+
* 0.6.95 did this for the two formatters, whose `''` is an answer. These throw, so the cost is a
|
|
37
|
+
* message rather than a wrong result — but it is the same argument, four functions over (fixed in
|
|
38
|
+
* 0.6.107).
|
|
39
|
+
*/
|
|
40
|
+
function assertAnnotations(annotations: readonly EdfAnnotation[], call: string): void {
|
|
41
|
+
if (Array.isArray(annotations)) return;
|
|
42
|
+
throw new RangeError(
|
|
43
|
+
`${call}(): the annotations are ${describeValue(annotations)}, not an array. Next: pass the ` +
|
|
44
|
+
'`annotations` field of what readAnnotations(recording, records) resolved to, which is a ' +
|
|
45
|
+
'result object rather than the list itself.',
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
26
49
|
/**
|
|
27
50
|
* The annotations that overlap a time window, in the recording's own timebase.
|
|
28
51
|
*
|
|
@@ -35,6 +58,7 @@ export function filterAnnotationsByTime(
|
|
|
35
58
|
annotations: readonly EdfAnnotation[],
|
|
36
59
|
window: EdfAnnotationWindow,
|
|
37
60
|
): readonly EdfAnnotation[] {
|
|
61
|
+
assertAnnotations(annotations, 'filterAnnotationsByTime');
|
|
38
62
|
const from = secondsToTicks(window.startSeconds, 'window.startSeconds');
|
|
39
63
|
const to = from + secondsToTicks(window.durationSeconds, 'window.durationSeconds');
|
|
40
64
|
if (to <= from) return Object.freeze([]);
|
|
@@ -78,6 +102,7 @@ export function filterAnnotationsByText(
|
|
|
78
102
|
annotations: readonly EdfAnnotation[],
|
|
79
103
|
match: string | RegExp | ((text: string) => boolean),
|
|
80
104
|
): readonly EdfAnnotation[] {
|
|
105
|
+
assertAnnotations(annotations, 'filterAnnotationsByText');
|
|
81
106
|
const test =
|
|
82
107
|
typeof match === 'string'
|
|
83
108
|
? (text: string): boolean => text === match
|
|
@@ -104,6 +129,7 @@ export function filterAnnotationsByText(
|
|
|
104
129
|
export function countAnnotationsByText(
|
|
105
130
|
annotations: readonly EdfAnnotation[],
|
|
106
131
|
): ReadonlyArray<{ readonly text: string; readonly count: number }> {
|
|
132
|
+
assertAnnotations(annotations, 'countAnnotationsByText');
|
|
107
133
|
const counts = new Map<string, number>();
|
|
108
134
|
for (const annotation of annotations) {
|
|
109
135
|
counts.set(annotation.text, (counts.get(annotation.text) ?? 0) + 1);
|
|
@@ -126,6 +152,7 @@ export function annotationsAt(
|
|
|
126
152
|
annotations: readonly EdfAnnotation[],
|
|
127
153
|
seconds: number,
|
|
128
154
|
): readonly EdfAnnotation[] {
|
|
155
|
+
assertAnnotations(annotations, 'annotationsAt');
|
|
129
156
|
const at = secondsToTicks(seconds, 'seconds');
|
|
130
157
|
return Object.freeze(
|
|
131
158
|
annotations.filter((annotation) => {
|
package/src/constants.ts
CHANGED
|
@@ -60,6 +60,19 @@ const SEVERITY_RANK: Record<EdfSeverity, number> = { error: 3, warning: 2, info:
|
|
|
60
60
|
* first. `Array.prototype.sort` is stable, so equal counts keep the order they were first seen.
|
|
61
61
|
*/
|
|
62
62
|
export function summarizeDiagnostics(diagnostics: readonly EdfDiagnostic[]): EdfDiagnosticSummary {
|
|
63
|
+
// Described in words rather than by type, because this module "imports one type module and
|
|
64
|
+
// nothing else" and that is the property that lets any layer summarise. Without the check the
|
|
65
|
+
// `for..of` below answered `diagnostics is not iterable`: an internal name, no `Next:` clause, and
|
|
66
|
+
// no mention of the three places a caller gets a list (fixed in 0.6.107).
|
|
67
|
+
// Cast in the test, not on the value: `Array.isArray` over a `readonly T[]` narrows the whole
|
|
68
|
+
// parameter to `any[]` and the element type is lost for the rest of the function.
|
|
69
|
+
if (!Array.isArray(diagnostics as unknown)) {
|
|
70
|
+
throw new RangeError(
|
|
71
|
+
'summarizeDiagnostics(): the diagnostics are not an array, so there is nothing to ' +
|
|
72
|
+
'summarise. Next: pass header.diagnostics, or the diagnostics on the chunk or the ' +
|
|
73
|
+
'report you have.',
|
|
74
|
+
);
|
|
75
|
+
}
|
|
63
76
|
let errors = 0;
|
|
64
77
|
let warnings = 0;
|
|
65
78
|
let infos = 0;
|
package/src/header/lookup.ts
CHANGED
|
@@ -26,6 +26,16 @@ import type { EdfHeader, EdfSignal } from '../types.js';
|
|
|
26
26
|
* expose a text channel as if it held samples.
|
|
27
27
|
*/
|
|
28
28
|
export function isAnnotationLabel(label: string): boolean {
|
|
29
|
+
// The label, not the signal that carries it. `header.signals.filter(isAnnotationLabel)` is the
|
|
30
|
+
// shape a predicate invites, and it reached `trimEdfField` and threw "text.slice is not a
|
|
31
|
+
// function" — an internal name, from the one function in this module that takes a plain string
|
|
32
|
+
// (fixed in 0.6.108).
|
|
33
|
+
if (typeof label !== 'string') {
|
|
34
|
+
throw new RangeError(
|
|
35
|
+
`isAnnotationLabel(): the label is ${describeValue(label)}, not a string. Next: pass ` +
|
|
36
|
+
'signal.label, which is the field this asks about.',
|
|
37
|
+
);
|
|
38
|
+
}
|
|
29
39
|
const trimmed = trimEdfField(label);
|
|
30
40
|
return trimmed === EDF_ANNOTATIONS_LABEL || trimmed === BDF_ANNOTATIONS_LABEL;
|
|
31
41
|
}
|
|
@@ -260,5 +270,19 @@ export function matchSignals(
|
|
|
260
270
|
* gaps between records are not covered by any record; `timeline.spanSeconds` is that number.
|
|
261
271
|
*/
|
|
262
272
|
export function declaredDurationSeconds(header: EdfHeader): number {
|
|
273
|
+
/*
|
|
274
|
+
* The header, which this module's other four entry points also take and which none of them
|
|
275
|
+
* checked. It is the one function here whose name says RECORDING, and `declaredDurationSeconds`
|
|
276
|
+
* is the sort of thing a reader asks of one — so the mistake it invites is passing it, and
|
|
277
|
+
* `BigInt(undefined)` answered "Cannot convert undefined to a BigInt": not edfcore's voice, no
|
|
278
|
+
* `Next:` clause, and nothing about the argument (fixed in 0.6.108).
|
|
279
|
+
*/
|
|
280
|
+
if (!Number.isInteger((header as { recordCount?: unknown } | null | undefined)?.recordCount)) {
|
|
281
|
+
throw new RangeError(
|
|
282
|
+
'declaredDurationSeconds(): that is not a header — it has no recordCount. Next: pass ' +
|
|
283
|
+
'recording.header, or what parseHeader(bytes, sourceByteLength) returned. For the span of ' +
|
|
284
|
+
'a discontinuous file, which is longer, read timeline.spanSeconds.',
|
|
285
|
+
);
|
|
286
|
+
}
|
|
263
287
|
return ticksToSeconds(BigInt(header.recordCount) * header.recordDurationTicks);
|
|
264
288
|
}
|