@prismatic-io/spectral 7.3.1 → 7.3.3
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/util.js
CHANGED
|
@@ -201,6 +201,7 @@ const isNumber = (value) => !Number.isNaN(Number(value));
|
|
|
201
201
|
*
|
|
202
202
|
* - `util.types.toNumber("3.22")` will return the number `3.22`.
|
|
203
203
|
* - `util.types.toNumber("", 5.5)` will return the default value `5.5`, since `value` was an empty string.
|
|
204
|
+
* - `util.types.toNumber(null, 5.5)` will return the default value `5.5`, since `value` was `null`.
|
|
204
205
|
* - `util.types.toNumber(undefined)` will return `0`, since `value` was undefined and no `defaultValue` was given.
|
|
205
206
|
* - `util.types.toNumber("Hello")` will throw an error, since the string `"Hello"` cannot be coerced into a number.
|
|
206
207
|
* @param value The value to turn into a number.
|
|
@@ -208,12 +209,12 @@ const isNumber = (value) => !Number.isNaN(Number(value));
|
|
|
208
209
|
* @returns This function returns the numerical version of `value` if possible, or the `defaultValue` if `value` is undefined or an empty string.
|
|
209
210
|
*/
|
|
210
211
|
const toNumber = (value, defaultValue) => {
|
|
212
|
+
if (typeof value === "undefined" || value === "" || value === null) {
|
|
213
|
+
return defaultValue || 0;
|
|
214
|
+
}
|
|
211
215
|
if (isNumber(value)) {
|
|
212
216
|
return Number(value);
|
|
213
217
|
}
|
|
214
|
-
if (typeof value === "undefined" || value === "") {
|
|
215
|
-
return defaultValue || 0;
|
|
216
|
-
}
|
|
217
218
|
throw new Error(`Value '${value}' cannot be coerced to a number.`);
|
|
218
219
|
};
|
|
219
220
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.3",
|
|
4
4
|
"description": "Utility library for building Prismatic components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismatic"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"date-fns": "2.28.0",
|
|
43
43
|
"form-data": "4.0.0",
|
|
44
44
|
"jest-mock": "27.0.3",
|
|
45
|
-
"soap": "0.
|
|
45
|
+
"soap": "0.45.0",
|
|
46
46
|
"uuid": "8.3.2",
|
|
47
47
|
"valid-url": "1.0.9",
|
|
48
48
|
"url-join": "5.0.0",
|