edfcore 0.6.114 → 0.6.115
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/options.d.ts.map +1 -1
- package/dist/options.js +16 -0
- package/dist/options.js.map +1 -1
- package/docs/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/options.ts +18 -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.115";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM,CAqBR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM,CAqBR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA4BjF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQ1E"}
|
package/dist/options.js
CHANGED
|
@@ -63,6 +63,22 @@ export function requireFiniteOption(value, name, fallback) {
|
|
|
63
63
|
export function requireItemLimit(value, total) {
|
|
64
64
|
if (value === undefined)
|
|
65
65
|
return total;
|
|
66
|
+
/*
|
|
67
|
+
* The one numeric option in this module that was silently coerced, which is the thing the module
|
|
68
|
+
* exists not to do. `Math.floor('3')` is 3, so `maxItems: '3'` printed three items and nothing
|
|
69
|
+
* said the option had been read as text — and `Math.floor` is where every other value in this
|
|
70
|
+
* function is decided, so the coercion sat underneath four documented behaviours.
|
|
71
|
+
*
|
|
72
|
+
* Text is exactly what reaches this option. `--limit` is a flag, a viewer's cap comes off a query
|
|
73
|
+
* parameter, and a config file holds strings; the fix for all three is `Number()`, and the `NaN`
|
|
74
|
+
* that a bad one produces is refused below with a message about that conversion (fixed in
|
|
75
|
+
* 0.6.115).
|
|
76
|
+
*/
|
|
77
|
+
if (typeof value !== 'number') {
|
|
78
|
+
throw new RangeError(`options.maxItems must be a number, and was given ${describeValue(value)}. Next: pass how ` +
|
|
79
|
+
'many items to print, or Infinity for no cap. A flag, a query parameter and a config key ' +
|
|
80
|
+
'all arrive as text — convert with Number() first.');
|
|
81
|
+
}
|
|
66
82
|
if (Number.isNaN(value)) {
|
|
67
83
|
throw new RangeError('options.maxItems must be a number, but was NaN. Next: check the expression that produced ' +
|
|
68
84
|
'it — Number() on an absent environment variable, query parameter or config key yields ' +
|
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAA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;AACzD,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAyB;IAChE,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,CAAC,CAAC;IAChG,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAC/B,MAAM,IAAI,UAAU,CAClB,6DAA6D,MAAM,0BAA0B;QAC3F,0DAA0D;QAC1D,GAAG,6BAA6B,gBAAgB,CACnD,CAAC;AACJ,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ 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.115
|
|
10
|
+
|
|
11
|
+
- **Behaviour change:** `maxItems` no longer accepts a value that is not a number.
|
|
12
|
+
- `options.ts` is titled "Numeric options, refused rather than silently coerced", and
|
|
13
|
+
`requireItemLimit` ended in `Math.floor(value)` — which is where all four of its documented
|
|
14
|
+
behaviours are decided, and which is also a coercion. `Math.floor('3')` is 3, so
|
|
15
|
+
`formatDiagnostics(list, { maxItems: '3' })` printed three blocks and nothing said the option had
|
|
16
|
+
been read as text.
|
|
17
|
+
- Text is exactly what reaches this option: `--limit` is a flag, a viewer's cap comes off a query
|
|
18
|
+
parameter, and a config file holds strings. The fix for all three is `Number()`, and the `NaN` a
|
|
19
|
+
bad one produces has been refused since 0.6.1 with a message about that same conversion.
|
|
20
|
+
- The four accepted behaviours are unchanged: `Infinity` means no cap, a fractional limit floors,
|
|
21
|
+
`0` and any negative render no blocks, and `NaN` throws.
|
|
22
|
+
|
|
9
23
|
## 0.6.114
|
|
10
24
|
|
|
11
25
|
- **Changed** how `options.ts` describes a rejected option value. It printed with `String(value)`, so
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/options.ts
CHANGED
|
@@ -69,6 +69,24 @@ export function requireFiniteOption(
|
|
|
69
69
|
*/
|
|
70
70
|
export function requireItemLimit(value: number | undefined, total: number): number {
|
|
71
71
|
if (value === undefined) return total;
|
|
72
|
+
/*
|
|
73
|
+
* The one numeric option in this module that was silently coerced, which is the thing the module
|
|
74
|
+
* exists not to do. `Math.floor('3')` is 3, so `maxItems: '3'` printed three items and nothing
|
|
75
|
+
* said the option had been read as text — and `Math.floor` is where every other value in this
|
|
76
|
+
* function is decided, so the coercion sat underneath four documented behaviours.
|
|
77
|
+
*
|
|
78
|
+
* Text is exactly what reaches this option. `--limit` is a flag, a viewer's cap comes off a query
|
|
79
|
+
* parameter, and a config file holds strings; the fix for all three is `Number()`, and the `NaN`
|
|
80
|
+
* that a bad one produces is refused below with a message about that conversion (fixed in
|
|
81
|
+
* 0.6.115).
|
|
82
|
+
*/
|
|
83
|
+
if (typeof value !== 'number') {
|
|
84
|
+
throw new RangeError(
|
|
85
|
+
`options.maxItems must be a number, and was given ${describeValue(value)}. Next: pass how ` +
|
|
86
|
+
'many items to print, or Infinity for no cap. A flag, a query parameter and a config key ' +
|
|
87
|
+
'all arrive as text — convert with Number() first.',
|
|
88
|
+
);
|
|
89
|
+
}
|
|
72
90
|
if (Number.isNaN(value)) {
|
|
73
91
|
throw new RangeError(
|
|
74
92
|
'options.maxItems must be a number, but was NaN. Next: check the expression that produced ' +
|