edfcore 0.4.442 → 0.4.443
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/io/read.d.ts.map +1 -1
- package/dist/io/read.js +17 -5
- package/dist/io/read.js.map +1 -1
- package/docs/CHANGELOG.md +18 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/io/read.ts +17 -5
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.4.
|
|
112
|
+
export declare const VERSION = "0.4.443";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/dist/io/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,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;
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,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;AAqDD;;;;;;;;;;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"}
|
package/dist/io/read.js
CHANGED
|
@@ -74,13 +74,25 @@ function describeRange(range) {
|
|
|
74
74
|
}
|
|
75
75
|
function assertRecordRange(header, records) {
|
|
76
76
|
const available = { start: 0, count: header.recordCount };
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
/*
|
|
78
|
+
* Read off a stand-in when there is no range at all.
|
|
79
|
+
*
|
|
80
|
+
* `records` is typed, and the type is not the only way in: a selection built from JSON, from a
|
|
81
|
+
* config file or from a JavaScript call site arrives at run time. Every wrong SHAPE already
|
|
82
|
+
* reached the message below — an array, a string and `{ start: 0 }` all read as
|
|
83
|
+
* `{ start: undefined, count: undefined }` and are refused with a next step — while `undefined`
|
|
84
|
+
* and `null` threw `TypeError: Cannot read properties of undefined (reading 'start')` from the
|
|
85
|
+
* two lines under this one, which names neither the option nor anything to do about it
|
|
86
|
+
* (fixed in 0.4.443).
|
|
87
|
+
*/
|
|
88
|
+
const range = records ?? {};
|
|
89
|
+
const startValid = Number.isSafeInteger(range.start) && range.start >= 0;
|
|
90
|
+
const countValid = Number.isSafeInteger(range.count) && range.count >= 0;
|
|
91
|
+
if (startValid && countValid && range.start + range.count <= header.recordCount)
|
|
80
92
|
return;
|
|
81
|
-
throw new EdfRangeError(`records ${describeRange(
|
|
93
|
+
throw new EdfRangeError(`records ${describeRange(range)} is not inside the ` +
|
|
82
94
|
`${header.recordCount} data records this file contains. Next: clamp the range against ` +
|
|
83
|
-
'header.recordCount, or call index.locate(seconds) to find a record index for a time.', { requested:
|
|
95
|
+
'header.recordCount, or call index.locate(seconds) to find a record index for a time.', { requested: range, available });
|
|
84
96
|
}
|
|
85
97
|
/**
|
|
86
98
|
* Refused BEFORE the allocation, never during it.
|
package/dist/io/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,WAAuB;IAC9C,IAAI,WAAW,CAAC,MAAM,GAAG,sBAAsB;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,WAAW,CAAC;IACrD,MAAM,KAAK,GAAG,eAAe,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3E,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,GAAG,oBAAoB;QAAE,OAAO,SAAS,CAAC;IACzF,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAkB,EAAE,OAAqB;IACxE,MAAM,gBAAgB,GAAG,MAAM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C,MAAkB,EAClB,MAAiB,EACjB,OAAoB,EACpB,OAAqB;IAErB,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;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,24 @@ 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.4.443
|
|
10
|
+
|
|
11
|
+
- **Fixed** a missing record range throwing a raw `TypeError`. `assertRecordRange` was already
|
|
12
|
+
thorough about the values a range can hold — a negative start, a fractional one, a `NaN` count, a
|
|
13
|
+
range past the last record, and shapes that are not ranges at all — and refused each with the
|
|
14
|
+
file's record count and a next step. Two values were not: `undefined` and `null` reach
|
|
15
|
+
`records.start` before anything has looked at them, and produced `Cannot read properties of
|
|
16
|
+
undefined (reading 'start')`, which names neither the option, nor the file, nor anything to do
|
|
17
|
+
about it.
|
|
18
|
+
- They are also the likeliest two. A range built from JSON, from a config file, from a JavaScript
|
|
19
|
+
call site, or from an object spread that dropped a key is absent rather than malformed —
|
|
20
|
+
`{ start: 0, count: undefined }` is what a half-built object looks like, and that was already
|
|
21
|
+
handled. The whole thing missing was not.
|
|
22
|
+
- One guard, two entry points: `readRecords` and `readAnnotations` share it. A count of zero is
|
|
23
|
+
still accepted, because a range naming no records is answerable and the answer is nothing; only
|
|
24
|
+
the absence of a range is a mistake. `requested` on the error is the stand-in, so a handler
|
|
25
|
+
reading it finds an object rather than `undefined`.
|
|
26
|
+
|
|
9
27
|
## 0.4.442
|
|
10
28
|
|
|
11
29
|
- **Fixed** the one required option with no default saying nothing useful when it was left off.
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/io/read.ts
CHANGED
|
@@ -84,14 +84,26 @@ function describeRange(range: RecordRange): string {
|
|
|
84
84
|
|
|
85
85
|
function assertRecordRange(header: EdfHeader, records: RecordRange): void {
|
|
86
86
|
const available: RecordRange = { start: 0, count: header.recordCount };
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
/*
|
|
88
|
+
* Read off a stand-in when there is no range at all.
|
|
89
|
+
*
|
|
90
|
+
* `records` is typed, and the type is not the only way in: a selection built from JSON, from a
|
|
91
|
+
* config file or from a JavaScript call site arrives at run time. Every wrong SHAPE already
|
|
92
|
+
* reached the message below — an array, a string and `{ start: 0 }` all read as
|
|
93
|
+
* `{ start: undefined, count: undefined }` and are refused with a next step — while `undefined`
|
|
94
|
+
* and `null` threw `TypeError: Cannot read properties of undefined (reading 'start')` from the
|
|
95
|
+
* two lines under this one, which names neither the option nor anything to do about it
|
|
96
|
+
* (fixed in 0.4.443).
|
|
97
|
+
*/
|
|
98
|
+
const range: RecordRange = records ?? ({} as RecordRange);
|
|
99
|
+
const startValid = Number.isSafeInteger(range.start) && range.start >= 0;
|
|
100
|
+
const countValid = Number.isSafeInteger(range.count) && range.count >= 0;
|
|
101
|
+
if (startValid && countValid && range.start + range.count <= header.recordCount) return;
|
|
90
102
|
throw new EdfRangeError(
|
|
91
|
-
`records ${describeRange(
|
|
103
|
+
`records ${describeRange(range)} is not inside the ` +
|
|
92
104
|
`${header.recordCount} data records this file contains. Next: clamp the range against ` +
|
|
93
105
|
'header.recordCount, or call index.locate(seconds) to find a record index for a time.',
|
|
94
|
-
{ requested:
|
|
106
|
+
{ requested: range, available },
|
|
95
107
|
);
|
|
96
108
|
}
|
|
97
109
|
|