edfcore 0.6.184 → 0.6.185
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/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/format-annotations.d.ts +0 -9
- package/dist/format-annotations.d.ts.map +1 -1
- package/dist/format-annotations.js +24 -0
- package/dist/format-annotations.js.map +1 -1
- package/docs/CHANGELOG.md +13 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/format-annotations.ts +26 -0
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.185";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -26,14 +26,5 @@ export interface FormatAnnotationsOptions {
|
|
|
26
26
|
/** Include the `description@@channel` label EDF+ allows. Off by default: most files have none. */
|
|
27
27
|
readonly includeChannel?: boolean;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
* A multi-line listing, one annotation per line, in the order given.
|
|
31
|
-
*
|
|
32
|
-
* Returns `''` for an empty list rather than a blank line, so it concatenates into a larger
|
|
33
|
-
* report cleanly — the same rule `formatDiagnostics` follows.
|
|
34
|
-
*
|
|
35
|
-
* The order is the caller's. `readAnnotations` already returns them sorted by onset, and
|
|
36
|
-
* re-sorting here would quietly discard a deliberate `filterAnnotationsByText` ordering.
|
|
37
|
-
*/
|
|
38
29
|
export declare function formatAnnotations(annotations: readonly EdfAnnotation[], options?: FormatAnnotationsOptions): string;
|
|
39
30
|
//# sourceMappingURL=format-annotations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;
|
|
1
|
+
{"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AA4ED,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAuER"}
|
|
@@ -62,6 +62,29 @@ function duration(annotation) {
|
|
|
62
62
|
* The order is the caller's. `readAnnotations` already returns them sorted by onset, and
|
|
63
63
|
* re-sorting here would quietly discard a deliberate `filterAnnotationsByText` ordering.
|
|
64
64
|
*/
|
|
65
|
+
/**
|
|
66
|
+
* The ELEMENTS, which the array check below never reaches.
|
|
67
|
+
*
|
|
68
|
+
* `formatDiagnostics` grew this in 0.6.160 and `summarizeDiagnostics` in 0.6.168, on the same
|
|
69
|
+
* argument: an array of the wrong thing satisfies `Array.isArray` and is then read for fields it
|
|
70
|
+
* does not have. The first field read here is `onsetTicksFromFirstRecord`, a BigInt, so a list of
|
|
71
|
+
* anything else threw V8's `Cannot mix BigInt and other types, use explicit conversions` — a
|
|
72
|
+
* sentence about arithmetic, out of a printer, naming no argument and carrying no `Next:` clause.
|
|
73
|
+
*
|
|
74
|
+
* `header.diagnostics` is the list that gets passed. It is the other array a reader holds after
|
|
75
|
+
* opening a file, `formatDiagnostics` sits beside this call in the barrel, and the two take the same
|
|
76
|
+
* shape of argument with the same shape of options — so the pair is easy to cross.
|
|
77
|
+
*/
|
|
78
|
+
function assertAnnotation(annotation, index) {
|
|
79
|
+
const onset = annotation
|
|
80
|
+
?.onsetTicksFromFirstRecord;
|
|
81
|
+
if (typeof onset === 'bigint')
|
|
82
|
+
return;
|
|
83
|
+
throw new RangeError(`formatAnnotations(): the value at ${index} carries no onset, so it is not an annotation — ` +
|
|
84
|
+
'this listing is one row per event, timed from the start of record 0. Next: pass the ' +
|
|
85
|
+
'`annotations` field of what readAnnotations(recording, records) resolved to, or print a ' +
|
|
86
|
+
'list of diagnostics with formatDiagnostics().');
|
|
87
|
+
}
|
|
65
88
|
export function formatAnnotations(annotations, options) {
|
|
66
89
|
/*
|
|
67
90
|
* `''` is this function's "no events", which is what makes a wrong argument dangerous here rather
|
|
@@ -99,6 +122,7 @@ export function formatAnnotations(annotations, options) {
|
|
|
99
122
|
const annotation = annotations[i];
|
|
100
123
|
if (annotation === undefined)
|
|
101
124
|
continue;
|
|
125
|
+
assertAnnotation(annotation, i);
|
|
102
126
|
cells.push({
|
|
103
127
|
onset: clock(annotation.onsetTicksFromFirstRecord),
|
|
104
128
|
duration: duration(annotation),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-annotations.js","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,o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AAI,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC9E,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG,KAAK,CAAC;IAC1C,mFAAmF;IACnF,IAAI,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,WAAW,MAAM,OAAO,CAAC,CAAC;IAEpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ 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.185
|
|
10
|
+
|
|
11
|
+
- **Fixed** `formatAnnotations` dying on the onset arithmetic for an array of the wrong thing. The
|
|
12
|
+
guard 0.6.95 added tests `Array.isArray`, and an array of anything passes it; the first field this
|
|
13
|
+
listing reads is `onsetTicksFromFirstRecord`, a BigInt, so the answer was V8's `Cannot mix BigInt
|
|
14
|
+
and other types, use explicit conversions` — a sentence about arithmetic, out of a printer, naming
|
|
15
|
+
no argument and carrying no `Next:` clause.
|
|
16
|
+
- `header.diagnostics` is the list that gets passed: the other array a reader holds after opening a
|
|
17
|
+
file, printed by the call that sits beside this one in the barrel, taking the same shape of
|
|
18
|
+
argument with the same shape of options.
|
|
19
|
+
- `formatDiagnostics` closed this in 0.6.160 and `summarizeDiagnostics` in 0.6.168, each checking the
|
|
20
|
+
one field its own rows must carry. This is the third of the three, and it checks the onset.
|
|
21
|
+
|
|
9
22
|
## 0.6.184
|
|
10
23
|
|
|
11
24
|
- **Fixed** `httpSource` handing an unusable address to `fetch` and letting `fetch` answer for it.
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -83,6 +83,31 @@ function duration(annotation: EdfAnnotation): string {
|
|
|
83
83
|
* The order is the caller's. `readAnnotations` already returns them sorted by onset, and
|
|
84
84
|
* re-sorting here would quietly discard a deliberate `filterAnnotationsByText` ordering.
|
|
85
85
|
*/
|
|
86
|
+
/**
|
|
87
|
+
* The ELEMENTS, which the array check below never reaches.
|
|
88
|
+
*
|
|
89
|
+
* `formatDiagnostics` grew this in 0.6.160 and `summarizeDiagnostics` in 0.6.168, on the same
|
|
90
|
+
* argument: an array of the wrong thing satisfies `Array.isArray` and is then read for fields it
|
|
91
|
+
* does not have. The first field read here is `onsetTicksFromFirstRecord`, a BigInt, so a list of
|
|
92
|
+
* anything else threw V8's `Cannot mix BigInt and other types, use explicit conversions` — a
|
|
93
|
+
* sentence about arithmetic, out of a printer, naming no argument and carrying no `Next:` clause.
|
|
94
|
+
*
|
|
95
|
+
* `header.diagnostics` is the list that gets passed. It is the other array a reader holds after
|
|
96
|
+
* opening a file, `formatDiagnostics` sits beside this call in the barrel, and the two take the same
|
|
97
|
+
* shape of argument with the same shape of options — so the pair is easy to cross.
|
|
98
|
+
*/
|
|
99
|
+
function assertAnnotation(annotation: EdfAnnotation, index: number): void {
|
|
100
|
+
const onset = (annotation as { onsetTicksFromFirstRecord?: unknown } | null | undefined)
|
|
101
|
+
?.onsetTicksFromFirstRecord;
|
|
102
|
+
if (typeof onset === 'bigint') return;
|
|
103
|
+
throw new RangeError(
|
|
104
|
+
`formatAnnotations(): the value at ${index} carries no onset, so it is not an annotation — ` +
|
|
105
|
+
'this listing is one row per event, timed from the start of record 0. Next: pass the ' +
|
|
106
|
+
'`annotations` field of what readAnnotations(recording, records) resolved to, or print a ' +
|
|
107
|
+
'list of diagnostics with formatDiagnostics().',
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
86
111
|
export function formatAnnotations(
|
|
87
112
|
annotations: readonly EdfAnnotation[],
|
|
88
113
|
options?: FormatAnnotationsOptions,
|
|
@@ -125,6 +150,7 @@ export function formatAnnotations(
|
|
|
125
150
|
for (let i = 0; i < limit; i += 1) {
|
|
126
151
|
const annotation = annotations[i];
|
|
127
152
|
if (annotation === undefined) continue;
|
|
153
|
+
assertAnnotation(annotation, i);
|
|
128
154
|
cells.push({
|
|
129
155
|
onset: clock(annotation.onsetTicksFromFirstRecord),
|
|
130
156
|
duration: duration(annotation),
|