edfcore 0.6.84 → 0.6.86
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/header/lookup.d.ts.map +1 -1
- package/dist/header/lookup.js +23 -0
- package/dist/header/lookup.js.map +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +17 -0
- package/dist/node.js.map +1 -1
- package/docs/CHANGELOG.md +29 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/header/lookup.ts +25 -0
- package/src/node.ts +20 -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.86";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGxD;
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGxD;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,CAuCjF;AAED;;;;;;;;;;;;;;GAcG;AACH,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,CAMtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEjE"}
|
package/dist/header/lookup.js
CHANGED
|
@@ -25,8 +25,29 @@ export function isAnnotationLabel(label) {
|
|
|
25
25
|
const trimmed = trimEdfField(label);
|
|
26
26
|
return trimmed === EDF_ANNOTATIONS_LABEL || trimmed === BDF_ANNOTATIONS_LABEL;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The selector, before the signals are walked with it.
|
|
30
|
+
*
|
|
31
|
+
* All three of these take a selector a caller supplies and nothing checked it. Omitting it made
|
|
32
|
+
* the failure depend on the FILE rather than on the call: `findSignals(header)` and
|
|
33
|
+
* `getSignal(header)` reached `trimEdfField(undefined)` and threw V8's "Cannot read properties of
|
|
34
|
+
* undefined (reading 'length')", while `matchSignals(header)` returned `[]` on a file with no
|
|
35
|
+
* data signals — the predicate is never called — and threw "test is not a function" on every other
|
|
36
|
+
* one, leaking an internal name (fixed in 0.6.86).
|
|
37
|
+
*
|
|
38
|
+
* A selector arrives from a montage in a config file, a channel name in a URL, or a spread that
|
|
39
|
+
* dropped a key at least as often as it is written out, which is the argument `assertSignalIndices`
|
|
40
|
+
* makes for the other required argument in this package.
|
|
41
|
+
*/
|
|
42
|
+
function assertSelector(selector, call, accepts) {
|
|
43
|
+
if (selector !== undefined && selector !== null)
|
|
44
|
+
return;
|
|
45
|
+
throw new RangeError(`${call}(): the selector is ${selector === null ? 'null' : 'missing'}. ` +
|
|
46
|
+
`Next: pass ${accepts}.`);
|
|
47
|
+
}
|
|
28
48
|
/** Every signal with this label, in signal order. Empty when none matches. */
|
|
29
49
|
export function findSignals(header, label) {
|
|
50
|
+
assertSelector(label, 'findSignals', 'the label to look for');
|
|
30
51
|
const wanted = trimEdfField(label);
|
|
31
52
|
return Object.freeze(header.signals.filter((signal) => signal.label === wanted));
|
|
32
53
|
}
|
|
@@ -77,6 +98,7 @@ function differsOnlyInCase(header, selector) {
|
|
|
77
98
|
* edfcore could return that would not be a guess.
|
|
78
99
|
*/
|
|
79
100
|
export function getSignal(header, selector) {
|
|
101
|
+
assertSelector(selector, 'getSignal', 'a label, or an index into header.signals');
|
|
80
102
|
if (typeof selector === 'number') {
|
|
81
103
|
const signal = header.signals[selector];
|
|
82
104
|
if (signal !== undefined)
|
|
@@ -143,6 +165,7 @@ export function matchesText(match) {
|
|
|
143
165
|
* exact-match case `findSignals` already covers.
|
|
144
166
|
*/
|
|
145
167
|
export function matchSignals(header, match) {
|
|
168
|
+
assertSelector(match, 'matchSignals', 'a RegExp, or a function taking a label');
|
|
146
169
|
const test = match instanceof RegExp ? matchesText(match) : match;
|
|
147
170
|
return Object.freeze(header.signals.filter((signal) => signal.kind === 'data' && test(signal.label)));
|
|
148
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM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AC;IAClE,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAChF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAiB;IACvD,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACjF,CAAC"}
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,YAAY,CAAC;AAElE;;;;;;GAMG;AACH,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CACF,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,YAAY,CAAC;AAElE;;;;;;GAMG;AACH,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CACF,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAyE/F;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAuC1E"}
|
package/dist/node.js
CHANGED
|
@@ -58,6 +58,23 @@ const fs = nodeFsPromises;
|
|
|
58
58
|
* closes it.
|
|
59
59
|
*/
|
|
60
60
|
export function fileHandleSource(handle, byteLength) {
|
|
61
|
+
/*
|
|
62
|
+
* The caller-supplied size is checked, and `fileSource` already checks the one it reads off the
|
|
63
|
+
* handle — the guard was on the path that cannot go wrong and absent from the path that can.
|
|
64
|
+
*
|
|
65
|
+
* A `NaN` or an absent `byteLength` disabled the range guard rather than failing: `assertReadRange`
|
|
66
|
+
* compares against it, every comparison against `NaN` is false, and `options.ts` names exactly
|
|
67
|
+
* this shape ("a guard written as `if (value < 1)` simply does not fire"). The source then
|
|
68
|
+
* advertised `byteLength: NaN` to everything downstream, and the failure surfaced in
|
|
69
|
+
* `parseHeader` — which does guard it — blaming a caller who passed it the right arguments
|
|
70
|
+
* (fixed in 0.6.85).
|
|
71
|
+
*/
|
|
72
|
+
if (!Number.isSafeInteger(byteLength) || byteLength < 0) {
|
|
73
|
+
throw new EdfSourceError(`fileHandleSource() was given a byteLength of ${String(byteLength)}, which is not a byte ` +
|
|
74
|
+
'count edfcore can address. Next: pass the size of the file or of the range you mean to ' +
|
|
75
|
+
'expose — (await handle.stat()).size is the whole file — or use fileSource(path), which ' +
|
|
76
|
+
'reads it from the handle it opens.', { offset: 0, requestedLength: 0 });
|
|
77
|
+
}
|
|
61
78
|
return {
|
|
62
79
|
byteLength,
|
|
63
80
|
async read(offset, length, options) {
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,4FAA4F;AAC5F,2FAA2F;AAC3F,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAoClF,MAAM,EAAE,GAAmB,cAA2C,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAsB,EAAE,UAAkB;IACzE,OAAO;QACL,UAAU;QACV,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAc,EAAE,OAAqB;YAC9D,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YAC5C,IAAI,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAE3C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,MAAM,GAAG,CAAC,CAAC;YACf,OAAO,MAAM,GAAG,MAAM,EAAE,CAAC;gBACvB,cAAc,CAAC,OAAO,CAAC,CAAC;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,CACtB,yDAAyD,UAAU,aAAa;gBAC9E,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mEAAmE;gBAC1F,mEAAmE,EACrE,EAAE,MAAM,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAClC,CAAC;QACJ,CAAC;QACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,wFAAwF;QACxF,0FAA0F;QAC1F,kFAAkF;QAClF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,35 @@ 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.86
|
|
10
|
+
|
|
11
|
+
- **Changed** `getSignal`, `findSignals` and `matchSignals` to refuse a selector that is not there.
|
|
12
|
+
Each takes one a caller supplies and none of them checked it, so omitting it made the failure
|
|
13
|
+
depend on the FILE rather than on the call — the shape 0.6.79 closed on the reading API.
|
|
14
|
+
- `findSignals(header)` and `getSignal(header)` threw V8's "Cannot read properties of undefined
|
|
15
|
+
(reading 'length')". `matchSignals(header)` returned `[]` on a file with no data signals, because
|
|
16
|
+
the predicate is never called there, and threw "test is not a function" on every other file —
|
|
17
|
+
leaking an internal name, and answering "no channels match" to a question nobody asked.
|
|
18
|
+
- A selector arrives from a montage in a config file, a channel name in a URL, or a spread that
|
|
19
|
+
dropped a key at least as often as it is written out, which is the argument `assertSignalIndices`
|
|
20
|
+
already makes for the other required argument in this package. A plain `RangeError` naming the
|
|
21
|
+
call and what it accepts, identical on both files.
|
|
22
|
+
|
|
23
|
+
## 0.6.85
|
|
24
|
+
|
|
25
|
+
- **Changed** `fileHandleSource` to refuse a `byteLength` that is not a byte count. `fileSource`
|
|
26
|
+
already validates the size it reads off the handle it opens; `fileHandleSource` exists so a
|
|
27
|
+
caller can supply that number themselves — "a range it intends to expose, a size it verified" —
|
|
28
|
+
and took whatever it was given. The guard was on the path that cannot go wrong and absent from
|
|
29
|
+
the one that can.
|
|
30
|
+
- A `NaN` or an omitted size did not fail, it disabled the range guard: `assertReadRange` compares
|
|
31
|
+
the read against `byteLength` and every comparison against `NaN` is false, which is the shape
|
|
32
|
+
`options.ts` names — "a guard written as `if (value < 1)` simply does not fire". The source then
|
|
33
|
+
advertised `byteLength: NaN` downstream and the first thing to notice was `parseHeader`, which
|
|
34
|
+
does guard it, so the failure named a caller who had passed `parseHeader` the right arguments.
|
|
35
|
+
- An `EdfSourceError` at construction now, naming the adapter, the value and where to get a real
|
|
36
|
+
one. Zero is still legal, and a read past the size given is still refused.
|
|
37
|
+
|
|
9
38
|
## 0.6.84
|
|
10
39
|
|
|
11
40
|
- **Fixed** the landing page carrying the "Before edfcore" absolutes with no qualification. 0.6.63
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/header/lookup.ts
CHANGED
|
@@ -29,8 +29,31 @@ export function isAnnotationLabel(label: string): boolean {
|
|
|
29
29
|
return trimmed === EDF_ANNOTATIONS_LABEL || trimmed === BDF_ANNOTATIONS_LABEL;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* The selector, before the signals are walked with it.
|
|
34
|
+
*
|
|
35
|
+
* All three of these take a selector a caller supplies and nothing checked it. Omitting it made
|
|
36
|
+
* the failure depend on the FILE rather than on the call: `findSignals(header)` and
|
|
37
|
+
* `getSignal(header)` reached `trimEdfField(undefined)` and threw V8's "Cannot read properties of
|
|
38
|
+
* undefined (reading 'length')", while `matchSignals(header)` returned `[]` on a file with no
|
|
39
|
+
* data signals — the predicate is never called — and threw "test is not a function" on every other
|
|
40
|
+
* one, leaking an internal name (fixed in 0.6.86).
|
|
41
|
+
*
|
|
42
|
+
* A selector arrives from a montage in a config file, a channel name in a URL, or a spread that
|
|
43
|
+
* dropped a key at least as often as it is written out, which is the argument `assertSignalIndices`
|
|
44
|
+
* makes for the other required argument in this package.
|
|
45
|
+
*/
|
|
46
|
+
function assertSelector(selector: unknown, call: string, accepts: string): void {
|
|
47
|
+
if (selector !== undefined && selector !== null) return;
|
|
48
|
+
throw new RangeError(
|
|
49
|
+
`${call}(): the selector is ${selector === null ? 'null' : 'missing'}. ` +
|
|
50
|
+
`Next: pass ${accepts}.`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
32
54
|
/** Every signal with this label, in signal order. Empty when none matches. */
|
|
33
55
|
export function findSignals(header: EdfHeader, label: string): readonly EdfSignal[] {
|
|
56
|
+
assertSelector(label, 'findSignals', 'the label to look for');
|
|
34
57
|
const wanted = trimEdfField(label);
|
|
35
58
|
return Object.freeze(header.signals.filter((signal) => signal.label === wanted));
|
|
36
59
|
}
|
|
@@ -87,6 +110,7 @@ function differsOnlyInCase(header: EdfHeader, selector: string): string | undefi
|
|
|
87
110
|
* edfcore could return that would not be a guess.
|
|
88
111
|
*/
|
|
89
112
|
export function getSignal(header: EdfHeader, selector: number | string): EdfSignal {
|
|
113
|
+
assertSelector(selector, 'getSignal', 'a label, or an index into header.signals');
|
|
90
114
|
if (typeof selector === 'number') {
|
|
91
115
|
const signal = header.signals[selector];
|
|
92
116
|
if (signal !== undefined) return signal;
|
|
@@ -167,6 +191,7 @@ export function matchSignals(
|
|
|
167
191
|
header: EdfHeader,
|
|
168
192
|
match: RegExp | ((label: string) => boolean),
|
|
169
193
|
): readonly EdfSignal[] {
|
|
194
|
+
assertSelector(match, 'matchSignals', 'a RegExp, or a function taking a label');
|
|
170
195
|
const test = match instanceof RegExp ? matchesText(match) : match;
|
|
171
196
|
return Object.freeze(
|
|
172
197
|
header.signals.filter((signal) => signal.kind === 'data' && test(signal.label)),
|
package/src/node.ts
CHANGED
|
@@ -95,6 +95,26 @@ const fs: NodeFsPromises = nodeFsPromises as unknown as NodeFsPromises;
|
|
|
95
95
|
* closes it.
|
|
96
96
|
*/
|
|
97
97
|
export function fileHandleSource(handle: FileHandleLike, byteLength: number): ClosableByteSource {
|
|
98
|
+
/*
|
|
99
|
+
* The caller-supplied size is checked, and `fileSource` already checks the one it reads off the
|
|
100
|
+
* handle — the guard was on the path that cannot go wrong and absent from the path that can.
|
|
101
|
+
*
|
|
102
|
+
* A `NaN` or an absent `byteLength` disabled the range guard rather than failing: `assertReadRange`
|
|
103
|
+
* compares against it, every comparison against `NaN` is false, and `options.ts` names exactly
|
|
104
|
+
* this shape ("a guard written as `if (value < 1)` simply does not fire"). The source then
|
|
105
|
+
* advertised `byteLength: NaN` to everything downstream, and the failure surfaced in
|
|
106
|
+
* `parseHeader` — which does guard it — blaming a caller who passed it the right arguments
|
|
107
|
+
* (fixed in 0.6.85).
|
|
108
|
+
*/
|
|
109
|
+
if (!Number.isSafeInteger(byteLength) || byteLength < 0) {
|
|
110
|
+
throw new EdfSourceError(
|
|
111
|
+
`fileHandleSource() was given a byteLength of ${String(byteLength)}, which is not a byte ` +
|
|
112
|
+
'count edfcore can address. Next: pass the size of the file or of the range you mean to ' +
|
|
113
|
+
'expose — (await handle.stat()).size is the whole file — or use fileSource(path), which ' +
|
|
114
|
+
'reads it from the handle it opens.',
|
|
115
|
+
{ offset: 0, requestedLength: 0 },
|
|
116
|
+
);
|
|
117
|
+
}
|
|
98
118
|
return {
|
|
99
119
|
byteLength,
|
|
100
120
|
async read(offset: number, length: number, options?: ReadOptions): Promise<Uint8Array> {
|