edfcore 0.6.95 → 0.6.96
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/bytes/latin1.d.ts.map +1 -1
- package/dist/bytes/latin1.js +24 -0
- package/dist/bytes/latin1.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/docs/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/bytes/latin1.ts +27 -0
- package/src/constants.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latin1.d.ts","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"latin1.d.ts","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgCH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAwB5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAK/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|
package/dist/bytes/latin1.js
CHANGED
|
@@ -26,12 +26,36 @@ function fromCharCodes(bytes) {
|
|
|
26
26
|
// `Function.prototype.apply` signature only admits `number[]`, hence the cast.
|
|
27
27
|
return String.fromCharCode.apply(null, bytes);
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The one-byte-per-element tags, written out rather than shared with `io/source.ts`'s `isByteArray`.
|
|
31
|
+
*
|
|
32
|
+
* This module is Layer 0 and imports nothing, which is the property that lets the header decoder be
|
|
33
|
+
* the one thing in the package with no dependencies. `a-header-that-was-never-bytes.test.ts`
|
|
34
|
+
* asserts the two admit the same set, which is the drift `io/bytes.ts` records being bitten by in
|
|
35
|
+
* 0.2.23 when one of its two copies was rewritten and the other was missed.
|
|
36
|
+
*/
|
|
37
|
+
const BYTE_ARRAY_TAGS = new Set(['[object Uint8Array]', '[object Uint8ClampedArray]']);
|
|
29
38
|
/**
|
|
30
39
|
* Decode header bytes as ISO-8859-1: byte `b` becomes code point U+00`b`, always.
|
|
31
40
|
*
|
|
32
41
|
* Never `TextDecoder` — see the module comment.
|
|
33
42
|
*/
|
|
34
43
|
export function decodeHeaderLatin1(bytes) {
|
|
44
|
+
/*
|
|
45
|
+
* The two wrong views both produced text rather than an error, which is the worst pair of
|
|
46
|
+
* outcomes a decoder can have. An `ArrayBuffer` has no `length`, so `undefined <= 4096` is false,
|
|
47
|
+
* the chunk loop never ran, and the whole header decoded to `''`. An `Int8Array` has one byte per
|
|
48
|
+
* element, so it passed every length check and then decoded every byte above 0x7f to a different
|
|
49
|
+
* character — 0xb5, the bare micro sign real equipment writes, came out as U+FFB5. `byteSource`
|
|
50
|
+
* refuses exactly this pair at construction and says why; this is the same refusal one layer
|
|
51
|
+
* down, where the bytes are actually read (fixed in 0.6.96).
|
|
52
|
+
*/
|
|
53
|
+
if (!ArrayBuffer.isView(bytes) || !BYTE_ARRAY_TAGS.has(Object.prototype.toString.call(bytes))) {
|
|
54
|
+
throw new RangeError('decodeHeaderLatin1() needs a Uint8Array. An ArrayBuffer has no length, so it decoded to ' +
|
|
55
|
+
'the empty string; an Int8Array has one byte per element, so it decoded every byte above ' +
|
|
56
|
+
'0x7f to a different character. Next: pass `new Uint8Array(buffer)` for an ArrayBuffer, ' +
|
|
57
|
+
'and `new Uint8Array(view.buffer, view.byteOffset, view.byteLength)` for any other view.');
|
|
58
|
+
}
|
|
35
59
|
if (bytes.length <= CHUNK_BYTES)
|
|
36
60
|
return fromCharCodes(bytes);
|
|
37
61
|
const parts = [];
|
package/dist/bytes/latin1.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AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,OAAO,GAAG,GAAG,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC;IACpE,OAAO,KAAK,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,KAAK,EAAE,CAAC;IACpE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
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.96";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
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.96
|
|
10
|
+
|
|
11
|
+
- **Fixed** `decodeHeaderLatin1` decoding two wrong arguments into text instead of refusing them.
|
|
12
|
+
- An `ArrayBuffer` — what `await blob.arrayBuffer()` and `await response.arrayBuffer()` hand you —
|
|
13
|
+
has no `length`, so the chunk loop never ran and the whole header decoded to `''`. An `Int8Array`
|
|
14
|
+
has one byte per element, so it passed every length check and then decoded every byte above 0x7f
|
|
15
|
+
to a different character: 0xb5, the bare micro sign real equipment writes into a physical
|
|
16
|
+
dimension, came out as U+FFB5.
|
|
17
|
+
- `byteSource` refuses that same pair at construction and says why — an Int8Array "would pass every
|
|
18
|
+
length check and then decode to fabricated sample values". This is that refusal one layer down,
|
|
19
|
+
where the bytes are read.
|
|
20
|
+
- The tag test is written out rather than imported, because this module is Layer 0 and imports
|
|
21
|
+
nothing; a test asserts it admits exactly what `isByteArray` does, so the two copies cannot drift
|
|
22
|
+
the way `io/bytes.ts`'s did in 0.2.23.
|
|
23
|
+
|
|
9
24
|
## 0.6.95
|
|
10
25
|
|
|
11
26
|
- **Fixed** `formatDiagnostics` and `formatAnnotations` returning `''` for an argument that is not a
|
package/package.json
CHANGED
package/src/bytes/latin1.ts
CHANGED
|
@@ -31,12 +31,39 @@ function fromCharCodes(bytes: Uint8Array): string {
|
|
|
31
31
|
return String.fromCharCode.apply(null, bytes as unknown as number[]);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The one-byte-per-element tags, written out rather than shared with `io/source.ts`'s `isByteArray`.
|
|
36
|
+
*
|
|
37
|
+
* This module is Layer 0 and imports nothing, which is the property that lets the header decoder be
|
|
38
|
+
* the one thing in the package with no dependencies. `a-header-that-was-never-bytes.test.ts`
|
|
39
|
+
* asserts the two admit the same set, which is the drift `io/bytes.ts` records being bitten by in
|
|
40
|
+
* 0.2.23 when one of its two copies was rewritten and the other was missed.
|
|
41
|
+
*/
|
|
42
|
+
const BYTE_ARRAY_TAGS = new Set(['[object Uint8Array]', '[object Uint8ClampedArray]']);
|
|
43
|
+
|
|
34
44
|
/**
|
|
35
45
|
* Decode header bytes as ISO-8859-1: byte `b` becomes code point U+00`b`, always.
|
|
36
46
|
*
|
|
37
47
|
* Never `TextDecoder` — see the module comment.
|
|
38
48
|
*/
|
|
39
49
|
export function decodeHeaderLatin1(bytes: Uint8Array): string {
|
|
50
|
+
/*
|
|
51
|
+
* The two wrong views both produced text rather than an error, which is the worst pair of
|
|
52
|
+
* outcomes a decoder can have. An `ArrayBuffer` has no `length`, so `undefined <= 4096` is false,
|
|
53
|
+
* the chunk loop never ran, and the whole header decoded to `''`. An `Int8Array` has one byte per
|
|
54
|
+
* element, so it passed every length check and then decoded every byte above 0x7f to a different
|
|
55
|
+
* character — 0xb5, the bare micro sign real equipment writes, came out as U+FFB5. `byteSource`
|
|
56
|
+
* refuses exactly this pair at construction and says why; this is the same refusal one layer
|
|
57
|
+
* down, where the bytes are actually read (fixed in 0.6.96).
|
|
58
|
+
*/
|
|
59
|
+
if (!ArrayBuffer.isView(bytes) || !BYTE_ARRAY_TAGS.has(Object.prototype.toString.call(bytes))) {
|
|
60
|
+
throw new RangeError(
|
|
61
|
+
'decodeHeaderLatin1() needs a Uint8Array. An ArrayBuffer has no length, so it decoded to ' +
|
|
62
|
+
'the empty string; an Int8Array has one byte per element, so it decoded every byte above ' +
|
|
63
|
+
'0x7f to a different character. Next: pass `new Uint8Array(buffer)` for an ArrayBuffer, ' +
|
|
64
|
+
'and `new Uint8Array(view.buffer, view.byteOffset, view.byteLength)` for any other view.',
|
|
65
|
+
);
|
|
66
|
+
}
|
|
40
67
|
if (bytes.length <= CHUNK_BYTES) return fromCharCodes(bytes);
|
|
41
68
|
const parts: string[] = [];
|
|
42
69
|
for (let start = 0; start < bytes.length; start += CHUNK_BYTES) {
|
package/src/constants.ts
CHANGED