edfcore 0.6.299 → 0.6.300
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 +36 -0
- package/dist/io/read.js.map +1 -1
- package/docs/CHANGELOG.md +21 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/io/read.ts +39 -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.300";
|
|
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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,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,CAuC9F;AAmKD;;;;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,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,CAuC9F;AAmKD;;;;;;;;;;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,CAgGrB"}
|
package/dist/io/read.js
CHANGED
|
@@ -285,6 +285,42 @@ export async function readRecordBytes(source, header, records, options) {
|
|
|
285
285
|
'parseHeader(bytes, sourceByteLength) returned.');
|
|
286
286
|
}
|
|
287
287
|
assertRecordRange(header, records);
|
|
288
|
+
/*
|
|
289
|
+
* The SOURCE against the HEADER, which are this function's own two arguments and are paired by
|
|
290
|
+
* nobody but the caller.
|
|
291
|
+
*
|
|
292
|
+
* `openEdf` establishes the relation at open time — a source too small for the header it parsed
|
|
293
|
+
* lowers `recordCount` and sets `recordCountSource` to `'sourceByteLength'` — and nothing
|
|
294
|
+
* re-checks it afterwards. `readWindow`'s docblock teaches rebuilding a recording by spread,
|
|
295
|
+
* `readWindow({ ...rec, index }, selection)`, so a recording whose four fields do not all come
|
|
296
|
+
* from one file is a shape the package asks for. `resolveTimeWindow` catches the index against
|
|
297
|
+
* the timeline; this is the other pair.
|
|
298
|
+
*
|
|
299
|
+
* What it did was blame the source. The first read asked for a range the HEADER describes, the
|
|
300
|
+
* source was shorter, and `assertReadRange` answered "ByteSource.read(offset 768, length 720)
|
|
301
|
+
* ends at byte 1488, past the end of a 1088-byte source. Next: clamp the request, or check that
|
|
302
|
+
* the source was built over the whole file rather than a prefix of it" — advice to clamp a range
|
|
303
|
+
* that is inside the file it was computed for, about a source that is the whole of a different
|
|
304
|
+
* one.
|
|
305
|
+
*
|
|
306
|
+
* A LOWER bound only, and that is the whole of what can be checked here: trailing bytes are legal
|
|
307
|
+
* and diagnosed rather than refused (`TRAILING_BYTES`, `PARTIAL_FINAL_RECORD`), so a source
|
|
308
|
+
* longer than the header implies is a real file and must keep reading. The reverse mix — a header
|
|
309
|
+
* describing less than its source holds — is therefore indistinguishable from one of those files
|
|
310
|
+
* and is not caught.
|
|
311
|
+
*
|
|
312
|
+
* Integer arithmetic on fields `assertRecordRange` above has already established, so a matched
|
|
313
|
+
* pair cannot reach it (0.6.300).
|
|
314
|
+
*/
|
|
315
|
+
const impliedByteLength = header.headerByteLength + header.recordCount * header.recordByteLength;
|
|
316
|
+
if (source.byteLength < impliedByteLength) {
|
|
317
|
+
throw new EdfRangeError(`this header describes a ${impliedByteLength}-byte file — a ${header.headerByteLength}-byte ` +
|
|
318
|
+
`header and ${pluralise(header.recordCount, 'record')} of ` +
|
|
319
|
+
`${header.recordByteLength} bytes — but the source holds ${source.byteLength}. A shorter ` +
|
|
320
|
+
'source is not a shorter file here: openEdf() lowers recordCount for one and records that ' +
|
|
321
|
+
'it did, so these two were not opened together. Next: pass the source this header was ' +
|
|
322
|
+
'parsed from — recording.source is the one openEdf() kept.', { requested: records, available: { start: 0, count: header.recordCount } });
|
|
323
|
+
}
|
|
288
324
|
const byteLength = records.count * header.recordByteLength;
|
|
289
325
|
if (byteLength === 0)
|
|
290
326
|
return new Uint8Array(0);
|
package/dist/io/read.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/io/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAA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,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,27 @@ 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.300
|
|
10
|
+
|
|
11
|
+
- **Fixed** a read blaming the source for a header from another file. `readRecordBytes(source,
|
|
12
|
+
header, records)` takes the two as separate arguments and nothing but the caller pairs them.
|
|
13
|
+
`openEdf` establishes the relation at open time — a source too small for the header it parsed
|
|
14
|
+
lowers `recordCount` and records that it did — and nothing re-checked it afterwards.
|
|
15
|
+
- The first read then asked for a range the HEADER describes, the source was shorter, and the
|
|
16
|
+
refusal was "ByteSource.read(...) past the end of a 1088-byte source. Next: clamp the request, or
|
|
17
|
+
check that the source was built over the whole file rather than a prefix of it" — advice to clamp a
|
|
18
|
+
range that is inside the file it was computed for, about a source that is the whole of a different
|
|
19
|
+
one.
|
|
20
|
+
- `readWindow`'s docblock teaches rebuilding a recording by spread, so a recording whose four fields
|
|
21
|
+
do not all come from one file is a shape the package asks for. `resolveTimeWindow` catches the
|
|
22
|
+
index against the timeline; this is the other pair, and it reaches every read because they all
|
|
23
|
+
funnel through this one function.
|
|
24
|
+
- **A lower bound only, and that is the whole of what can be checked here.** Trailing bytes are legal
|
|
25
|
+
and diagnosed rather than refused — `TRAILING_BYTES`, `PARTIAL_FINAL_RECORD` — so a source longer
|
|
26
|
+
than its header implies is a real file and keeps reading. The reverse mix, a header describing less
|
|
27
|
+
than its source holds, is indistinguishable from one of those files and is still not caught; a test
|
|
28
|
+
pins that it reads, so the limit is on the record rather than implied.
|
|
29
|
+
|
|
9
30
|
## 0.6.299
|
|
10
31
|
|
|
11
32
|
- **Fixed** `sampleAt` naming a record the file does not have. Its scanned-index branch bounded the
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/io/read.ts
CHANGED
|
@@ -324,6 +324,45 @@ export async function readRecordBytes(
|
|
|
324
324
|
);
|
|
325
325
|
}
|
|
326
326
|
assertRecordRange(header, records);
|
|
327
|
+
/*
|
|
328
|
+
* The SOURCE against the HEADER, which are this function's own two arguments and are paired by
|
|
329
|
+
* nobody but the caller.
|
|
330
|
+
*
|
|
331
|
+
* `openEdf` establishes the relation at open time — a source too small for the header it parsed
|
|
332
|
+
* lowers `recordCount` and sets `recordCountSource` to `'sourceByteLength'` — and nothing
|
|
333
|
+
* re-checks it afterwards. `readWindow`'s docblock teaches rebuilding a recording by spread,
|
|
334
|
+
* `readWindow({ ...rec, index }, selection)`, so a recording whose four fields do not all come
|
|
335
|
+
* from one file is a shape the package asks for. `resolveTimeWindow` catches the index against
|
|
336
|
+
* the timeline; this is the other pair.
|
|
337
|
+
*
|
|
338
|
+
* What it did was blame the source. The first read asked for a range the HEADER describes, the
|
|
339
|
+
* source was shorter, and `assertReadRange` answered "ByteSource.read(offset 768, length 720)
|
|
340
|
+
* ends at byte 1488, past the end of a 1088-byte source. Next: clamp the request, or check that
|
|
341
|
+
* the source was built over the whole file rather than a prefix of it" — advice to clamp a range
|
|
342
|
+
* that is inside the file it was computed for, about a source that is the whole of a different
|
|
343
|
+
* one.
|
|
344
|
+
*
|
|
345
|
+
* A LOWER bound only, and that is the whole of what can be checked here: trailing bytes are legal
|
|
346
|
+
* and diagnosed rather than refused (`TRAILING_BYTES`, `PARTIAL_FINAL_RECORD`), so a source
|
|
347
|
+
* longer than the header implies is a real file and must keep reading. The reverse mix — a header
|
|
348
|
+
* describing less than its source holds — is therefore indistinguishable from one of those files
|
|
349
|
+
* and is not caught.
|
|
350
|
+
*
|
|
351
|
+
* Integer arithmetic on fields `assertRecordRange` above has already established, so a matched
|
|
352
|
+
* pair cannot reach it (0.6.300).
|
|
353
|
+
*/
|
|
354
|
+
const impliedByteLength = header.headerByteLength + header.recordCount * header.recordByteLength;
|
|
355
|
+
if (source.byteLength < impliedByteLength) {
|
|
356
|
+
throw new EdfRangeError(
|
|
357
|
+
`this header describes a ${impliedByteLength}-byte file — a ${header.headerByteLength}-byte ` +
|
|
358
|
+
`header and ${pluralise(header.recordCount, 'record')} of ` +
|
|
359
|
+
`${header.recordByteLength} bytes — but the source holds ${source.byteLength}. A shorter ` +
|
|
360
|
+
'source is not a shorter file here: openEdf() lowers recordCount for one and records that ' +
|
|
361
|
+
'it did, so these two were not opened together. Next: pass the source this header was ' +
|
|
362
|
+
'parsed from — recording.source is the one openEdf() kept.',
|
|
363
|
+
{ requested: records, available: { start: 0, count: header.recordCount } },
|
|
364
|
+
);
|
|
365
|
+
}
|
|
327
366
|
const byteLength = records.count * header.recordByteLength;
|
|
328
367
|
if (byteLength === 0) return new Uint8Array(0);
|
|
329
368
|
|