edfcore 0.6.84 → 0.6.85
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/node.d.ts.map +1 -1
- package/dist/node.js +17 -0
- package/dist/node.js.map +1 -1
- package/docs/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- 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.85";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
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,CAA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EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAClC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,cAAc,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,21 @@ 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.85
|
|
10
|
+
|
|
11
|
+
- **Changed** `fileHandleSource` to refuse a `byteLength` that is not a byte count. `fileSource`
|
|
12
|
+
already validates the size it reads off the handle it opens; `fileHandleSource` exists so a
|
|
13
|
+
caller can supply that number themselves — "a range it intends to expose, a size it verified" —
|
|
14
|
+
and took whatever it was given. The guard was on the path that cannot go wrong and absent from
|
|
15
|
+
the one that can.
|
|
16
|
+
- A `NaN` or an omitted size did not fail, it disabled the range guard: `assertReadRange` compares
|
|
17
|
+
the read against `byteLength` and every comparison against `NaN` is false, which is the shape
|
|
18
|
+
`options.ts` names — "a guard written as `if (value < 1)` simply does not fire". The source then
|
|
19
|
+
advertised `byteLength: NaN` downstream and the first thing to notice was `parseHeader`, which
|
|
20
|
+
does guard it, so the failure named a caller who had passed `parseHeader` the right arguments.
|
|
21
|
+
- An `EdfSourceError` at construction now, naming the adapter, the value and where to get a real
|
|
22
|
+
one. Zero is still legal, and a read past the size given is still refused.
|
|
23
|
+
|
|
9
24
|
## 0.6.84
|
|
10
25
|
|
|
11
26
|
- **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/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> {
|