edfcore 0.6.14 → 0.6.16
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 +17 -0
- package/dist/bytes/latin1.d.ts.map +1 -1
- package/dist/bytes/latin1.js +19 -3
- package/dist/bytes/latin1.js.map +1 -1
- package/dist/bytes/numbers.d.ts +2 -1
- package/dist/bytes/numbers.d.ts.map +1 -1
- package/dist/bytes/numbers.js +5 -7
- package/dist/bytes/numbers.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/header/fields.d.ts.map +1 -1
- package/dist/header/fields.js +3 -8
- package/dist/header/fields.js.map +1 -1
- package/dist/header/variant.d.ts.map +1 -1
- package/dist/header/variant.js +2 -4
- package/dist/header/variant.js.map +1 -1
- package/docs/CHANGELOG.md +46 -0
- package/package.json +1 -1
- package/src/bytes/latin1.ts +19 -3
- package/src/bytes/numbers.ts +6 -8
- package/src/constants.ts +1 -1
- package/src/header/fields.ts +3 -10
- package/src/header/variant.ts +2 -5
package/dist/bytes/latin1.d.ts
CHANGED
|
@@ -26,6 +26,23 @@ export declare function decodeHeaderLatin1(bytes: Uint8Array): string;
|
|
|
26
26
|
* that wants to tolerate it can check the padding itself.
|
|
27
27
|
*/
|
|
28
28
|
export declare function hasNonPrintableAscii(bytes: Uint8Array): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* What EDF field padding is, once, for the four modules that act on it.
|
|
31
|
+
*
|
|
32
|
+
* `trimEdfField` below states the rule and the reason: only 0x20 and 0x00, because a trailing TAB
|
|
33
|
+
* or CR is not padding but content the file should not contain, and hiding it here would hide it
|
|
34
|
+
* from `NON_ASCII_HEADER_FIELD`. `bytes/numbers.ts` trims the same padding before parsing a number
|
|
35
|
+
* and `header/fields.ts` finds a field's content bounds inside its own bytes, `header/variant.ts` decides whether the version block is `'0'` and
|
|
36
|
+
* seven pad bytes, and each had grown a byte-identical copy of these two lines with its own pair
|
|
37
|
+
* of constants.
|
|
38
|
+
*
|
|
39
|
+
* Three copies of a rule are three chances for two of them to disagree, and the disagreement would
|
|
40
|
+
* not look like one: a field would trim one way for display and another way for its numeric parse,
|
|
41
|
+
* so `NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called
|
|
42
|
+
* clean. `padding.test.ts` checks the rule across all 256 byte values from both public
|
|
43
|
+
* sides, and that every module acting on it imports this rather than growing another.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isEdfPadding(code: number): boolean;
|
|
29
46
|
/**
|
|
30
47
|
* Strip EDF field padding: spaces and NULs, from both ends.
|
|
31
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latin1.d.ts","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsBH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAK/D;
|
|
1
|
+
{"version":3,"file":"latin1.d.ts","sourceRoot":"","sources":["../../src/bytes/latin1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsBH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAO5D;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
|
@@ -56,7 +56,23 @@ export function hasNonPrintableAscii(bytes) {
|
|
|
56
56
|
}
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* What EDF field padding is, once, for the four modules that act on it.
|
|
61
|
+
*
|
|
62
|
+
* `trimEdfField` below states the rule and the reason: only 0x20 and 0x00, because a trailing TAB
|
|
63
|
+
* or CR is not padding but content the file should not contain, and hiding it here would hide it
|
|
64
|
+
* from `NON_ASCII_HEADER_FIELD`. `bytes/numbers.ts` trims the same padding before parsing a number
|
|
65
|
+
* and `header/fields.ts` finds a field's content bounds inside its own bytes, `header/variant.ts` decides whether the version block is `'0'` and
|
|
66
|
+
* seven pad bytes, and each had grown a byte-identical copy of these two lines with its own pair
|
|
67
|
+
* of constants.
|
|
68
|
+
*
|
|
69
|
+
* Three copies of a rule are three chances for two of them to disagree, and the disagreement would
|
|
70
|
+
* not look like one: a field would trim one way for display and another way for its numeric parse,
|
|
71
|
+
* so `NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called
|
|
72
|
+
* clean. `padding.test.ts` checks the rule across all 256 byte values from both public
|
|
73
|
+
* sides, and that every module acting on it imports this rather than growing another.
|
|
74
|
+
*/
|
|
75
|
+
export function isEdfPadding(code) {
|
|
60
76
|
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
61
77
|
}
|
|
62
78
|
/**
|
|
@@ -75,9 +91,9 @@ function isPadding(code) {
|
|
|
75
91
|
export function trimEdfField(text) {
|
|
76
92
|
let start = 0;
|
|
77
93
|
let end = text.length;
|
|
78
|
-
while (end > start &&
|
|
94
|
+
while (end > start && isEdfPadding(text.charCodeAt(end - 1)))
|
|
79
95
|
end--;
|
|
80
|
-
while (start < end &&
|
|
96
|
+
while (start < end && isEdfPadding(text.charCodeAt(start)))
|
|
81
97
|
start++;
|
|
82
98
|
return text.slice(start, end);
|
|
83
99
|
}
|
package/dist/bytes/latin1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latin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CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,QAAQ,CAAC;AAClD,CAAC;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/bytes/numbers.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two EDF numeric grammars.
|
|
3
3
|
*
|
|
4
|
-
* Layer 0. Imports nothing. Sole owner of turning an
|
|
4
|
+
* Layer 0. Imports one predicate from `latin1.ts` and nothing else. Sole owner of turning an
|
|
5
|
+
* 8-byte ASCII field into a number.
|
|
5
6
|
*
|
|
6
7
|
* The spec says these fields are ASCII, left-justified and space-padded. Real files break
|
|
7
8
|
* that in every way imaginable, so parsing reports *why* it failed rather than returning NaN
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/bytes/numbers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/bytes/numbers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,GAAG,WAAW,CAAC;CAC3F;AA6DD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAE1D"}
|
package/dist/bytes/numbers.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two EDF numeric grammars.
|
|
3
3
|
*
|
|
4
|
-
* Layer 0. Imports nothing. Sole owner of turning an
|
|
4
|
+
* Layer 0. Imports one predicate from `latin1.ts` and nothing else. Sole owner of turning an
|
|
5
|
+
* 8-byte ASCII field into a number.
|
|
5
6
|
*
|
|
6
7
|
* The spec says these fields are ASCII, left-justified and space-padded. Real files break
|
|
7
8
|
* that in every way imaginable, so parsing reports *why* it failed rather than returning NaN
|
|
8
9
|
* and leaving the caller to guess which diagnostic the bytes deserve: a comma decimal is
|
|
9
10
|
* fatal, a right-justified field is a warning, and `'20 48'` is neither of those.
|
|
10
11
|
*/
|
|
12
|
+
import { isEdfPadding } from './latin1.js';
|
|
11
13
|
const CHAR_NUL = 0x00;
|
|
12
|
-
const CHAR_SPACE = 0x20;
|
|
13
14
|
/** No decimal point and no exponent — see `parseEdfInteger`. */
|
|
14
15
|
const INTEGER_GRAMMAR = /^[+-]?[0-9]+$/;
|
|
15
16
|
/** `'.5'`, `'+22'`, `'1E3'` and `'-1.23E-4'` are all emitted by real writers. */
|
|
16
17
|
const NUMBER_GRAMMAR = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
17
|
-
function isPadding(code) {
|
|
18
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
19
|
-
}
|
|
20
18
|
function failure(raw, problem) {
|
|
21
19
|
return { ok: false, value: Number.NaN, raw, problem };
|
|
22
20
|
}
|
|
@@ -30,9 +28,9 @@ function containsNul(text) {
|
|
|
30
28
|
function parseField(raw, grammar, integral) {
|
|
31
29
|
let start = 0;
|
|
32
30
|
let end = raw.length;
|
|
33
|
-
while (start < end &&
|
|
31
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start)))
|
|
34
32
|
start++;
|
|
35
|
-
while (end > start &&
|
|
33
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1)))
|
|
36
34
|
end--;
|
|
37
35
|
const core = raw.slice(start, end);
|
|
38
36
|
// Distinct from malformed: an all-space field is a writer omitting a value, not corrupting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/bytes/numbers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/bytes/numbers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsB3C,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,gEAAgE;AAChE,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,iFAAiF;AACjF,MAAM,cAAc,GAAG,6DAA6D,CAAC;AAErF,SAAS,OAAO,CAAC,GAAW,EAAE,OAAyB;IACrD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM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K,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,uFAAuF;IACvF,0FAA0F;IAC1F,uBAAuB;IACvB,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,4FAA4F;IAC5F,wFAAwF;IACxF,6DAA6D;IAC7D,MAAM,aAAa,GAAG,KAAK,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;AAC1F,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAChD,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.16";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/header/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,KAAK,cAAc,EAAmC,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAwB,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAuB,KAAK,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEnG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/header/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,KAAK,cAAc,EAAmC,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAwB,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAuB,KAAK,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEnG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,aAAa,CAAC;AAoC9D,0DAA0D;AAC1D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAG3E;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAGtE;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,UAAU,GAAG,kBAAkB,CAe/E;AA8CD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CA2B9F;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAuED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,cAAc,GACnB,MAAM,CAKR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,cAAc,GACnB,MAAM,CAKR;AAmBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAsB1E;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,MAAM,EACX,wBAAwB,EAAE,MAAM,EAChC,IAAI,EAAE,cAAc,GACnB,MAAM,CAqBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAmE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAOlF"}
|
package/dist/header/fields.js
CHANGED
|
@@ -11,13 +11,11 @@
|
|
|
11
11
|
* needs the bytes as written, so every field is exposed as text before it is interpreted.
|
|
12
12
|
*/
|
|
13
13
|
import { hexBytes } from '../bytes/hex.js';
|
|
14
|
-
import { hasNonPrintableAscii } from '../bytes/latin1.js';
|
|
14
|
+
import { hasNonPrintableAscii, isEdfPadding } from '../bytes/latin1.js';
|
|
15
15
|
import { parseEdfInteger, parseEdfNumber } from '../bytes/numbers.js';
|
|
16
16
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
17
17
|
import { EDF_MAX_SIGNAL_COUNT, HEADER_FIELDS, TICKS_PER_SECOND } from '../constants.js';
|
|
18
18
|
import { fatalError } from '../diagnostics/collector.js';
|
|
19
|
-
const CHAR_NUL = 0x00;
|
|
20
|
-
const CHAR_SPACE = 0x20;
|
|
21
19
|
/** Enough bytes to recognise the problem in a message without pasting an 80-byte field. */
|
|
22
20
|
const RAW_EVIDENCE_MAX_BYTES = 16;
|
|
23
21
|
/** 10^7 is far below 2^53, so this conversion is exact. */
|
|
@@ -74,9 +72,6 @@ export function readRawHeaderFields(headerBytes) {
|
|
|
74
72
|
signalCount: read('signalCount'),
|
|
75
73
|
};
|
|
76
74
|
}
|
|
77
|
-
function isPadding(code) {
|
|
78
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
79
|
-
}
|
|
80
75
|
/**
|
|
81
76
|
* The bounds of a field's content inside its own bytes, stripping the same padding
|
|
82
77
|
* `trimEdfField` does.
|
|
@@ -88,9 +83,9 @@ function isPadding(code) {
|
|
|
88
83
|
function contentBounds(raw) {
|
|
89
84
|
let start = 0;
|
|
90
85
|
let end = raw.length;
|
|
91
|
-
while (end > start &&
|
|
86
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1)))
|
|
92
87
|
end--;
|
|
93
|
-
while (start < end &&
|
|
88
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start)))
|
|
94
89
|
start++;
|
|
95
90
|
return { start, end };
|
|
96
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/header/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAW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BAA+B;YACjC,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC;YAC5B,QAAQ,EAAE,sEAAsE;YAChF,MAAM,EAAE,GAAG;YACX,aAAa,EAAE,+DAA+D;SAC/E,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW,EAAE,IAAoB;IACxE,MAAM,OAAO,GAAG,YAAY,CAC1B,aAAa,EACb,uEAAuE,EACvE,uDAAuD,CACxD,CAAC;IACF,OAAO,gBAAgB,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW9C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,8FAA8F;AAC9F,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAUhF;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,YAAY,GAAG,eAAe,CAAC;IACpD;uFACmF;IACnF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;wBACoB;IACpB,QAAQ,CAAC,cAAc,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACvD,gEAAgE;IAChE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,kFAAkF;IAClF,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,UAAU,GAAG,OAAO,CAOnE;AAED,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,UAAU,GAAG,OAAO,CAMnE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAKhF;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,cAAc,CAgG3F"}
|
package/dist/header/variant.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - BDF's version block is not ASCII: byte 0 is 0xFF, then `'BIOSEMI'`.
|
|
14
14
|
*/
|
|
15
15
|
import { hexBytes } from '../bytes/hex.js';
|
|
16
|
-
import { trimEdfField } from '../bytes/latin1.js';
|
|
16
|
+
import { isEdfPadding, trimEdfField } from '../bytes/latin1.js';
|
|
17
17
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
18
18
|
import { BDF_ANNOTATIONS_LABEL, BDF_DIGITAL_MAX, BDF_DIGITAL_MIN, EDF_ANNOTATIONS_LABEL, EDF_DIGITAL_MAX, EDF_DIGITAL_MIN, HEADER_FIELDS, } from '../constants.js';
|
|
19
19
|
import { fatalError } from '../diagnostics/collector.js';
|
|
@@ -22,8 +22,6 @@ const EDF_VERSION_BYTE = 0x30;
|
|
|
22
22
|
/** Not ASCII. This single byte is what separates a BDF file from an EDF one. */
|
|
23
23
|
const BDF_VERSION_BYTE = 0xff;
|
|
24
24
|
const BDF_VERSION_TEXT = 'BIOSEMI';
|
|
25
|
-
const CHAR_NUL = 0x00;
|
|
26
|
-
const CHAR_SPACE = 0x20;
|
|
27
25
|
const EDF_BYTES_PER_SAMPLE = 2;
|
|
28
26
|
const BDF_BYTES_PER_SAMPLE = 3;
|
|
29
27
|
const RESERVED_MARKERS = [
|
|
@@ -45,7 +43,7 @@ export function isEdfVersionBlock(versionBytes) {
|
|
|
45
43
|
return false;
|
|
46
44
|
for (let i = 1; i < versionBytes.length; i++) {
|
|
47
45
|
const byte = versionBytes[i];
|
|
48
|
-
if (byte
|
|
46
|
+
if (byte === undefined || !isEdfPadding(byte))
|
|
49
47
|
return false;
|
|
50
48
|
}
|
|
51
49
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant.js","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"variant.js","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,eAAe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N,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB;QAC9E,UAAU;QACV,MAAM;QACN,cAAc,EAAE,MAAM;QACtB,gBAAgB,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB;QAClF,mBAAmB,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe;QACzE,mBAAmB,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe;KAC1E,CAAC;AACJ,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,52 @@ 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.16
|
|
10
|
+
|
|
11
|
+
- **Added** the check that the five source constructors are interchangeable, which is what
|
|
12
|
+
`data-sources.md` promises and what nothing executed. Each was tested for the thing it does —
|
|
13
|
+
`file-source.test.ts` for descriptors and stat, the `http-*` files for Range and 200s and
|
|
14
|
+
concurrency, `cache-invisible.test.ts` for the block cache — and nothing ran the reading API over
|
|
15
|
+
all of them and compared the answers.
|
|
16
|
+
- That is the claim a caller depends on: develop against `byteSource` in a test, ship `httpSource`
|
|
17
|
+
in a browser and `fileSource` in a batch job, and expect one recording. The seams are real.
|
|
18
|
+
`fileSource` reads through a descriptor at an offset, `httpSource` splits a read into Range
|
|
19
|
+
requests, `cachedSource` serves from blocks that never line up with a record — three paths to the
|
|
20
|
+
same bytes, each a place an off-by-one would show through one source and no other.
|
|
21
|
+
- Header, timeline, segments, gaps, annotations, records, window, envelope and the validation
|
|
22
|
+
report, over every shape in the matrix, through all five. They agree.
|
|
23
|
+
- `bytesRead` is compared exactly, cache included. A block cache reads whole blocks, but a full
|
|
24
|
+
conformance sweep reads the whole file whatever the blocking and no source may read it twice —
|
|
25
|
+
checked with a block size small enough to split every record. The over-reading a partial window
|
|
26
|
+
provokes is `cache.test.ts`'s subject and is not this one.
|
|
27
|
+
- Every source is closed, in a `finally`. `fileSource` holds a descriptor and `close()` is optional
|
|
28
|
+
on the interface, so a sweep that opens one per shape per spelling leaks them — which on Node 26
|
|
29
|
+
is not a warning but an uncaught `ERR_INVALID_STATE` when the handle is collected. The three-way
|
|
30
|
+
Node matrix in CI is what said so, on a run that passed on 22.12 and 24.
|
|
31
|
+
- No behaviour changed. Nothing disagreed.
|
|
32
|
+
|
|
33
|
+
## 0.6.15
|
|
34
|
+
|
|
35
|
+
- **Fixed** four copies of the definition of EDF field padding. `trimEdfField` states the rule and
|
|
36
|
+
why it is narrow — only 0x20 and 0x00, because a trailing TAB or CR is content the file should
|
|
37
|
+
not contain and stripping it there would hide it from `NON_ASCII_HEADER_FIELD` — and
|
|
38
|
+
`bytes/numbers.ts`, `header/fields.ts` and `header/variant.ts` each had a byte-identical copy of
|
|
39
|
+
the same two lines, with their own pair of constants. One owner now, in `bytes/latin1.ts`, which
|
|
40
|
+
is where the rule was already written down.
|
|
41
|
+
- Four copies are four chances for two of them to disagree, and the disagreement would not look
|
|
42
|
+
like one. A field would trim one way for display and another way for its numeric parse, so
|
|
43
|
+
`NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called clean,
|
|
44
|
+
or an evidence window would point at a byte the message says is not there. Nothing would name
|
|
45
|
+
padding as the cause.
|
|
46
|
+
- Same treatment `floorDiv` and `ceilDiv` got, and for the reason their docblock gives: one owner,
|
|
47
|
+
and a test saying every module doing the thing imports it.
|
|
48
|
+
- `padding.test.ts` also checks the direction that is invisible. A padding byte kept is visible —
|
|
49
|
+
the value is wrong, the label does not match. A CONTENT byte stripped is not: the field parses,
|
|
50
|
+
the label compares equal, and the diagnostic that would have named the byte never fires. So it
|
|
51
|
+
checks that no byte outside the number grammar survives being appended to a numeric field, over
|
|
52
|
+
all 256 values, which can only happen if something stripped it.
|
|
53
|
+
- No behaviour changed. The four copies agreed; this is about the fifth.
|
|
54
|
+
|
|
9
55
|
## 0.6.14
|
|
10
56
|
|
|
11
57
|
- **Fixed** two spellings of a byte in one sentence. `header/variant.ts` and `header/fields.ts`
|
package/package.json
CHANGED
package/src/bytes/latin1.ts
CHANGED
|
@@ -61,7 +61,23 @@ export function hasNonPrintableAscii(bytes: Uint8Array): boolean {
|
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* What EDF field padding is, once, for the four modules that act on it.
|
|
66
|
+
*
|
|
67
|
+
* `trimEdfField` below states the rule and the reason: only 0x20 and 0x00, because a trailing TAB
|
|
68
|
+
* or CR is not padding but content the file should not contain, and hiding it here would hide it
|
|
69
|
+
* from `NON_ASCII_HEADER_FIELD`. `bytes/numbers.ts` trims the same padding before parsing a number
|
|
70
|
+
* and `header/fields.ts` finds a field's content bounds inside its own bytes, `header/variant.ts` decides whether the version block is `'0'` and
|
|
71
|
+
* seven pad bytes, and each had grown a byte-identical copy of these two lines with its own pair
|
|
72
|
+
* of constants.
|
|
73
|
+
*
|
|
74
|
+
* Three copies of a rule are three chances for two of them to disagree, and the disagreement would
|
|
75
|
+
* not look like one: a field would trim one way for display and another way for its numeric parse,
|
|
76
|
+
* so `NUMERIC_FIELD_NOT_LEFT_JUSTIFIED` would fire on a field `trimEdfField` had already called
|
|
77
|
+
* clean. `padding.test.ts` checks the rule across all 256 byte values from both public
|
|
78
|
+
* sides, and that every module acting on it imports this rather than growing another.
|
|
79
|
+
*/
|
|
80
|
+
export function isEdfPadding(code: number): boolean {
|
|
65
81
|
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
66
82
|
}
|
|
67
83
|
|
|
@@ -81,7 +97,7 @@ function isPadding(code: number): boolean {
|
|
|
81
97
|
export function trimEdfField(text: string): string {
|
|
82
98
|
let start = 0;
|
|
83
99
|
let end = text.length;
|
|
84
|
-
while (end > start &&
|
|
85
|
-
while (start < end &&
|
|
100
|
+
while (end > start && isEdfPadding(text.charCodeAt(end - 1))) end--;
|
|
101
|
+
while (start < end && isEdfPadding(text.charCodeAt(start))) start++;
|
|
86
102
|
return text.slice(start, end);
|
|
87
103
|
}
|
package/src/bytes/numbers.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The two EDF numeric grammars.
|
|
3
3
|
*
|
|
4
|
-
* Layer 0. Imports nothing. Sole owner of turning an
|
|
4
|
+
* Layer 0. Imports one predicate from `latin1.ts` and nothing else. Sole owner of turning an
|
|
5
|
+
* 8-byte ASCII field into a number.
|
|
5
6
|
*
|
|
6
7
|
* The spec says these fields are ASCII, left-justified and space-padded. Real files break
|
|
7
8
|
* that in every way imaginable, so parsing reports *why* it failed rather than returning NaN
|
|
@@ -9,6 +10,8 @@
|
|
|
9
10
|
* fatal, a right-justified field is a warning, and `'20 48'` is neither of those.
|
|
10
11
|
*/
|
|
11
12
|
|
|
13
|
+
import { isEdfPadding } from './latin1.js';
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* The outcome of parsing one numeric field.
|
|
14
17
|
*
|
|
@@ -30,7 +33,6 @@ export interface EdfNumberParse {
|
|
|
30
33
|
type EdfNumberProblem = EdfNumberParse['problem'];
|
|
31
34
|
|
|
32
35
|
const CHAR_NUL = 0x00;
|
|
33
|
-
const CHAR_SPACE = 0x20;
|
|
34
36
|
|
|
35
37
|
/** No decimal point and no exponent — see `parseEdfInteger`. */
|
|
36
38
|
const INTEGER_GRAMMAR = /^[+-]?[0-9]+$/;
|
|
@@ -38,10 +40,6 @@ const INTEGER_GRAMMAR = /^[+-]?[0-9]+$/;
|
|
|
38
40
|
/** `'.5'`, `'+22'`, `'1E3'` and `'-1.23E-4'` are all emitted by real writers. */
|
|
39
41
|
const NUMBER_GRAMMAR = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
40
42
|
|
|
41
|
-
function isPadding(code: number): boolean {
|
|
42
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
43
|
function failure(raw: string, problem: EdfNumberProblem): EdfNumberParse {
|
|
46
44
|
return { ok: false, value: Number.NaN, raw, problem };
|
|
47
45
|
}
|
|
@@ -56,8 +54,8 @@ function containsNul(text: string): boolean {
|
|
|
56
54
|
function parseField(raw: string, grammar: RegExp, integral: boolean): EdfNumberParse {
|
|
57
55
|
let start = 0;
|
|
58
56
|
let end = raw.length;
|
|
59
|
-
while (start < end &&
|
|
60
|
-
while (end > start &&
|
|
57
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start))) start++;
|
|
58
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1))) end--;
|
|
61
59
|
const core = raw.slice(start, end);
|
|
62
60
|
|
|
63
61
|
// Distinct from malformed: an all-space field is a writer omitting a value, not corrupting
|
package/src/constants.ts
CHANGED
package/src/header/fields.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { hexBytes } from '../bytes/hex.js';
|
|
15
|
-
import { hasNonPrintableAscii } from '../bytes/latin1.js';
|
|
15
|
+
import { hasNonPrintableAscii, isEdfPadding } from '../bytes/latin1.js';
|
|
16
16
|
import { type EdfNumberParse, parseEdfInteger, parseEdfNumber } from '../bytes/numbers.js';
|
|
17
17
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
18
18
|
import { EDF_MAX_SIGNAL_COUNT, HEADER_FIELDS, TICKS_PER_SECOND } from '../constants.js';
|
|
@@ -23,9 +23,6 @@ import type { EdfRawHeaderFields } from '../types.js';
|
|
|
23
23
|
/** The ten fixed fields. Same keys as `EdfRawHeaderFields`, by construction. */
|
|
24
24
|
export type FixedHeaderFieldName = keyof typeof HEADER_FIELDS;
|
|
25
25
|
|
|
26
|
-
const CHAR_NUL = 0x00;
|
|
27
|
-
const CHAR_SPACE = 0x20;
|
|
28
|
-
|
|
29
26
|
/** Enough bytes to recognise the problem in a message without pasting an 80-byte field. */
|
|
30
27
|
const RAW_EVIDENCE_MAX_BYTES = 16;
|
|
31
28
|
|
|
@@ -90,10 +87,6 @@ export function readRawHeaderFields(headerBytes: Uint8Array): EdfRawHeaderFields
|
|
|
90
87
|
};
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
function isPadding(code: number): boolean {
|
|
94
|
-
return code === CHAR_SPACE || code === CHAR_NUL;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
90
|
/**
|
|
98
91
|
* The bounds of a field's content inside its own bytes, stripping the same padding
|
|
99
92
|
* `trimEdfField` does.
|
|
@@ -105,8 +98,8 @@ function isPadding(code: number): boolean {
|
|
|
105
98
|
function contentBounds(raw: string): { readonly start: number; readonly end: number } {
|
|
106
99
|
let start = 0;
|
|
107
100
|
let end = raw.length;
|
|
108
|
-
while (end > start &&
|
|
109
|
-
while (start < end &&
|
|
101
|
+
while (end > start && isEdfPadding(raw.charCodeAt(end - 1))) end--;
|
|
102
|
+
while (start < end && isEdfPadding(raw.charCodeAt(start))) start++;
|
|
110
103
|
return { start, end };
|
|
111
104
|
}
|
|
112
105
|
|
package/src/header/variant.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { hexBytes } from '../bytes/hex.js';
|
|
17
|
-
import { trimEdfField } from '../bytes/latin1.js';
|
|
17
|
+
import { isEdfPadding, trimEdfField } from '../bytes/latin1.js';
|
|
18
18
|
import { readAsciiField, sliceBytes } from '../bytes/view.js';
|
|
19
19
|
import {
|
|
20
20
|
BDF_ANNOTATIONS_LABEL,
|
|
@@ -34,9 +34,6 @@ const EDF_VERSION_BYTE = 0x30;
|
|
|
34
34
|
const BDF_VERSION_BYTE = 0xff;
|
|
35
35
|
const BDF_VERSION_TEXT = 'BIOSEMI';
|
|
36
36
|
|
|
37
|
-
const CHAR_NUL = 0x00;
|
|
38
|
-
const CHAR_SPACE = 0x20;
|
|
39
|
-
|
|
40
37
|
const EDF_BYTES_PER_SAMPLE = 2 as const;
|
|
41
38
|
const BDF_BYTES_PER_SAMPLE = 3 as const;
|
|
42
39
|
|
|
@@ -93,7 +90,7 @@ export function isEdfVersionBlock(versionBytes: Uint8Array): boolean {
|
|
|
93
90
|
if (versionBytes[0] !== EDF_VERSION_BYTE) return false;
|
|
94
91
|
for (let i = 1; i < versionBytes.length; i++) {
|
|
95
92
|
const byte = versionBytes[i];
|
|
96
|
-
if (byte
|
|
93
|
+
if (byte === undefined || !isEdfPadding(byte)) return false;
|
|
97
94
|
}
|
|
98
95
|
return true;
|
|
99
96
|
}
|