edfcore 0.6.167 → 0.6.169
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/diagnostics/summary.d.ts.map +1 -1
- package/dist/diagnostics/summary.js +26 -1
- package/dist/diagnostics/summary.js.map +1 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +18 -0
- package/dist/stream.js.map +1 -1
- package/docs/CHANGELOG.md +23 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/diagnostics/summary.ts +28 -1
- package/src/stream.ts +19 -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.169";
|
|
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;
|
|
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;AA+BD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CA+ChG"}
|
|
@@ -17,6 +17,30 @@
|
|
|
17
17
|
*/
|
|
18
18
|
/** Descending, so the first entry is the worst thing in the list. */
|
|
19
19
|
const SEVERITY_RANK = { error: 3, warning: 2, info: 1 };
|
|
20
|
+
/**
|
|
21
|
+
* One ELEMENT, before it is counted.
|
|
22
|
+
*
|
|
23
|
+
* The check above refuses the summary itself; it cannot refuse the summary's own rows, because
|
|
24
|
+
* those are an array. `byCode` carries `code` and `severity` — both of the fields this loop reads —
|
|
25
|
+
* so `summarizeDiagnostics(summary.byCode)` counted them and returned a summary that is wrong in
|
|
26
|
+
* the two numbers the call exists for: `total` became the number of distinct codes rather than of
|
|
27
|
+
* diagnostics, and every `count` became 1. On a file where one code fired four hundred times that
|
|
28
|
+
* reads as a file with one of it.
|
|
29
|
+
*
|
|
30
|
+
* `formatDiagnostics` refused the same rows in 0.6.160, one directory over, and threw on the third
|
|
31
|
+
* field it reads. This one reads only the two a row has, so it answered instead — and the answer is
|
|
32
|
+
* itself a well-formed summary, which is the outcome this package treats as the worst kind.
|
|
33
|
+
*
|
|
34
|
+
* Said in words rather than through `describeValue`, for the reason the check above gives.
|
|
35
|
+
*/
|
|
36
|
+
function assertDiagnostic(diagnostic, index) {
|
|
37
|
+
if (typeof diagnostic?.message === 'string')
|
|
38
|
+
return;
|
|
39
|
+
throw new RangeError(`summarizeDiagnostics(): the value at ${index} carries no message, so it is not a ` +
|
|
40
|
+
'diagnostic — a row of a by-code summary counts a code rather than being one, and counting ' +
|
|
41
|
+
'those again reports the number of distinct codes as the number of diagnostics. Next: pass ' +
|
|
42
|
+
'header.diagnostics, or the diagnostics on the chunk or the report you have.');
|
|
43
|
+
}
|
|
20
44
|
/**
|
|
21
45
|
* Counts by severity and by code.
|
|
22
46
|
*
|
|
@@ -45,7 +69,8 @@ export function summarizeDiagnostics(diagnostics) {
|
|
|
45
69
|
let infos = 0;
|
|
46
70
|
let worst;
|
|
47
71
|
const counts = new Map();
|
|
48
|
-
for (const diagnostic of diagnostics) {
|
|
72
|
+
for (const [index, diagnostic] of diagnostics.entries()) {
|
|
73
|
+
assertDiagnostic(diagnostic, index);
|
|
49
74
|
if (diagnostic.severity === 'error')
|
|
50
75
|
errors += 1;
|
|
51
76
|
else if (diagnostic.severity === 'warning')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA+BH,qEAAqE;AACrE,MAAM,aAAa,GAAgC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAErF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAqC;IACxE,2FAA2F;IAC3F,8FAA8F;IAC9F,mGAAmG;IACnG,0EAA0E;IAC1E,8FAA8F;IAC9F,kFAAkF;IAClF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAsB,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,UAAU,CAClB,mFAAmF;YACjF,mFAAmF;YACnF,kBAAkB,CACrB,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAA8B,CAAC;IAEnC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAmC,CAAC;IAC1D,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/diagnostics/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA+BH,qEAAqE;AACrE,MAAM,aAAa,GAAgC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAErF;;;;;;;;;;;;;;;GAeG;AACH,SAAS,gBAAgB,CAAC,UAAyB,EAAE,KAAa;IAChE,IAAI,OAAQ,UAAuD,EAAE,OAAO,KAAK,QAAQ;QAAE,OAAO;IAClG,MAAM,IAAI,UAAU,CAClB,wCAAwC,KAAK,sCAAsC;QACjF,4FAA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;YACrF,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAI,UAAU,CAAC,QAAQ;YACnD,KAAK,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK,EAAE,WAAW,CAAC,MAAM;QACzB,MAAM;QACN,QAAQ;QACR,KAAK;QACL,KAAK;QACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;KAC9E,CAAC;AACJ,CAAC"}
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,YAAY,CAAC;AAKpG;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAiE3C"}
|
package/dist/stream.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* Chunks arrive in time order, never span a gap, and carry the same `precededByGap` a
|
|
13
13
|
* `readWindow` chunk would, so a consumer sees the discontinuities rather than a smooth lie.
|
|
14
14
|
*/
|
|
15
|
+
import { assertReadOptions } from './io/source.js';
|
|
15
16
|
import { assertRecording, assertSelection, readRecords, resolveSignals } from './recording.js';
|
|
16
17
|
import { describeValue } from './text/describe.js';
|
|
17
18
|
import { assertMonotonicOnsets } from './time/timeline.js';
|
|
@@ -50,6 +51,23 @@ export function streamRecords(recording, selection, options) {
|
|
|
50
51
|
`${describeValue(chunkRecords)}. ` +
|
|
51
52
|
'Next: omit it for the default, or pass how many records you want to hold at once.');
|
|
52
53
|
}
|
|
54
|
+
/*
|
|
55
|
+
* The OPTIONS, here rather than on the first read.
|
|
56
|
+
*
|
|
57
|
+
* `readRecords` refuses a bare value — 0.6.155 for an `AbortSignal` handed over in place of the
|
|
58
|
+
* options, 0.6.166 for any other — but this function does not read; the generator below does, and
|
|
59
|
+
* only once someone iterates it. So `streamRecords(recording, selection, controller.signal)` was
|
|
60
|
+
* built without complaint and refused in the `for await`, which is the split 0.6.118 was spent
|
|
61
|
+
* closing: "a caller who builds the stream in one place and consumes it in another gets the
|
|
62
|
+
* refusal in the second".
|
|
63
|
+
*
|
|
64
|
+
* And on a window that resolves to no records — past the end, inside an EDF+D gap, of zero
|
|
65
|
+
* duration — the loop body never runs, so it was never refused at all: the stream simply
|
|
66
|
+
* completed, empty. That is the same data-dependent guard 0.6.118 found here, one argument over,
|
|
67
|
+
* and for the signal case it is the worst version of it. An abort that was never wired up and a
|
|
68
|
+
* window with nothing in it both end as a stream that yielded nothing.
|
|
69
|
+
*/
|
|
70
|
+
assertReadOptions(options);
|
|
53
71
|
// Validated BEFORE the window is resolved, for the reason `readWindow` and `readEnvelope` both
|
|
54
72
|
// state: a caller mistake is a caller mistake wherever the window lands. Resolving first meant
|
|
55
73
|
// that a window past the end, one inside an EDF+D gap, or one of zero duration produced no
|
package/dist/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EA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AM,KAAK,CAAC;YACZ,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ 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.169
|
|
10
|
+
|
|
11
|
+
- **Fixed** `streamRecords` handing the read options to the generator unchecked. `readRecords`
|
|
12
|
+
refuses a bare value where they belong, but it is the generator that calls it, so
|
|
13
|
+
`streamRecords(recording, selection, controller.signal)` was built without complaint and refused
|
|
14
|
+
on the first `for await` — the split 0.6.118 turned this function inside out to close.
|
|
15
|
+
- On a window that resolves to no records — past the end, inside an EDF+D gap, of zero duration —
|
|
16
|
+
the loop body never runs, so nothing was ever refused: the stream completed, empty, with the
|
|
17
|
+
options dropped. Whether a caller mistake was reported depended on where the window landed.
|
|
18
|
+
- The `AbortSignal` case is the pair that cannot be told apart: a cancellation that was never wired
|
|
19
|
+
up, and a stream that yields nothing, which is what an abort looks like from outside.
|
|
20
|
+
|
|
21
|
+
## 0.6.168
|
|
22
|
+
|
|
23
|
+
- **Fixed** a by-code summary counted as a diagnostics list. `summarizeDiagnostics` reads `code`
|
|
24
|
+
and `severity`, which are exactly the two fields a `byCode` row carries, so
|
|
25
|
+
`summarizeDiagnostics(summary.byCode)` did not fail — it returned a summary.
|
|
26
|
+
- A well-formed one, and wrong in the two numbers the call exists to produce: `total` became the
|
|
27
|
+
number of distinct codes rather than of diagnostics, and every `count` became 1. A file where one
|
|
28
|
+
code fired four hundred times reads, on the second pass, as a file with one thing wrong with it.
|
|
29
|
+
- 0.6.160 refused the same rows in `formatDiagnostics`, one directory over; that one reads a third
|
|
30
|
+
field and threw. The elements are now checked here too, per element and by position.
|
|
31
|
+
|
|
9
32
|
## 0.6.167
|
|
10
33
|
|
|
11
34
|
- **Fixed** an array passed as the selection walking past the check added in 0.6.79. An array is an
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -48,6 +48,32 @@ export interface EdfDiagnosticSummary {
|
|
|
48
48
|
/** Descending, so the first entry is the worst thing in the list. */
|
|
49
49
|
const SEVERITY_RANK: Record<EdfSeverity, number> = { error: 3, warning: 2, info: 1 };
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* One ELEMENT, before it is counted.
|
|
53
|
+
*
|
|
54
|
+
* The check above refuses the summary itself; it cannot refuse the summary's own rows, because
|
|
55
|
+
* those are an array. `byCode` carries `code` and `severity` — both of the fields this loop reads —
|
|
56
|
+
* so `summarizeDiagnostics(summary.byCode)` counted them and returned a summary that is wrong in
|
|
57
|
+
* the two numbers the call exists for: `total` became the number of distinct codes rather than of
|
|
58
|
+
* diagnostics, and every `count` became 1. On a file where one code fired four hundred times that
|
|
59
|
+
* reads as a file with one of it.
|
|
60
|
+
*
|
|
61
|
+
* `formatDiagnostics` refused the same rows in 0.6.160, one directory over, and threw on the third
|
|
62
|
+
* field it reads. This one reads only the two a row has, so it answered instead — and the answer is
|
|
63
|
+
* itself a well-formed summary, which is the outcome this package treats as the worst kind.
|
|
64
|
+
*
|
|
65
|
+
* Said in words rather than through `describeValue`, for the reason the check above gives.
|
|
66
|
+
*/
|
|
67
|
+
function assertDiagnostic(diagnostic: EdfDiagnostic, index: number): void {
|
|
68
|
+
if (typeof (diagnostic as { message?: unknown } | null | undefined)?.message === 'string') return;
|
|
69
|
+
throw new RangeError(
|
|
70
|
+
`summarizeDiagnostics(): the value at ${index} carries no message, so it is not a ` +
|
|
71
|
+
'diagnostic — a row of a by-code summary counts a code rather than being one, and counting ' +
|
|
72
|
+
'those again reports the number of distinct codes as the number of diagnostics. Next: pass ' +
|
|
73
|
+
'header.diagnostics, or the diagnostics on the chunk or the report you have.',
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
51
77
|
/**
|
|
52
78
|
* Counts by severity and by code.
|
|
53
79
|
*
|
|
@@ -79,7 +105,8 @@ export function summarizeDiagnostics(diagnostics: readonly EdfDiagnostic[]): Edf
|
|
|
79
105
|
let worst: EdfSeverity | undefined;
|
|
80
106
|
|
|
81
107
|
const counts = new Map<EdfDiagnosticCode, EdfCodeCount>();
|
|
82
|
-
for (const diagnostic of diagnostics) {
|
|
108
|
+
for (const [index, diagnostic] of diagnostics.entries()) {
|
|
109
|
+
assertDiagnostic(diagnostic, index);
|
|
83
110
|
if (diagnostic.severity === 'error') errors += 1;
|
|
84
111
|
else if (diagnostic.severity === 'warning') warnings += 1;
|
|
85
112
|
else infos += 1;
|
package/src/stream.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* `readWindow` chunk would, so a consumer sees the discontinuities rather than a smooth lie.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { assertReadOptions } from './io/source.js';
|
|
16
17
|
import { assertRecording, assertSelection, readRecords, resolveSignals } from './recording.js';
|
|
17
18
|
import { describeValue } from './text/describe.js';
|
|
18
19
|
import { assertMonotonicOnsets } from './time/timeline.js';
|
|
@@ -65,6 +66,24 @@ export function streamRecords(
|
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
/*
|
|
70
|
+
* The OPTIONS, here rather than on the first read.
|
|
71
|
+
*
|
|
72
|
+
* `readRecords` refuses a bare value — 0.6.155 for an `AbortSignal` handed over in place of the
|
|
73
|
+
* options, 0.6.166 for any other — but this function does not read; the generator below does, and
|
|
74
|
+
* only once someone iterates it. So `streamRecords(recording, selection, controller.signal)` was
|
|
75
|
+
* built without complaint and refused in the `for await`, which is the split 0.6.118 was spent
|
|
76
|
+
* closing: "a caller who builds the stream in one place and consumes it in another gets the
|
|
77
|
+
* refusal in the second".
|
|
78
|
+
*
|
|
79
|
+
* And on a window that resolves to no records — past the end, inside an EDF+D gap, of zero
|
|
80
|
+
* duration — the loop body never runs, so it was never refused at all: the stream simply
|
|
81
|
+
* completed, empty. That is the same data-dependent guard 0.6.118 found here, one argument over,
|
|
82
|
+
* and for the signal case it is the worst version of it. An abort that was never wired up and a
|
|
83
|
+
* window with nothing in it both end as a stream that yielded nothing.
|
|
84
|
+
*/
|
|
85
|
+
assertReadOptions(options);
|
|
86
|
+
|
|
68
87
|
// Validated BEFORE the window is resolved, for the reason `readWindow` and `readEnvelope` both
|
|
69
88
|
// state: a caller mistake is a caller mistake wherever the window lands. Resolving first meant
|
|
70
89
|
// that a window past the end, one inside an EDF+D gap, or one of zero duration produced no
|